Class AbstractColumnHideShowLayer
java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
org.eclipse.nebula.widgets.nattable.hideshow.AbstractColumnHideShowLayer
- All Implemented Interfaces:
ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
- Direct Known Subclasses:
ColumnGroupExpandCollapseLayer
,ColumnGroupExpandCollapseLayer
,ColumnHideShowLayer
public abstract class AbstractColumnHideShowLayer
extends AbstractLayerTransform
implements IUniqueIndexLayer
Abstract implementation for column hide/show operations.
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
underlyingLayer
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Build up the column caches.boolean
doCommand
(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.getCellByPosition
(int columnPosition, int rowPosition) Returns the cell for the given coordinates on this layer.int
int
getColumnIndexByPosition
(int columnPosition) Gets the underlying non-transformed column index for the given column position on this layer.int
getColumnPositionByIndex
(int columnIndex) int
getColumnPositionByX
(int x) Returns the column position that contains the given x coordinate.int[]
getColumnPositionsByIndexes
(int... columnIndexes) Get the local column positions for the given column indexes.getColumnPositionsByIndexes
(Collection<Integer> columnIndexes) Get the local column positions for the given column indexes.abstract Collection<Integer>
Will collect and return all indexes of the columns that are hidden in this layer.abstract int[]
Will collect and return all indexes of the columns that are hidden in this layer.int
getRowPositionByIndex
(int rowIndex) int
getStartXOfColumnPosition
(int localColumnPosition) Returns the x offset in pixels of the given column.protected IUniqueIndexLayer
int
getWidth()
Returns the total width in pixels of this layer.void
handleLayerEvent
(ILayerEvent event) Handle layer event notification.abstract boolean
Check if this layer actively hides columns.protected void
Invalidate the cache to ensure that information is rebuild.abstract boolean
isColumnIndexHidden
(int columnIndex) Will check if the column at the specified index is hidden or not.int
localToUnderlyingColumnPosition
(int localColumnPosition) Convert a column position to the coordinates of the underlying layer.int
underlyingToLocalColumnPosition
(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Transforms the column position relative to the given underlying layer to this layer coordinates.underlyingToLocalColumnPositions
(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) Transforms the column position ranges relative to the given underlying layer to this layer coordinates.Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getCellPainter, getColumnWidthByPosition, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartYOfRowPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, loadState, localToUnderlyingRowPosition, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalRowPosition, underlyingToLocalRowPositions
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getProvidedLabels, getRegionName, 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, configure, dispose, fireLayerEvent, getBoundsByPosition, getCellPainter, getClientAreaProvider, getColumnWidthByPosition, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getProvidedLabels, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartYOfRowPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, hasLayerListener, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingRowPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalRowPosition, underlyingToLocalRowPositions, unregisterCommandHandler, unregisterPersistable
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
-
Constructor Details
-
AbstractColumnHideShowLayer
Constructor.- Parameters:
underlyingLayer
- The underlying layer.
-
-
Method Details
-
getUnderlyingLayer
- Overrides:
getUnderlyingLayer
in classAbstractLayerTransform
- Returns:
- The underlying layer.
- Since:
- 2.0
-
handleLayerEvent
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 callingsuper.fireLayerEvent(event)
- unless you plan to eat the event yourself.- Specified by:
handleLayerEvent
in interfaceILayerListener
- Overrides:
handleLayerEvent
in classAbstractLayer
- Parameters:
event
- the event
-
doCommand
Description copied from interface:ILayer
Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack.Note: Before the layer can process a command it must convert the command to its local coordinates using
ILayerCommand.convertToTargetLayer(ILayer)
- Specified by:
doCommand
in interfaceILayer
- Overrides:
doCommand
in classAbstractLayerTransform
- Parameters:
command
- The command to execute.- Returns:
true
if the command has been handled and was therefore consumed,false
otherwise.
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceILayer
- Overrides:
getColumnCount
in classAbstractLayerTransform
- Returns:
- The number of columns in this layer.
-
getColumnIndexByPosition
public int getColumnIndexByPosition(int columnPosition) Description copied from interface:ILayer
Gets the underlying non-transformed column index for the given column position on this layer.- Specified by:
getColumnIndexByPosition
in interfaceILayer
- Overrides:
getColumnIndexByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position relative to this layer.- Returns:
- An underlying non-transformed column index, or -1 if the given column position does not exist within this coordinate system.
-
getColumnPositionByIndex
public int getColumnPositionByIndex(int columnIndex) - Specified by:
getColumnPositionByIndex
in interfaceIUniqueIndexLayer
-
getColumnPositionsByIndexes
Get the local column positions for the given column indexes.- Parameters:
columnIndexes
- The column indexes for which the local column positions are requested.- Returns:
- The local column positions for the given column indexes.
-
getColumnPositionsByIndexes
public int[] getColumnPositionsByIndexes(int... columnIndexes) Get the local column positions for the given column indexes.- Parameters:
columnIndexes
- The column indexes for which the local column positions are requested.- Returns:
- The local column positions for the given column indexes.
- Since:
- 2.0
-
localToUnderlyingColumnPosition
public int localToUnderlyingColumnPosition(int localColumnPosition) Description copied from interface:ILayer
Convert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Specified by:
localToUnderlyingColumnPosition
in interfaceILayer
- Overrides:
localToUnderlyingColumnPosition
in classAbstractLayerTransform
- Parameters:
localColumnPosition
- column position in local (the layer's own) coordinates- Returns:
- column position in the underlying layer's coordinates
-
underlyingToLocalColumnPosition
public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Description copied from interface:ILayer
Transforms the column position relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPosition
in interfaceILayer
- Overrides:
underlyingToLocalColumnPosition
in classAbstractLayerTransform
- Parameters:
sourceUnderlyingLayer
- The underlying layer to which the given column position matches.underlyingColumnPosition
- The column position in the given underlying layer that should be converted to a local column position.- Returns:
- The given column position transformed to be local to this layer.
-
underlyingToLocalColumnPositions
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) Description copied from interface:ILayer
Transforms the column position ranges relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPositions
in interfaceILayer
- Overrides:
underlyingToLocalColumnPositions
in classAbstractLayerTransform
- Parameters:
sourceUnderlyingLayer
- The underlying layer to which the given column positions match.underlyingColumnPositionRanges
- The column position ranges relative to the given underlying layer that should be converted to local column positions.- Returns:
- The given column position ranges transformed to this layer.
-
getWidth
public int getWidth()Description copied from interface:ILayer
Returns the total width in pixels of this layer.- Specified by:
getWidth
in interfaceILayer
- Overrides:
getWidth
in classAbstractLayerTransform
- Returns:
- The total width in pixels of this layer.
-
getColumnPositionByX
public int getColumnPositionByX(int x) Description copied from interface:ILayer
Returns the column position that contains the given x coordinate.- Specified by:
getColumnPositionByX
in interfaceILayer
- Overrides:
getColumnPositionByX
in classAbstractLayerTransform
- Parameters:
x
- A horizontal pixel location relative to the pixel boundary of this layer.- Returns:
- A column position relative to the associated coordinate system, or -1 if there is no column that contains x.
-
getStartXOfColumnPosition
public int getStartXOfColumnPosition(int localColumnPosition) Description copied from interface:ILayer
Returns the x offset in pixels of the given column.- Specified by:
getStartXOfColumnPosition
in interfaceILayer
- Overrides:
getStartXOfColumnPosition
in classAbstractLayerTransform
- Parameters:
localColumnPosition
- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-
getRowPositionByIndex
public int getRowPositionByIndex(int rowIndex) - Specified by:
getRowPositionByIndex
in interfaceIUniqueIndexLayer
-
isColumnIndexHidden
public abstract boolean isColumnIndexHidden(int columnIndex) Will check if the column at the specified index is hidden or not.- 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
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
getHiddenColumnIndexesArray()
to avoid unnecessary autoboxing operations.- Returns:
- Collection of all column indexes that are hidden in this layer.
-
getHiddenColumnIndexesArray
public abstract int[] getHiddenColumnIndexesArray()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.
- Returns:
- All column indexes that are hidden in this layer.
- Since:
- 2.0
-
hasHiddenColumns
public abstract boolean hasHiddenColumns()Check if this layer actively hides columns.- Returns:
true
if columns are hidden by this layer,false
if not.- Since:
- 2.0
-
getCellByPosition
Description copied from interface:ILayer
Returns the cell for the given coordinates on this layer.- Specified by:
getCellByPosition
in interfaceILayer
- Overrides:
getCellByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the requested cell.rowPosition
- The row position of the requested cell.- Returns:
- The
ILayerCell
for the given coordinates in this layer ornull
if the coordinates are invalid on this layer.
-
invalidateCache
protected void invalidateCache()Invalidate the cache to ensure that information is rebuild. -
cacheVisibleColumnIndexes
protected void cacheVisibleColumnIndexes()Build up the column caches.- Since:
- 2.0
-