Class ActionWithProgress
java.lang.Object
javax.swing.AbstractAction
org.hortonmachine.gui.utils.monitor.ActionWithProgress
- All Implemented Interfaces:
java.awt.event.ActionListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action
public abstract class ActionWithProgress
extends javax.swing.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 java.util.List<javax.swing.AbstractAction>connectedActionsprotected java.awt.Componentparent -
Constructor Summary
Constructors Constructor Description ActionWithProgress(java.awt.Component parent, java.lang.String progressTitle, int total, boolean indeterminate)Constructor. -
Method Summary
Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent event)voidaddConnectedAction(javax.swing.AbstractAction action)abstract voidbackGroundWork(ProgressMonitor monitor)Implements here the heavy work to be done.voidonError(java.lang.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 Details
-
parent
protected java.awt.Component parent -
connectedActions
protected java.util.List<javax.swing.AbstractAction> connectedActions
-
-
Constructor Details
-
ActionWithProgress
public ActionWithProgress(java.awt.Component parent, java.lang.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 Details
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event) -
backGroundWork
Implements here the heavy work to be done.- Parameters:
monitor- the monitor that can be used to update the user.- Throws:
java.lang.Exception
-
postWork
public void postWork() throws java.lang.ExceptionThis is run once the heavy work is done and the button of the action has been enabled again.- Throws:
java.lang.Exception
-
addConnectedAction
public void addConnectedAction(javax.swing.AbstractAction action) -
onError
public void onError(java.lang.Exception e)Called if an error occurrs. Can be overridden. SHows dialog by default.- Parameters:
e- the exception thrown.
-