Package org.jppf.ui.actions
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
Abstract superclass for actions used in toolbars or popup menus.
- Author:
- Laurent Cohen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe base location for internationalized messages.protected PointLocation at which to display any window or dialog created by this action.The list of selected elements.Fields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddisposeDialog(JDialog dialog) Dispose of the specified dialog.Get the location at which to display any window or dialog created by this action.protected OptionElementLoad the persisted preferences for the specified element and all of its descendants.protected OptionElementloadWithPreferences(String xmlPath) Load the persisted preferences for the specified element and all of its descendants.protected StringGet a localized message given its unique name and the current locale.protected StringGet a localized message given its unique name and the current locale.protected voidreadyDialog(JDialog dialog, JComponent comp, Point location) Make the specified dialog ready for display.protected voidExecute the specified runnable in a new thread.protected OptionElementSave the persisted preferences for the specified element and all of its descendants.protected static voidsetKeyAction(JComponent comp, KeyStroke vkey, Action action, Object actionKey) Associate a keyboard virtual key with an action.voidsetLocation(Point location) Set the location at which to display any window or dialog created by this action.static voidsetOkCancelKeys(JComponent option, Action okAction, Action cancelAction) Associate 'ok' and 'cancel' actions with 'Enter' and 'Esc' keys, repsectively.static voidsetOkCancelKeys(OptionElement option, Action okAction, Action cancelAction) Associate 'ok' and 'cancel' actions with 'Enter' and 'Esc' keys, repsectively.protected voidSet the icon for this action using the specified image file name.protected voidsetupNameAndTooltip(String name) Set the action name and tooltip text.protected voidsetupTooltip(String name) Set the action tooltip text.voidupdateState(List<Object> selectedElements) Update this action's enabled state based on a list of selected elements.voidvalueChanged(ValueChangeEvent event) Method called when the action is triggered.Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabledMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.Action
accept, addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabledMethods inherited from interface java.awt.event.ActionListener
actionPerformed
-
Field Details
-
BASE
The base location for internationalized messages. -
selectedElements
The list of selected elements. -
location
Location at which to display any window or dialog created by this action.
-
-
Constructor Details
-
AbstractUpdatableAction
public AbstractUpdatableAction()
-
-
Method Details
-
getLocation
Get the location at which to display any window or dialog created by this action.- Returns:
- a
Pointinstance.
-
setLocation
Set the location at which to display any window or dialog created by this action.- Parameters:
location- aPointinstance.
-
updateState
Update this action's enabled state based on a list of selected elements.- Specified by:
updateStatein interfaceUpdatableAction- Parameters:
selectedElements- a list of objects.
-
valueChanged
Method called when the action is triggered.- Specified by:
valueChangedin interfaceValueChangeListener- Parameters:
event- the event encapsulating the source of the event.
-
setupIcon
Set the icon for this action using the specified image file name.- Parameters:
name- the name of the icon image file.
-
setupNameAndTooltip
Set the action name and tooltip text.- Parameters:
name- the key to find the name and tooltip in the localized resource bundles.
-
setupTooltip
Set the action tooltip text.- Parameters:
name- the key to find the tooltip in the localized resource bundles.
-
localize
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
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
Execute the specified runnable in a new thread. The thread name isthis.getClass().getSimpleName().- Parameters:
r- theRunnableto execute.
-
setKeyAction
protected static void setKeyAction(JComponent comp, KeyStroke vkey, Action action, Object actionKey) Associate a keyboard virtual key with an action.- Parameters:
comp- theJComponentwhoseInputMapandActionMapthis method modifies.vkey- the virtual key code to associate with the action, built from one of the values inKeyEvent, for instance:KeyEvent.VK_ENTER.action- the action to trigger upon pressing the keyboard key.actionKey- a key to use int heActionMap.
-
setOkCancelKeys
Associate 'ok' and 'cancel' actions with 'Enter' and 'Esc' keys, repsectively.- Parameters:
option- contains theJComponentwhoseInputMapandActionMapthis method modifies.okAction- the action to execute upon pressing 'Enter'.cancelAction- the action to execute upon pressing 'Esc'.
-
setOkCancelKeys
Associate 'ok' and 'cancel' actions with 'Enter' and 'Esc' keys, repsectively.- Parameters:
option- contains theJComponentwhoseInputMapandActionMapthis method modifies.okAction- the action to execute upon pressing 'Enter'.cancelAction- the action to execute upon pressing 'Esc'.
-
loadWithPreferences
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
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
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
Make the specified dialog ready for display.- Parameters:
dialog- the dialog to prepare.comp- the dialog"'s content.location- the dialog's location, may benull.
-
disposeDialog
Dispose of the specified dialog.- Parameters:
dialog- the dialog to dispose of.
-