public abstract class CallbackSystemAction extends CallableSystemAction implements ContextAwareAction
<file name="action-pkg-ClassName.instance"> <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.callback"/> <attr name="key" stringvalue="KeyInActionMap"/> <attr name="surviveFocusChange" boolvalue="false"/> <!-- defaults to false --> <attr name="fallback" newvalue="action.pkg.DefaultAction"/> <!-- may be missing --> <attr name="displayName" bundlevalue="your.pkg.Bundle#key"/> <attr name="iconBase" stringvalue="your/pkg/YourImage.png"/> <!-- if desired: <attr name="noIconInMenu" boolvalue="false"/> --> </file>
Presenter.Menu, Presenter.Popup, Presenter.ToolbarPROP_ENABLED, PROP_ICONACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON| Constructor and Description |
|---|
CallbackSystemAction() |
| Modifier and Type | Method and Description |
|---|---|
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()
Deprecated.
use TopComponent.getActionMap() as described in the javadoc
|
boolean |
getSurviveFocusChange()
Test whether the action will survive a change in focus.
|
protected void |
initialize()
Initialize the action to have no performer.
|
void |
performAction()
Deprecated.
This only uses
ActionPerformer. Use actionPerformed(java.awt.event.ActionEvent) instead. |
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.
|
asynchronous, getMenuPresenter, getPopupPresenter, getToolbarPresenterclearSharedData, createPopupMenu, createToolbarPresenter, get, getHelpCtx, getIcon, getIcon, getName, getValue, iconResource, isEnabled, linkActions, putValue, setEnabled, setIconaddNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, putProperty, putProperty, readExternal, removeNotify, removePropertyChangeListener, reset, writeExternal, writeReplaceclone, getClass, notify, notifyAll, toString, wait, wait, waitaddPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabledprotected void initialize()
initialize in class SystemAction@Deprecated public ActionPerformer getActionPerformer()
null if there is currently no performer@Deprecated public 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 ActionListeneractionPerformed in class CallableSystemActionev - the event triggering the action@Deprecated public void performAction()
ActionPerformer. Use actionPerformed(java.awt.event.ActionEvent) instead.performAction in class CallableSystemActionpublic 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 ContextAwareActionactionContext - an arbitrary context (e.g. "cookies" from a node selection)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 themBuilt on August 24 2014. | Portions Copyright 1997-2014 Sun Microsystems, Inc. All rights reserved.