Search in sources :

Example 11 with ColumnReorderCommand

use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupReorderLayerTest method shouldDragRightAndRemoveColumnFromGroup.

@Test
public void shouldDragRightAndRemoveColumnFromGroup() {
    // Index in CG: 0,1
    // Drag 1 -> 1
    assertEquals(2, getColumnIndexesInGroup(0).size());
    // Drag right out of group
    ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 1, 2);
    this.layer.doCommand(command);
    assertEquals(1, getColumnIndexesInGroup(0).size());
    assertNull(this.modelFixture.getColumnGroupByIndex(1));
}
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 12 with ColumnReorderCommand

use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupReorderLayerTest method shouldDragLeftAndMoveColumnIntoGroup.

@Test
public void shouldDragLeftAndMoveColumnIntoGroup() {
    // Drag left into group containing (0,1)
    ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 5, 1);
    this.layer.doCommand(command);
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(5).getName());
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(1).getName());
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(0).getName());
    assertEquals(3, getColumnIndexesInGroup(5).size());
    assertEquals(0, this.reorderLayer.getColumnIndexByPosition(0));
    assertEquals(5, this.reorderLayer.getColumnIndexByPosition(1));
    assertEquals(1, this.reorderLayer.getColumnIndexByPosition(2));
}
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 13 with ColumnReorderCommand

use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupReorderLayerTest method shouldDragFirstCellRightAndAddColumnToGroup.

@Test
public void shouldDragFirstCellRightAndAddColumnToGroup() {
    ColumnGroup columnGroup = this.modelFixture.getColumnGroupByIndex(0);
    columnGroup.removeColumn(0);
    assertEquals(1, getColumnIndexesInGroup(1).size());
    this.modelFixture.insertColumnIndexes(ColumnGroupModelFixture.TEST_GROUP_1, 2);
    assertEquals(2, getColumnIndexesInGroup(1).size());
    // Drag right into group
    ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 0, 2);
    this.layer.doCommand(command);
    final int fromColumnIndex = 0;
    final int toColumnIndex = 2;
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(fromColumnIndex).getName());
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(toColumnIndex).getName());
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(2).getName());
    assertEquals(3, getColumnIndexesInGroup(fromColumnIndex).size());
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 14 with ColumnReorderCommand

use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupReorderLayerTest method shouldRemoveFromOneGroupAndAddToAnother.

@Test
public void shouldRemoveFromOneGroupAndAddToAnother() {
    final int fromColumnIndex = 3;
    final int toColumnIndex = 1;
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_2, this.modelFixture.getColumnGroupByIndex(3).getName());
    assertEquals(2, getColumnIndexesInGroup(3).size());
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(1).getName());
    assertEquals(2, getColumnIndexesInGroup(1).size());
    // Swap members of column groups
    ColumnReorderCommand command = new ColumnReorderCommand(this.layer, fromColumnIndex, toColumnIndex);
    this.layer.doCommand(command);
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(3).getName());
    assertEquals(3, getColumnIndexesInGroup(3).size());
    assertEquals(ColumnGroupModelFixture.TEST_GROUP_2, this.modelFixture.getColumnGroupByIndex(4).getName());
    assertEquals(1, getColumnIndexesInGroup(4).size());
}
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 15 with ColumnReorderCommand

use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupReorderLayerTest method adjacentColumnGroups.

/*
     * .. 3 4 5 6 7 ... ------------------------------------- |<- G2 ->||<- G4
     * ->|
     */
@Test
public void adjacentColumnGroups() {
    this.modelFixture.addColumnsIndexesToGroup("G4", 5, 6);
    // Drag between the two groups
    ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 2, 4);
    this.layer.doCommand(command);
    assertEquals(3, getColumnIndexesInGroup(3).size());
    assertTrue(getColumnIndexesInGroup(3).contains(Integer.valueOf(2)));
    assertTrue(getColumnIndexesInGroup(3).contains(Integer.valueOf(4)));
    assertTrue(getColumnIndexesInGroup(3).contains(Integer.valueOf(4)));
    assertEquals(2, getColumnIndexesInGroup(5).size());
    assertTrue(getColumnIndexesInGroup(5).contains(Integer.valueOf(5)));
    assertTrue(getColumnIndexesInGroup(5).contains(Integer.valueOf(6)));
}
Also used : ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) 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