Class ActionWithProgress
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.hortonmachine.gui.utils.monitor.ActionWithProgress
-
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action
public abstract class ActionWithProgress extends AbstractAction
An action that uses a progress monitor to update.- Author:
- Antonello Andrea (www.hydrologis.com)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<AbstractAction>connectedActionsprotected Componentparent-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Constructor Summary
Constructors Constructor Description ActionWithProgress(Component parent, String progressTitle, int total, boolean indeterminate)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(ActionEvent event)voidaddConnectedAction(AbstractAction action)abstract voidbackGroundWork(ProgressMonitor monitor)Implements here the heavy work to be done.voidonError(Exception e)Called if an error occurrs.voidpostWork()This is run once the heavy work is done and the button of the action has been enabled again.-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
parent
protected Component parent
-
connectedActions
protected List<AbstractAction> connectedActions
-
-
Constructor Detail
-
ActionWithProgress
public ActionWithProgress(Component parent, String progressTitle, int total, boolean indeterminate)
Constructor.- Parameters:
parent- the parent component.progressTitle- the initial title of the progress.total- the total count of work.indeterminate- iftrue, the dialog is indeterminate.
-
-
Method Detail
-
actionPerformed
public void actionPerformed(ActionEvent event)
-
backGroundWork
public abstract void backGroundWork(ProgressMonitor monitor) throws Exception
Implements here the heavy work to be done.- Parameters:
monitor- the monitor that can be used to update the user.- Throws:
Exception
-
postWork
public void postWork() throws ExceptionThis is run once the heavy work is done and the button of the action has been enabled again.- Throws:
Exception
-
addConnectedAction
public void addConnectedAction(AbstractAction action)
-
onError
public void onError(Exception e)
Called if an error occurrs. Can be overridden. SHows dialog by default.- Parameters:
e- the exception thrown.
-
-