Class GlazedListsRowHideShowLayer<T>

java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
org.eclipse.nebula.widgets.nattable.extension.glazedlists.hideshow.GlazedListsRowHideShowLayer<T>
All Implemented Interfaces:
IRowHideShowLayer, ILayer, ILayerListener, IUniqueIndexLayer, IPersistable

public class GlazedListsRowHideShowLayer<T> extends AbstractLayerTransform implements IRowHideShowLayer, IUniqueIndexLayer
Adds the functionality for manually hiding rows in a NatTable that is based on GlazedLists. Technically it will filter items by id in the FilterList.

Note: If you want to add row hide/show AND filtering to your NatTable, you need to use the DefaultGlazedListsStaticFilterStrategy and add the Matcher that is used by this command as a static MatcherEditor. Otherwise these two functions will not work correctly together.

  • Field Details

    • PERSISTENCE_KEY_HIDDEN_ROW_IDS_COUNT

      public static final String PERSISTENCE_KEY_HIDDEN_ROW_IDS_COUNT
      Key for persisting the number of hidden row id's. This is necessary because the id's are serializables and reading them againd by ObjectInputStream need to know how long to read.
      See Also:
    • PERSISTENCE_KEY_HIDDEN_ROW_IDS

      public static final String PERSISTENCE_KEY_HIDDEN_ROW_IDS
      See Also:
  • Constructor Details

    • GlazedListsRowHideShowLayer

      public GlazedListsRowHideShowLayer(ILayer underlyingLayer, IRowDataProvider<T> rowDataProvider, IRowIdAccessor<T> rowIdAccessor)
      Creates a GlazedListsRowHideShowLayer for adding row hide/show for GlazedLists based NatTables. Using this constructor will only instantiate this layer. To use this correctly you need to register the local row hide MatcherEditor against the FilterList yourself.
      Parameters:
      underlyingLayer - The underlying layer.
      rowDataProvider - The IRowDataProvider needed to get the object at a given position so it is possible to retrieve the id that is used for filtering.
      rowIdAccessor - The IRowIdAccessor that is used to extract the id out of the row object. This is necessary to determine the row object to hide in terms of content.
    • GlazedListsRowHideShowLayer

      public GlazedListsRowHideShowLayer(ILayer underlyingLayer, IRowDataProvider<T> rowDataProvider, IRowIdAccessor<T> rowIdAccessor, ca.odell.glazedlists.FilterList<T> filterList)
      Creates a GlazedListsRowHideShowLayer for adding row hide/show for GlazedLists based NatTables. Using this constructor will add the MatcherEditor to the given FilterList. This might not work correctly in combination with other filters like e.g. the filter row.
      Parameters:
      underlyingLayer - The underlying layer.
      rowDataProvider - The IRowDataProvider needed to get the object at a given position so it is possible to retrieve the id that is used for filtering.
      rowIdAccessor - The IRowIdAccessor that is used to extract the id out of the row object. This is necessary to determine the row object to hide in terms of content.
      filterList - The FilterList to apply the local row hide Matcher to.
    • GlazedListsRowHideShowLayer

      public GlazedListsRowHideShowLayer(ILayer underlyingLayer, IRowDataProvider<T> rowDataProvider, IRowIdAccessor<T> rowIdAccessor, ca.odell.glazedlists.matchers.CompositeMatcherEditor<T> matcherEditor)
      Creates a GlazedListsRowHideShowLayer for adding row hide/show for GlazedLists based NatTables. Using this constructor will add the MatcherEditor to the given CompositeMatcherEditor. This way it is possible to add more filter logic than only the row hide filter.
      Parameters:
      underlyingLayer - The underlying layer.
      rowDataProvider - The IRowDataProvider needed to get the object at a given position so it is possible to retrieve the id that is used for filtering.
      rowIdAccessor - The IRowIdAccessor that is used to extract the id out of the row object. This is necessary to determine the row object to hide in terms of content.
      matcherEditor - The CompositeMatcherEditor to which the local row hide Matcher should be added.
  • Method Details

    • registerCommandHandlers

      protected void registerCommandHandlers()
      Register the ILayerCommandHandler that will handle the row hide/show events for this layer.
      Overrides:
      registerCommandHandlers in class AbstractLayer
    • getHideRowMatcherEditor

      public ca.odell.glazedlists.matchers.MatcherEditor<T> getHideRowMatcherEditor()
      Returns:
      The MatcherEditor that is used to filter rows via row id's.
      Since:
      2.0
    • hideRowPositions

      public void hideRowPositions(int... rowPositions)
      Description copied from interface: IRowHideShowLayer
      Hide the rows at the given positions.
      Specified by:
      hideRowPositions in interface IRowHideShowLayer
      Parameters:
      rowPositions - The positions of the rows to hide.
    • hideRowPositions

      public void hideRowPositions(Collection<Integer> rowPositions)
      Hide the rows at the given positions. Will collect the id's of the rows at the given positions as this layer operates on content rather than positions.
      Specified by:
      hideRowPositions in interface IRowHideShowLayer
      Parameters:
      rowPositions - The positions of the rows to hide.
    • hideRowIndexes

      public void hideRowIndexes(int... rowIndexes)
      Description copied from interface: IRowHideShowLayer
      Hide the rows with the given indexes.
      Specified by:
      hideRowIndexes in interface IRowHideShowLayer
      Parameters:
      rowIndexes - The indexes of the rows to hide.
    • hideRowIndexes

      public void hideRowIndexes(Collection<Integer> rowIndexes)
      Hide the rows at the given indexes. Will collect the id's of the rows at the given positions as this layer operates on content rather than positions.
      Specified by:
      hideRowIndexes in interface IRowHideShowLayer
      Parameters:
      rowIndexes - The indexes of the rows to hide.
    • showRowIndexes

      public void showRowIndexes(int... rowIndexes)
      Description copied from interface: IRowHideShowLayer
      Show the rows with the given indexes again.
      Specified by:
      showRowIndexes in interface IRowHideShowLayer
      Parameters:
      rowIndexes - The indexes of the rows that should be showed again.
    • showRowIndexes

      public void showRowIndexes(Collection<Integer> rowIndexes)
      Show the rows with the given indexes again. Will collect the id's of the rows at the given positions as this layer operates on content rather than positions.
      Specified by:
      showRowIndexes in interface IRowHideShowLayer
      Parameters:
      rowIndexes - The indexes of the rows that should be showed again.
    • hideRows

      public void hideRows(Collection<Serializable> rowIds)
      Hide the rows that contain the objects with the given row ids.
      Parameters:
      rowIds - The row ids of the rows that should be hidden.
    • showRows

      public void showRows(Collection<Serializable> rowIds)
      Show the rows that contain the objects with the given row ids. Will of course only have impact if those rows are currently hidden.
      Parameters:
      rowIds - The row ids of the rows that should be showed.
    • showRowPosition

      public void showRowPosition(int rowPosition, boolean showToTop, boolean showAll)
      Show the row(s) that are hidden next to the given row position.

      This method is not supported by this layer as hidden rows are actually filtered from the content and therefore not next to another position on a deeper layer!

      Specified by:
      showRowPosition in interface IRowHideShowLayer
      Parameters:
      rowPosition - The row position whose neighbors should be shown again.
      showToTop - Whether the row positions to the top or the bottom of the given row position should be shown again.
      showAll - Whether all hidden adjacent rows should be shown again or only the single direct adjacent row.
    • showAllRows

      public void showAllRows()
      Show all rows that where previously hidden.
      Specified by:
      showAllRows in interface IRowHideShowLayer
    • getMatcherEditor

      public ca.odell.glazedlists.matchers.MatcherEditor<T> getMatcherEditor()
      Returns:
      The MatcherEditor that is used to filter the rows with the specified id's.
    • getColumnPositionByIndex

      public int getColumnPositionByIndex(int columnIndex)
      Specified by:
      getColumnPositionByIndex in interface IUniqueIndexLayer
    • getRowPositionByIndex

      public int getRowPositionByIndex(int rowIndex)
      Specified by:
      getRowPositionByIndex in interface IUniqueIndexLayer
    • 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
      Overrides:
      saveState in class AbstractLayerTransform
      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 class: AbstractLayerTransform
      Underlying layers must load state first. If this is not done, IStructuralChangeEvent from underlying layers will reset caches after state has been loaded
      Specified by:
      loadState in interface IPersistable
      Overrides:
      loadState in class AbstractLayerTransform
      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.