Class ActionUtils


  • public class ActionUtils
    extends java.lang.Object
    Utility class implementing Action related functions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static @NotNull java.lang.String DEFAULT_ACCELERATOR_KEY
      Action key to store the default shortcut.
      static @NotNull java.lang.String NO_SHORTCUT
      The shortcut description for actions without shortcuts.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @NotNull java.lang.String getActionCategory​(@NotNull javax.swing.Action action)
      Returns an Action's category.
      static @NotNull java.lang.String getActionDescription​(@NotNull javax.swing.Action action)
      Returns the description for an Action.
      static @Nullable javax.swing.Icon getActionIcon​(@NotNull javax.swing.Action action)
      Returns an Icon associated with the action.
      static @NotNull java.lang.String getActionId​(@NotNull javax.swing.Action action)
      Returns an Action's ID string.
      static @NotNull java.lang.String getActionName​(@NotNull javax.swing.Action action)
      Returns the name of an Action.
      static @Nullable javax.swing.KeyStroke getAlternativeShortcut​(@NotNull javax.swing.Action action)
      Returns the alternative shortcut of an Action.
      static @Nullable javax.swing.KeyStroke getShortcut​(@NotNull javax.swing.Action action)
      Returns the shortcut of an Action.
      static @NotNull java.lang.String getShortcutDescription​(@NotNull javax.swing.Action action, @NotNull java.lang.String key)
      Returns a description of the shortcut of an Action.
      static @NotNull javax.swing.Action newAction​(@NotNull net.sf.japi.swing.action.ActionBuilder actionBuilder, @NotNull java.lang.String category, @NotNull EditorAction editorAction, @NotNull java.lang.String key)
      Creates a new Action instance.
      static @NotNull javax.swing.Action newToggleAction​(@NotNull net.sf.japi.swing.action.ActionBuilder actionBuilder, @NotNull java.lang.String category, @NotNull EditorAction editorAction, @NotNull java.lang.String key)
      Creates a new Action instance.
      static void setActionShortcut​(@NotNull javax.swing.Action action, @Nullable javax.swing.KeyStroke shortcut)
      Sets the shortcut of an Action.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_SHORTCUT

        @NotNull
        public static final @NotNull java.lang.String NO_SHORTCUT
        The shortcut description for actions without shortcuts.
        See Also:
        Constant Field Values
      • DEFAULT_ACCELERATOR_KEY

        @NotNull
        public static final @NotNull java.lang.String DEFAULT_ACCELERATOR_KEY
        Action key to store the default shortcut.
        See Also:
        Constant Field Values
    • Method Detail

      • getActionName

        @NotNull
        public static @NotNull java.lang.String getActionName​(@NotNull
                                                              @NotNull javax.swing.Action action)
        Returns the name of an Action.
        Parameters:
        action - the action
        Returns:
        the name
      • getActionId

        @NotNull
        public static @NotNull java.lang.String getActionId​(@NotNull
                                                            @NotNull javax.swing.Action action)
        Returns an Action's ID string.
        Parameters:
        action - the action
        Returns:
        the ID string
        Throws:
        java.lang.IllegalArgumentException - if the action does not define an ID string
      • getActionDescription

        @NotNull
        public static @NotNull java.lang.String getActionDescription​(@NotNull
                                                                     @NotNull javax.swing.Action action)
        Returns the description for an Action.
        Parameters:
        action - the action
        Returns:
        the description
      • getShortcut

        @Nullable
        public static @Nullable javax.swing.KeyStroke getShortcut​(@NotNull
                                                                  @NotNull javax.swing.Action action)
        Returns the shortcut of an Action.
        Parameters:
        action - the action
        Returns:
        the shortcut or null
      • getAlternativeShortcut

        @Nullable
        public static @Nullable javax.swing.KeyStroke getAlternativeShortcut​(@NotNull
                                                                             @NotNull javax.swing.Action action)
        Returns the alternative shortcut of an Action.
        Parameters:
        action - the action
        Returns:
        the alternative shortcut or null
      • setActionShortcut

        public static void setActionShortcut​(@NotNull
                                             @NotNull javax.swing.Action action,
                                             @Nullable
                                             @Nullable javax.swing.KeyStroke shortcut)
        Sets the shortcut of an Action.
        Parameters:
        action - the action
        shortcut - the shortcut or null to remove it
      • getShortcutDescription

        @NotNull
        public static @NotNull java.lang.String getShortcutDescription​(@NotNull
                                                                       @NotNull javax.swing.Action action,
                                                                       @NotNull
                                                                       @NotNull java.lang.String key)
        Returns a description of the shortcut of an Action. Returns NO_SHORTCUT if the action defines no shortcut.
        Parameters:
        action - the action
        key - the action key to query
        Returns:
        the description
      • getActionIcon

        @Nullable
        public static @Nullable javax.swing.Icon getActionIcon​(@NotNull
                                                               @NotNull javax.swing.Action action)
        Returns an Icon associated with the action.
        Parameters:
        action - the action
        Returns:
        the icon or null
      • newAction

        @NotNull
        public static @NotNull javax.swing.Action newAction​(@NotNull
                                                            @NotNull net.sf.japi.swing.action.ActionBuilder actionBuilder,
                                                            @NotNull
                                                            @NotNull java.lang.String category,
                                                            @NotNull
                                                            @NotNull EditorAction editorAction,
                                                            @NotNull
                                                            @NotNull java.lang.String key)
        Creates a new Action instance. It is basically the same as ActionBuilder.createAction(boolean, String, Object) except that the category is set.
        Parameters:
        actionBuilder - the action builder to use
        category - the category to set
        editorAction - the object which defines the action method
        key - the action's key
        Returns:
        the new action
      • newToggleAction

        @NotNull
        public static @NotNull javax.swing.Action newToggleAction​(@NotNull
                                                                  @NotNull net.sf.japi.swing.action.ActionBuilder actionBuilder,
                                                                  @NotNull
                                                                  @NotNull java.lang.String category,
                                                                  @NotNull
                                                                  @NotNull EditorAction editorAction,
                                                                  @NotNull
                                                                  @NotNull java.lang.String key)
        Creates a new Action instance. It is basically the same as ActionBuilder.createToggle(boolean, String, Object) except that the category is set.
        Parameters:
        actionBuilder - the action builder to use
        category - the category to set
        editorAction - the object which defines the action method
        key - the action's key
        Returns:
        the new action
      • getActionCategory

        @NotNull
        public static @NotNull java.lang.String getActionCategory​(@NotNull
                                                                  @NotNull javax.swing.Action action)
        Returns an Action's category.
        Parameters:
        action - the action
        Returns:
        the category