- java.lang.Object
-
- org.controlsfx.control.action.ActionUtils
-
public class ActionUtils extends Object
Convenience class for users of theActionAPI. 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
Collectionofactions. In these cases, it is likely they are designed to work withaction groups. For examples on how to work with these methods, refer to theActionGroupclass documentation.- See Also:
Action,ActionGroup
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classActionUtils.ActionTextBehaviorAction text behavior.
-
Field Summary
Fields Modifier and Type Field Description static ActionACTION_SEPARATORAction representation of the generic separator.static ActionACTION_SPAN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ButtonBaseconfigureButton(Action action, ButtonBase button)static ButtonBaseconfigureButton(Action action, ButtonBase button, ActionUtils.ActionTextBehavior textBehavior)static MenuItemconfigureMenuItem(Action action, MenuItem menuItem)static ButtoncreateButton(Action action)static ButtoncreateButton(Action action, ActionUtils.ActionTextBehavior textBehavior)static ButtonBarcreateButtonBar(Collection<? extends Action> actions)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aButtonBarpopulated with appropriatenodesbound to the providedactions.static CheckBoxcreateCheckBox(Action action)static CheckMenuItemcreateCheckMenuItem(Action action)Takes the providedActionand returns aCheckMenuIteminstance with all relevant properties bound to the properties of the Action.static ContextMenucreateContextMenu(Collection<? extends Action> actions)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aContextMenupopulated with appropriatenodesbound to the providedactions.static HyperlinkcreateHyperlink(Action action)static MenucreateMenu(Action action)static MenuBarcreateMenuBar(Collection<? extends Action> actions)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aMenuBarpopulated with appropriatenodesbound to the providedactions.static MenuButtoncreateMenuButton(Action action)Takes the providedActionand returns aMenuButtoninstance with all relevant properties bound to the properties of the Action.static MenuButtoncreateMenuButton(Action action, ActionUtils.ActionTextBehavior textBehavior)Takes the providedActionand returns aMenuButtoninstance with all relevant properties bound to the properties of the Action.static MenuItemcreateMenuItem(Action action)static RadioButtoncreateRadioButton(Action action)Takes the providedActionand returns aRadioButtoninstance with all relevant properties bound to the properties of the Action.static RadioMenuItemcreateRadioMenuItem(Action action)Takes the providedActionand returns aRadioMenuIteminstance with all relevant properties bound to the properties of the Action.static SegmentedButtoncreateSegmentedButton(Collection<? extends Action> actions)Takes the providedCollectionofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.static SegmentedButtoncreateSegmentedButton(Action... actions)Takes the provided varargs array ofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.static SegmentedButtoncreateSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Collection<? extends Action> actions)Takes the providedCollectionofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.static SegmentedButtoncreateSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Action... actions)Takes the provided varargs array ofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.static ToggleButtoncreateToggleButton(Action action)Takes the providedActionand returns aToggleButtoninstance with all relevant properties bound to the properties of the Action.static ToggleButtoncreateToggleButton(Action action, ActionUtils.ActionTextBehavior textBehavior)Takes the providedActionand returns aToggleButtoninstance with all relevant properties bound to the properties of the Action.static ToolBarcreateToolBar(Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aToolBarpopulated with appropriatenodesbound to the providedactions.static voidunconfigureButton(ButtonBase button)Removes all bindings and listeners which were added when the suppliedButtonBasewas bound to anActionvia one of the methods of this class.static voidunconfigureMenuItem(MenuItem menuItem)static ButtonBarupdateButtonBar(ButtonBar buttonBar, Collection<? extends Action> actions)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and updates aButtonBarpopulated with appropriatenodesbound to the providedactions.static ContextMenuupdateContextMenu(ContextMenu menu, Collection<? extends Action> actions)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and updates aContextMenupopulated with appropriatenodesbound to the providedactions.static MenuBarupdateMenuBar(MenuBar menuBar, Collection<? extends Action> actions)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and updates aMenuBarpopulated with appropriatenodesbound to the providedactions.static ToolBarupdateToolBar(ToolBar toolbar, Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns providedToolBarpopulated with appropriatenodesbound 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. SeeActionGroupfor 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 providedActionand returns aButtoninstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theButtonshould bind to.textBehavior- DefinesActionUtils.ActionTextBehavior- Returns:
- A
Buttonthat is bound to the state of the providedAction
-
configureButton
public static ButtonBase configureButton(Action action, ButtonBase button, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedActionand binds the relevant properties to the suppliedButton. This allows for the use of Actions within custom Button subclasses.- Parameters:
action- TheActionthat theButtonshould bind to.button- TheButtonBasethat theActionshould be bound to.textBehavior- DefinesActionUtils.ActionTextBehavior- Returns:
- The
ButtonBasethat was bound to theAction.
-
configureButton
public static ButtonBase configureButton(Action action, ButtonBase button)
Takes the providedActionand binds the relevant properties to the suppliedButton. This allows for the use of Actions within custom Button subclasses.- Parameters:
action- TheActionthat theButtonshould bind to.button- TheButtonBasethat theActionshould be bound to.- Returns:
- The
ButtonBasethat was bound to theAction.
-
unconfigureButton
public static void unconfigureButton(ButtonBase button)
Removes all bindings and listeners which were added when the suppliedButtonBasewas bound to anActionvia one of the methods of this class.- Parameters:
button- aButtonBasethat was bound to anAction
-
createMenuButton
public static MenuButton createMenuButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedActionand returns aMenuButtoninstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theMenuButtonshould bind to.textBehavior- DefinesActionUtils.ActionTextBehavior- Returns:
- A
MenuButtonthat is bound to the state of the providedAction
-
createMenuButton
public static MenuButton createMenuButton(Action action)
Takes the providedActionand returns aMenuButtoninstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theMenuButtonshould bind to.- Returns:
- A
MenuButtonthat is bound to the state of the providedAction
-
createToggleButton
public static ToggleButton createToggleButton(Action action, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedActionand returns aToggleButtoninstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theToggleButtonshould bind to.textBehavior- DefinesActionUtils.ActionTextBehavior- Returns:
- A
ToggleButtonthat is bound to the state of the providedAction
-
createToggleButton
public static ToggleButton createToggleButton(Action action)
Takes the providedActionand returns aToggleButtoninstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theToggleButtonshould bind to.- Returns:
- A
ToggleButtonthat is bound to the state of the providedAction
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Collection<? extends Action> actions)
Takes the providedCollectionofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.- Parameters:
actions- TheCollectionofActionthat theSegmentedButtonshould bind to.textBehavior- DefinesActionUtils.ActionTextBehavior- Returns:
- A
SegmentedButtonthat is bound to the state of the providedActions
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(Collection<? extends Action> actions)
Takes the providedCollectionofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.- Parameters:
actions- TheCollectionofActionthat theSegmentedButtonshould bind to.- Returns:
- A
SegmentedButtonthat is bound to the state of the providedActions
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(ActionUtils.ActionTextBehavior textBehavior, Action... actions)
Takes the provided varargs array ofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.- Parameters:
actions- A varargs array ofActionthat theSegmentedButtonshould bind to.textBehavior- DefinesActionUtils.ActionTextBehavior- Returns:
- A
SegmentedButtonthat is bound to the state of the providedActions
-
createSegmentedButton
public static SegmentedButton createSegmentedButton(Action... actions)
Takes the provided varargs array ofActionand returns aSegmentedButtoninstance with all relevant properties bound to the properties of the actions.- Parameters:
actions- A varargs array ofActionthat theSegmentedButtonshould bind to.- Returns:
- A
SegmentedButtonthat is bound to the state of the providedActions
-
createRadioButton
public static RadioButton createRadioButton(Action action)
Takes the providedActionand returns aRadioButtoninstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theRadioButtonshould bind to.- Returns:
- A
RadioButtonthat is bound to the state of the providedAction
-
unconfigureMenuItem
public static void unconfigureMenuItem(MenuItem menuItem)
-
createCheckMenuItem
public static CheckMenuItem createCheckMenuItem(Action action)
Takes the providedActionand returns aCheckMenuIteminstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theCheckMenuItemshould bind to.- Returns:
- A
CheckMenuItemthat is bound to the state of the providedAction
-
createRadioMenuItem
public static RadioMenuItem createRadioMenuItem(Action action)
Takes the providedActionand returns aRadioMenuIteminstance with all relevant properties bound to the properties of the Action.- Parameters:
action- TheActionthat theRadioMenuItemshould bind to.- Returns:
- A
RadioMenuItemthat is bound to the state of the providedAction
-
createToolBar
public static ToolBar createToolBar(Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aToolBarpopulated with appropriatenodesbound to the providedactions.
-
updateToolBar
public static ToolBar updateToolBar(ToolBar toolbar, Collection<? extends Action> actions, ActionUtils.ActionTextBehavior textBehavior)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns providedToolBarpopulated with appropriatenodesbound to the providedactions. Previous toolbar content is removed
-
createMenuBar
public static MenuBar createMenuBar(Collection<? extends Action> actions)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aMenuBarpopulated with appropriatenodesbound to the providedactions.
-
updateMenuBar
public static MenuBar updateMenuBar(MenuBar menuBar, Collection<? extends Action> actions)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and updates aMenuBarpopulated with appropriatenodesbound to the providedactions. Previous MenuBar content is removed.
-
createButtonBar
public static ButtonBar createButtonBar(Collection<? extends Action> actions)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aButtonBarpopulated with appropriatenodesbound to the providedactions.
-
updateButtonBar
public static ButtonBar updateButtonBar(ButtonBar buttonBar, Collection<? extends Action> actions)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and updates aButtonBarpopulated with appropriatenodesbound to the providedactions. Previous content of button bar is removed
-
createContextMenu
public static ContextMenu createContextMenu(Collection<? extends Action> actions)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and returns aContextMenupopulated with appropriatenodesbound to the providedactions.- Parameters:
actions- Theactionsto place on theContextMenu.- Returns:
- A
ContextMenuthat containsnodeswhich are bound to the state of the providedAction
-
updateContextMenu
public static ContextMenu updateContextMenu(ContextMenu menu, Collection<? extends Action> actions)
Takes the providedCollectionofAction(or subclasses, such asActionGroup) instances and updates aContextMenupopulated with appropriatenodesbound to the providedactions. Previous content of context menu is removed- Parameters:
menu- Themenuto updateactions- Theactionsto place on theContextMenu.- Returns:
- A
ContextMenuthat containsnodeswhich are bound to the state of the providedAction
-
-