Class AbstractUpdatableAction

java.lang.Object
javax.swing.AbstractAction
org.jppf.ui.actions.AbstractUpdatableAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, UpdatableAction, ValueChangeListener
Direct Known Subclasses:
AbstractJobAction, AbstractTopologyAction, ShowHideColumnsAction

public abstract class AbstractUpdatableAction extends AbstractAction implements UpdatableAction
Abstract superclass for actions used in toolbars or popup menus.
Author:
Laurent Cohen
See Also:
  • Field Details

    • BASE

      protected String BASE
      The base location for internationalized messages.
    • selectedElements

      protected List<Object> selectedElements
      The list of selected elements.
    • location

      protected Point location
      Location at which to display any window or dialog created by this action.
  • Constructor Details

    • AbstractUpdatableAction

      public AbstractUpdatableAction()
  • Method Details

    • getLocation

      public Point getLocation()
      Get the location at which to display any window or dialog created by this action.
      Returns:
      a Point instance.
    • setLocation

      public void setLocation(Point location)
      Set the location at which to display any window or dialog created by this action.
      Parameters:
      location - a Point instance.
    • updateState

      public void updateState(List<Object> selectedElements)
      Update this action's enabled state based on a list of selected elements.
      Specified by:
      updateState in interface UpdatableAction
      Parameters:
      selectedElements - a list of objects.
    • valueChanged

      public void valueChanged(ValueChangeEvent event)
      Method called when the action is triggered.
      Specified by:
      valueChanged in interface ValueChangeListener
      Parameters:
      event - the event encapsulating the source of the event.
    • setupIcon

      protected void setupIcon(String name)
      Set the icon for this action using the specified image file name.
      Parameters:
      name - the name of the icon image file.
    • setupNameAndTooltip

      protected void setupNameAndTooltip(String name)
      Set the action name and tooltip text.
      Parameters:
      name - the key to find the name and tooltip in the localized resource bundles.
    • setupTooltip

      protected void setupTooltip(String name)
      Set the action tooltip text.
      Parameters:
      name - the key to find the tooltip in the localized resource bundles.
    • localize

      protected String localize(String message)
      Get a localized message given its unique name and the current locale.
      Parameters:
      message - the unique name of the localized message.
      Returns:
      a message in the current locale, or the default locale if the localization for the current locale is not found.
    • localize

      protected String localize(String message, Object... params)
      Get a localized message given its unique name and the current locale.
      Parameters:
      message - the unique name of the localized message.
      params - optional parmeters for the message.
      Returns:
      a message in the current locale, or the default locale if the localization for the current locale is not found.
    • runAction

      protected void runAction(Runnable r)
      Execute the specified runnable in a new thread. The thread name is this.getClass().getSimpleName().
      Parameters:
      r - the Runnable to execute.
    • setKeyAction

      protected static void setKeyAction(JComponent comp, KeyStroke vkey, Action action, Object actionKey)
      Associate a keyboard virtual key with an action.
      Parameters:
      comp - the JComponent whose InputMap and ActionMap this method modifies.
      vkey - the virtual key code to associate with the action, built from one of the values in KeyEvent, for instance: KeyEvent.VK_ENTER.
      action - the action to trigger upon pressing the keyboard key.
      actionKey - a key to use int he ActionMap.
    • setOkCancelKeys

      public static void setOkCancelKeys(OptionElement option, Action okAction, Action cancelAction)
      Associate 'ok' and 'cancel' actions with 'Enter' and 'Esc' keys, repsectively.
      Parameters:
      option - contains the JComponent whose InputMap and ActionMap this method modifies.
      okAction - the action to execute upon pressing 'Enter'.
      cancelAction - the action to execute upon pressing 'Esc'.
    • setOkCancelKeys

      public static void setOkCancelKeys(JComponent option, Action okAction, Action cancelAction)
      Associate 'ok' and 'cancel' actions with 'Enter' and 'Esc' keys, repsectively.
      Parameters:
      option - contains the JComponent whose InputMap and ActionMap this method modifies.
      okAction - the action to execute upon pressing 'Enter'.
      cancelAction - the action to execute upon pressing 'Esc'.
    • loadWithPreferences

      protected OptionElement loadWithPreferences(String xmlPath)
      Load the persisted preferences for the specified element and all of its descendants.
      Parameters:
      xmlPath - path to the xml resource to load.
      Returns:
      elt, for method chaining.
    • loadPreferences

      protected OptionElement loadPreferences(OptionElement elt)
      Load the persisted preferences for the specified element and all of its descendants.
      Parameters:
      elt - the root of element for which preferences are loaded.
      Returns:
      elt, for method chaining.
    • savePreferences

      protected OptionElement savePreferences(OptionElement elt)
      Save the persisted preferences for the specified element and all of its descendants.
      Parameters:
      elt - the root element for which preferences are saved.
      Returns:
      elt, for method chaining.
    • readyDialog

      protected void readyDialog(JDialog dialog, JComponent comp, Point location)
      Make the specified dialog ready for display.
      Parameters:
      dialog - the dialog to prepare.
      comp - the dialog"'s content.
      location - the dialog's location, may be null.
    • disposeDialog

      protected void disposeDialog(JDialog dialog)
      Dispose of the specified dialog.
      Parameters:
      dialog - the dialog to dispose of.