Class GroupModel
- All Implemented Interfaces:
IPersistable
- Since:
- 1.6
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Model class to track the states of a group.static interface
Interface to support layer based position-index conversion. -
Field Summary
Modifier and TypeFieldDescriptionprotected GroupModel.IndexPositionConverter
Converter to support layer based position-index conversion.Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Creates and adds a group.void
addGroup
(GroupModel.Group group) Adds the given group.void
addPositionsToGroup
(GroupModel.Group group, int... positions) Adds the given positions to the given group.void
addStaticIndexesToGroup
(int position, int... indexes) This method will add static indexes to the given group.void
addStaticIndexesToGroup
(String groupName, int... indexes) This method will add static indexes to the given group.void
addStaticIndexesToGroup
(GroupModel.Group group, int... indexes) This method will add static indexes to the given group.void
clear()
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.boolean
boolean
boolean
isEmpty()
boolean
isPartOfACollapseableGroup
(int position) Check if the specified position belongs to aGroupModel.Group
and if thisGroupModel.Group
is collabseable.boolean
isPartOfAGroup
(int position) Check if the given position is part of a group in thisGroupModel
.boolean
isPartOfAnUnbreakableGroup
(int position) Check if the specified position belongs to aGroupModel.Group
and if thisGroupModel.Group
is unbreakable.boolean
isStatic
(int position) Checks if the given position is configured to be static in one of the groups.void
loadState
(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.void
removeGroup
(GroupModel.Group group) Removes the given group.removePositionsFromGroup
(int... positions) Removes the given positions from corresponding groups.void
removePositionsFromGroup
(GroupModel.Group group, int... positions) Removes the given positions from the given group.void
saveState
(String prefix, Properties properties) Saves the state to the given Properties using the specified prefix.void
setDefaultCollapseable
(boolean defaultCollapseable) Sets the default value for the collapseable flag when creatingGroupModel.Group
objects.void
setDefaultUnbreakable
(boolean defaultUnbreakable) Sets the default value for the unbreakable flag when creatingGroupModel.Group
objects.void
setGroupCollapseable
(int position, boolean collabseable) Set theGroupModel.Group
to which the specified position belongs to, to be collapseable or not.void
setGroupCollapseable
(String groupName, boolean collabseable) Set theGroupModel.Group
with the given group name to be collapseable or not.void
setGroupUnbreakable
(int position, boolean unbreakable) Set theGroupModel.Group
to which the position belongs to unbreakable/breakable.void
setGroupUnbreakable
(String groupName, boolean unbreakable) Set the group with the given name to unbreakable/breakable.int
size()
toString()
-
Field Details
-
indexPositionConverter
Converter to support layer based position-index conversion.
-
-
Constructor Details
-
GroupModel
public GroupModel()
-
-
Method Details
-
saveState
Description copied from interface:IPersistable
Saves 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:
saveState
in 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:IPersistable
Restore 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:
loadState
in 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.Group
to 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.Group
from 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.Group
s 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
null
if 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
null
if 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
null
if 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
null
if 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:
true
if the position is part of a group,false
if 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.Group
s configured in thisGroupModel
.
-
isEmpty
public boolean isEmpty()- Returns:
true
if 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:
true
if 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.Group
and if thisGroupModel.Group
is collabseable.- Parameters:
position
- The position used to retrieve the corresponding group.- Returns:
true
if the specified position belongs to aGroupModel.Group
and thisGroupModel.Group
is collabseable,false
if not.
-
setGroupCollapseable
Set theGroupModel.Group
with the given group name to be collapseable or not.- Parameters:
groupName
- The name of the group that should be modified.collabseable
-true
to set the group collapseable,false
to set it not to be collapseable.
-
setGroupCollapseable
public void setGroupCollapseable(int position, boolean collabseable) Set theGroupModel.Group
to which the specified position belongs to, to be collapseable or not.- Parameters:
position
- The position used to retrieve the corresponding group.collabseable
-true
to set the group collapseable,false
to set it not to be collapseable.
-
isPartOfAnUnbreakableGroup
public boolean isPartOfAnUnbreakableGroup(int position) Check if the specified position belongs to aGroupModel.Group
and if thisGroupModel.Group
is unbreakable.- Parameters:
position
- The position used to retrieve the corresponding group.- Returns:
true
if the specified position belongs to aGroupModel.Group
and thisGroupModel.Group
is unbreakable,false
if not.
-
setGroupUnbreakable
Set the group with the given name to unbreakable/breakable.- Parameters:
groupName
- The name of the group that should be modified.unbreakable
-true
to set the group unbreakable,false
to remove the unbreakable state.
-
setGroupUnbreakable
public void setGroupUnbreakable(int position, boolean unbreakable) Set theGroupModel.Group
to which the position belongs to unbreakable/breakable.- Parameters:
position
- The position used to retrieve the corresponding group.unbreakable
-true
to set the group unbreakable,false
to remove the unbreakable state.
-
isDefaultCollapseable
public boolean isDefaultCollapseable()- Returns:
- The default value for the collapseable flag of newly created
GroupModel.Group
objects.
-
setDefaultCollapseable
public void setDefaultCollapseable(boolean defaultCollapseable) Sets the default value for the collapseable flag when creatingGroupModel.Group
objects.- Parameters:
defaultCollapseable
- the default value forGroupModel.Group.collapseable
that should be set on creatingGroupModel.Group
.
-
isDefaultUnbreakable
public boolean isDefaultUnbreakable()- Returns:
- The default value for the unbreakable flag of newly created
GroupModel.Group
objects.
-
setDefaultUnbreakable
public void setDefaultUnbreakable(boolean defaultUnbreakable) Sets the default value for the unbreakable flag when creatingGroupModel.Group
objects.- Parameters:
defaultUnbreakable
- the default value forGroupModel.Group.unbreakable
that should be set on creatingGroupModel.Group
.
-
toString
-