View Javadoc

1   package com.melloware.jukes.gui.view.tasks;
2   
3   
4   /**
5    * Abstract class that uses a SwingWorker to perform a time-consuming task.
6    * <p>
7    * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
8    * @author Emil A. Lefkof III <info@melloware.com>
9    * @version 4.0
10   * 2010 AZ Development
11   */
12  @SuppressWarnings("PMD")
13  abstract public class LongTask {
14  
15      protected boolean canceled = false;
16      protected boolean done = false;
17      protected boolean warning = false;//AZ
18      protected int current = 0;
19      protected int lengthOfTask = 0;
20      protected String statMessage;
21  
22      /**
23       * Constructor that needs a config object and a filename to work on.
24       * <p>
25       */
26      public LongTask() {
27      	super();
28      }
29  
30      /**
31       * Called to start the task.
32       */
33      abstract public void go();
34  
35      /**
36       * Called to find out how much has been done.
37       */
38      public int getCurrent() {
39          return current;
40      }
41  
42      /**
43       * Called to find out how much work needs
44       * to be done.
45       */
46      public int getLengthOfTask() {
47          return lengthOfTask;
48      }
49  
50      /**
51       * Returns the most recent status message, or null
52       * if there is no current status message.
53       */
54      public String getMessage() {
55          return statMessage;
56      }
57  
58      /**
59       * Called to find out if the task has been canceled.
60       */
61      public boolean isCancelled() {
62          return canceled;
63      }
64  
65      /**
66       * Called to find out if the task has completed.
67       */
68      public boolean isDone() {
69          return done;
70      }
71  
72      /**
73       * Stops the current long task.
74       */
75      public void stop() {
76          canceled = true;
77          statMessage = null;
78      }
79      
80      /**AZ
81       * Called to find out if the task has completed with errors or warnings.
82       */
83      public boolean hasWarning() {
84          return warning;
85      }
86  
87  }