Class MultiStateDockingAction<T>
- Type Parameters:
T
- the type of the user data
- All Implemented Interfaces:
DockingActionIf
,HelpDescriptor
- Direct Known Subclasses:
NonToolbarMultiStateAction
The button of this action has a drop-down icon that allows users to change the state of the
button. As the user changes the state of this action,
actionStateChanged(ActionState, EventTrigger)
will be called. Clients may also use the
button of this action to respond to button presses by overriding
actionPerformed(ActionContext)
.
This action is intended primarily for use as toolbar actions. Alternatively, some clients use
this action to add a button to custom widgets. In the custom use case, clients should use
NonToolbarMultiStateAction
.
- See Also:
-
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
actionPerformed
(ActionContext context) This method is called when the user clicks the button when this action is used as part of the defaultDockingAction
framework.abstract void
actionStateChanged
(ActionState<T> newActionState, EventTrigger trigger) This method will be called as the user changes the selected button statevoid
addActionState
(ActionState<T> actionState) Add the suppliedActionState
.protected void
doSetCurrentActionState
(ActionState<T> actionState, EventTrigger trigger) List
<ActionState<T>> protected List
<DockingActionIf> protected List
<ActionState<T>> Extension point: Get the states to display when the button is clickedprotected boolean
isStateEnabled
(ActionState<T> state) Check if the given state can be selectedvoid
setActionStates
(List<ActionState<T>> newStates) void
setCurrentActionState
(ActionState<T> actionState) void
void
setCurrentActionStateWithTrigger
(ActionState<T> actionState, EventTrigger trigger) void
setDefaultIcon
(Icon icon) Sets the icon to use if the active action state does not supply an icon.void
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
setSubGroup
(String subGroup) void
setUseCheckboxForIcons
(boolean useCheckboxForIcons) Overrides the default icons for actions shown in popup menu of the multi-state action.protected void
protected void
superSetMenuBarData
(MenuData newMenuData) Methods inherited from class docking.action.DockingAction
addPropertyChangeListener, addToWindowWhen, createButton, createMenuItem, dispose, doCreateMenuItem, enabledWhen, firePropertyChanged, getContextClass, getDefaultKeyBindingData, getDescription, getFullName, getHelpInfo, getHelpLocation, getHelpObject, getInceptionFromTheFirstClassThatIsNotUsOrABuilder, getInceptionInformation, getKeyBinding, getKeyBindingData, getKeyBindingType, getMenuBarData, getName, getOwner, getPopupMenuData, getPreferredKeyBindingType, getToolBarData, isAddToPopup, isEnabled, isEnabledForContext, isValidContext, markHelpUnnecessary, popupWhen, removePropertyChangeListener, setAddToAllWindows, setContextClass, setDescription, setEnabled, setHelpLocation, setKeyBindingData, setToolBarData, setUnvalidatedKeyBindingData, shouldAddToWindow, supportsDefaultContext, toString, validContextWhen
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
-
MultiStateDockingAction
Constructor- Parameters:
name
- the action nameowner
- the owner
-
-
Method Details
-
actionPerformed
This method is called when the user clicks the button when this action is used as part of the defaultDockingAction
framework.This is the callback to be overridden when the child wishes to respond to user button presses that are on the button and not the drop-down. The default behavior is to show the popup menu when the button is clicked.
- Specified by:
actionPerformed
in interfaceDockingActionIf
- Specified by:
actionPerformed
in classDockingAction
- Parameters:
context
- theActionContext
object that provides information about where and how this action was invoked.
-
setUseCheckboxForIcons
public void setUseCheckboxForIcons(boolean useCheckboxForIcons) Overrides the default icons for actions shown in popup menu of the multi-state action.By default, the popup menu items will use the icons as provided by the
ActionState
. By passing true to this method, icons will not be used in the popup menu. Instead, a checkbox icon will be used to show the active action state.- Parameters:
useCheckboxForIcons
- true to use a checkbox
-
setDefaultIcon
Sets the icon to use if the active action state does not supply an icon.This is useful if you wish for your action states to not use icon, but desire the action itself to have an icon.
- Parameters:
icon
- the icon
-
getStates
Extension point: Get the states to display when the button is clickedThis is called when the button is clicked, immediately before the menu is displayed. It is generally recommended to ensure the current state is included in this list. The states will be displayed in the order of the returned list.
- Returns:
- the list of possible states
-
getStateActions
-
setGroup
-
setSubGroup
-
setActionStates
-
getCurrentUserData
-
getCurrentState
-
getAllActionStates
-
setCurrentActionStateByUserData
-
doCreateButton
- Overrides:
doCreateButton
in classDockingAction
-
setMenuBarData
Description copied from class:DockingAction
Sets theMenuData
to be used to put this action on the tool's menu bar- Overrides:
setMenuBarData
in classDockingAction
- Parameters:
newMenuData
- the MenuData to be used to put this action on the tool's menu bar
-
superSetMenuBarData
-
setPopupMenuData
Description copied from class:DockingAction
Sets theMenuData
to be used to put this action in the tool's popup menu- Overrides:
setPopupMenuData
in classDockingAction
- Parameters:
newMenuData
- the MenuData to be used to put this action on the tool's popup menu
-
getToolTipText
-
showPopup
protected void showPopup()