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 for
MultiStateDockingAction
-
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
-
Method Summary
Modifier and TypeMethodDescriptionaddState
(ActionState<T> actionState) Add an action stateAdd an action stateaddStates
(List<ActionState<T>> list) Add a list of action statesbuild()
Builds the action.onActionStateChanged
(BiConsumer<ActionState<T>, EventTrigger> biConsumer) Sets the primary callback to be executed when this action changes its action state.protected MultiStateActionBuilder
<T> self()
Returns this (typed for subclass) for chainingstateGenerator
(Supplier<List<ActionState<T>>> generator) Generate the states dynamically upon the user clicking the buttonuseCheckboxForIcons
(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, toolBarGroup, toolBarGroup, toolBarIcon, toolBarIcon, validContextWhen, withContext, withContext
-
Constructor Details
-
MultiStateActionBuilder
Builder constructor- Parameters:
name
- the name of the action to be builtowner
- the owner of the action to be build
-
-
Method Details
-
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(BiConsumer<ActionState<T>, EventTrigger> biConsumer) Sets the primary callback to be executed when this action changes its action state.This builder will throw an
IllegalStateException
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)
-
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:
b
- true to use a checkbox- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
addState
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)
-
addStates
Add a list of action states- Parameters:
list
- a list of ActionStates;- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
stateGenerator
Generate the states dynamically upon the user clicking the buttonIt is highly recommended that the current state is included in the list of available states. Otherwise, the user could become confused or frustrated.
- Parameters:
generator
- a function from action context to available states- Returns:
- this MultiActionDockingActionBuilder (for chaining)
-
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>>
-