Class CL_ContextAction
java.lang.Object
javax.swing.AbstractAction
org.jjazz.cl_editor.api.CL_ContextAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,ClsChangeListener,CL_ContextActionListener,org.openide.util.ContextAwareAction
public abstract class CL_ContextAction
extends AbstractAction
implements CL_ContextActionListener, ClsChangeListener, org.openide.util.ContextAwareAction
A base class for CL_Editor context aware actions.
To be used by actions associated to static menus, buttons or keyboard shortcuts, which act on the selection (chord symbols, bars, etc.), and whose enabled state depends on this selection. If your action is only used in a transient popupmenu created by Utilities.actionsToPopup() with no keyboard shorcut, you might prefer to use a simple AbstractAction+ContextAwareAction (see SetChordColor.java for example).
If your action is used in a transient popup menu (created by Utilities.actionsToPopup()) and needs to listen to a shared service, use a WeakListener or make your action a singleton (see Paste.java for example).
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAction property which defines the items listened to.Fields 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
ConstructorsConstructorDescriptionCreate an action which listens to all possible ListeningTargets in the global context. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidDefault implementation does nothing.createContextAwareInstance(org.openide.util.Lookup lkp) Convenience method to get the Action.NAME value or "not set".org.openide.util.LookupbooleanOverridden to defer initialization as late as possible.abstract voidselectionChange(CL_Selection selection) Called when selection in the provided context has changed.Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener, setEnabledMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.Action
accept, addPropertyChangeListener, getValue, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
LISTENING_TARGETS
Action property which defines the items listened to.Expected value is an EnumSet<ListeningTarget>.
- See Also:
-
-
Constructor Details
-
CL_ContextAction
public CL_ContextAction()Create an action which listens to all possible ListeningTargets in the global context.- See Also:
-
-
Method Details
-
getContext
public org.openide.util.Lookup getContext() -
getActionName
Convenience method to get the Action.NAME value or "not set".- Returns:
-
isEnabled
public boolean isEnabled()Overridden to defer initialization as late as possible.- Specified by:
isEnabledin interfaceAction- Overrides:
isEnabledin classAbstractAction- Returns:
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
selectionChange
Called when selection in the provided context has changed.Typically used to update the enabled state.
- Specified by:
selectionChangein interfaceCL_ContextActionListener- Parameters:
selection-- See Also:
-
createContextAwareInstance
- Specified by:
createContextAwareInstancein interfaceorg.openide.util.ContextAwareAction
-
chordLeadSheetChanged
Default implementation does nothing.- Specified by:
chordLeadSheetChangedin interfaceClsChangeListener- Parameters:
event-- See Also:
-