Class ActionGroupModelImpl
java.lang.Object
ch.tocco.nice2.netui.impl.actions.ActionModelImpl
ch.tocco.nice2.netui.impl.actions.ActionGroupModelImpl
- All Implemented Interfaces:
ActionGroupModel
,ActionModel
,Serializable
,Iterable<ActionModel>
An action group model specifies all properties for an action group.
- See Also:
-
Field Summary
Fields inherited from interface ch.tocco.nice2.netui.api.actions.ActionGroupModel
NO_DEFAULT_ACTION, UNSPECIFIED_DEFAULT_ACTION
-
Constructor Summary
ConstructorDescriptionActionGroupModelImpl
(String id, String name, @Nullable ActionModel... actions) ActionGroupModelImpl
(String id, String name, @Nullable Collection<ActionModel> actions) -
Method Summary
Modifier and TypeMethodDescriptionReturns the child actions of this group as an unmodifiable list.void
addAction
(ActionModel action) Adds the specified action unmodified to this action array.deepCopy()
Creates a deep copy of this group.boolean
findActionModel
(String propertyName, String propertyValue) findActionModels
(String propertyName, String propertyValue) Finds an Action within the action tree of this group using the specified action-id.void
If this group has no default action set, it finds the first enabled action in this group and sets it as the default action.int
int
hashCode()
boolean
isEmpty()
Returns whether this group has any actions.boolean
isGroup()
boolean
iterator()
Iterator for looping through all child actions in preorder.void
mergeGroup
(ActionGroupModel group) Merges the actions from the specified group into this group.void
preserveOrder
(boolean overwrite) Adds position objects to the child actions that reflect their current order.boolean
removeAction
(ActionModel action) Removes the specified action from this group.void
removeActions
(Predicate<ActionModel> predicate) Removes all actions which match the given predicate.void
Recursively removes all empty action groups from this group.void
removeEntry
(int index) Removes the action at the specified index.void
replaceAction
(ActionModel modelToReplace, ActionModel newActionModel) protected void
setActions
(@Nullable Collection<ActionModel> actions) void
setDefaultAction
(int defaultAction) void
setMutualExclusive
(boolean mutualExclusive) void
sort()
Recursively sorts this groups children with respect to itsActionModel.getPosition()
property.toString()
Methods inherited from class ch.tocco.nice2.netui.impl.actions.ActionModelImpl
getIcon, getId, getName, getPosition, getProperties, getProperty, getRelativePosition, getRelativePositionProperty, getShortDescription, isEnabled, isToggle, setEnabled, setIcon, setName, setPosition, setProperties, setProperty, setRelativePosition, setShortDescription, setToggle
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.netui.api.actions.ActionModel
getIcon, getId, getName, getPosition, getProperty, getRelativePosition, getRelativePositionProperty, getShortDescription, isEnabled, isToggle, setEnabled, setIcon, setName, setPosition, setProperty, setRelativePosition, setShortDescription, setToggle
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ActionGroupModelImpl
-
ActionGroupModelImpl
public ActionGroupModelImpl(String id, String name, @Nullable @Nullable Collection<ActionModel> actions) -
ActionGroupModelImpl
-
-
Method Details
-
getDefaultAction
public int getDefaultAction()- Specified by:
getDefaultAction
in interfaceActionGroupModel
-
setDefaultAction
public void setDefaultAction(int defaultAction) - Specified by:
setDefaultAction
in interfaceActionGroupModel
-
isMutualExclusive
public boolean isMutualExclusive()- Specified by:
isMutualExclusive
in interfaceActionGroupModel
-
setMutualExclusive
public void setMutualExclusive(boolean mutualExclusive) - Specified by:
setMutualExclusive
in interfaceActionGroupModel
-
isGroup
public boolean isGroup()- Overrides:
isGroup
in classActionModelImpl
-
findById
Finds an Action within the action tree of this group using the specified action-id.- Specified by:
findById
in interfaceActionGroupModel
-
getActions
-
setActions
-
iterator
Iterator for looping through all child actions in preorder.Note that this action group is not visited, only its children.
- Specified by:
iterator
in interfaceIterable<ActionModel>
-
removeEntry
public void removeEntry(int index) Removes the action at the specified index.
If you are iterating through an action group, please consider the remove() method if the iterator!
-
removeAction
Description copied from interface:ActionGroupModel
Removes the specified action from this group.
Only remove from root action array. This method does not iterate recursively through all actions.
- Specified by:
removeAction
in interfaceActionGroupModel
- Parameters:
action
- action in this action array to remove
-
removeActions
Description copied from interface:ActionGroupModel
Removes all actions which match the given predicate. Not only root actions are removed; this method iterates recursively through all actions.- Specified by:
removeActions
in interfaceActionGroupModel
- Parameters:
predicate
- the predicate to apply.
-
replaceAction
- Specified by:
replaceAction
in interfaceActionGroupModel
-
addAction
Description copied from interface:ActionGroupModel
Adds the specified action unmodified to this action array.- Specified by:
addAction
in interfaceActionGroupModel
-
actionList
Returns the child actions of this group as an unmodifiable list.- Specified by:
actionList
in interfaceActionGroupModel
- Returns:
- child actions of this group
-
findDefaultAction
public void findDefaultAction()Description copied from interface:ActionGroupModel
If this group has no default action set, it finds the first enabled action in this group and sets it as the default action. Does this recursively for any other action group encountered.- Specified by:
findDefaultAction
in interfaceActionGroupModel
-
deepCopy
Description copied from interface:ActionGroupModel
Creates a deep copy of this group.- Specified by:
deepCopy
in interfaceActionGroupModel
- Specified by:
deepCopy
in interfaceActionModel
- Overrides:
deepCopy
in classActionModelImpl
- Returns:
- a new this
-
isEmpty
public boolean isEmpty()Description copied from interface:ActionGroupModel
Returns whether this group has any actions.- Specified by:
isEmpty
in interfaceActionGroupModel
- Returns:
- true if there is at least one action in this group, false if there are none
-
mergeGroup
Description copied from interface:ActionGroupModel
Merges the actions from the specified group into this group.
The properties of the given group itself are discarded. Only their containing actions are added to the actions of this group. If the given action contains a group that is already defined in here, their actions will be added to the existing group, such that no doublet groups arise.
- Specified by:
mergeGroup
in interfaceActionGroupModel
- Throws:
IllegalStateException
-
sort
public void sort()Description copied from interface:ActionGroupModel
Recursively sorts this groups children with respect to itsActionModel.getPosition()
property.- Specified by:
sort
in interfaceActionGroupModel
-
findActionModel
- Specified by:
findActionModel
in interfaceActionGroupModel
-
findActionModels
- Specified by:
findActionModels
in interfaceActionGroupModel
- Parameters:
propertyName
- name of a propertypropertyValue
- value for property- Returns:
- all action models contained in this model with the specified property
-
collectActionModels
- Specified by:
collectActionModels
in interfaceActionGroupModel
- Returns:
- all action models contained in this model
-
removeEmptyGroups
public void removeEmptyGroups()Description copied from interface:ActionGroupModel
Recursively removes all empty action groups from this group.- Specified by:
removeEmptyGroups
in interfaceActionGroupModel
-
preserveOrder
public void preserveOrder(boolean overwrite) Description copied from interface:ActionGroupModel
Adds position objects to the child actions that reflect their current order. This method does not step into any child group.- Specified by:
preserveOrder
in interfaceActionGroupModel
- Parameters:
overwrite
- if true overwrite existing position entries
-
equals
- Overrides:
equals
in classActionModelImpl
-
hashCode
public int hashCode()- Overrides:
hashCode
in classActionModelImpl
-
toString
- Overrides:
toString
in classActionModelImpl
-