Class DockingAction
- All Implemented Interfaces:
DockingActionIf
,HelpDescriptor
- Direct Known Subclasses:
AbstractFindReferencesDataTypeAction
,AbstractHelpAction
,AddAllFieldAction
,AddFieldAction
,AddSpacerFieldAction
,ComponentThemeInspectorAction
,ContextSpecificAction
,DeleteTableRowAction
,DisableFieldAction
,DomainFileProviderContextAction
,EnableFieldAction
,GlobalFocusTraversalAction
,HorizontalRuleAction
,InsertRowAction
,ListingContextAction
,MakeProgramSelectionAction
,MultiActionDockingAction
,MultiStateDockingAction
,NavigatableContextAction
,NextPreviousWindowAction
,ProgramContextAction
,ProgramLocationContextAction
,ProgramSymbolContextAction
,ProjectTreeAction
,RemoveAllFieldsAction
,RemoveFieldAction
,RemoveRowAction
,ResetAllFormatsAction
,ResetFormatAction
,ResetTranslationAction
,SaveImageAction
,SetKeyBindingAction
,SetSpacerTextAction
,SharedStubKeyBindingAction
,ShowActionChooserDialogAction
,ShowAllComponentsAction
,ShowContextMenuAction
,ShowFocusCycleAction
,ShowFocusInfoAction
,ToggleDockingAction
,ZoomInAction
,ZoomOutAction
,ZoomResetAction
DockingAction
defines a user action associated with a toolbar icon and/or
menu item. All actions must specify an action name which will be used to associate key bindings
and will be used as the popup menu item when needed. This name should be unique across
the entire application.
DockingActions can be invoked from the global menu, a popup menu, a toolbar, and/or a keybinding, depending on whether or not menuBarData, popupMenuData, toolBarData, and/or keyBindingData have been set.
Implementors of this class should override actionPerformed(ActionContext)
.
Generally, implementors should also override isEnabledForContext(ActionContext)
. This
method is used to determine if an action if applicable to the current context. Overriding this
method allows actions to manage their own enablement. Otherwise, the default behavior for this
method is to return the current enabled property of the action. This allows for the possibility
for plugins to externally manage the enablement of its actions.
NOTE: If you wish to do your own external enablement management for an action (which is highly
discouraged), it is very important that you don't use any of the internal enablement mechanisms
by setting the predicates enabledWhen(Predicate)
, validContextWhen(Predicate)
or overriding isValidContext(ActionContext)
. These predicates and methods trigger
internal enablement management which will interfere with you own calls to
setEnabled(boolean)
.
-
Field Summary
Fields inherited from interface docking.action.DockingActionIf
DESCRIPTION_PROPERTY, ENABLEMENT_PROPERTY, GLOBALCONTEXT_PROPERTY, KEYBINDING_DATA_PROPERTY, MENUBAR_DATA_PROPERTY, POPUP_MENU_DATA_PROPERTY, TOOLBAR_DATA_PROPERTY
-
Constructor Summary
ConstructorDescriptionDockingAction
(String name, String owner) DockingAction
(String name, String owner, boolean supportsKeyBindings) DockingAction
(String name, String owner, KeyBindingType kbType) -
Method Summary
Modifier and TypeMethodDescriptionabstract void
actionPerformed
(ActionContext context) method to actually perform the action logic for this action.void
Adds a listener to be notified if any property changesvoid
addToWindowWhen
(Class<? extends ActionContext> addToWindowContextClass) Sets the ActionContext class for when this action should be added to a windowfinal JButton
Returns a JButton that is suitable for this action.createMenuItem
(boolean isPopup) Returns a JMenuItem that is suitable for this action.void
dispose()
Cleans up any resources used by the action.protected JButton
protected JMenuItem
void
enabledWhen
(Predicate<ActionContext> predicate) Sets a predicate for dynamically determining the action's enabled state.void
firePropertyChanged
(String propertyName, Object oldValue, Object newValue) Class
<? extends ActionContext> Returns the class of a specific action context that this action requires for it to operate.Returns the defaultKeyBindingData
to be used to assign this action to a key binding.Returns a short description of this action.Returns the full name (the action name combined with the owner name)Returns a descriptive String about the help object that this descriptor represents.Returns the help location for this actionReturns the object for which help locations are defined.protected String
Returns a string that includes source file and line number information of where this action was createdConvenience method for getting the keybinding for this action.Returns theKeyBindingData
to be used to assign this action to a key binding.Returns this actions level of support for key binding accelerator keysReturns theMenuData
to be used to put this action in the menu bar.getName()
Returns the name of the actiongetOwner()
Returns the owner of this actionReturns theMenuData
to be used to put this action in a popup menu.protected KeyBindingType
Returns theToolBarData
to be used to put this action in a toolbar.boolean
isAddToPopup
(ActionContext context) method is used to determine if this action should be displayed on the current popup.boolean
Returns true if the action is enabled.boolean
isEnabledForContext
(ActionContext context) Method used to determine if this action should be enabled for the given context.boolean
isValidContext
(ActionContext context) Method that actions implement to indicate if this action is valid (knows how to work with, is appropriate for) for the given context.void
Signals the the help system that this action does not need a help entry.void
popupWhen
(Predicate<ActionContext> predicate) Sets a predicate for dynamically determining if this action should be included in an impending pop-up menu.void
Removes a listener to be notified of property changes.void
setAddToAllWindows
(boolean b) Tells this action to add itself to all windowsvoid
setContextClass
(Class<? extends ActionContext> type, boolean supportsDefaultContext) Sets the specific action context class that this action works on and if the action supports default context.void
setDescription
(String newDescription) Sets the description to be used in the tooltip.void
setEnabled
(boolean newValue) Enables or disables the actionvoid
setHelpLocation
(HelpLocation location) Set a specific Help location for this action.void
setKeyBindingData
(KeyBindingData newKeyBindingData) Sets theKeyBindingData
on an action to either assign a keybinding or remove it (keyBindingData = null).void
setMenuBarData
(MenuData newMenuData) Sets theMenuData
to be used to put this action on the tool's menu barvoid
setPopupMenuData
(MenuData newMenuData) Sets theMenuData
to be used to put this action in the tool's popup menuvoid
setToolBarData
(ToolBarData newToolBarData) Sets theToolBarData
to be used to put this action on the tool's toolbarvoid
setUnvalidatedKeyBindingData
(KeyBindingData newKeyBindingData) Users creating actions should not call this method, but should instead callDockingActionIf.setKeyBindingData(KeyBindingData)
.final boolean
shouldAddToWindow
(boolean isMainWindow, Set<Class<?>> contextTypes) Determines if this action should be added to a window.boolean
Returns true if this action also supports operating on a default context other then the active (focused) provider's context.toString()
void
validContextWhen
(Predicate<ActionContext> predicate) Sets a predicate for dynamically determining if this action is valid for the currentActionContext
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface docking.action.DockingActionIf
createMenuComponent, getOwnerDescription
-
Constructor Details
-
DockingAction
-
DockingAction
-
DockingAction
-
-
Method Details
-
getPreferredKeyBindingType
-
actionPerformed
Description copied from interface:DockingActionIf
method to actually perform the action logic for this action.- Specified by:
actionPerformed
in interfaceDockingActionIf
- Parameters:
context
- theActionContext
object that provides information about where and how this action was invoked.
-
addPropertyChangeListener
Description copied from interface:DockingActionIf
Adds a listener to be notified if any property changes- Specified by:
addPropertyChangeListener
in interfaceDockingActionIf
- Parameters:
listener
- The property change listener that will be notified of property change events.- See Also:
-
removePropertyChangeListener
Description copied from interface:DockingActionIf
Removes a listener to be notified of property changes.- Specified by:
removePropertyChangeListener
in interfaceDockingActionIf
- Parameters:
listener
- The property change listener that will be notified of property change events.- See Also:
-
getDescription
Description copied from interface:DockingActionIf
Returns a short description of this action. Generally used for a tooltip- Specified by:
getDescription
in interfaceDockingActionIf
- Returns:
- the description
-
getFullName
Description copied from interface:DockingActionIf
Returns the full name (the action name combined with the owner name)- Specified by:
getFullName
in interfaceDockingActionIf
- Returns:
- the full name
-
getMenuBarData
Description copied from interface:DockingActionIf
Returns theMenuData
to be used to put this action in the menu bar. The MenuData will be null if the action in not set to be in the menu bar.- Specified by:
getMenuBarData
in interfaceDockingActionIf
- Returns:
- the
MenuData
for the menu bar or null if the action is not in the menu bar.
-
getName
Description copied from interface:DockingActionIf
Returns the name of the action- Specified by:
getName
in interfaceDockingActionIf
- Returns:
- the name
-
getOwner
Description copied from interface:DockingActionIf
Returns the owner of this action- Specified by:
getOwner
in interfaceDockingActionIf
- Returns:
- the owner
-
getPopupMenuData
Description copied from interface:DockingActionIf
Returns theMenuData
to be used to put this action in a popup menu. The MenuData will be null if the action in not set to be in a popup menu.- Specified by:
getPopupMenuData
in interfaceDockingActionIf
- Returns:
- the
MenuData
for a popup menu or null if the action is not to be in a popup menu.
-
getToolBarData
Description copied from interface:DockingActionIf
Returns theToolBarData
to be used to put this action in a toolbar. The ToolBarData will be null if the action in not set to be in a toolbar.- Specified by:
getToolBarData
in interfaceDockingActionIf
- Returns:
- the
ToolBarData
for the popup menu or null if the action is not in a popup menu.
-
getInceptionInformation
Description copied from interface:DockingActionIf
Returns a string that includes source file and line number information of where this action was created- Specified by:
getInceptionInformation
in interfaceDockingActionIf
- Returns:
- the inception information
-
isEnabled
public boolean isEnabled()Description copied from interface:DockingActionIf
Returns true if the action is enabled.- Specified by:
isEnabled
in interfaceDockingActionIf
- Returns:
- true if the action is enabled, false otherwise
-
isAddToPopup
Description copied from interface:DockingActionIf
method is used to determine if this action should be displayed on the current popup. This method will only be called if the action has popupPopupMenuData
set.Generally, actions don't need to override this method as the default implementation will defer to the
DockingActionIf.isEnabledForContext(ActionContext)
, which will have the effect of adding the action to the popup only if it is enabled for a given context. By overriding this method, you can change this behavior so that the action will be added to the popup, even if it is disabled for the context, by having this method return true even if theDockingActionIf.isEnabledForContext(ActionContext)
method will return false, resulting in the action appearing in the popup menu, but begin disabled.- Specified by:
isAddToPopup
in interfaceDockingActionIf
- Parameters:
context
- theActionContext
from the active provider.- Returns:
- true if this action is appropriate for the given context.
-
isEnabledForContext
Description copied from interface:DockingActionIf
Method used to determine if this action should be enabled for the given context.This is the method implementors override to control when the action may be used.
This method will be called by the DockingWindowManager for actions on the global menuBar and toolBar and for actions that have a keyBinding.
This method will be called whenever one of the following events occur:
- when the user invokes the action via its keyBinding,
- the user changes focus from one component provider to another,
- the user moves a component to another position in the window or into another window,
- a component provider reports a change in it's context,
- any plugin or software component reports a general change in context (calls the tool.contextChanged(ComponentProvider) with a null parameter).
- Specified by:
isEnabledForContext
in interfaceDockingActionIf
- Parameters:
context
- the currentActionContext
for the window.- Returns:
- true if the action should be enabled for the context or false otherwise.
-
isValidContext
Description copied from interface:DockingActionIf
Method that actions implement to indicate if this action is valid (knows how to work with, is appropriate for) for the given context. This method is used to determine if the action should be enabled based on the either the local context or the global context. The action is first asked if it is valid for the local context and if not, then it is asked if it is valid for the global context. If a context is valid, then it will then be asked if it is enabled for that context.- Specified by:
isValidContext
in interfaceDockingActionIf
- Parameters:
context
- theActionContext
from the active provider.- Returns:
- true if this action is appropriate for the given context.
-
shouldAddToWindow
Determines if this action should be added to a window.If the client wants the action on all windows, then they can call
shouldAddToAllWindows
If the client wants the action to be on a window only when the window can produce a certain context type, the the client should call
addToWindowWhen(Class)
Otherwise, by default, the action will only be on the main window.
- Specified by:
shouldAddToWindow
in interfaceDockingActionIf
- Parameters:
isMainWindow
- true if the window in question is the main windowcontextTypes
- a list of contextTypes (Classes) based on the providers that are currently in the window.- Returns:
- true if this action should be added to the window, false otherwise.
-
setHelpLocation
Set a specific Help location for this action. This will replace the default help location- Parameters:
location
- the help location for the action.
-
getHelpLocation
Returns the help location for this action- Returns:
- the help location for this action
-
markHelpUnnecessary
public void markHelpUnnecessary()Signals the the help system that this action does not need a help entry. Some actions are so obvious that they do not require help, such as an action that renames a file.The method should be sparsely used, as most actions should provide help.
-
setEnabled
public void setEnabled(boolean newValue) Description copied from interface:DockingActionIf
Enables or disables the action- Specified by:
setEnabled
in interfaceDockingActionIf
- Parameters:
newValue
- true to enable the action, false to disable it
-
createButton
Description copied from interface:DockingActionIf
Returns a JButton that is suitable for this action. For example, It creates a ToggleButton if the action is aToggleDockingActionIf
.- Specified by:
createButton
in interfaceDockingActionIf
- Returns:
- a JButton to be used in a toolbar or null if the action does not have ToolBarData set.
-
createMenuItem
Description copied from interface:DockingActionIf
Returns a JMenuItem that is suitable for this action. For example, if the action is aToggleDockingActionIf
, then a JCheckBoxMenuItem will be created.- Specified by:
createMenuItem
in interfaceDockingActionIf
- Parameters:
isPopup
- true if the action should use its Popup MenuData, else it uses the MenuBar MenuData.- Returns:
- a JMenuItem for placement in either the menu bar or a popup menu.
-
getKeyBindingType
Description copied from interface:DockingActionIf
Returns this actions level of support for key binding accelerator keysActions support key bindings by default. Some reserved actions do not support key bindings, while others wish to share the same key bindings with multiple, equivalent actions (this allows the user to set one binding that works in many different contexts).
- Specified by:
getKeyBindingType
in interfaceDockingActionIf
- Returns:
- the key binding support
-
getKeyBinding
Description copied from interface:DockingActionIf
Convenience method for getting the keybinding for this action.- Specified by:
getKeyBinding
in interfaceDockingActionIf
- Returns:
- the
KeyStroke
to be used as a keybinding for this action or null if there is no
-
getKeyBindingData
Description copied from interface:DockingActionIf
Returns theKeyBindingData
to be used to assign this action to a key binding. The KeyBindingData will be null if the action is not set to have a keyBinding.- Specified by:
getKeyBindingData
in interfaceDockingActionIf
- Returns:
- the
KeyBindingData
for the action or null if the action does not have a keyBinding.
-
getDefaultKeyBindingData
Description copied from interface:DockingActionIf
Returns the defaultKeyBindingData
to be used to assign this action to a key binding. The KeyBindingData will be null if the action is not set to have a keyBinding. The value of this method is that which is set from a call toDockingActionIf.setKeyBindingData(KeyBindingData)
.- Specified by:
getDefaultKeyBindingData
in interfaceDockingActionIf
- Returns:
- the
KeyBindingData
for the action or null if the action does not have a keyBinding.
-
setKeyBindingData
Description copied from interface:DockingActionIf
Sets theKeyBindingData
on an action to either assign a keybinding or remove it (keyBindingData = null).- Specified by:
setKeyBindingData
in interfaceDockingActionIf
- Parameters:
newKeyBindingData
- if non-null, assigns a keybinding to the action. Otherwise, removes any keybinding from the action.
-
setUnvalidatedKeyBindingData
Description copied from interface:DockingActionIf
Users creating actions should not call this method, but should instead callDockingActionIf.setKeyBindingData(KeyBindingData)
.Call this method when you wish to bypass the validation of
DockingActionIf.setKeyBindingData(KeyBindingData)
so that keybindings are set exactly as they are given (such as when set by the user and not by the programmer).- Specified by:
setUnvalidatedKeyBindingData
in interfaceDockingActionIf
- Parameters:
newKeyBindingData
- the KeyBindingData to be used to assign this action to a keybinding
-
getContextClass
Description copied from interface:DockingActionIf
Returns the class of a specific action context that this action requires for it to operate. SeeActionContext
for details on the action context system.- Specified by:
getContextClass
in interfaceDockingActionIf
- Returns:
- the class of a specific action context that this action requires for it to operate
-
supportsDefaultContext
public boolean supportsDefaultContext()Description copied from interface:DockingActionIf
Returns true if this action also supports operating on a default context other then the active (focused) provider's context. See the class header for more details.- Specified by:
supportsDefaultContext
in interfaceDockingActionIf
- Returns:
- true if this action also supports operating on a default context other then the active (focused) provider's context.
-
setContextClass
Description copied from interface:DockingActionIf
Sets the specific action context class that this action works on and if the action supports default context. SeeActionContext
for details on how the action context system works.- Specified by:
setContextClass
in interfaceDockingActionIf
- Parameters:
type
- theActionContext
class that this action works on.supportsDefaultContext
- if true, then this action also support operating on a default context other than the active (focused) provider's context.
-
setMenuBarData
Sets theMenuData
to be used to put this action on the tool's menu bar- Parameters:
newMenuData
- the MenuData to be used to put this action on the tool's menu bar
-
setPopupMenuData
Sets theMenuData
to be used to put this action in the tool's popup menu- Parameters:
newMenuData
- the MenuData to be used to put this action on the tool's popup menu
-
setToolBarData
Sets theToolBarData
to be used to put this action on the tool's toolbar- Parameters:
newToolBarData
- the ToolBarData to be used to put this action on the tool's toolbar
-
setDescription
Sets the description to be used in the tooltip.- Parameters:
newDescription
- the description to be set.
-
dispose
public void dispose()Cleans up any resources used by the action.- Specified by:
dispose
in interfaceDockingActionIf
-
toString
-
getHelpInfo
Description copied from interface:HelpDescriptor
Returns a descriptive String about the help object that this descriptor represents.- Specified by:
getHelpInfo
in interfaceHelpDescriptor
- Returns:
- the help info
-
firePropertyChanged
-
getHelpObject
Description copied from interface:HelpDescriptor
Returns the object for which help locations are defined. This may be the implementor of this interface or some other delegate object.- Specified by:
getHelpObject
in interfaceHelpDescriptor
- Returns:
- the help object
-
enabledWhen
Sets a predicate for dynamically determining the action's enabled state. If this predicate is not set, the action's enable state must be controlled directly using thesetEnabled(boolean)
method. SeeDockingActionIf.isEnabledForContext(ActionContext)
- Parameters:
predicate
- the predicate that will be used to dynamically determine an action's enabled state.
-
popupWhen
Sets a predicate for dynamically determining if this action should be included in an impending pop-up menu. If this predicate is not set, the action's will be included in an impending pop-up, if it is enabled. SeeDockingActionIf.isAddToPopup(ActionContext)
- Parameters:
predicate
- the predicate that will be used to dynamically determine an action's enabled state.
-
validContextWhen
Sets a predicate for dynamically determining if this action is valid for the currentActionContext
. SeeDockingActionIf.isValidContext(ActionContext)
- Parameters:
predicate
- the predicate that will be used to dynamically determine an action's validity for a givenActionContext
-
addToWindowWhen
Sets the ActionContext class for when this action should be added to a windowIf this is set, the the action will only be added to windows that have providers that can produce an ActionContext that is appropriate for this action.
- Parameters:
addToWindowContextClass
- the ActionContext class required to be producible by a provider that is hosted in that window before this action is added to that window.
-
setAddToAllWindows
public void setAddToAllWindows(boolean b) Tells this action to add itself to all windows- Parameters:
b
- to add to all windows or not
-
doCreateButton
-
doCreateMenuItem
-
getInceptionFromTheFirstClassThatIsNotUsOrABuilder
-