Search in sources :

Example 36 with ColumnReorderCommand

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());
}
Also used : ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 37 with ColumnReorderCommand

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));
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 38 with ColumnReorderCommand

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));
}
Also used : ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 39 with ColumnReorderCommand

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));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 40 with ColumnReorderCommand

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());
}
Also used : RenameColumnHeaderEvent(org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent) RenameColumnHeaderCommand(org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Aggregations

ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)42 Test (org.junit.Test)39 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)22 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)4 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)4 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)4 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)3 RenameColumnHeaderEvent (org.eclipse.nebula.widgets.nattable.columnRename.event.RenameColumnHeaderEvent)2 ILayerCommand (org.eclipse.nebula.widgets.nattable.command.ILayerCommand)2 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)2 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)2 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)2 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)2 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)2 ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)2 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RenameColumnHeaderCommand (org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand)1