Package net.sf.gridarta.utils
Class ActionUtils
- java.lang.Object
-
- net.sf.gridarta.utils.ActionUtils
-
public class ActionUtils extends java.lang.ObjectUtility class implementingActionrelated functions.
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull java.lang.StringDEFAULT_ACCELERATOR_KEYActionkey to store the default shortcut.static @NotNull java.lang.StringNO_SHORTCUTThe shortcut description for actions without shortcuts.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull java.lang.StringgetActionCategory(@NotNull javax.swing.Action action)Returns anAction's category.static @NotNull java.lang.StringgetActionDescription(@NotNull javax.swing.Action action)Returns the description for anAction.static @Nullable javax.swing.IcongetActionIcon(@NotNull javax.swing.Action action)Returns anIconassociated with the action.static @NotNull java.lang.StringgetActionId(@NotNull javax.swing.Action action)Returns anAction's ID string.static @NotNull java.lang.StringgetActionName(@NotNull javax.swing.Action action)Returns the name of anAction.static @Nullable javax.swing.KeyStrokegetAlternativeShortcut(@NotNull javax.swing.Action action)Returns the alternative shortcut of anAction.static @Nullable javax.swing.KeyStrokegetShortcut(@NotNull javax.swing.Action action)Returns the shortcut of anAction.static @NotNull java.lang.StringgetShortcutDescription(@NotNull javax.swing.Action action, @NotNull java.lang.String key)Returns a description of the shortcut of anAction.static @NotNull javax.swing.ActionnewAction(@NotNull net.sf.japi.swing.action.ActionBuilder actionBuilder, @NotNull java.lang.String category, @NotNull EditorAction editorAction, @NotNull java.lang.String key)Creates a newActioninstance.static @NotNull javax.swing.ActionnewToggleAction(@NotNull net.sf.japi.swing.action.ActionBuilder actionBuilder, @NotNull java.lang.String category, @NotNull EditorAction editorAction, @NotNull java.lang.String key)Creates a newActioninstance.static voidsetActionShortcut(@NotNull javax.swing.Action action, @Nullable javax.swing.KeyStroke shortcut)Sets the shortcut of anAction.
-
-
-
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
Actionkey 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 anAction.- Parameters:
action- the action- Returns:
- the name
-
getActionId
@NotNull public static @NotNull java.lang.String getActionId(@NotNull @NotNull javax.swing.Action action)Returns anAction'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 anAction.- 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 anAction.- 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 anAction.- 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 anAction.- Parameters:
action- the actionshortcut- the shortcut ornullto 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 anAction. ReturnsNO_SHORTCUTif the action defines no shortcut.- Parameters:
action- the actionkey- the action key to query- Returns:
- the description
-
getActionIcon
@Nullable public static @Nullable javax.swing.Icon getActionIcon(@NotNull @NotNull javax.swing.Action action)Returns anIconassociated 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 newActioninstance. It is basically the same asActionBuilder.createAction(boolean, String, Object)except that the category is set.- Parameters:
actionBuilder- the action builder to usecategory- the category to seteditorAction- the object which defines the action methodkey- 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 newActioninstance. It is basically the same asActionBuilder.createToggle(boolean, String, Object)except that the category is set.- Parameters:
actionBuilder- the action builder to usecategory- the category to seteditorAction- the object which defines the action methodkey- the action's key- Returns:
- the new action
-
getActionCategory
@NotNull public static @NotNull java.lang.String getActionCategory(@NotNull @NotNull javax.swing.Action action)Returns anAction's category.- Parameters:
action- the action- Returns:
- the category
-
-