Package org.eclipse.nebula.widgets.nattable.reorder.command

Examples of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand


    @Test
    public void testMovingAroundColumns() {
        // ---------------------- Move into middle of frozen area
        // Frozen Columns: 1 5 2 3
        // Frozen Rows: 0 3 3 3
        hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 5, 2));

        // Test positions
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(4,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        // Test indexes
        Assert.assertEquals(4, freezeLayer.getColumnCount());
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(4,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(0));
        Assert.assertEquals(5, freezeLayer.getColumnIndexByPosition(1));
        Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(2));
        Assert.assertEquals(3, freezeLayer.getColumnIndexByPosition(3));

        // ---------------------- Move right edge out of frozen area
        // Frozen Columns: 1 5 2
        // Frozen Rows: 0 3 3
        hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 4, 6));

        // Test indexes
        Assert.assertEquals(3, freezeLayer.getColumnCount());
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(3,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        // Test positions
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(3,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        // ---------------------- Swap right edge with preceeding column
        // Frozen Columns: 1 2 5
        // Frozen Rows: 0 3 3
        hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 3, 2));

        // Test indexes
        Assert.assertEquals(3, freezeLayer.getColumnCount());
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(3,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
        Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(0));
        Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(1));
        Assert.assertEquals(5, freezeLayer.getColumnIndexByPosition(2));

        // Test positions
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(3,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        // ---------------------- Move new right edge out
        // Frozen Columns: 1 2
        // Frozen Rows: 0 3
        hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 3, 5));

        // Test indexes
        Assert.assertEquals(2, freezeLayer.getColumnCount());
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(2,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
        Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(0));
        Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(1));

        // Test positions
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(2,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        // ---------------------- Move column into frozen area replacing top
        // left index
        // Frozen Columns: 8 1 2
        // Frozen Rows: 1 3 3
        hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 8, 1));

        // Test indexes
        Assert.assertEquals(3, freezeLayer.getColumnCount());
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(3,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
        Assert.assertEquals(8, freezeLayer.getColumnIndexByPosition(0));
        Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(1));
        Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(2));

        // Test positions
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(3,
                freezeLayer.getBottomRightPosition().columnPosition);
        Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);

        // ---------------------- Move right edge out
        // Frozen Columns: 8 1
        // Frozen Rows: 1 3
        hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 3, 5));
        Assert.assertEquals(2, freezeLayer.getColumnCount());
        Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
        Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
        Assert.assertEquals(2,
                freezeLayer.getBottomRightPosition().columnPosition);
View Full Code Here


        assertEquals(8, layerStack.getColumnIndexByPosition(6));
        assertEquals(9, layerStack.getColumnIndexByPosition(7));
        assertEquals(-1, layerStack.getColumnIndexByPosition(8));

        // Reorder 0 -> 4
        layerStack.doCommand(new ColumnReorderCommand(layerStack, 0, 4));

        assertEquals(1, layerStack.getColumnIndexByPosition(0));
        assertEquals(2, layerStack.getColumnIndexByPosition(1));
        assertEquals(5, layerStack.getColumnIndexByPosition(2));
        assertEquals(0, layerStack.getColumnIndexByPosition(3));
View Full Code Here

        // Resize 2
        layerStack.doCommand(new ColumnResizeCommand(layerStack, 2, 500));
        assertEquals(1400, layerStack.getWidth());

        // Reorder 2 -> 4
        layerStack.doCommand(new ColumnReorderCommand(layerStack, 2, 4));

        assertEquals(0, layerStack.getColumnIndexByPosition(0));
        assertEquals(1, layerStack.getColumnIndexByPosition(1));
        assertEquals(3, layerStack.getColumnIndexByPosition(2));
        assertEquals(2, layerStack.getColumnIndexByPosition(3));
View Full Code Here

    }

    @Test
    public void shouldDragLeftAndMoveColumnIntoGroup() {
        // Drag left into group containing (0,1)
        ColumnReorderCommand command = new ColumnReorderCommand(layer, 5, 1);
        layer.doCommand(command);

        assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, modelFixture
                .getColumnGroupByIndex(5).getName());
        assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, modelFixture
View Full Code Here

    }

    @Test
    public void shouldDragLeftAndRemoveColumnFromGroup() {
        // Drag left out of group
        ColumnReorderCommand command = new ColumnReorderCommand(layer, 3, 2);
        layer.doCommand(command);

        assertNull(modelFixture.getColumnGroupByIndex(3));
        assertNull(modelFixture.getColumnGroupByIndex(2));
View Full Code Here

    public void shouldDragRightAndAddColumnToGroup() {
        final int fromColumnIndex = 2;
        final int toColumnIndex = 4;

        // Drag right into group
        ColumnReorderCommand command = new ColumnReorderCommand(layer,
                fromColumnIndex, toColumnIndex);
        layer.doCommand(command);

        assertEquals(ColumnGroupModelFixture.TEST_GROUP_2, modelFixture
                .getColumnGroupByIndex(fromColumnIndex).getName());
View Full Code Here

        modelFixture.insertColumnIndexes(ColumnGroupModelFixture.TEST_GROUP_1,
                2);
        assertEquals(2, getColumnIndexesInGroup(1).size());

        // Drag right into group
        ColumnReorderCommand command = new ColumnReorderCommand(layer, 0, 2);
        layer.doCommand(command);

        final int fromColumnIndex = 0;
        final int toColumnIndex = 2;
View Full Code Here

        // Drag 0 -> 1

        assertEquals(2, getColumnIndexesInGroup(0).size());

        // Drag right out of group
        ColumnReorderCommand command = new ColumnReorderCommand(layer, 0, 2);
        layer.doCommand(command);

        assertEquals(1, getColumnIndexesInGroup(1).size());
        assertNull(modelFixture.getColumnGroupByIndex(0));
        assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, modelFixture
View Full Code Here

    @Test
    public void shouldDragRightAndNotRemoveFromAnUnbreakableGroup() {
        assertEquals(2, getColumnIndexesInGroup(0).size());

        setGroupUnBreakable(0);
        layer.doCommand(new ColumnReorderCommand(layer, 0, 1));

        assertEquals(2, getColumnIndexesInGroup(0).size());
    }
View Full Code Here

        assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, modelFixture
                .getColumnGroupByIndex(1).getName());
        assertEquals(2, getColumnIndexesInGroup(1).size());

        // Swap members of column groups
        ColumnReorderCommand command = new ColumnReorderCommand(layer,
                fromColumnIndex, toColumnIndex);
        layer.doCommand(command);

        assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, modelFixture
                .getColumnGroupByIndex(3).getName());
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.