use of org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class RowReorderCommand method convertToTargetLayer.
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
RowPositionCoordinate targetFromRowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(this.fromRowPositionCoordinate, targetLayer);
RowPositionCoordinate targetToRowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(this.toRowPositionCoordinate, targetLayer);
if (targetFromRowPositionCoordinate != null && targetToRowPositionCoordinate != null) {
this.fromRowPositionCoordinate = targetFromRowPositionCoordinate;
this.toRowPositionCoordinate = targetToRowPositionCoordinate;
return true;
} else {
return false;
}
}
use of org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate 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.RowPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class LayerCommandUtil method convertRowPositionToTargetContext.
public static RowPositionCoordinate convertRowPositionToTargetContext(RowPositionCoordinate rowPositionCoordinate, ILayer targetLayer) {
if (rowPositionCoordinate != null) {
ILayer layer = rowPositionCoordinate.getLayer();
if (layer == targetLayer) {
return rowPositionCoordinate;
}
int rowPosition = rowPositionCoordinate.getRowPosition();
int underlyingRowPosition = layer.localToUnderlyingRowPosition(rowPosition);
if (underlyingRowPosition < 0) {
return null;
}
Collection<ILayer> underlyingLayers = layer.getUnderlyingLayersByRowPosition(rowPosition);
if (underlyingLayers != null) {
for (ILayer underlyingLayer : underlyingLayers) {
if (underlyingLayer != null) {
RowPositionCoordinate convertedRowPositionCoordinate = convertRowPositionToTargetContext(new RowPositionCoordinate(underlyingLayer, underlyingRowPosition), targetLayer);
if (convertedRowPositionCoordinate != null) {
return convertedRowPositionCoordinate;
}
}
}
}
}
return null;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate 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;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate in project nebula.widgets.nattable by eclipse.
the class MultiRowReorderCommand method convertToTargetLayer.
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
List<RowPositionCoordinate> convertedFromRowPositionCoordinates = new ArrayList<RowPositionCoordinate>(this.fromRowPositionCoordinates.size());
for (RowPositionCoordinate fromRowPositionCoordinate : this.fromRowPositionCoordinates) {
RowPositionCoordinate convertedFromRowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(fromRowPositionCoordinate, targetLayer);
if (convertedFromRowPositionCoordinate != null) {
convertedFromRowPositionCoordinates.add(convertedFromRowPositionCoordinate);
}
}
RowPositionCoordinate targetToRowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(this.toRowPositionCoordinate, targetLayer);
if (convertedFromRowPositionCoordinates.size() > 0 && targetToRowPositionCoordinate != null) {
this.fromRowPositionCoordinates = convertedFromRowPositionCoordinates;
this.toRowPositionCoordinate = targetToRowPositionCoordinate;
return true;
} else {
return false;
}
}
Aggregations