Package docking.menu
Class MultiStateDockingAction<T>
- java.lang.Object
-
- docking.action.DockingAction
-
- docking.menu.MultiStateDockingAction<T>
-
- Type Parameters:
T
- the type of the user data
- All Implemented Interfaces:
DockingActionIf
,HelpDescriptor
- Direct Known Subclasses:
NonToolbarMultiStateAction
public abstract class MultiStateDockingAction<T> extends DockingAction
An action that can be in one of multiple states. The button of this action has a drop-down icon that allows users to change the state of the button. Also, by default, as the user presses the button, it will execute the action corresponding to the current state.Warning: if you use this action in a toolbar, then be sure to call the
correct constructor
. If you call another constructor, or pass false for this boolean above, yourdoActionPerformed(ActionContext)
method will get called twice.- See Also:
MultiActionDockingAction
-
-
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
Constructors Modifier Constructor Description MultiStateDockingAction(java.lang.String name, java.lang.String owner)
Call this constructor with this action will not be added to a toolbarprotected
MultiStateDockingAction(java.lang.String name, java.lang.String owner, boolean isToolbarAction)
Use this constructor explicitly when this action is used in a toolbar, passing true forisToolbarAction
(see the javadoc header note).
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(ActionContext context)
method to actually perform the action logic for this action.abstract void
actionStateChanged(ActionState<T> newActionState, EventTrigger trigger)
void
addActionState(ActionState<T> actionState)
add the suppliedActionState
iffireFirstEvent
istrue
the first one will fire its eventprotected void
doActionPerformed(ActionContext context)
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.javax.swing.JButton
doCreateButton()
java.util.List<ActionState<T>>
getAllActionStates()
ActionState<T>
getCurrentState()
T
getCurrentUserData()
protected java.util.List<DockingActionIf>
getStateActions()
java.lang.String
getToolTipText()
void
setActionStates(java.util.List<ActionState<T>> newStates)
void
setCurrentActionState(ActionState<T> actionState)
void
setCurrentActionStateByUserData(T t)
void
setCurrentActionStateWithTrigger(ActionState<T> actionState, EventTrigger trigger)
void
setDefaultIcon(javax.swing.Icon icon)
Sets the icon to use if the active action state does not supply an icon.void
setGroup(java.lang.String group)
void
setMenuBarData(MenuData newMenuData)
Sets theMenuData
to be used to put this action on the tool's menu barvoid
setPerformActionOnPrimaryButtonClick(boolean doPerformAction)
IfdoPerformAction
istrue
, then, when the user clicks the button and not the drop-down arrow, thedoActionPerformed(ActionContext)
method will be called.void
setPopupMenuData(MenuData newMenuData)
Sets theMenuData
to be used to put this action in the tool's popup menuvoid
setSubGroup(java.lang.String subGroup)
void
setUseCheckboxForIcons(boolean useCheckboxForIcons)
Overrides the default icons for actions shown in popup menu of the multi-state action.protected void
superSetMenuBarData(MenuData newMenuData)
-
Methods inherited from class docking.action.DockingAction
addPropertyChangeListener, addToWindowWhen, createButton, createMenuItem, dispose, doCreateMenuItem, enabledWhen, firePropertyChanged, getDefaultKeyBindingData, getDescription, getFullName, getHelpInfo, getHelpObject, getInceptionFromTheFirstClassThatIsNotUsOrABuilder, getInceptionInformation, getKeyBinding, getKeyBindingData, getKeyBindingType, getMenuBarData, getName, getOwner, getPopupMenuData, getPreferredKeyBindingType, getToolBarData, isAddToPopup, isEnabled, isEnabledForContext, isValidContext, markHelpUnnecessary, popupWhen, removePropertyChangeListener, setAddToAllWindows, setDescription, setEnabled, setHelpLocation, setKeyBindingData, setSupportsDefaultToolContext, setToolBarData, setUnvalidatedKeyBindingData, shouldAddToWindow, supportsDefaultToolContext, 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
getOwnerDescription
-
-
-
-
Constructor Detail
-
MultiStateDockingAction
public MultiStateDockingAction(java.lang.String name, java.lang.String owner)
Call this constructor with this action will not be added to a toolbar- Parameters:
name
- the action nameowner
- the owner- See Also:
MultiStateDockingAction(String, String, boolean)
-
MultiStateDockingAction
protected MultiStateDockingAction(java.lang.String name, java.lang.String owner, boolean isToolbarAction)
Use this constructor explicitly when this action is used in a toolbar, passing true forisToolbarAction
(see the javadoc header note).- Parameters:
name
- the action nameowner
- the ownerisToolbarAction
- true if this action is a toolbar action
-
-
Method Detail
-
actionStateChanged
public abstract void actionStateChanged(ActionState<T> newActionState, EventTrigger trigger)
-
setPerformActionOnPrimaryButtonClick
public void setPerformActionOnPrimaryButtonClick(boolean doPerformAction)
IfdoPerformAction
istrue
, then, when the user clicks the button and not the drop-down arrow, thedoActionPerformed(ActionContext)
method will be called. IfdoPerformAction
isfalse
, then, when the user clicks the button and not the drop-down arrow, the popup menu will be shown, just as if the user had clicked the drop-down arrow.Also, if the parameter is true, then the button will behave like a button in terms of mouse feedback. If false, then the button will behave more like a label.
- Parameters:
doPerformAction
- true to calldoActionPerformed(ActionContext)
when the user presses the button for this action (not the drop-down menu; see above)
-
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 theActionState
. 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
public void setDefaultIcon(javax.swing.Icon icon)
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
-
actionPerformed
public final void actionPerformed(ActionContext context)
Description copied from interface:DockingActionIf
method to actually perform the action logic for this action.- 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.
-
doActionPerformed
protected void doActionPerformed(ActionContext context)
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. This will only be called ifperformActionOnPrimaryButtonClick
is true.- Parameters:
context
- the action context
-
getStateActions
protected java.util.List<DockingActionIf> getStateActions()
-
setGroup
public void setGroup(java.lang.String group)
-
setSubGroup
public void setSubGroup(java.lang.String subGroup)
-
addActionState
public void addActionState(ActionState<T> actionState)
add the suppliedActionState
iffireFirstEvent
istrue
the first one will fire its event- Parameters:
actionState
- theActionState
to add
-
setActionStates
public void setActionStates(java.util.List<ActionState<T>> newStates)
-
getCurrentUserData
public T getCurrentUserData()
-
getCurrentState
public ActionState<T> getCurrentState()
-
getAllActionStates
public java.util.List<ActionState<T>> getAllActionStates()
-
setCurrentActionStateByUserData
public void setCurrentActionStateByUserData(T t)
-
setCurrentActionState
public void setCurrentActionState(ActionState<T> actionState)
-
setCurrentActionStateWithTrigger
public void setCurrentActionStateWithTrigger(ActionState<T> actionState, EventTrigger trigger)
-
doCreateButton
public javax.swing.JButton doCreateButton()
- Overrides:
doCreateButton
in classDockingAction
-
setMenuBarData
public void setMenuBarData(MenuData newMenuData)
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
protected void superSetMenuBarData(MenuData newMenuData)
-
setPopupMenuData
public void setPopupMenuData(MenuData newMenuData)
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
public java.lang.String getToolTipText()
-
-