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));
}
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));
}
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());
}
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());
}
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)));
}
Aggregations