Search in sources :

Example 6 with ColumnReorderCommand

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

Example 7 with ColumnReorderCommand

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

Example 8 with ColumnReorderCommand

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());
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 9 with ColumnReorderCommand

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();
}
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 10 with ColumnReorderCommand

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