View Javadoc

1   /*
2    * WizCryptCallback.java
3    *
4    * Created on 07 January 2007, 23:20
5    *
6    * To change this template, choose Tools | Template Manager
7    * and open the template in the editor.
8    */
9   
10  package org.wiztools.jenkryptor;
11  
12  import java.io.File;
13  import java.io.IOException;
14  import org.wiztools.jenkryptor.util.StringUtil;
15  import org.wiztools.wizcrypt.Callback;
16  
17  /***
18   *
19   * @author subhash
20   */
21  public class WizCryptCallback implements Callback {
22      
23      private final File file;
24      private final LabelProgressbarEnsc lpe;
25      private String originalLabel;
26      
27      /*** Creates a new instance of WizCryptCallback */
28      public WizCryptCallback(final File file, final LabelProgressbarEnsc lpe) {
29          this.file = file;
30          this.lpe = lpe;
31      }
32  
33      public void begin() {
34          originalLabel = lpe.getLabelText();
35          String path = StringUtil.getCompactedPath(file.getAbsolutePath());
36          lpe.setLabel(path);
37      }
38  
39      public void notifyProgress(long value) {
40          lpe.setProgress((int)value);
41      }
42  
43      public void end() {
44          lpe.setLabel(originalLabel);
45          lpe.setProgress(0);
46      }
47      
48  }