@OpenApiAll
public class ActionsManager
extends java.lang.Object
implements java.lang.Cloneable
ActionsCategory
,
NMAction
Modifier and Type | Class and Description |
---|---|
static class |
ActionsManager.ActionPropertyChangeListener
The action property change listener class.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SHORTCUTS_MODIFIED
A key for Boolean which marks action with modified shortcuts in UI
|
Constructor and Description |
---|
ActionsManager()
Creates the actions manager.
|
ActionsManager(ActionsManager parent)
Creates the actions manager.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionNearTheGiven(java.lang.String givenID,
boolean addAfter,
NMAction action)
Adds given action near the action with the given id.
|
void |
addActionNearTheGiven(java.lang.String givenID,
boolean addAfter,
NMAction action,
ActionsCategory defaultCategory)
Adds given action near the action with the given id.
|
void |
addCategory(ActionsCategory category)
Adds the given category to the manager.
|
void |
addCategory(ActionsCategory relatedCategory,
ActionsCategory category,
boolean addAfter)
Adds the given category to the manager.
|
void |
addCategory(int index,
ActionsCategory category)
Adds the given category to the manager.
|
void |
addCategory(java.lang.String relatedCategoryID,
ActionsCategory category,
boolean addAfter)
Adds the given category to the manager.
|
ActionsManager |
clone()
Clones the manager.
|
static MDAction |
constructNoneAction()
Constructs a none action.
|
protected com.nomagic.actions.ActionsCache |
createCache() |
void |
dropCache() |
void |
forEach(java.util.function.Consumer<NMAction> consumer)
Performs the given consumer for each owned action.
|
void |
forEachIncludingSelf(java.util.function.Consumer<NMAction> consumer)
Performs the given consumer for each owned action including self.
|
NMAction |
getActionFor(javax.swing.KeyStroke stroke)
Returns the action for given stroke.
|
NMAction |
getActionFor(java.lang.String id)
Returns the action for given id.
|
NMAction |
getActionParent(NMAction action)
Returns parent action for given action.
|
ActionsCategory |
getActionsCategoryRecursively(java.util.List<ActionsCategory> categories,
java.lang.String id)
Recursively finds an action category with a given id.
|
java.util.List<NMAction> |
getAllActions()
Returns the list of all actions registered in this manager.
|
java.util.List<NMAction> |
getAllOrderedActions(boolean includeCategories)
Returns the list if all ordered actions registered in this manager.
|
java.util.List<ActionsCategory> |
getCategories()
Returns the list of the categories.
|
ActionsCategory |
getCategory(java.lang.String id)
Returns the category with given id.
|
java.util.Map<java.lang.String,NMAction> |
getIdToActionMap() |
ActionsCategory |
getLastActionsCategory()
Returns last category by order.
|
protected com.nomagic.actions.ActionsCache |
getOrCreateCache() |
ActionsManager |
getParent()
Returns the actions manager parent.
|
boolean |
isEmpty() |
ActionsManager |
makeCopy()
Copies this manager and adds property change listeners to all actions in
order to have the same action state in source and copy.
|
static void |
markShortcutsModified(javax.swing.Action action)
Add a mark that shortcuts are modified externally in UI
|
void |
removeAction(NMAction action)
Removes action from this manager.
|
void |
removeAction(NMAction action,
NMAction parent)
Removes action with given ID from this manager.
|
void |
removeAction(java.lang.String actionID)
Removes action with given ID from this manager.
|
void |
removeAllActions()
Removes all actions.
|
void |
removeCategory(ActionsCategory category)
Removes the given category from the manager.
|
void |
removeIf(java.util.function.Predicate<NMAction> filter)
Removes all of the actions of this manager that satisfy the given predicate
|
void |
setCategories(java.util.List<? extends ActionsCategory> list)
Sets the list of the categories.
|
void |
setParent(ActionsManager parent)
Sets the actions manager parent.
|
void |
updateCommandKeysFrom(ActionsManager manager)
Deprecated.
|
void |
updateShortcutsFrom(ActionsManager manager)
Takes all action from the given manager with modified shortcuts and overwrites the shortcuts for actions in this manager.
|
void |
updateStateForAllActions()
Calls updateState() method for all inner actions.
|
public static final java.lang.String SHORTCUTS_MODIFIED
public ActionsManager(@CheckForNull ActionsManager parent)
parent
- the parent of the actions manager. May be null.public ActionsManager()
public static void markShortcutsModified(javax.swing.Action action)
action
- actionpublic java.util.List<ActionsCategory> getCategories()
@CheckForNull public ActionsCategory getActionsCategoryRecursively(java.util.List<ActionsCategory> categories, java.lang.String id)
categories
- categories to search.id
- id of a category to find.public void setCategories(java.util.List<? extends ActionsCategory> list)
list
- the list of the categories.public void addCategory(ActionsCategory category)
category
- the given category.public void addCategory(int index, ActionsCategory category)
category
- the given category.index
- index where category will be added.public void removeCategory(ActionsCategory category)
category
- the given category.public void addCategory(java.lang.String relatedCategoryID, ActionsCategory category, boolean addAfter)
relatedCategoryID
- related category idcategory
- the given categoryaddAfter
- add after related category or before related categorypublic void addCategory(@CheckForNull ActionsCategory relatedCategory, ActionsCategory category, boolean addAfter)
relatedCategory
- related categorycategory
- the given categoryaddAfter
- add after related category or before related category@CheckForNull public ActionsCategory getCategory(java.lang.String id)
id
- the id of the category.@Deprecated public void updateCommandKeysFrom(ActionsManager manager)
updateShortcutsFrom(ActionsManager)
public void updateShortcutsFrom(ActionsManager manager)
manager
- the given manager.SHORTCUTS_MODIFIED
public java.util.List<NMAction> getAllActions()
public void removeIf(java.util.function.Predicate<NMAction> filter)
filter
- given predicatepublic void forEachIncludingSelf(java.util.function.Consumer<NMAction> consumer)
consumer
- the action to be performed for each NMActionNMAction.forEachIncludingSelf(Consumer)
public void forEach(java.util.function.Consumer<NMAction> consumer)
consumer
- the action to be performed for each NMActionNMAction.forEach(Consumer)
public boolean isEmpty()
public java.util.List<NMAction> getAllOrderedActions(boolean includeCategories)
includeCategories
- If true, then ActionsCategories will be included in the listpublic void removeAllActions()
@CheckForNull public NMAction getActionFor(@CheckForNull javax.swing.KeyStroke stroke)
stroke
- stroke@CheckForNull public NMAction getActionFor(java.lang.String id)
id
- action idpublic java.util.Map<java.lang.String,NMAction> getIdToActionMap()
public ActionsManager clone()
clone
in class java.lang.Object
public void dropCache()
public void setParent(@CheckForNull ActionsManager parent)
parent
- the new parent.@CheckForNull public ActionsManager getParent()
@CheckForNull public NMAction getActionParent(NMAction action)
action
- the given action.public ActionsManager makeCopy()
public void updateStateForAllActions()
NMAction.updateState()
@CheckForNull public ActionsCategory getLastActionsCategory()
public void removeAction(java.lang.String actionID)
actionID
- actionID id of action to remove.public void removeAction(NMAction action)
action
- action to remove.public void removeAction(NMAction action, @CheckForNull NMAction parent)
action
- action to remove.parent
- parent of action to remove from.public void addActionNearTheGiven(@CheckForNull java.lang.String givenID, boolean addAfter, @CheckForNull NMAction action)
givenID
- the id of action to add nearaddAfter
- add after or before "givenID"action
- the action to add.public void addActionNearTheGiven(@CheckForNull java.lang.String givenID, boolean addAfter, @CheckForNull NMAction action, @CheckForNull ActionsCategory defaultCategory)
givenID
- the id of action to add nearaddAfter
- add after or before "givenID"action
- the action to adddefaultCategory
- category to add action into if action with givenID does not exist. Last category from manager is used if defaultCategory is null@InternalApi protected com.nomagic.actions.ActionsCache getOrCreateCache()
@InternalApi protected com.nomagic.actions.ActionsCache createCache()
public static MDAction constructNoneAction()