use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldMoveInAndOutGroupsByOneStepDown.
@Test
public void shouldMoveInAndOutGroupsByOneStepDown() {
this.modelFixture.addColumnsIndexesToGroup("G4", 7, 8, 9);
assertEquals("G4", this.modelFixture.getColumnGroupByIndex(9).getName());
ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 9, 11);
this.layer.doCommand(command);
assertNull(this.modelFixture.getColumnGroupByIndex(9));
this.layer.doCommand(command);
assertEquals("G3", this.modelFixture.getColumnGroupByIndex(9).getName());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class DefaultBodyLayerStackTest method resizeAColumnAndReorderIt.
@Test
public void resizeAColumnAndReorderIt() throws Exception {
assertEquals(10, this.layerStack.getColumnCount());
assertEquals(1000, this.layerStack.getWidth());
// Resize 2
this.layerStack.doCommand(new ColumnResizeCommand(this.layerStack, 2, 500));
assertEquals(1400, this.layerStack.getWidth());
// Reorder 2 -> 4
this.layerStack.doCommand(new ColumnReorderCommand(this.layerStack, 2, 4));
assertEquals(0, this.layerStack.getColumnIndexByPosition(0));
assertEquals(1, this.layerStack.getColumnIndexByPosition(1));
assertEquals(3, this.layerStack.getColumnIndexByPosition(2));
assertEquals(2, this.layerStack.getColumnIndexByPosition(3));
assertEquals(4, this.layerStack.getColumnIndexByPosition(4));
assertEquals(5, this.layerStack.getColumnIndexByPosition(5));
assertEquals(6, this.layerStack.getColumnIndexByPosition(6));
assertEquals(7, this.layerStack.getColumnIndexByPosition(7));
assertEquals(8, this.layerStack.getColumnIndexByPosition(8));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class DefaultBodyLayerStackTest method hideColumnsAndReorder.
/*
* Data Layer: 0 1 2 3 4 5 6 7 8 9
* -----------------------------------------------------
*/
@Test
public void hideColumnsAndReorder() throws Exception {
// Hide 3, 4
this.layerStack.doCommand(new ColumnHideCommand(this.layerStack, 3));
this.layerStack.doCommand(new ColumnHideCommand(this.layerStack, 3));
assertEquals(0, this.layerStack.getColumnIndexByPosition(0));
assertEquals(1, this.layerStack.getColumnIndexByPosition(1));
assertEquals(2, this.layerStack.getColumnIndexByPosition(2));
assertEquals(5, this.layerStack.getColumnIndexByPosition(3));
assertEquals(6, this.layerStack.getColumnIndexByPosition(4));
assertEquals(7, this.layerStack.getColumnIndexByPosition(5));
assertEquals(8, this.layerStack.getColumnIndexByPosition(6));
assertEquals(9, this.layerStack.getColumnIndexByPosition(7));
assertEquals(-1, this.layerStack.getColumnIndexByPosition(8));
// Reorder 0 -> 4
this.layerStack.doCommand(new ColumnReorderCommand(this.layerStack, 0, 4));
assertEquals(1, this.layerStack.getColumnIndexByPosition(0));
assertEquals(2, this.layerStack.getColumnIndexByPosition(1));
assertEquals(5, this.layerStack.getColumnIndexByPosition(2));
assertEquals(0, this.layerStack.getColumnIndexByPosition(3));
assertEquals(6, this.layerStack.getColumnIndexByPosition(4));
assertEquals(7, this.layerStack.getColumnIndexByPosition(5));
assertEquals(8, this.layerStack.getColumnIndexByPosition(6));
assertEquals(9, this.layerStack.getColumnIndexByPosition(7));
assertEquals(-1, this.layerStack.getColumnIndexByPosition(8));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnReorderLayerTest method canHandleColumnReorderCommand.
@Test
public void canHandleColumnReorderCommand() throws Exception {
ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new DataLayerFixture());
ColumnReorderCommand reorderCommand = new ColumnReorderCommand(reorderLayer, 0, 2);
assertTrue(reorderLayer.doCommand(reorderCommand));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class RenameColumnIntegrationTest method shouldRenameColumnHeaderForReorderedColumn.
@Test
public void shouldRenameColumnHeaderForReorderedColumn() {
String originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals("Column 2", originalColumnHeader);
this.natTableFixture.doCommand(new ColumnReorderCommand(this.natTableFixture, 1, 5));
originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals("Column 3", originalColumnHeader);
this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 2, TEST_COLUMN_NAME));
String renamedColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals(TEST_COLUMN_NAME, renamedColumnHeader);
assertEquals(2, this.listener.getEventsCount());
RenameColumnHeaderEvent event = (RenameColumnHeaderEvent) this.listener.getReceivedEvent(RenameColumnHeaderEvent.class);
assertEquals(new Range(2, 3), event.getColumnPositionRanges().iterator().next());
}
Aggregations