org.eclipse.nebula.widgets.nattable.reorder
Class ColumnReorderLayer

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
      extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
          extended by org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer
All Implemented Interfaces:
ILayer, ILayerListener, IUniqueIndexLayer, IPersistable
Direct Known Subclasses:
BaseColumnReorderLayerFixture, ColumnReorderLayerFixture

public class ColumnReorderLayer
extends AbstractLayerTransform
implements IUniqueIndexLayer

Adds functionality for reordering column(s) Also responsible for saving/loading the column order state.

See Also:
DefaultColumnReorderLayerConfiguration

Field Summary
protected  List<Integer> columnIndexOrder
           
static String PERSISTENCE_KEY_COLUMN_INDEX_ORDER
           
 
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, layerPainter
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
ColumnReorderLayer(IUniqueIndexLayer underlyingLayer)
           
ColumnReorderLayer(IUniqueIndexLayer underlyingLayer, boolean useDefaultConfiguration)
           
 
Method Summary
 int getColumnIndexByPosition(int columnPosition)
          Gets the underlying non-transformed column index for the given column position.
 List<Integer> getColumnIndexOrder()
           
 int getColumnPositionByIndex(int columnIndex)
           
 int getColumnPositionByX(int x)
          Returns the column position that contains the given x coordinate.
 int getReorderFromColumnPosition()
           
 int getRowPositionByIndex(int rowIndex)
           
 int getStartXOfColumnPosition(int targetColumnPosition)
          Returns the x offset in pixels of the given column.
 void handleLayerEvent(ILayerEvent event)
          Handle layer event notification.
protected  boolean isRestoredStateValid(List<Integer> newColumnIndexOrder)
          Ensure that columns haven't changed in the underlying data source
 void loadState(String prefix, Properties properties)
          Underlying layers must load state first.
 int localToUnderlyingColumnPosition(int localColumnPosition)
          Convert a column position to the coordinates of the underlying layer.
protected  void registerCommandHandlers()
          Layers should use this method to register their command handlers and call it from their constructor.
 void reorderColumnPosition(int fromColumnPosition, int toColumnPosition)
           
 void reorderColumnPosition(int fromColumnPosition, int toColumnPosition, boolean reorderToLeftEdge)
           
 void reorderMultipleColumnPositions(List<Integer> fromColumnPositions, int toColumnPosition)
           
 void reorderMultipleColumnPositions(List<Integer> fromColumnPositions, int toColumnPosition, boolean reorderToLeftEdge)
           
 void saveState(String prefix, Properties properties)
          Saves the state to the given Properties using the specified prefix.
 void setReorderFromColumnPosition(int fromColumnPosition)
           
 int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
           
 Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
           
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, doCommand, getCellByPosition, getCellPainter, getColumnCount, getColumnWidthByPosition, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartYOfRowPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, isRowPositionResizable, localToUnderlyingRowPosition, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalRowPosition, underlyingToLocalRowPositions
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, hasLayerListener, registerCommandHandler, 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, doCommand, fireLayerEvent, getBoundsByPosition, getCellByPosition, getCellPainter, getClientAreaProvider, getColumnCount, getColumnWidthByPosition, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartYOfRowPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, hasLayerListener, isColumnPositionResizable, isRowPositionResizable, localToUnderlyingRowPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalRowPosition, underlyingToLocalRowPositions, unregisterCommandHandler, unregisterPersistable
 

Field Detail

PERSISTENCE_KEY_COLUMN_INDEX_ORDER

public static final String PERSISTENCE_KEY_COLUMN_INDEX_ORDER
See Also:
Constant Field Values

columnIndexOrder

protected final List<Integer> columnIndexOrder
Constructor Detail

ColumnReorderLayer

public ColumnReorderLayer(IUniqueIndexLayer underlyingLayer)

ColumnReorderLayer

public ColumnReorderLayer(IUniqueIndexLayer underlyingLayer,
                          boolean useDefaultConfiguration)
Method Detail

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 AbstractLayer
Parameters:
event - the event

registerCommandHandlers

protected void registerCommandHandlers()
Description copied from class: AbstractLayer
Layers should use this method to register their command handlers and call it from their constructor. This allows easy overriding if required of command handlers

Overrides:
registerCommandHandlers in class AbstractLayer

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.

isRestoredStateValid

protected boolean isRestoredStateValid(List<Integer> newColumnIndexOrder)
Ensure that columns haven't changed in the underlying data source

Parameters:
newColumnIndexOrder - restored from the properties file.

getColumnIndexOrder

public List<Integer> getColumnIndexOrder()

getColumnIndexByPosition

public int getColumnIndexByPosition(int columnPosition)
Description copied from interface: ILayer
Gets the underlying non-transformed column index for the given column position.

Specified by:
getColumnIndexByPosition in interface ILayer
Overrides:
getColumnIndexByPosition in class AbstractLayerTransform
Parameters:
columnPosition - a column position relative to this coordinate model
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 interface IUniqueIndexLayer

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 interface ILayer
Overrides:
localToUnderlyingColumnPosition in class AbstractLayerTransform
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)
Specified by:
underlyingToLocalColumnPosition in interface ILayer
Overrides:
underlyingToLocalColumnPosition in class AbstractLayerTransform

underlyingToLocalColumnPositions

public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer,
                                                          Collection<Range> underlyingColumnPositionRanges)
Specified by:
underlyingToLocalColumnPositions in interface ILayer
Overrides:
underlyingToLocalColumnPositions in class AbstractLayerTransform

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 interface ILayer
Overrides:
getColumnPositionByX in class AbstractLayerTransform
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 targetColumnPosition)
Description copied from interface: ILayer
Returns the x offset in pixels of the given column.

Specified by:
getStartXOfColumnPosition in interface ILayer
Overrides:
getStartXOfColumnPosition in class AbstractLayerTransform
Parameters:
targetColumnPosition - 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 interface IUniqueIndexLayer

reorderColumnPosition

public void reorderColumnPosition(int fromColumnPosition,
                                  int toColumnPosition)

reorderColumnPosition

public void reorderColumnPosition(int fromColumnPosition,
                                  int toColumnPosition,
                                  boolean reorderToLeftEdge)

reorderMultipleColumnPositions

public void reorderMultipleColumnPositions(List<Integer> fromColumnPositions,
                                           int toColumnPosition)

reorderMultipleColumnPositions

public void reorderMultipleColumnPositions(List<Integer> fromColumnPositions,
                                           int toColumnPosition,
                                           boolean reorderToLeftEdge)

getReorderFromColumnPosition

public int getReorderFromColumnPosition()

setReorderFromColumnPosition

public void setReorderFromColumnPosition(int fromColumnPosition)


Copyright © 2015. All rights reserved.