Class GroupModel
- All Implemented Interfaces:
IPersistable
- Since:
- 1.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassModel class to track the states of a group.static interfaceInterface to support layer based position-index conversion. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GroupModel.IndexPositionConverterConverter to support layer based position-index conversion.Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates and adds a group.voidaddGroup(GroupModel.Group group) Adds the given group.voidaddPositionsToGroup(GroupModel.Group group, int... positions) Adds the given positions to the given group.voidaddStaticIndexesToGroup(int position, int... indexes) This method will add static indexes to the given group.voidaddStaticIndexesToGroup(String groupName, int... indexes) This method will add static indexes to the given group.voidaddStaticIndexesToGroup(GroupModel.Group group, int... indexes) This method will add static indexes to the given group.voidclear()Removes all groups from thisGroupModel.findGroupByMemberIndex(int memberIndex) Searches for a group that has a given member index.getGroupByName(String groupName) getGroupByPosition(int position) Checks if the given position is part of a group and returns the group if the position is part of it.getGroupByStaticIndex(int staticIndex) Checks if there is a group that has the given index as static index.booleanbooleanbooleanisEmpty()booleanisPartOfACollapseableGroup(int position) Check if the specified position belongs to aGroupModel.Groupand if thisGroupModel.Groupis collabseable.booleanisPartOfAGroup(int position) Check if the given position is part of a group in thisGroupModel.booleanisPartOfAnUnbreakableGroup(int position) Check if the specified position belongs to aGroupModel.Groupand if thisGroupModel.Groupis unbreakable.booleanisStatic(int position) Checks if the given position is configured to be static in one of the groups.voidloadState(String prefix, Properties properties) Restore the state out of the given Properties identified by the specified prefix.removeGroup(int position) Removes the group identified by the given position.removeGroup(String groupName) Removes the group identified by the given name.voidremoveGroup(GroupModel.Group group) Removes the given group.removePositionsFromGroup(int... positions) Removes the given positions from corresponding groups.voidremovePositionsFromGroup(GroupModel.Group group, int... positions) Removes the given positions from the given group.voidsaveState(String prefix, Properties properties) Saves the state to the given Properties using the specified prefix.voidsetDefaultCollapseable(boolean defaultCollapseable) Sets the default value for the collapseable flag when creatingGroupModel.Groupobjects.voidsetDefaultUnbreakable(boolean defaultUnbreakable) Sets the default value for the unbreakable flag when creatingGroupModel.Groupobjects.voidsetGroupCollapseable(int position, boolean collabseable) Set theGroupModel.Groupto which the specified position belongs to, to be collapseable or not.voidsetGroupCollapseable(String groupName, boolean collabseable) Set theGroupModel.Groupwith the given group name to be collapseable or not.voidsetGroupUnbreakable(int position, boolean unbreakable) Set theGroupModel.Groupto which the position belongs to unbreakable/breakable.voidsetGroupUnbreakable(String groupName, boolean unbreakable) Set the group with the given name to unbreakable/breakable.intsize()toString()
-
Field Details
-
indexPositionConverter
Converter to support layer based position-index conversion.
-
-
Constructor Details
-
GroupModel
public GroupModel()
-
-
Method Details
-
saveState
Description copied from interface:IPersistableSaves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.- Specified by:
saveStatein interfaceIPersistable- Parameters:
prefix- The prefix to use for the state keys. Is also used as the state configuration name.properties- The Properties instance to save the state to.
-
loadState
Description copied from interface:IPersistableRestore the state out of the given Properties identified by the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.- Specified by:
loadStatein interfaceIPersistable- Parameters:
prefix- The prefix to use for the state keys. Is also used as the state configuration name.properties- The Properties instance to load the state from.
-
addPositionsToGroup
Adds the given positions to the given group.- Parameters:
group- TheGroupModel.Groupto which the positions should be added.positions- The positions to add.
-
removePositionsFromGroup
Removes the given positions from the given group.Note:
A removal will only happen for positions at the beginning or the end of a group. Removing a position in the middle will cause removal of positions at the end of the group to avoid splitting a group.Note:
A removal does only work for visible positions. That means removing something from a collapsed group does not work.- Parameters:
group- TheGroupModel.Groupfrom which the positions should be removed.positions- The positions to remove.
-
removePositionsFromGroup
Removes the given positions from corresponding groups. Searches the groups by position and removes the position in case the group is not unbreakable.Note:
A removal will only happen for positions at the beginning or the end of a group. Removing a position in the middle will cause removal of positions at the end of the group to avoid splitting a group.Note:
A removal does only work for visible positions. That means removing something from a collapsed group does not work.- Parameters:
positions- The positions to remove.- Returns:
- The collection of
GroupModel.Groups that have been modified.
-
addStaticIndexesToGroup
This method will add static indexes to the given group.Static indexes remain visible when a group is collapsed.
- Parameters:
groupName- The name of the group on which the static indexes should be inserted.indexes- The static indexes to add.
-
addStaticIndexesToGroup
public void addStaticIndexesToGroup(int position, int... indexes) This method will add static indexes to the given group.Static indexes remain visible when a group is collapsed.
- Parameters:
position- The position of a group on which the static indexes should be inserted.indexes- The static indexes to add.
-
addStaticIndexesToGroup
This method will add static indexes to the given group.Static indexes remain visible when a group is collapsed.
- Parameters:
group- The group on which the static indexes should be inserted.indexes- The static indexes to add.
-
getGroupByName
- Parameters:
groupName- The name of the requested group.- Returns:
- The group with the given group name or
nullif there is no group with such a name.
-
getGroupByPosition
Checks if the given position is part of a group and returns the group if the position is part of it.- Parameters:
position- The position to check.- Returns:
- The Group to which the given position belongs to or
nullif the position is not part of a group.
-
getGroupByStaticIndex
Checks if there is a group that has the given index as static index.Note: This method iterates over all groups and checks if the static index collection contains the given index. Could have a bad performance in case of huge groups.
- Parameters:
staticIndex- The index to check.- Returns:
- The Group in which the given index is configured as static index
or
nullif the index is not a static index in any group.
-
findGroupByMemberIndex
Searches for a group that has a given member index.Note: This method iterates over all groups and checks if the member collection contains the given index. Could have a bad performance in case of huge groups.
- Parameters:
memberIndex- The index to check.- Returns:
- The Group that contains the given index or
nullif the index is not a member in any group.
-
isPartOfAGroup
public boolean isPartOfAGroup(int position) Check if the given position is part of a group in thisGroupModel.- Parameters:
position- The position to check.- Returns:
trueif the position is part of a group,falseif not.
-
addGroup
Creates and adds a group.- Parameters:
groupName- The name of the group. Typically used as value in the cell.startIndex- The index of the first item in the group.span- The configured number of items that belong to this group.
-
addGroup
Adds the given group.- Parameters:
group- The group to add.
-
removeGroup
Removes the group identified by the given name.- Parameters:
groupName- The name of the group to remove.- Returns:
- The group that was removed from the model.
-
removeGroup
Removes the group identified by the given position.- Parameters:
position- The group that contains the given position.- Returns:
- The group that was removed from the model.
-
removeGroup
Removes the given group.- Parameters:
group- The group to remove.
-
clear
public void clear()Removes all groups from thisGroupModel. -
size
public int size()- Returns:
- Number of
GroupModel.Groups configured in thisGroupModel.
-
isEmpty
public boolean isEmpty()- Returns:
trueif no group is configured in thisGroupModel.
-
isStatic
public boolean isStatic(int position) Checks if the given position is configured to be static in one of the groups.- Parameters:
position- The position to check.- Returns:
trueif the given position is configured to be static in a group.
-
isPartOfACollapseableGroup
public boolean isPartOfACollapseableGroup(int position) Check if the specified position belongs to aGroupModel.Groupand if thisGroupModel.Groupis collabseable.- Parameters:
position- The position used to retrieve the corresponding group.- Returns:
trueif the specified position belongs to aGroupModel.Groupand thisGroupModel.Groupis collabseable,falseif not.
-
setGroupCollapseable
Set theGroupModel.Groupwith the given group name to be collapseable or not.- Parameters:
groupName- The name of the group that should be modified.collabseable-trueto set the group collapseable,falseto set it not to be collapseable.
-
setGroupCollapseable
public void setGroupCollapseable(int position, boolean collabseable) Set theGroupModel.Groupto which the specified position belongs to, to be collapseable or not.- Parameters:
position- The position used to retrieve the corresponding group.collabseable-trueto set the group collapseable,falseto set it not to be collapseable.
-
isPartOfAnUnbreakableGroup
public boolean isPartOfAnUnbreakableGroup(int position) Check if the specified position belongs to aGroupModel.Groupand if thisGroupModel.Groupis unbreakable.- Parameters:
position- The position used to retrieve the corresponding group.- Returns:
trueif the specified position belongs to aGroupModel.Groupand thisGroupModel.Groupis unbreakable,falseif not.
-
setGroupUnbreakable
Set the group with the given name to unbreakable/breakable.- Parameters:
groupName- The name of the group that should be modified.unbreakable-trueto set the group unbreakable,falseto remove the unbreakable state.
-
setGroupUnbreakable
public void setGroupUnbreakable(int position, boolean unbreakable) Set theGroupModel.Groupto which the position belongs to unbreakable/breakable.- Parameters:
position- The position used to retrieve the corresponding group.unbreakable-trueto set the group unbreakable,falseto remove the unbreakable state.
-
isDefaultCollapseable
public boolean isDefaultCollapseable()- Returns:
- The default value for the collapseable flag of newly created
GroupModel.Groupobjects.
-
setDefaultCollapseable
public void setDefaultCollapseable(boolean defaultCollapseable) Sets the default value for the collapseable flag when creatingGroupModel.Groupobjects.- Parameters:
defaultCollapseable- the default value forGroupModel.Group.collapseablethat should be set on creatingGroupModel.Group.
-
isDefaultUnbreakable
public boolean isDefaultUnbreakable()- Returns:
- The default value for the unbreakable flag of newly created
GroupModel.Groupobjects.
-
setDefaultUnbreakable
public void setDefaultUnbreakable(boolean defaultUnbreakable) Sets the default value for the unbreakable flag when creatingGroupModel.Groupobjects.- Parameters:
defaultUnbreakable- the default value forGroupModel.Group.unbreakablethat should be set on creatingGroupModel.Group.
-
toString
-