Class ColumnHideShowLayer

All Implemented Interfaces:
IColumnHideShowLayer, ILayer, ILayerListener, IUniqueIndexLayer, IPersistable
Direct Known Subclasses:
ColumnHideShowLayerFixture

public class ColumnHideShowLayer extends AbstractColumnHideShowLayer implements IColumnHideShowLayer
Layer to add support for column hide/show feature to a NatTable. Technically the columns are hidden by this layer which leads to a index-position transformation. With percentage sizing this this leads to gaps for hidden columns as the size of the other columns is not re-calculated. For percentage sizing and size increase use the ResizeColumnHideShowLayer.
See Also:
  • Field Details

    • PERSISTENCE_KEY_HIDDEN_COLUMN_INDEXES

      public static final String PERSISTENCE_KEY_HIDDEN_COLUMN_INDEXES
      See Also:
  • Constructor Details

    • ColumnHideShowLayer

      public ColumnHideShowLayer(IUniqueIndexLayer underlyingLayer)
  • Method Details

    • handleLayerEvent

      public void handleLayerEvent(ILayerEvent event)
      Description copied from class: AbstractLayer
      Handle layer event notification. Convert it to your context and propagate UP. If you override this method you MUST NOT FORGET to raise the event up the layer stack by calling super.fireLayerEvent(event) - unless you plan to eat the event yourself.
      Specified by:
      handleLayerEvent in interface ILayerListener
      Overrides:
      handleLayerEvent in class AbstractColumnHideShowLayer
      Parameters:
      event - the event
    • 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.
    • getConfigLabelsByPosition

      public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry.
      Specified by:
      getConfigLabelsByPosition in interface ILayer
      Overrides:
      getConfigLabelsByPosition in class AbstractLayerTransform
      Parameters:
      columnPosition - The column position of the cell.
      rowPosition - The row position of the cell.
      Returns:
      The LabelStack with the config labels for the cell at the given coordinates.
    • isColumnIndexHidden

      public boolean isColumnIndexHidden(int columnIndex)
      Description copied from class: AbstractColumnHideShowLayer
      Will check if the column at the specified index is hidden or not.
      Specified by:
      isColumnIndexHidden in class AbstractColumnHideShowLayer
      Parameters:
      columnIndex - The column index of the column whose visibility state should be checked.
      Returns:
      true if the column at the specified index is hidden, false if it is visible.
    • getHiddenColumnIndexes

      public Collection<Integer> getHiddenColumnIndexes()
      Description copied from class: AbstractColumnHideShowLayer
      Will collect and return all indexes of the columns that are hidden in this layer.

      Note: It is not intended that it also collects the column indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.

      Since 2.0 it is recommended to use AbstractColumnHideShowLayer.getHiddenColumnIndexesArray() to avoid unnecessary autoboxing operations.

      Specified by:
      getHiddenColumnIndexes in interface IColumnHideShowLayer
      Specified by:
      getHiddenColumnIndexes in class AbstractColumnHideShowLayer
      Returns:
      Collection of all column indexes that are hidden in this layer.
    • getHiddenColumnIndexesArray

      public int[] getHiddenColumnIndexesArray()
      Description copied from class: AbstractColumnHideShowLayer
      Will collect and return all indexes of the columns that are hidden in this layer.

      Note: It is not intended that it also collects the column indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.

      Specified by:
      getHiddenColumnIndexesArray in interface IColumnHideShowLayer
      Specified by:
      getHiddenColumnIndexesArray in class AbstractColumnHideShowLayer
      Returns:
      All column indexes that are hidden in this layer.
    • hasHiddenColumns

      public boolean hasHiddenColumns()
      Description copied from class: AbstractColumnHideShowLayer
      Check if this layer actively hides columns.
      Specified by:
      hasHiddenColumns in class AbstractColumnHideShowLayer
      Returns:
      true if columns are hidden by this layer, false if not.
    • hideColumnPositions

      public void hideColumnPositions(int... columnPositions)
      Hide the columns at the specified positions. Note that the positions are required as this method might get called via user interaction in a transformed table (e.g. reordered).
      Specified by:
      hideColumnPositions in interface IColumnHideShowLayer
      Parameters:
      columnPositions - The column positions to hide.
      Since:
      1.6
    • hideColumnPositions

      public void hideColumnPositions(Collection<Integer> columnPositions)
      Description copied from interface: IColumnHideShowLayer
      Hide the columns at the specified positions. Note that the positions are required as this method might get called via user interaction in a transformed table (e.g. reordered).
      Specified by:
      hideColumnPositions in interface IColumnHideShowLayer
      Parameters:
      columnPositions - The column positions to hide.
    • hideColumnIndexes

      public void hideColumnIndexes(int... columnIndexes)
      Description copied from interface: IColumnHideShowLayer
      Hide the columns with the given indexes.
      Specified by:
      hideColumnIndexes in interface IColumnHideShowLayer
      Parameters:
      columnIndexes - The indexes of the columns to hide.
    • hideColumnIndexes

      public void hideColumnIndexes(Collection<Integer> columnIndexes)
      Description copied from interface: IColumnHideShowLayer
      Hide the columns with the given indexes.
      Specified by:
      hideColumnIndexes in interface IColumnHideShowLayer
      Parameters:
      columnIndexes - The indexes of the columns to hide.
    • showColumnIndexes

      public void showColumnIndexes(int... columnIndexes)
      Show the columns with the given indexes again if they are hidden by this layer. Note that the indexes are needed and not the positions. This is because a user is not able to select the hidden column in the NatTable and therefore the position is not available anymore.
      Specified by:
      showColumnIndexes in interface IColumnHideShowLayer
      Parameters:
      columnIndexes - The column indexes to show again.
      Since:
      1.6
    • showColumnIndexes

      public void showColumnIndexes(Collection<Integer> columnIndexes)
      Description copied from interface: IColumnHideShowLayer
      Show the columns with the given indexes again if they are hidden by this layer. Note that the indexes are needed and not the positions. This is because a user is not able to select the hidden column in the NatTable and therefore the position is not available anymore.
      Specified by:
      showColumnIndexes in interface IColumnHideShowLayer
      Parameters:
      columnIndexes - The column indexes to show again.
    • showColumnPosition

      public void showColumnPosition(int columnPosition, boolean showToLeft, boolean showAll)
      Description copied from interface: IColumnHideShowLayer
      Show the column(s) that are hidden next to the given column position.
      Specified by:
      showColumnPosition in interface IColumnHideShowLayer
      Parameters:
      columnPosition - The column position whose neighbors should be shown again.
      showToLeft - Whether the column positions to the left or the right of the given column position should be shown again.
      showAll - Whether all hidden adjacent columns should be shown again or only the single direct adjacent column.
    • showAllColumns

      public void showAllColumns()
      Description copied from interface: IColumnHideShowLayer
      Show all hidden columns again.
      Specified by:
      showAllColumns in interface IColumnHideShowLayer
    • getProvidedLabels

      public Collection<String> getProvidedLabels()
      Specified by:
      getProvidedLabels in interface ILayer
      Overrides:
      getProvidedLabels in class AbstractLayer
      Returns:
      The collection of labels that are provided by this layer.