Class ActionUtils


  • public class ActionUtils
    extends Object
    Convenience class for users of the Action 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 of actions. In these cases, it is likely they are designed to work with action groups. For examples on how to work with these methods, refer to the ActionGroup class documentation.

    See Also:
    Action, ActionGroup
    • 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. See ActionGroup for example of action tree creation
      • ACTION_SPAN

        public static Action ACTION_SPAN
    • Method Detail

      • createButton

        public static javafx.scene.control.Button createButton​(Action action,
                                                               ActionUtils.ActionTextBehavior textBehavior)
        Takes the provided Action and returns a Button instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the Button should bind to.
        textBehavior - Defines ActionUtils.ActionTextBehavior
        Returns:
        A Button that is bound to the state of the provided Action
      • createButton

        public static javafx.scene.control.Button createButton​(Action action)
        Takes the provided Action and returns a Button instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the Button should bind to.
        Returns:
        A Button that is bound to the state of the provided Action
      • configureButton

        public static javafx.scene.control.ButtonBase configureButton​(Action action,
                                                                      javafx.scene.control.ButtonBase button,
                                                                      ActionUtils.ActionTextBehavior textBehavior)
        Takes the provided Action and binds the relevant properties to the supplied Button. This allows for the use of Actions within custom Button subclasses.
        Parameters:
        action - The Action that the Button should bind to.
        button - The ButtonBase that the Action should be bound to.
        textBehavior - Defines ActionUtils.ActionTextBehavior
        Returns:
        The ButtonBase that was bound to the Action.
      • configureButton

        public static javafx.scene.control.ButtonBase configureButton​(Action action,
                                                                      javafx.scene.control.ButtonBase button)
        Takes the provided Action and binds the relevant properties to the supplied Button. This allows for the use of Actions within custom Button subclasses.
        Parameters:
        action - The Action that the Button should bind to.
        button - The ButtonBase that the Action should be bound to.
        Returns:
        The ButtonBase that was bound to the Action.
      • unconfigureButton

        public static void unconfigureButton​(javafx.scene.control.ButtonBase button)
        Removes all bindings and listeners which were added when the supplied ButtonBase was bound to an Action via one of the methods of this class.
        Parameters:
        button - a ButtonBase that was bound to an Action
      • createMenuButton

        public static javafx.scene.control.MenuButton createMenuButton​(Action action,
                                                                       ActionUtils.ActionTextBehavior textBehavior)
        Takes the provided Action and returns a MenuButton instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the MenuButton should bind to.
        textBehavior - Defines ActionUtils.ActionTextBehavior
        Returns:
        A MenuButton that is bound to the state of the provided Action
      • createMenuButton

        public static javafx.scene.control.MenuButton createMenuButton​(Action action)
        Takes the provided Action and returns a MenuButton instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the MenuButton should bind to.
        Returns:
        A MenuButton that is bound to the state of the provided Action
      • createHyperlink

        public static javafx.scene.control.Hyperlink createHyperlink​(Action action)
        Takes the provided Action and returns a Hyperlink instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the Hyperlink should bind to.
        Returns:
        A Hyperlink that is bound to the state of the provided Action
      • createToggleButton

        public static javafx.scene.control.ToggleButton createToggleButton​(Action action,
                                                                           ActionUtils.ActionTextBehavior textBehavior)
        Takes the provided Action and returns a ToggleButton instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the ToggleButton should bind to.
        textBehavior - Defines ActionUtils.ActionTextBehavior
        Returns:
        A ToggleButton that is bound to the state of the provided Action
      • createToggleButton

        public static javafx.scene.control.ToggleButton createToggleButton​(Action action)
        Takes the provided Action and returns a ToggleButton instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the ToggleButton should bind to.
        Returns:
        A ToggleButton that is bound to the state of the provided Action
      • createCheckBox

        public static javafx.scene.control.CheckBox createCheckBox​(Action action)
        Takes the provided Action and returns a CheckBox instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the CheckBox should bind to.
        Returns:
        A CheckBox that is bound to the state of the provided Action
      • createRadioButton

        public static javafx.scene.control.RadioButton createRadioButton​(Action action)
        Takes the provided Action and returns a RadioButton instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the RadioButton should bind to.
        Returns:
        A RadioButton that is bound to the state of the provided Action
      • createMenuItem

        public static javafx.scene.control.MenuItem createMenuItem​(Action action)
        Takes the provided Action and returns a MenuItem instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the MenuItem should bind to.
        Returns:
        A MenuItem that is bound to the state of the provided Action
      • configureMenuItem

        public static javafx.scene.control.MenuItem configureMenuItem​(Action action,
                                                                      javafx.scene.control.MenuItem menuItem)
      • unconfigureMenuItem

        public static void unconfigureMenuItem​(javafx.scene.control.MenuItem menuItem)
        Removes all bindings and listeners which were added when the supplied MenuItem was bound to an Action via one of the methods of this class.
        Parameters:
        menuItem - a MenuItem that was bound to an Action
      • createMenu

        public static javafx.scene.control.Menu createMenu​(Action action)
        Takes the provided Action and returns a Menu instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the Menu should bind to.
        Returns:
        A Menu that is bound to the state of the provided Action
      • createCheckMenuItem

        public static javafx.scene.control.CheckMenuItem createCheckMenuItem​(Action action)
        Takes the provided Action and returns a CheckMenuItem instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the CheckMenuItem should bind to.
        Returns:
        A CheckMenuItem that is bound to the state of the provided Action
      • createRadioMenuItem

        public static javafx.scene.control.RadioMenuItem createRadioMenuItem​(Action action)
        Takes the provided Action and returns a RadioMenuItem instance with all relevant properties bound to the properties of the Action.
        Parameters:
        action - The Action that the RadioMenuItem should bind to.
        Returns:
        A RadioMenuItem that is bound to the state of the provided Action
      • updateToolBar

        public static javafx.scene.control.ToolBar updateToolBar​(javafx.scene.control.ToolBar toolbar,
                                                                 Collection<? extends Action> actions,
                                                                 ActionUtils.ActionTextBehavior textBehavior)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and returns provided ToolBar populated with appropriate nodes bound to the provided actions. Previous toolbar content is removed
        Parameters:
        toolbar - The toolbar to update
        actions - The actions to place on the ToolBar.
        textBehavior - defines ActionUtils.ActionTextBehavior
        Returns:
        A ToolBar that contains nodes which are bound to the state of the provided Action
      • createMenuBar

        public static javafx.scene.control.MenuBar createMenuBar​(Collection<? extends Action> actions)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and returns a MenuBar populated with appropriate nodes bound to the provided actions.
        Parameters:
        actions - The actions to place on the MenuBar.
        Returns:
        A MenuBar that contains nodes which are bound to the state of the provided Action
      • updateMenuBar

        public static javafx.scene.control.MenuBar updateMenuBar​(javafx.scene.control.MenuBar menuBar,
                                                                 Collection<? extends Action> actions)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and updates a MenuBar populated with appropriate nodes bound to the provided actions. Previous MenuBar content is removed.
        Parameters:
        menuBar - The menuBar to update
        actions - The actions to place on the MenuBar.
        Returns:
        A MenuBar that contains nodes which are bound to the state of the provided Action
      • createButtonBar

        public static javafx.scene.control.ButtonBar createButtonBar​(Collection<? extends Action> actions)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and returns a ButtonBar populated with appropriate nodes bound to the provided actions.
        Parameters:
        actions - The actions to place on the ButtonBar.
        Returns:
        A ButtonBar that contains nodes which are bound to the state of the provided Action
      • updateButtonBar

        public static javafx.scene.control.ButtonBar updateButtonBar​(javafx.scene.control.ButtonBar buttonBar,
                                                                     Collection<? extends Action> actions)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and updates a ButtonBar populated with appropriate nodes bound to the provided actions. Previous content of button bar is removed
        Parameters:
        buttonBar - The buttonBar to update
        actions - The actions to place on the ButtonBar.
        Returns:
        A ButtonBar that contains nodes which are bound to the state of the provided Action
      • createContextMenu

        public static javafx.scene.control.ContextMenu createContextMenu​(Collection<? extends Action> actions)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and returns a ContextMenu populated with appropriate nodes bound to the provided actions.
        Parameters:
        actions - The actions to place on the ContextMenu.
        Returns:
        A ContextMenu that contains nodes which are bound to the state of the provided Action
      • updateContextMenu

        public static javafx.scene.control.ContextMenu updateContextMenu​(javafx.scene.control.ContextMenu menu,
                                                                         Collection<? extends Action> actions)
        Takes the provided Collection of Action (or subclasses, such as ActionGroup) instances and updates a ContextMenu populated with appropriate nodes bound to the provided actions. Previous content of context menu is removed
        Parameters:
        menu - The menu to update
        actions - The actions to place on the ContextMenu.
        Returns:
        A ContextMenu that contains nodes which are bound to the state of the provided Action