VLab Common 1.2

pl.psnc.vlab.util.thread
Class DefaultLongTask

java.lang.Object
  extended by javax.swing.SwingWorker<java.lang.Object,java.lang.String[]>
      extended by pl.psnc.vlab.util.thread.DefaultLongTask
All Implemented Interfaces:
java.lang.Runnable, java.util.concurrent.Future<java.lang.Object>, java.util.concurrent.RunnableFuture<java.lang.Object>, ProgressTask

public abstract class DefaultLongTask
extends javax.swing.SwingWorker<java.lang.Object,java.lang.String[]>
implements ProgressTask

DefaultLongTask class - DefaultLongTask - abstract class is used as a base class for time consuming operations. Some of the utility methods have been already implemented. Child classes are required to override doInBackground() method.

Author:
Dominik Stoklosa (~osa~)
Email address
osa@man.poznan.pl

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.SwingWorker
javax.swing.SwingWorker.StateValue
 
Constructor Summary
protected DefaultLongTask(java.awt.Component parent, ProgressTask progress, javax.swing.Action action)
          Crates a new instance of DefaultLongTask
protected DefaultLongTask(ProgressTask progress, javax.swing.Action action)
          Crates a new instance of DefaultLongTask
 
Method Summary
protected  void done()
           
 javax.swing.Action getAction()
          Get value of action
 void hideProgress()
          Hides Progress bar
protected  void process(java.util.List<java.lang.String[]> arg0)
           
protected  int showProceedQuestion(java.lang.String message)
          Show proceed question message for this LongTask.
 void showProgress(boolean interminate)
          Show Progress bar
 void showProgress(java.lang.String message, boolean interminate)
          Show Progress bar with the initial message
 void updateMessage(java.lang.String... messages)
          Update current progress bar message.
protected  void updateProgress(java.lang.String message)
          Update progress bar.
 
Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, doInBackground, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, publish, removePropertyChangeListener, run, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLongTask

protected DefaultLongTask(java.awt.Component parent,
                          ProgressTask progress,
                          javax.swing.Action action)
Crates a new instance of DefaultLongTask

Parameters:
parent - parent object of this DefaultLongTask
progress - instance of ProgressTask
action - action object for this long task

DefaultLongTask

protected DefaultLongTask(ProgressTask progress,
                          javax.swing.Action action)
Crates a new instance of DefaultLongTask

Parameters:
progress - instance of ProgressTask
action - action object for this long task
Method Detail

process

protected void process(java.util.List<java.lang.String[]> arg0)
Overrides:
process in class javax.swing.SwingWorker<java.lang.Object,java.lang.String[]>

updateProgress

protected void updateProgress(java.lang.String message)
Update progress bar. The message is constructed from parent component title, given message and please wait message

Parameters:
message - message to display

done

protected void done()
Overrides:
done in class javax.swing.SwingWorker<java.lang.Object,java.lang.String[]>

hideProgress

public void hideProgress()
Description copied from interface: ProgressTask
Hides Progress bar

Specified by:
hideProgress in interface ProgressTask

showProgress

public void showProgress(boolean interminate)
Description copied from interface: ProgressTask
Show Progress bar

Specified by:
showProgress in interface ProgressTask
Parameters:
interminate - defines the behavior of the progress: interminate or not

showProgress

public void showProgress(java.lang.String message,
                         boolean interminate)
Description copied from interface: ProgressTask
Show Progress bar with the initial message

Specified by:
showProgress in interface ProgressTask
Parameters:
message - message to be displayed on the status bar
interminate - defines the behavior of the progress: interminate or not

updateMessage

public void updateMessage(java.lang.String... messages)
Description copied from interface: ProgressTask
Update current progress bar message. Please note, that progress has to be turned on first

Specified by:
updateMessage in interface ProgressTask
Parameters:
messages - list of messages to be displayed. Each message will be separated by white space

showProceedQuestion

protected int showProceedQuestion(java.lang.String message)
Show proceed question message for this LongTask. The option pane with YES and NO choices is shown. User can choose whether to proceed or quit.

Parameters:
message - proceed question
Returns:
JMessage.YES_OPTION if proceed, JMessage.NO_OPTION otherwise

getAction

public javax.swing.Action getAction()
Get value of action

Returns:
the action

VLab Common 1.2

Copyright 2004 by VLAB Dominik Stoklosa.