|
org.openide.util 6.8.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.util.SharedClassObject org.openide.util.actions.SystemAction
public abstract class SystemAction
The common predecessor of callable actions in the IDE.
Also implements the Swing Action
to enable use
with the Swing action model.
An action class is a singleton, i.e. should generally contain no instance state. Rather, subclassing and use of abstract protected methods should be used to create variants of the action.
While it is possible to subclass this class directly--for example, if your "action" is really a placeholder for a popup menu that shows other actions--most people will prefer to use one of the subclasses, which are more convenient.
Field Summary | |
---|---|
static String |
PROP_ENABLED
Name of property indicating whether or not the action is enabled. |
static String |
PROP_ICON
Name of property for the action's display icon. |
Fields inherited from interface javax.swing.Action |
---|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
---|---|
SystemAction()
|
Method Summary | |
---|---|
abstract void |
actionPerformed(ActionEvent ev)
Actually perform the action. |
protected boolean |
clearSharedData()
Indicate whether action state should be cleared after the last action of this class is deleted. |
static JPopupMenu |
createPopupMenu(SystemAction[] actions)
Deprecated. Use Utilities.actionsToPopup(javax.swing.Action[], org.openide.util.Lookup) |
static JToolBar |
createToolbarPresenter(SystemAction[] actions)
Create the default toolbar representation of an array of actions. |
static SystemAction |
get(Class actionClass)
Obtain a singleton instance of the action with a specified class. |
abstract HelpCtx |
getHelpCtx()
Get a help context for the action. |
Icon |
getIcon()
Get the action's display icon. |
Icon |
getIcon(boolean createLabel)
Get the action's display icon, possibly creating a text label. |
abstract String |
getName()
Get a human presentable name of the action. |
Object |
getValue(String name)
Get a property in the singleton. |
protected String |
iconResource()
Specify the proper resource name for the action's icon. |
protected void |
initialize()
Initialize the action. |
boolean |
isEnabled()
Test whether the action is currently enabled. |
static SystemAction[] |
linkActions(SystemAction[] actions1,
SystemAction[] actions2)
Concatenate two arrays of actions. |
void |
putValue(String name,
Object value)
Set a property in the singleton. |
void |
setEnabled(boolean value)
Set whether the action should be enabled. |
void |
setIcon(Icon icon)
Set the action's display icon. |
Methods inherited from class org.openide.util.SharedClassObject |
---|
addNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, putProperty, putProperty, readExternal, removeNotify, removePropertyChangeListener, reset, writeExternal, writeReplace |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.Action |
---|
addPropertyChangeListener, removePropertyChangeListener |
Field Detail |
---|
public static final String PROP_ENABLED
public static final String PROP_ICON
Constructor Detail |
---|
public SystemAction()
Method Detail |
---|
public static SystemAction get(Class actionClass)
actionClass
- the class of the action to find
ClassCastException
- if the class is not SystemAction
IllegalArgumentException
- if the instance cannot be createdpublic abstract String getName()
Using the normal menu presenters, an included ampersand before a letter will be treated as the name of a mnemonic.
public abstract HelpCtx getHelpCtx()
getHelpCtx
in interface HelpCtx.Provider
public boolean isEnabled()
true
if sopublic void setEnabled(boolean value)
setEnabled
in interface Action
value
- true
to enable itpublic final void putValue(String name, Object value)
name
- the name of the propertyvalue
- the valuepublic final Object getValue(String name)
Action.NAME
, Action.SMALL_ICON
and "iconBase" are also recognized
and delegated to getName()
, getIcon()
and iconResource()
resp.
name
- the name of the property
public abstract void actionPerformed(ActionEvent ev)
ActionListener.actionPerformed(java.awt.event.ActionEvent)
.
In some cases, the implementation may have an empty body, if the presenters handle the performing of the action in a different way than by calling this method.
Since 4.11, will be performed directly in the event thread.
actionPerformed
in interface ActionListener
ev
- the event triggering the actionprotected void initialize()
initialize
in class SharedClassObject
protected boolean clearSharedData()
clearSharedData
in class SharedClassObject
false
in the default implementationpublic final void setIcon(Icon icon)
icon
- the iconpublic final Icon getIcon()
IllegalStateException
- if an icon could not be createdpublic final Icon getIcon(boolean createLabel)
createLabel
- if true
, create a textual icon if otherwise there
would be none; if false
, create a blank icon
IllegalStateException
- if an icon could not be createdprotected String iconResource()
putValue("noIconInMenu", Boolean.TRUE)
to make sure that no extra space is allotted for an icon in the menu item.
com/mycom/mymodule/myIcon.gif
; or null
to have no icon (make a text label)public static JToolBar createToolbarPresenter(SystemAction[] actions)
actions
- actions to show in the generated toolbar
public static SystemAction[] linkActions(SystemAction[] actions1, SystemAction[] actions2)
actions1
- first array of actions to linkactions2
- second array of actions to link
public static JPopupMenu createPopupMenu(SystemAction[] actions)
Utilities.actionsToPopup(javax.swing.Action[], org.openide.util.Lookup)
actions
- actions to show in the generated menu
|
org.openide.util 6.8.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |