Class ActionsCategory

All Implemented Interfaces:
ActionListener, Serializable, Cloneable, Comparable, EventListener, Action
Direct Known Subclasses:
MDActionsCategory, MenuAction, SelectItemAction, SetFontAction

@OpenApiAll public class ActionsCategory extends NMAction
Actions category owns a list of actions. Actions category can represent structure of menu or toolbar, and it can be nested (represents sub menu).
See Also:
  • Field Details

  • Constructor Details

    • ActionsCategory

      public ActionsCategory()
      Creates actions category with no name
    • ActionsCategory

      public ActionsCategory(@CheckForNull String id, @CheckForNull String name)
      Creates actions category with given name and id.
      Parameters:
      id - the id of the category.
      name - the name of the category.
    • ActionsCategory

      public ActionsCategory(@CheckForNull String id, @CheckForNull String name, @CheckForNull KeyStroke stroke)
      Creates actions category with given id, name, and keystroke.
      Parameters:
      id - the id of the category.
      name - the name of the category.
      stroke - keystroke used for invoking action category.
    • ActionsCategory

      public ActionsCategory(@CheckForNull String id, @CheckForNull String name, @CheckForNull KeyStroke stroke, @CheckForNull String group)
      Creates actions category with given id, name, keystroke and assigned group.
      Parameters:
      id - the id of the category.
      name - the name of the category.
      stroke - keystroke used for invoking action category.
      group - the name of the related commands group.
    • ActionsCategory

      public ActionsCategory(@CheckForNull String id, @CheckForNull String name, int keyCode)
      Creates actions category with given id, name, and key code.
      Parameters:
      id - the id of the category.
      name - the name of the category.
      keyCode - keystroke used for invoking action category.
    • ActionsCategory

      public ActionsCategory(@CheckForNull String id, @CheckForNull String name, int keyCode, @CheckForNull String group)
      Creates actions category with given id, name, and key code.
      Parameters:
      id - the id of the category.
      name - the name of the category.
      keyCode - keystroke used for invoking action category.
      group - the name of the related commands group.
  • Method Details

    • createSeparatorCategory

      public static ActionsCategory createSeparatorCategory()
    • addAction

      public void addAction(@CheckForNull NMAction action)
      Adds the given action to the category. Fires ADDED_ACTION_PROPERTY property change event, where new value is added action. Fires CHANGE_ACTIONS_PROPERTY (for backward compatibility) property change event, where old value is old actions list, new value is new actions list.
      Overrides:
      addAction in class NMAction
      Parameters:
      action - the given action to add, parameter can be null.
    • addActions

      public void addActions(List<? extends NMAction> actions)
      Adds given actions to the category. Fires ACTIONS_PROPERTY (and CHANGE_ACTIONS_PROPERTY for backward compatibility) property change event, where old value is old actions list, new value is new actions list.
      Parameters:
      actions - the given actions to add, parameter can be null.
    • addAction

      public void addAction(@CheckForNull NMAction action, int position)
      Adds the given action at the specified position to the category. Fires ADDED_ACTION_PROPERTY property change event, where new value is added action. Fires CHANGE_ACTIONS_PROPERTY (for backward compatibility) property change event, where old value is old actions list, new value is new actions list.
      Parameters:
      action - the given action to add, parameter can be null.
      position - the given position to be added.
    • addActionNearTheGiven

      public void addActionNearTheGiven(@CheckForNull String givenID, boolean addAfter, @CheckForNull NMAction action)
      Adds given action near the action with the given id. The given action will be added into the same parent as action with givenID. The position of the given action will be above or below the "givenID".
      Parameters:
      givenID - the id of action to add near
      addAfter - add after or before "givenID"
      action - the action to add.
    • removeAction

      public void removeAction(@CheckForNull NMAction action)
      Removes the given action from the category. Fires REMOVED_ACTION_PROPERTY property change event, where old value is removed action. Fires CHANGE_ACTIONS_PROPERTY (for backward compatibility) property change event, where old value is old actions list, new value is new actions list.
      Overrides:
      removeAction in class NMAction
      Parameters:
      action - the given action to remove, parameter can be null.
    • getActions

      public List<NMAction> getActions()
      Returns the list of the owned actions.
      Overrides:
      getActions in class NMAction
      Returns:
      the cloned list of the actions.
    • getCategories

      public List<ActionsCategory> getCategories()
      Gets inner action categories.
      Returns:
      a list of action categories.
    • getActionsRecursively

      public List<NMAction> getActionsRecursively(boolean includeCategories)
      Returns all simple actions (not ActionsCategory) recursively.
      Parameters:
      includeCategories - If true, then ActionsCategories will be included in the list
      Returns:
      all actions recursively
    • setActions

      public void setActions(List<? extends NMAction> actions)
      Sets the list of the new actions overriding old actions. Fires ACTIONS_PROPERTY (and CHANGE_ACTIONS_PROPERTY for backward compatibility) property change event, where old value is old actions list, new value is new actions list.
      Overrides:
      setActions in class NMAction
      Parameters:
      actions - the new list of the actions.
    • removeIf

      public void removeIf(Predicate<NMAction> filter)
      Description copied from class: NMAction
      Removes all of the owned actions that satisfy the given predicate
      Overrides:
      removeIf in class NMAction
      Parameters:
      filter - given predicate
    • forEach

      public void forEach(Consumer<NMAction> consumer)
      Description copied from class: NMAction
      Performs the given consumer for each owned action. Owned actions should not be added/removed inside consumer.
      Overrides:
      forEach in class NMAction
      Parameters:
      consumer - the action to be performed for each NMAction
    • forEachIncludingSelf

      public void forEachIncludingSelf(Consumer<NMAction> consumer)
      Description copied from class: NMAction
      Performs the given consumer for each owned action including self. Owned actions should not be added/removed inside consumer.
      Overrides:
      forEachIncludingSelf in class NMAction
      Parameters:
      consumer - the action to be performed for each NMAction
    • clone

      public ActionsCategory clone()
      Clones the category. During clone does not fire any property change events. Does deep clone.
      Overrides:
      clone in class NMAction
      Returns:
      deep clone of category.
    • shallowClone

      public ActionsCategory shallowClone()
      Clones the category. During clone does not fire any property change events. Does deep clone.
      Overrides:
      shallowClone in class NMAction
      Returns:
      deep clone of category.
    • setNested

      public void setNested(boolean nested)
      Sets new value of nested flag. Flag indicates that children of this action is nested elements. When representing this action as menu, nested action means new sub menu. Not nested means group(usually separated by some menu separator).
      Parameters:
      nested - new value of nested flag.
    • isNested

      public boolean isNested()
      Returns value of nested flag.
      Returns:
      true if this category is nested.
      See Also:
    • accept

      public void accept(ActionsVisitor visitor)
      Accepts visitor and calls visit method of visitor.
      Overrides:
      accept in class NMAction
      Parameters:
      visitor - ActionsVisitor.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Empty implementation.
      Specified by:
      actionPerformed in interface ActionListener
      Specified by:
      actionPerformed in class NMAction
      Parameters:
      e - event caused this action execution.
    • setUseActionForDisable

      public void setUseActionForDisable(boolean use)
      Parameters:
      use - if true, menus created from this category will be disabled if all children are disabled.
      See Also:
      • useActionForDisable
    • isUseActionForDisable

      public boolean isUseActionForDisable()
      Returns value of nested flag.
      Returns:
      value of mUseActionForDisable field
      See Also:
    • breakActions

      public static void breakActions(ActionsCategory category, List<NMAction> actions)
      Breaks given actions into subcategories of given category if the actions number exceeds predefined number.
      Parameters:
      category - category to add created inner categories
      actions - actions to break into categories
    • breakeActions

      @Deprecated public static void breakeActions(ActionsCategory category, List<? extends NMAction> actions, int maxCategorySize, String categoryName, boolean nested)
    • breakActions

      public static void breakActions(ActionsCategory category, List<? extends NMAction> actions, int maxCategorySize, String categoryName, boolean nested)
      Breaks given actions into subcategories of given category if the actions number exceeds maxCategorySize.
      Parameters:
      category - category to add created inner categories
      actions - actions to break into categories
      maxCategorySize - max size of inner category
      categoryName - subcategory name
      nested - make nested subcategories
    • breakActions

      public static void breakActions(ActionsCategory category, List<? extends NMAction> actions, int maxCategorySize, String categoryName, boolean nested, int innerCategorySize)
      Breaks category into sub categories, but it has ability to specify inner category size separately
      Parameters:
      category - category to add created inner categories
      actions - actions to break into categories
      maxCategorySize - max size of inner category
      categoryName - subcategory name
      nested - make nested subcategories
      innerCategorySize - maximum size of inner category
    • sort

      public void sort()
    • getAction

      @CheckForNull public NMAction getAction(String actionID)
      Find direct action with given ID
      Parameters:
      actionID - action ID
      Returns:
      a list of action categories.
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if this category contains no actions at all
    • isDisplayHeader

      public boolean isDisplayHeader()
      Returns:
      display header flag
    • setDisplayHeader

      public void setDisplayHeader(boolean displayHeader)
      Display category name as header of category. This has affect only if category is not nested
      Parameters:
      displayHeader - display header of not nested menu
    • size

      public int size()
      Size of category - number of inner actions.
      Returns:
      size of category