|
|||||||||||
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 org.openide.util.actions.CallableSystemAction org.openide.util.actions.CallbackSystemAction
Action that can have a performer of the action attached to it at any time, or changed. The action will be automatically disabled when it has no performer.
Also may be made sensitive to changes in window focus.
Nested Class Summary |
Nested classes inherited from class org.openide.util.actions.Presenter |
Presenter.Menu, Presenter.Popup, Presenter.Toolbar |
Field Summary |
Fields inherited from class org.openide.util.actions.SystemAction |
PROP_ENABLED, PROP_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 | |
CallbackSystemAction()
|
Method Summary | |
void |
actionPerformed(ActionEvent ev)
Perform the action. |
Action |
createContextAwareInstance(Lookup actionContext)
Implements ContextAwareAction interface method. |
Object |
getActionMapKey()
Getter for action map key, which is used to find action from provided context (i.e. |
ActionPerformer |
getActionPerformer()
Get the current action performer. |
boolean |
getSurviveFocusChange()
Test whether the action will survive a change in focus. |
protected void |
initialize()
Initialize the action to have no performer. |
void |
performAction()
Perform the action. |
void |
setActionPerformer(ActionPerformer performer)
Deprecated. use TopComponent.getActionMap() as described in the javadoc |
void |
setSurviveFocusChange(boolean b)
Set whether the action will survive a change in focus. |
Methods inherited from class org.openide.util.actions.CallableSystemAction |
asynchronous, getMenuPresenter, getPopupPresenter, getToolbarPresenter |
Methods inherited from class org.openide.util.actions.SystemAction |
clearSharedData, createPopupMenu, createToolbarPresenter, get, getHelpCtx, getIcon, getIcon, getName, getValue, iconResource, isEnabled, linkActions, putValue, setEnabled, setIcon |
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, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Constructor Detail |
public CallbackSystemAction()
Method Detail |
protected void initialize()
initialize
in class SystemAction
public ActionPerformer getActionPerformer()
null
if there is currently no performerpublic void setActionPerformer(ActionPerformer performer)
null
, which means that the action will have no performer
and is disabled. (SystemAction.isEnabled()
will return false
regardless its previous state.)
This method is too dynamic it depends on the actuall order of callers and is for example very fragile with respect to focus switching and correct delivering of focus change events. That is why an alternative based on ActionMap proposal has been developed.
So if you are providing a TopComponent and want to provide your own handling of CopyAction use following code:
TopComponent tc = ...; javax.swing.Action yourCopyAction = ...; // the action to invoke instead of Copy CopyAction globalCopyAction = SystemAction.get (CopyAction.class); Object key = globalCopyAction.getActionMapKey(); // key is a special value defined by all CallbackSystemActions // and finally: tc.getActionMap ().put (key, yourCopyAction);This code registers
yourCopyAction
with tc
top component, so whenever a globalCopyAction
is invoked,
your action is being delegated to.
performer
- the new action performer or null
to disablepublic void actionPerformed(ActionEvent ev)
actionPerformed
in interface ActionListener
actionPerformed
in class CallableSystemAction
public void performAction()
performAction
in class CallableSystemAction
public Object getActionMapKey()
ActionMap
provided by the context),
which acts as a callback.
Override this method in subclasses to provide 'nice' key.
public boolean getSurviveFocusChange()
true
if the enabled state of the action survives focus changespublic Action createContextAwareInstance(Lookup actionContext)
ContextAwareAction
interface method.
createContextAwareInstance
in interface ContextAwareAction
public void setSurviveFocusChange(boolean b)
false
, then the action will be automatically
disabled (using setActionPerformer(org.openide.util.actions.ActionPerformer)
) when the window
focus changes.
b
- true
to survive focus changes, false
to be sensitive to them
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |