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> connectedActions  
    protected java.awt.Component parent  

    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​(java.awt.Component parent, java.lang.String progressTitle, int total, boolean indeterminate)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    void actionPerformed​(java.awt.event.ActionEvent event)  
    void addConnectedAction​(javax.swing.AbstractAction action)  
    abstract void backGroundWork​(ProgressMonitor monitor)
    Implements here the heavy work to be done.
    void onError​(java.lang.Exception e)
    Called if an error occurrs.
    void postWork()
    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

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface javax.swing.Action

    accept
  • 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 - if true, the dialog is indeterminate.
  • Method Details

    • actionPerformed

      public void actionPerformed​(java.awt.event.ActionEvent event)
    • backGroundWork

      public abstract void backGroundWork​(ProgressMonitor monitor) throws java.lang.Exception
      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.Exception
      This 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.