- java.lang.Object
-
- org.controlsfx.control.action.ActionUtils
-
public class ActionUtils extends Object
Convenience class for users of theAction
API. Primarily this class is used to conveniently create UI controls from a given Action (this is necessary for now as there is no built-in support for Action in JavaFX UI controls at present).Some of the methods in this class take a
Collection
ofactions
. In these cases, it is likely they are designed to work withaction groups
. For examples on how to work with these methods, refer to theActionGroup
class documentation.- See Also:
Action
,ActionGroup
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ActionUtils.ActionTextBehavior
Action text behavior.
-
Field Summary
Fields Modifier and Type Field Description static Action
ACTION_SEPARATOR
Action representation of the generic separator.static Action
ACTION_SPAN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ButtonBase
configureButton(Action action, ButtonBase button)
static ButtonBase
configureButton(Action action, ButtonBase button, ActionUtils.ActionTextBehavior textBehavior)
static MenuItem
configureMenuItem(Action action, MenuItem menuItem)
static Button
createButton(Action action)
static Button
createButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
static ButtonBar
createButtonBar(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aButtonBar
populated with appropriatenodes
bound to the providedactions
.static CheckBox
createCheckBox(Action action)
static CheckMenuItem
createCheckMenuItem(Action action)
Takes the providedAction
and returns aCheckMenuItem
instance with all relevant properties bound to the properties of the Action.static ContextMenu
createContextMenu(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aContextMenu
populated with appropriatenodes
bound to the providedactions
.static Hyperlink
createHyperlink(Action action)
static Menu
createMenu(Action action)
static MenuBar
createMenuBar(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aMenuBar
populated with appropriatenodes
bound to the providedactions
.static MenuButton
createMenuButton(Action action)
Takes the providedAction
and returns aMenuButton
instance with all relevant properties bound to the properties of the Action.static MenuButton
createMenuButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedAction
and returns aMenuButton
instance with all relevant properties bound to the properties of the Action.static MenuItem
createMenuItem(Action action)
static RadioButton
createRadioButton(Action action)
Takes the providedAction
and returns aRadioButton
instance with all relevant properties bound to the properties of the Action.static RadioMenuItem
createRadioMenuItem(Action action)
Takes the providedAction
and returns aRadioMenuItem
instance with all relevant properties bound to the properties of the Action.static SegmentedButton
createSegmentedButton(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.static SegmentedButton
createSegmentedButton(Action... actions)
Takes the provided varargs array ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.static SegmentedButton
createSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.static SegmentedButton
createSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Action... actions)
Takes the provided varargs array ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.static ToggleButton
createToggleButton(Action action)
Takes the providedAction
and returns aToggleButton
instance with all relevant properties bound to the properties of the Action.static ToggleButton
createToggleButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedAction
and returns aToggleButton
instance with all relevant properties bound to the properties of the Action.static ToolBar
createToolBar(Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aToolBar
populated with appropriatenodes
bound to the providedactions
.static void
unconfigureButton(ButtonBase button)
Removes all bindings and listeners which were added when the suppliedButtonBase
was bound to anAction
via one of the methods of this class.static void
unconfigureMenuItem(MenuItem menuItem)
static ButtonBar
updateButtonBar(ButtonBar buttonBar, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and updates aButtonBar
populated with appropriatenodes
bound to the providedactions
.static ContextMenu
updateContextMenu(ContextMenu menu, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and updates aContextMenu
populated with appropriatenodes
bound to the providedactions
.static MenuBar
updateMenuBar(MenuBar menuBar, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and updates aMenuBar
populated with appropriatenodes
bound to the providedactions
.static ToolBar
updateToolBar(ToolBar toolbar, Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns providedToolBar
populated with appropriatenodes
bound to the providedactions
.
-
-
-
Field Detail
-
ACTION_SEPARATOR
public static Action ACTION_SEPARATOR
Action representation of the generic separator. Adding this action anywhere in the action tree serves as indication that separator has be created in its place. SeeActionGroup
for example of action tree creation
-
ACTION_SPAN
public static Action ACTION_SPAN
-
-
Method Detail
-
createButton
public static Button createButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedAction
and returns aButton
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theButton
should bind to.textBehavior
- DefinesActionUtils.ActionTextBehavior
- Returns:
- A
Button
that is bound to the state of the providedAction
-
configureButton
public static ButtonBase configureButton(Action action, ButtonBase button, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedAction
and binds the relevant properties to the suppliedButton
. This allows for the use of Actions within custom Button subclasses.- Parameters:
action
- TheAction
that theButton
should bind to.button
- TheButtonBase
that theAction
should be bound to.textBehavior
- DefinesActionUtils.ActionTextBehavior
- Returns:
- The
ButtonBase
that was bound to theAction
.
-
configureButton
public static ButtonBase configureButton(Action action, ButtonBase button)
Takes the providedAction
and binds the relevant properties to the suppliedButton
. This allows for the use of Actions within custom Button subclasses.- Parameters:
action
- TheAction
that theButton
should bind to.button
- TheButtonBase
that theAction
should be bound to.- Returns:
- The
ButtonBase
that was bound to theAction
.
-
unconfigureButton
public static void unconfigureButton(ButtonBase button)
Removes all bindings and listeners which were added when the suppliedButtonBase
was bound to anAction
via one of the methods of this class.- Parameters:
button
- aButtonBase
that was bound to anAction
-
createMenuButton
public static MenuButton createMenuButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedAction
and returns aMenuButton
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theMenuButton
should bind to.textBehavior
- DefinesActionUtils.ActionTextBehavior
- Returns:
- A
MenuButton
that is bound to the state of the providedAction
-
createMenuButton
public static MenuButton createMenuButton(Action action)
Takes the providedAction
and returns aMenuButton
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theMenuButton
should bind to.- Returns:
- A
MenuButton
that is bound to the state of the providedAction
-
createToggleButton
public static ToggleButton createToggleButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedAction
and returns aToggleButton
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theToggleButton
should bind to.textBehavior
- DefinesActionUtils.ActionTextBehavior
- Returns:
- A
ToggleButton
that is bound to the state of the providedAction
-
createToggleButton
public static ToggleButton createToggleButton(Action action)
Takes the providedAction
and returns aToggleButton
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theToggleButton
should bind to.- Returns:
- A
ToggleButton
that is bound to the state of the providedAction
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.- Parameters:
actions
- TheCollection
ofAction
that theSegmentedButton
should bind to.textBehavior
- DefinesActionUtils.ActionTextBehavior
- Returns:
- A
SegmentedButton
that is bound to the state of the providedAction
s
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.- Parameters:
actions
- TheCollection
ofAction
that theSegmentedButton
should bind to.- Returns:
- A
SegmentedButton
that is bound to the state of the providedAction
s
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Action... actions)
Takes the provided varargs array ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.- Parameters:
actions
- A varargs array ofAction
that theSegmentedButton
should bind to.textBehavior
- DefinesActionUtils.ActionTextBehavior
- Returns:
- A
SegmentedButton
that is bound to the state of the providedAction
s
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(Action... actions)
Takes the provided varargs array ofAction
and returns aSegmentedButton
instance with all relevant properties bound to the properties of the actions.- Parameters:
actions
- A varargs array ofAction
that theSegmentedButton
should bind to.- Returns:
- A
SegmentedButton
that is bound to the state of the providedAction
s
-
createRadioButton
public static RadioButton createRadioButton(Action action)
Takes the providedAction
and returns aRadioButton
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theRadioButton
should bind to.- Returns:
- A
RadioButton
that is bound to the state of the providedAction
-
unconfigureMenuItem
public static void unconfigureMenuItem(MenuItem menuItem)
-
createCheckMenuItem
public static CheckMenuItem createCheckMenuItem(Action action)
Takes the providedAction
and returns aCheckMenuItem
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theCheckMenuItem
should bind to.- Returns:
- A
CheckMenuItem
that is bound to the state of the providedAction
-
createRadioMenuItem
public static RadioMenuItem createRadioMenuItem(Action action)
Takes the providedAction
and returns aRadioMenuItem
instance with all relevant properties bound to the properties of the Action.- Parameters:
action
- TheAction
that theRadioMenuItem
should bind to.- Returns:
- A
RadioMenuItem
that is bound to the state of the providedAction
-
createToolBar
public static ToolBar createToolBar(Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aToolBar
populated with appropriatenodes
bound to the providedactions
.
-
updateToolBar
public static ToolBar updateToolBar(ToolBar toolbar, Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns providedToolBar
populated with appropriatenodes
bound to the providedactions
. Previous toolbar content is removed
-
createMenuBar
public static MenuBar createMenuBar(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aMenuBar
populated with appropriatenodes
bound to the providedactions
.
-
updateMenuBar
public static MenuBar updateMenuBar(MenuBar menuBar, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and updates aMenuBar
populated with appropriatenodes
bound to the providedactions
. Previous MenuBar content is removed.
-
createButtonBar
public static ButtonBar createButtonBar(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aButtonBar
populated with appropriatenodes
bound to the providedactions
.
-
updateButtonBar
public static ButtonBar updateButtonBar(ButtonBar buttonBar, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and updates aButtonBar
populated with appropriatenodes
bound to the providedactions
. Previous content of button bar is removed
-
createContextMenu
public static ContextMenu createContextMenu(Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and returns aContextMenu
populated with appropriatenodes
bound to the providedactions
.- Parameters:
actions
- Theactions
to place on theContextMenu
.- Returns:
- A
ContextMenu
that containsnodes
which are bound to the state of the providedAction
-
updateContextMenu
public static ContextMenu updateContextMenu(ContextMenu menu, Collection<? extends Action> actions)
Takes the providedCollection
ofAction
(or subclasses, such asActionGroup
) instances and updates aContextMenu
populated with appropriatenodes
bound to the providedactions
. Previous content of context menu is removed- Parameters:
menu
- Themenu
to updateactions
- Theactions
to place on theContextMenu
.- Returns:
- A
ContextMenu
that containsnodes
which are bound to the state of the providedAction
-
-