Class DockingAction

    • Constructor Detail

      • DockingAction

        public DockingAction​(java.lang.String name,
                             java.lang.String owner)
      • DockingAction

        public DockingAction​(java.lang.String name,
                             java.lang.String owner,
                             KeyBindingType kbType)
      • DockingAction

        public DockingAction​(java.lang.String name,
                             java.lang.String owner,
                             boolean supportsKeyBindings)
    • Method Detail

      • getPreferredKeyBindingType

        protected KeyBindingType getPreferredKeyBindingType()
      • actionPerformed

        public abstract void actionPerformed​(ActionContext context)
        Description copied from interface: DockingActionIf
        method to actually perform the action logic for this action.
        Specified by:
        actionPerformed in interface DockingActionIf
        Parameters:
        context - the ActionContext object that provides information about where and how this action was invoked.
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Description copied from interface: DockingActionIf
        Adds a listener to be notified if any property changes
        Specified by:
        addPropertyChangeListener in interface DockingActionIf
        Parameters:
        listener - The property change listener that will be notified of property change events.
        See Also:
        Action.addPropertyChangeListener(java.beans.PropertyChangeListener)
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: DockingActionIf
        Returns a short description of this action. Generally used for a tooltip
        Specified by:
        getDescription in interface DockingActionIf
        Returns:
        the description
      • getFullName

        public java.lang.String getFullName()
        Description copied from interface: DockingActionIf
        Returns the full name (the action name combined with the owner name)
        Specified by:
        getFullName in interface DockingActionIf
        Returns:
        the full name
      • getMenuBarData

        public MenuData getMenuBarData()
        Description copied from interface: DockingActionIf
        Returns the MenuData 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 interface DockingActionIf
        Returns:
        the MenuData for the menu bar or null if the action is not in the menu bar.
      • getName

        public java.lang.String getName()
        Description copied from interface: DockingActionIf
        Returns the name of the action
        Specified by:
        getName in interface DockingActionIf
        Returns:
        the name
      • getOwner

        public java.lang.String getOwner()
        Description copied from interface: DockingActionIf
        Returns the owner of this action
        Specified by:
        getOwner in interface DockingActionIf
        Returns:
        the owner
      • getPopupMenuData

        public MenuData getPopupMenuData()
        Description copied from interface: DockingActionIf
        Returns the MenuData 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 interface DockingActionIf
        Returns:
        the MenuData for a popup menu or null if the action is not to be in a popup menu.
      • getToolBarData

        public ToolBarData getToolBarData()
        Description copied from interface: DockingActionIf
        Returns the ToolBarData 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 interface DockingActionIf
        Returns:
        the ToolBarData for the popup menu or null if the action is not in a popup menu.
      • getInceptionInformation

        public java.lang.String 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 interface DockingActionIf
        Returns:
        the inception information
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: DockingActionIf
        Returns true if the action is enabled.
        Specified by:
        isEnabled in interface DockingActionIf
        Returns:
        true if the action is enabled, false otherwise
      • isAddToPopup

        public boolean isAddToPopup​(ActionContext context)
        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 popup PopupMenuData 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 the DockingActionIf.isEnabledForContext(ActionContext) method will return false, resulting in the action appearing in the popup menu, but begin disabled.

        Specified by:
        isAddToPopup in interface DockingActionIf
        Parameters:
        context - the ActionContext from the active provider.
        Returns:
        true if this action is appropriate for the given context.
      • isEnabledForContext

        public boolean isEnabledForContext​(ActionContext context)
        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:

        1. when the user invokes the action via its keyBinding,
        2. the user changes focus from one component provider to another,
        3. the user moves a component to another position in the window or into another window,
        4. a component provider reports a change in it's context,
        5. any plugin or software component reports a general change in context (calls the tool.contextChanged(ComponentProvider) with a null parameter).
        The default implementation will simply return this action's enablement state.
        Specified by:
        isEnabledForContext in interface DockingActionIf
        Parameters:
        context - the current ActionContext for the window.
        Returns:
        true if the action should be enabled for the context or false otherwise.
      • isValidContext

        public boolean isValidContext​(ActionContext context)
        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 interface DockingActionIf
        Parameters:
        context - the ActionContext from the active provider.
        Returns:
        true if this action is appropriate for the given context.
      • shouldAddToWindow

        public final boolean shouldAddToWindow​(boolean isMainWindow,
                                               java.util.Set<java.lang.Class<?>> contextTypes)
        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 interface DockingActionIf
        Parameters:
        isMainWindow - true if the window in question is the main window
        contextTypes - 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

        public void setHelpLocation​(HelpLocation location)
        Set a specific Help location for this action. This will replace the default help location
        Parameters:
        location - the help location for the 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 interface DockingActionIf
        Parameters:
        newValue - true to enable the action, false to disable it
      • setSupportsDefaultToolContext

        public void setSupportsDefaultToolContext​(boolean newValue)
        Description copied from interface: DockingActionIf
        Sets whether or not this action should be activated using the default tool context if the current focused provider's context is not valid for this action. Typically, this should be set on actions that are mostly independent of which component has focus such as those on the tool's main toolbar.
        Specified by:
        setSupportsDefaultToolContext in interface DockingActionIf
        Parameters:
        newValue - if true, the action will be activated using the default tool context if the local context is not valid for this action. If false, the action will only ever be activated using the focused context.
      • createButton

        public final javax.swing.JButton 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 a ToggleDockingActionIf.
        Specified by:
        createButton in interface DockingActionIf
        Returns:
        a JButton to be used in a toolbar or null if the action does not have ToolBarData set.
      • createMenuItem

        public javax.swing.JMenuItem createMenuItem​(boolean isPopup)
        Description copied from interface: DockingActionIf
        Returns a JMenuItem that is suitable for this action. For example, if the action is a ToggleDockingActionIf, then a JCheckBoxMenuItem will be created.
        Specified by:
        createMenuItem in interface DockingActionIf
        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

        public KeyBindingType getKeyBindingType()
        Description copied from interface: DockingActionIf
        Returns this actions level of support for key binding accelerator keys

        Actions 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 interface DockingActionIf
        Returns:
        the key binding support
      • getKeyBinding

        public javax.swing.KeyStroke getKeyBinding()
        Description copied from interface: DockingActionIf
        Convenience method for getting the keybinding for this action.
        Specified by:
        getKeyBinding in interface DockingActionIf
        Returns:
        the KeyStroke to be used as a keybinding for this action or null if there is no
      • setKeyBindingData

        public void setKeyBindingData​(KeyBindingData newKeyBindingData)
        Description copied from interface: DockingActionIf
        Sets the KeyBindingData on an action to either assign a keybinding or remove it (keyBindingData = null).
        Specified by:
        setKeyBindingData in interface DockingActionIf
        Parameters:
        newKeyBindingData - if non-null, assigns a keybinding to the action. Otherwise, removes any keybinding from the action.
      • setMenuBarData

        public void setMenuBarData​(MenuData newMenuData)
        Sets the MenuData 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

        public void setPopupMenuData​(MenuData newMenuData)
        Sets the MenuData 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

        public void setToolBarData​(ToolBarData newToolBarData)
        Sets the ToolBarData 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

        public void setDescription​(java.lang.String newDescription)
        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 interface DockingActionIf
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getHelpInfo

        public java.lang.String getHelpInfo()
        Description copied from interface: HelpDescriptor
        Returns a descriptive String about the help object that this descriptor represents.
        Specified by:
        getHelpInfo in interface HelpDescriptor
      • firePropertyChanged

        public void firePropertyChanged​(java.lang.String propertyName,
                                        java.lang.Object oldValue,
                                        java.lang.Object newValue)
      • getHelpObject

        public java.lang.Object 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 interface HelpDescriptor
      • enabledWhen

        public void enabledWhen​(java.util.function.Predicate<ActionContext> predicate)
        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 the setEnabled(boolean) method. See DockingActionIf.isEnabledForContext(ActionContext)
        Parameters:
        predicate - the predicate that will be used to dynamically determine an action's enabled state.
      • popupWhen

        public void popupWhen​(java.util.function.Predicate<ActionContext> predicate)
        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. See DockingActionIf.isAddToPopup(ActionContext)
        Parameters:
        predicate - the predicate that will be used to dynamically determine an action's enabled state.
      • addToWindowWhen

        public void addToWindowWhen​(java.lang.Class<? extends ActionContext> contextClass)
        Sets the ActionContext class for when this action should be added to a window

        If 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:
        contextClass - 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

        protected javax.swing.JButton doCreateButton()
      • doCreateMenuItem

        protected javax.swing.JMenuItem doCreateMenuItem()
      • getInceptionFromTheFirstClassThatIsNotUsOrABuilder

        protected java.lang.String getInceptionFromTheFirstClassThatIsNotUsOrABuilder()