Class ResizeColumnHideShowLayer
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
-
- org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
-
- org.eclipse.nebula.widgets.nattable.hideshow.ResizeColumnHideShowLayer
-
- All Implemented Interfaces:
IColumnHideShowLayer
,ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
public class ResizeColumnHideShowLayer extends AbstractIndexLayerTransform implements IColumnHideShowLayer
Layer to add support for column hide/show feature to a NatTable. Technically hides columns by setting the column width to 0. This way percentage sized columns increase correctly to take the remaining space. This approach is different from the classicalColumnHideShowLayer
where the column is really hidden in the layer which leads to index-position-transformation instead of basic column resizing.Note: It is suggested to set
DataLayer.setDistributeRemainingColumnSpace(boolean)
totrue
when using this layer, or setDataLayer.setFixColumnPercentageValuesOnResize(boolean)
tofalse
. Otherwise a column resize triggers the percentage value calculation of dynamic sized columns, which then leads to gaps as the fixed percentage sized columns to not grow by default.- Since:
- 1.6
- See Also:
ColumnHideShowLayer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ResizeColumnHideShowLayer.ColumnSizeInfo
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.collections.api.map.primitive.MutableIntObjectMap<ResizeColumnHideShowLayer.ColumnSizeInfo>
hiddenColumns
Map that contains the columns hidden by this layer with the initial width so it can be shown again with the previous width.static String
PERSISTENCE_KEY_HIDDEN_COLUMNS
-
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainter
-
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description ResizeColumnHideShowLayer(IUniqueIndexLayer underlyingLayer, DataLayer bodyDataLayer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LabelStack
getConfigLabelsByPosition(int columnPosition, int rowPosition)
Returns the config labels for the cell at the given coordinates.Collection<Integer>
getHiddenColumnIndexes()
Returns all indexes of the columns that are hidden in this layer.int[]
getHiddenColumnIndexesArray()
Will collect and return all indexes of the columns that are hidden in this layer.Collection<String>
getProvidedLabels()
void
hideColumnIndexes(int... columnIndexes)
Hide the columns with the given indexes.void
hideColumnIndexes(Collection<Integer> columnIndexes)
Hide the columns with the given indexes.void
hideColumnPositions(int... columnPositions)
Hide the columns at the specified positions.void
hideColumnPositions(Collection<Integer> columnPositions)
Hide the columns at the specified positions.void
loadState(String prefix, Properties properties)
Underlying layers must load state first.void
saveState(String prefix, Properties properties)
Saves the state to the given Properties using the specified prefix.void
showAllColumns()
Show all hidden columns again.void
showColumnIndexes(int... columnIndexes)
Show the columns with the given indexes again if they are hidden by this layer.void
showColumnIndexes(Collection<Integer> columnIndexes)
Show the columns with the given indexes again if they are hidden by this layer.void
showColumnPosition(int columnPosition, boolean showToLeft, boolean showAll)
Show the column(s) that are hidden next to the given column position.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
configure, dispose, doCommand, getCellByPosition, getCellPainter, getColumnCount, getColumnIndexByPosition, getColumnPositionByIndex, getColumnPositionByX, getColumnWidthByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByIndex, getRowPositionByY, getStartXOfColumnPosition, getStartYOfRowPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions
-
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayer
addLayerListener, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, hasLayerListener, registerCommandHandler, registerPersistable, removeLayerListener, unregisterCommandHandler, unregisterPersistable
-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayerListener
handleLayerEvent
-
-
-
-
Field Detail
-
PERSISTENCE_KEY_HIDDEN_COLUMNS
public static final String PERSISTENCE_KEY_HIDDEN_COLUMNS
- See Also:
- Constant Field Values
-
hiddenColumns
protected org.eclipse.collections.api.map.primitive.MutableIntObjectMap<ResizeColumnHideShowLayer.ColumnSizeInfo> hiddenColumns
Map that contains the columns hidden by this layer with the initial width so it can be shown again with the previous width.
-
-
Constructor Detail
-
ResizeColumnHideShowLayer
public ResizeColumnHideShowLayer(IUniqueIndexLayer underlyingLayer, DataLayer bodyDataLayer)
- Parameters:
underlyingLayer
- The underlying layer.bodyDataLayer
- TheDataLayer
of the body region needed to retrieve the configured column width.
-
-
Method Detail
-
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
- Overrides:
saveState
in classAbstractIndexLayerTransform
- 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:AbstractIndexLayerTransform
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 interfaceIPersistable
- Overrides:
loadState
in classAbstractIndexLayerTransform
- 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 theIConfigRegistry
.- Specified by:
getConfigLabelsByPosition
in interfaceILayer
- Overrides:
getConfigLabelsByPosition
in classAbstractIndexLayerTransform
- 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.
-
getHiddenColumnIndexes
public Collection<Integer> getHiddenColumnIndexes()
Description copied from interface:IColumnHideShowLayer
Returns all indexes of the columns that are hidden in this layer.Note: It does not include the column indexes of hidden columns from underlying layers. This would cause issues on calculating positions as every layer is responsible for those calculations itself.
- Specified by:
getHiddenColumnIndexes
in interfaceIColumnHideShowLayer
- Returns:
- The indexes of the columns that are hidden in this layer.
-
getHiddenColumnIndexesArray
public int[] getHiddenColumnIndexesArray()
Description copied from interface:IColumnHideShowLayer
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 interfaceIColumnHideShowLayer
- Returns:
- All column indexes that are hidden in this layer.
-
hideColumnPositions
public void hideColumnPositions(int... 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 interfaceIColumnHideShowLayer
- Parameters:
columnPositions
- The column positions to hide.
-
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 interfaceIColumnHideShowLayer
- 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 interfaceIColumnHideShowLayer
- 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 interfaceIColumnHideShowLayer
- Parameters:
columnIndexes
- The indexes of the columns to hide.
-
showColumnIndexes
public void showColumnIndexes(int... 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 interfaceIColumnHideShowLayer
- Parameters:
columnIndexes
- The column indexes to show again.
-
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 interfaceIColumnHideShowLayer
- 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 interfaceIColumnHideShowLayer
- 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 interfaceIColumnHideShowLayer
-
getProvidedLabels
public Collection<String> getProvidedLabels()
- Specified by:
getProvidedLabels
in interfaceILayer
- Overrides:
getProvidedLabels
in classAbstractLayer
- Returns:
- The collection of labels that are provided by this layer.
-
-