use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class FreezeLayerTest method testMovingAroundColumns.
@Test
public void testMovingAroundColumns() {
// ---------------------- Move into middle of frozen area
// Frozen Columns: 1 5 2 3
// Frozen Rows: 0 3 3 3
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 5, 2));
// Test positions
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(4, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
// Test indexes
Assert.assertEquals(4, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(4, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(5, this.freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(2, this.freezeLayer.getColumnIndexByPosition(2));
Assert.assertEquals(3, this.freezeLayer.getColumnIndexByPosition(3));
// ---------------------- Move right edge out of frozen area
// Frozen Columns: 1 5 2
// Frozen Rows: 0 3 3
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 4, 6));
// Test indexes
Assert.assertEquals(3, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
// Test positions
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Swap right edge with preceeding column
// Frozen Columns: 1 2 5
// Frozen Rows: 0 3 3
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 3, 2));
// Test indexes
Assert.assertEquals(3, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(2, this.freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(5, this.freezeLayer.getColumnIndexByPosition(2));
// Test positions
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Move new right edge out
// Frozen Columns: 1 2
// Frozen Rows: 0 3
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 3, 5));
// Test indexes
Assert.assertEquals(2, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(2, this.freezeLayer.getColumnIndexByPosition(1));
// Test positions
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Move column into frozen area replacing top
// left index
// Frozen Columns: 8 1 2
// Frozen Rows: 1 3 3
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 8, 1));
// Test indexes
Assert.assertEquals(3, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(8, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(2, this.freezeLayer.getColumnIndexByPosition(2));
// Test positions
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Move right edge out
// Frozen Columns: 8 1
// Frozen Rows: 1 3
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 3, 5));
Assert.assertEquals(2, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(8, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(1));
// Test positions
Assert.assertEquals(1, this.freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2, this.freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class FreezeLayerTest method testReorderOutInteriorColumn.
@Test
public void testReorderOutInteriorColumn() {
this.hideShowLayer.doCommand(new ColumnReorderCommand(this.hideShowLayer, 2, 5));
Assert.assertEquals(2, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(3, this.freezeLayer.getColumnIndexByPosition(1));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class FreezeHandlerTest method testFreezeReorderToAllColumns.
@Test
public void testFreezeReorderToAllColumns() {
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 1500, 400);
}
});
// Fire this command so that the viewport can be initialized
this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
// freeze all-1 columns
this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 8));
assertEquals(9, this.freezeLayer.getColumnCount());
assertEquals(1, this.viewportLayer.getColumnCount());
assertEquals(900, this.viewportLayer.getOrigin().getX());
this.compositeFreezeLayer.doCommand(new ColumnReorderCommand(this.compositeFreezeLayer, 9, 7));
assertEquals(10, this.freezeLayer.getColumnCount());
assertEquals(0, this.viewportLayer.getColumnCount());
assertEquals(1000, this.viewportLayer.getOrigin().getX());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldLeaveModelUnchangedOnDragRightWithinSameGroup.
@Test
public void shouldLeaveModelUnchangedOnDragRightWithinSameGroup() {
this.modelFixture.assertTestGroup3IsUnchanged();
// Drag right and swap positions in group
ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 10, 12);
this.layer.doCommand(command);
this.modelFixture.assertTestGroup3IsUnchanged();
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldLeaveModelUnchangedOnDragLeftWithinSameGroup.
@Test
public void shouldLeaveModelUnchangedOnDragLeftWithinSameGroup() {
this.modelFixture.assertTestGroup3IsUnchanged();
// Drag right and swap positions in group
ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 11, 10);
this.layer.doCommand(command);
// The group remains unchanged - order not tracked
this.modelFixture.assertTestGroup3IsUnchanged();
}
Aggregations