Package docking.action.builder
Class MultiStateActionBuilder<T>
- java.lang.Object
-
- docking.action.builder.AbstractActionBuilder<MultiStateDockingAction<T>,ActionContext,MultiStateActionBuilder<T>>
-
- docking.action.builder.MultiStateActionBuilder<T>
-
- Type Parameters:
T
- The action state type
public class MultiStateActionBuilder<T> extends AbstractActionBuilder<MultiStateDockingAction<T>,ActionContext,MultiStateActionBuilder<T>>
Builder forMultiStateDockingAction
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class docking.action.builder.AbstractActionBuilder
AbstractActionBuilder.When
-
-
Field Summary
-
Fields inherited from class docking.action.builder.AbstractActionBuilder
actionCallback, actionContextClass, keyBindingType, name, owner
-
-
Constructor Summary
Constructors Constructor Description MultiStateActionBuilder(java.lang.String name, java.lang.String owner)
Builder constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiStateActionBuilder<T>
addState(ActionState<T> actionState)
Add an action stateMultiStateActionBuilder<T>
addState(java.lang.String displayName, javax.swing.Icon icon, T userData)
Add an action stateMultiStateActionBuilder<T>
addStates(java.util.List<ActionState<T>> list)
Add a list of action statesMultiStateDockingAction<T>
build()
Builds the action.MultiStateActionBuilder<T>
onActionStateChanged(java.util.function.BiConsumer<ActionState<T>,EventTrigger> biConsumer)
Sets the primary callback to be executed when this action changes its action state.MultiStateActionBuilder<T>
performActionOnButtonClick(boolean b)
Configure whether to perform actions on a button click.protected MultiStateActionBuilder<T>
self()
Returns this (typed for subclass) for chainingMultiStateActionBuilder<T>
useCheckboxForIcons(boolean b)
Overrides the default icons for actions shown in popup menu of the multi-state action.protected void
validate()
-
Methods inherited from class docking.action.builder.AbstractActionBuilder
buildAndInstall, buildAndInstallLocal, decorateAction, description, enabled, enabledWhen, helpLocation, inWindow, isKeyBindingAction, isMenuAction, isPopupAction, isToolbarAction, keyBinding, keyBinding, menuGroup, menuGroup, menuIcon, menuMnemonic, menuPath, onAction, popupMenuGroup, popupMenuGroup, popupMenuIcon, popupMenuPath, popupWhen, sharedKeyBinding, supportsDefaultToolContext, toolBarGroup, toolBarGroup, toolBarIcon, toolBarIcon, validContextWhen, withContext
-
-
-
-
Method Detail
-
self
protected MultiStateActionBuilder<T> self()
Description copied from class:AbstractActionBuilder
Returns this (typed for subclass) for chaining- Specified by:
self
in classAbstractActionBuilder<MultiStateDockingAction<T>,ActionContext,MultiStateActionBuilder<T>>
- Returns:
- this for chaining
-
onActionStateChanged
public MultiStateActionBuilder<T> onActionStateChanged(java.util.function.BiConsumer<ActionState<T>,EventTrigger> biConsumer)
Sets the primary callback to be executed when this action changes its action state. This builder will throw anIllegalStateException
if one of the build methods is called without providing this callback- Parameters:
biConsumer
- the callback to execute when the selected action state is changed.- Returns:
- this builder (for chaining)
-
performActionOnButtonClick
public MultiStateActionBuilder<T> performActionOnButtonClick(boolean b)
Configure whether to perform actions on a button click. SeeMultiActionDockingAction.setPerformActionOnButtonClick(boolean)
- Parameters:
b
- true if the main action is invokable- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
useCheckboxForIcons
public MultiStateActionBuilder<T> useCheckboxForIcons(boolean b)
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:
b
- true to use a checkbox- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
addState
public MultiStateActionBuilder<T> addState(java.lang.String displayName, javax.swing.Icon icon, T userData)
Add an action state- Parameters:
displayName
- the name to appear in the action menuicon
- the icon to appear in the action menuuserData
- the data associated with this state- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
addState
public MultiStateActionBuilder<T> addState(ActionState<T> actionState)
Add an action state- Parameters:
actionState
- the action state to add- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
addStates
public MultiStateActionBuilder<T> addStates(java.util.List<ActionState<T>> list)
Add a list of action states- Parameters:
list
- a list of ActionStates;- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
build
public MultiStateDockingAction<T> build()
Description copied from class:AbstractActionBuilder
Builds the action. To build and install the action in one step, useAbstractActionBuilder.buildAndInstall(Tool)
orAbstractActionBuilder.buildAndInstallLocal(ComponentProvider)
.AbstractActionBuilder.inWindow(When)
- Specified by:
build
in classAbstractActionBuilder<MultiStateDockingAction<T>,ActionContext,MultiStateActionBuilder<T>>
- Returns:
- the newly build action
-
validate
protected void validate()
- Overrides:
validate
in classAbstractActionBuilder<MultiStateDockingAction<T>,ActionContext,MultiStateActionBuilder<T>>
-
-