Class RowGroupModel<T>
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel<T>
-
- Type Parameters:
T
- the type of the row objects.
- All Implemented Interfaces:
IRowGroupModel<T>
,IPersistable
public class RowGroupModel<T> extends Object implements IRowGroupModel<T>
A thread-safe implementation ofIRowGroupModel
which is optimised for larger data-sets (it should cope with at least 10k rows spread across 2-300 groups).- Author:
- Stefan Bolton
-
-
Field Summary
-
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description RowGroupModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addRowGroup(IRowGroup<T> rowGroup)
Adds a group into the model.void
addRowGroups(List<IRowGroup<T>> rowGroups)
Adds multiple row groups into the model and only fires off a single change notification.void
clear()
Wipes all groups from the model.IRowDataProvider<T>
getDataProvider()
int
getIndexFromRowCache(T row)
Retrieves a row's index by from our cache.T
getRowFromIndexCache(int rowIndex)
Retrieves a row T by it's index from our cache.IRowGroup<T>
getRowGroupForName(String groupName)
Returns an theIRowGroup
with the specified group name.IRowGroup<T>
getRowGroupForRow(T row)
Returns the firstIRowGroup
found containing the specified row.List<IRowGroup<T>>
getRowGroups()
void
invalidateIndexCache()
boolean
isEmpty()
boolean
isSuppressNoficiations()
void
loadState(String prefix, Properties properties)
Restore the state out of the given Properties identified by the specified prefix.void
notifyListeners()
Notify anyIRowGroupModelListener
s that something in the model has changed.void
registerRowGroupModelListener(IRowGroupModelListener listener)
Registers a listener to the model to receive notification of any changes.boolean
removeRowGroup(IRowGroup<T> rowGroup)
Removes the group from the model.void
saveState(String prefix, Properties properties)
Saves the state to the given Properties using the specified prefix.void
setDataProvider(IRowDataProvider<T> dataProvider)
Required for the index-to-row cache to populate itseld.void
setSuppressNoficiations(boolean suppressNoficiations)
Set to true to stop model change notifications.String
toString()
void
unregisterRowGroupModelListener(IRowGroupModelListener listener)
Unregisters the listener from the model.
-
-
-
Method Detail
-
getRowFromIndexCache
public T getRowFromIndexCache(int rowIndex)
Description copied from interface:IRowGroupModel
Retrieves a row T by it's index from our cache. It will be added to the cache if not present.- Specified by:
getRowFromIndexCache
in interfaceIRowGroupModel<T>
-
getIndexFromRowCache
public int getIndexFromRowCache(T row)
Description copied from interface:IRowGroupModel
Retrieves a row's index by from our cache. It will be added to the cache if not present.- Specified by:
getIndexFromRowCache
in interfaceIRowGroupModel<T>
-
invalidateIndexCache
public void invalidateIndexCache()
- Specified by:
invalidateIndexCache
in interfaceIRowGroupModel<T>
-
setDataProvider
public void setDataProvider(IRowDataProvider<T> dataProvider)
Description copied from interface:IRowGroupModel
Required for the index-to-row cache to populate itseld.- Specified by:
setDataProvider
in interfaceIRowGroupModel<T>
-
getDataProvider
public IRowDataProvider<T> getDataProvider()
- Specified by:
getDataProvider
in interfaceIRowGroupModel<T>
- Returns:
- an
IRowDataProvider
used for the index-to-row cache.
-
notifyListeners
public void notifyListeners()
Notify any
IRowGroupModelListener
s that something in the model has changed.- Specified by:
notifyListeners
in interfaceIRowGroupModel<T>
-
setSuppressNoficiations
public void setSuppressNoficiations(boolean suppressNoficiations)
Set to true to stop model change notifications.- Parameters:
suppressNoficiations
-
-
isSuppressNoficiations
public boolean isSuppressNoficiations()
-
addRowGroups
public void addRowGroups(List<IRowGroup<T>> rowGroups)
Description copied from interface:IRowGroupModel
Adds multiple row groups into the model and only fires off a single change notification.
- Specified by:
addRowGroups
in interfaceIRowGroupModel<T>
- Parameters:
rowGroups
- A list ofIRowGroup
s to add.
-
addRowGroup
public boolean addRowGroup(IRowGroup<T> rowGroup)
Description copied from interface:IRowGroupModel
Adds a group into the model.
A notification should be sent to any
IRowGroupModelListener
s to indicate a change in the model has occurred.- Specified by:
addRowGroup
in interfaceIRowGroupModel<T>
- Parameters:
rowGroup
- TheIRowGroup
to be added.- Returns:
- false if the group wasn't added.
-
removeRowGroup
public boolean removeRowGroup(IRowGroup<T> rowGroup)
Description copied from interface:IRowGroupModel
Removes the group from the model.
A notification should be sent to any
IRowGroupModelListener
s to indicate a change in the model has occurred.- Specified by:
removeRowGroup
in interfaceIRowGroupModel<T>
- Parameters:
rowGroup
- TheIRowGroup
to remove.- Returns:
- true if the group was present and removed, false if the group was not present.
-
getRowGroups
public List<IRowGroup<T>> getRowGroups()
- Specified by:
getRowGroups
in interfaceIRowGroupModel<T>
- Returns:
- an unmodifiable
List
ofIRowGroup
in the model.
-
getRowGroupForName
public IRowGroup<T> getRowGroupForName(String groupName)
Description copied from interface:IRowGroupModel
Returns an theIRowGroup
with the specified group name.- Specified by:
getRowGroupForName
in interfaceIRowGroupModel<T>
- Parameters:
groupName
- The unique name assigned to anIRowGroup
.- Returns:
- An
IRowGroup
or null if there is no group with the specified name.
-
getRowGroupForRow
public IRowGroup<T> getRowGroupForRow(T row)
Description copied from interface:IRowGroupModel
Returns the firstIRowGroup
found containing the specified row.- Specified by:
getRowGroupForRow
in interfaceIRowGroupModel<T>
- Parameters:
row
- The row object.- Returns:
- An
IRowGroup
or null if there is no group with the specified row.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceIRowGroupModel<T>
- Returns:
- true if there are no
IRowGroup
s in the model. Note: if there are groups but there are no rows, then true is still returned.
-
clear
public void clear()
Description copied from interface:IRowGroupModel
Wipes all groups from the model.
A notification should be sent to any
IRowGroupModelListener
s to indicate a change in the model has occurred.- Specified by:
clear
in interfaceIRowGroupModel<T>
-
registerRowGroupModelListener
public void registerRowGroupModelListener(IRowGroupModelListener listener)
Description copied from interface:IRowGroupModel
Registers a listener to the model to receive notification of any changes.- Specified by:
registerRowGroupModelListener
in interfaceIRowGroupModel<T>
- Parameters:
listener
- anIRowGroupModelListener
.
-
unregisterRowGroupModelListener
public void unregisterRowGroupModelListener(IRowGroupModelListener listener)
Description copied from interface:IRowGroupModel
Unregisters the listener from the model.- Specified by:
unregisterRowGroupModelListener
in interfaceIRowGroupModel<T>
- Parameters:
listener
- anIRowGroupModelListener
.
-
saveState
public void saveState(String prefix, Properties properties)
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
public void loadState(String prefix, Properties properties)
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.
-
-