use of org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class LayerCommandUtil method convertColumnPositionToTargetContext.
public static ColumnPositionCoordinate convertColumnPositionToTargetContext(ColumnPositionCoordinate columnPositionCoordinate, ILayer targetLayer) {
if (columnPositionCoordinate != null) {
ILayer layer = columnPositionCoordinate.getLayer();
if (layer == targetLayer) {
return columnPositionCoordinate;
}
int columnPosition = columnPositionCoordinate.getColumnPosition();
int underlyingColumnPosition = layer.localToUnderlyingColumnPosition(columnPosition);
if (underlyingColumnPosition < 0) {
return null;
}
Collection<ILayer> underlyingLayers = layer.getUnderlyingLayersByColumnPosition(columnPosition);
if (underlyingLayers != null) {
for (ILayer underlyingLayer : underlyingLayers) {
if (underlyingLayer != null) {
ColumnPositionCoordinate convertedColumnPositionCoordinate = convertColumnPositionToTargetContext(new ColumnPositionCoordinate(underlyingLayer, underlyingColumnPosition), targetLayer);
if (convertedColumnPositionCoordinate != null) {
return convertedColumnPositionCoordinate;
}
}
}
}
}
return null;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class ColumnReorderCommand method convertToTargetLayer.
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
ColumnPositionCoordinate targetFromColumnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(this.fromColumnPositionCoordinate, targetLayer);
ColumnPositionCoordinate targetToColumnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(this.toColumnPositionCoordinate, targetLayer);
if (targetFromColumnPositionCoordinate != null && targetToColumnPositionCoordinate != null) {
this.fromColumnPositionCoordinate = targetFromColumnPositionCoordinate;
this.toColumnPositionCoordinate = targetToColumnPositionCoordinate;
return true;
} else {
return false;
}
}
use of org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SelectRegionCommand method convertToTargetLayer.
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
PositionCoordinate sourceCoordinate = new PositionCoordinate(this.sourceLayer, this.region.x, this.region.y);
PositionCoordinate targetCoordinate = LayerCommandUtil.convertPositionToTargetContext(sourceCoordinate, targetLayer);
if (targetCoordinate != null) {
this.sourceLayer = targetCoordinate.getLayer();
this.region.x = targetCoordinate.columnPosition;
this.region.y = targetCoordinate.rowPosition;
if (this.anchorColumnPosition >= 0) {
ColumnPositionCoordinate sourceColumn = new ColumnPositionCoordinate(this.sourceLayer, this.anchorColumnPosition);
ColumnPositionCoordinate targetColumn = LayerCommandUtil.convertColumnPositionToTargetContext(sourceColumn, targetLayer);
this.anchorColumnPosition = targetColumn.getColumnPosition();
}
if (this.anchorRowPosition >= 0) {
RowPositionCoordinate sourceRow = new RowPositionCoordinate(this.sourceLayer, this.anchorRowPosition);
RowPositionCoordinate targetRow = LayerCommandUtil.convertRowPositionToTargetContext(sourceRow, targetLayer);
this.anchorRowPosition = targetRow.getRowPosition();
}
return true;
}
return false;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SelectRowsCommand method convertToTargetLayer.
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
ColumnPositionCoordinate targetColumnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(this.columnPositionCoordinate, targetLayer);
if (targetColumnPositionCoordinate != null && targetColumnPositionCoordinate.getColumnPosition() >= 0 && super.convertToTargetLayer(targetLayer)) {
this.columnPositionCoordinate = targetColumnPositionCoordinate;
this.rowPositionCoordinateToMoveIntoViewport = LayerCommandUtil.convertRowPositionToTargetContext(this.rowPositionCoordinateToMoveIntoViewport, targetLayer);
return true;
}
return false;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class ViewportSelectColumnGroupCommandHandler method doCommand.
@Override
protected boolean doCommand(ViewportSelectColumnGroupCommand command) {
int start = -1;
int span = -1;
// if a column group group is configured, we inspect the row position
if (this.columnGroupGroupHeaderLayer != null && command.getNatTableRowPosition() == 0) {
start = this.columnGroupGroupHeaderLayer.getStartPositionOfGroup(command.getColumnPosition());
span = this.columnGroupGroupHeaderLayer.getColumnSpan(command.getColumnPosition());
} else {
start = this.columnGroupHeaderLayer.getStartPositionOfGroup(command.getColumnPosition());
span = this.columnGroupHeaderLayer.getColumnSpan(command.getColumnPosition());
}
// the SelectRegionCommand needs to be executed on the underlying layer
// this way the row range from 0 to MAX works, which otherwise breaks
// when selecting a column group on scrolled state
ILayer underlyingLayer = this.viewportLayer.getUnderlyingLayerByPosition(0, 0);
ColumnPositionCoordinate underlyingStart = LayerCommandUtil.convertColumnPositionToTargetContext(new ColumnPositionCoordinate(this.viewportLayer, start), underlyingLayer);
SelectRegionCommand regionCommand = new SelectRegionCommand(underlyingLayer, underlyingStart.getColumnPosition(), 0, span, Integer.MAX_VALUE, command.isWithShiftMask(), command.isWithControlMask());
// set the anchor row position to the first row in the viewport
RowPositionCoordinate underlyingRow = LayerCommandUtil.convertRowPositionToTargetContext(new RowPositionCoordinate(this.viewportLayer, 0), underlyingLayer);
regionCommand.setAnchorRowPosition(underlyingRow.rowPosition);
underlyingLayer.doCommand(regionCommand);
return true;
}
Aggregations