use of org.eclipse.nebula.widgets.nattable.command.ILayerCommand in project nebula.widgets.nattable by eclipse.
the class ReorderColumnCommandTest method testReorderColumnCommand.
@Test
public void testReorderColumnCommand() {
int fromColumnPosition = 4;
int toColumnPosition = 1;
ILayerCommand reorderColumnCommand = new ColumnReorderCommand(this.columnReorderLayer, fromColumnPosition, toColumnPosition);
this.columnReorderLayer.doCommand(reorderColumnCommand);
Assert.assertEquals(0, this.columnReorderLayer.getColumnIndexByPosition(0));
Assert.assertEquals(4, this.columnReorderLayer.getColumnIndexByPosition(1));
Assert.assertEquals(1, this.columnReorderLayer.getColumnIndexByPosition(2));
Assert.assertEquals(2, this.columnReorderLayer.getColumnIndexByPosition(3));
Assert.assertEquals(3, this.columnReorderLayer.getColumnIndexByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.command.ILayerCommand in project nebula.widgets.nattable by eclipse.
the class ReorderRowCommandTest method testReorderRowCommand.
@Test
public void testReorderRowCommand() {
int fromRowPosition = 4;
int toRowPosition = 1;
ILayerCommand reorderRowCommand = new RowReorderCommand(this.rowReorderLayer, fromRowPosition, toRowPosition);
this.rowReorderLayer.doCommand(reorderRowCommand);
Assert.assertEquals(0, this.rowReorderLayer.getRowIndexByPosition(0));
Assert.assertEquals(4, this.rowReorderLayer.getRowIndexByPosition(1));
Assert.assertEquals(1, this.rowReorderLayer.getRowIndexByPosition(2));
Assert.assertEquals(2, this.rowReorderLayer.getRowIndexByPosition(3));
Assert.assertEquals(3, this.rowReorderLayer.getRowIndexByPosition(4));
}
use of org.eclipse.nebula.widgets.nattable.command.ILayerCommand in project nebula.widgets.nattable by eclipse.
the class ChooseColumnsFromCategoriesCommandHandler method itemsMoved.
/**
* Moves the columns up or down by firing commands on the dialog.
*
* Individual columns are moved using the {@link ColumnReorderCommand}
* Contiguously selected columns are moved using the
* {@link MultiColumnReorderCommand}
*
* @param direction
* the direction to move
* @param selectedPositions
* the column positions to move
*/
@Override
public void itemsMoved(MoveDirectionEnum direction, List<Integer> selectedPositions) {
List<List<Integer>> fromPositions = PositionUtil.getGroupedByContiguous(selectedPositions);
List<Integer> toPositions = getDestinationPositions(direction, fromPositions);
for (int i = 0; i < fromPositions.size(); i++) {
boolean multipleColumnsMoved = fromPositions.get(i).size() > 1;
ILayerCommand command = null;
if (!multipleColumnsMoved) {
int fromPosition = fromPositions.get(i).get(0).intValue();
int toPosition = toPositions.get(i);
command = new ColumnReorderCommand(this.columnHideShowLayer, fromPosition, toPosition);
} else if (multipleColumnsMoved) {
command = new MultiColumnReorderCommand(this.columnHideShowLayer, fromPositions.get(i), toPositions.get(i));
}
this.columnHideShowLayer.doCommand(command);
}
refreshDialog();
}
use of org.eclipse.nebula.widgets.nattable.command.ILayerCommand in project nebula.widgets.nattable by eclipse.
the class DimensionallyDependentLayer method doCommand.
// Commands
@Override
public boolean doCommand(ILayerCommand command) {
// Invoke command handler(s) on the Dimensionally dependent layer
ILayerCommand clonedCommand = command.cloneCommand();
if (super.doCommand(clonedCommand)) {
return true;
}
// that no other regions are affected
if (!(command instanceof AbstractRegionCommand)) {
clonedCommand = command.cloneCommand();
if (this.horizontalLayerDependency.doCommand(clonedCommand)) {
return true;
}
clonedCommand = command.cloneCommand();
if (this.verticalLayerDependency.doCommand(clonedCommand)) {
return true;
}
}
return this.baseLayer.doCommand(command);
}
use of org.eclipse.nebula.widgets.nattable.command.ILayerCommand in project nebula.widgets.nattable by eclipse.
the class CompositeLayer method doCommandOnChildLayers.
protected boolean doCommandOnChildLayers(ILayerCommand command) {
for (int layoutX = 0; layoutX < this.layoutXCount; layoutX++) {
for (int layoutY = 0; layoutY < this.layoutYCount; layoutY++) {
ILayer childLayer = this.childLayerLayout[layoutX][layoutY];
ILayerCommand childCommand = command.cloneCommand();
if (childLayer.doCommand(childCommand)) {
return true;
}
}
}
return false;
}
Aggregations