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 of IRowGroupModel which is optimised for larger data-sets (it should cope with at least 10k rows spread across 2-300 groups).
Author:
Stefan Bolton
  • Constructor Details

    • RowGroupModel

      public RowGroupModel()
  • Method Details

    • 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 interface IRowGroupModel<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 interface IRowGroupModel<T>
    • invalidateIndexCache

      public void invalidateIndexCache()
      Specified by:
      invalidateIndexCache in interface IRowGroupModel<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 interface IRowGroupModel<T>
    • getDataProvider

      public IRowDataProvider<T> getDataProvider()
      Specified by:
      getDataProvider in interface IRowGroupModel<T>
      Returns:
      an IRowDataProvider used for the index-to-row cache.
    • notifyListeners

      public void notifyListeners()

      Notify any IRowGroupModelListeners that something in the model has changed.

      Specified by:
      notifyListeners in interface IRowGroupModel<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 interface IRowGroupModel<T>
      Parameters:
      rowGroups - A list of IRowGroups 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 IRowGroupModelListeners to indicate a change in the model has occurred.

      Specified by:
      addRowGroup in interface IRowGroupModel<T>
      Parameters:
      rowGroup - The IRowGroup 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 IRowGroupModelListeners to indicate a change in the model has occurred.

      Specified by:
      removeRowGroup in interface IRowGroupModel<T>
      Parameters:
      rowGroup - The IRowGroup 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 interface IRowGroupModel<T>
      Returns:
      an unmodifiable List of IRowGroup in the model.
    • getRowGroupForName

      public IRowGroup<T> getRowGroupForName(String groupName)
      Description copied from interface: IRowGroupModel
      Returns an the IRowGroup with the specified group name.
      Specified by:
      getRowGroupForName in interface IRowGroupModel<T>
      Parameters:
      groupName - The unique name assigned to an IRowGroup.
      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 first IRowGroup found containing the specified row.
      Specified by:
      getRowGroupForRow in interface IRowGroupModel<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 interface IRowGroupModel<T>
      Returns:
      true if there are no IRowGroups 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 IRowGroupModelListeners to indicate a change in the model has occurred.

      Specified by:
      clear in interface IRowGroupModel<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 interface IRowGroupModel<T>
      Parameters:
      listener - an IRowGroupModelListener.
    • unregisterRowGroupModelListener

      public void unregisterRowGroupModelListener(IRowGroupModelListener listener)
      Description copied from interface: IRowGroupModel
      Unregisters the listener from the model.
      Specified by:
      unregisterRowGroupModelListener in interface IRowGroupModel<T>
      Parameters:
      listener - an IRowGroupModelListener.
    • 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 interface IPersistable
      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 interface IPersistable
      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.
    • toString

      public String toString()
      Overrides:
      toString in class Object