Search in sources :

Example 6 with ShowAllColumnsCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.

the class CompositeFreezeLayerHideShowTest method testFreezeHideShowColumnAllViewportRegion.

@Test
public void testFreezeHideShowColumnAllViewportRegion() {
    // freeze
    this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 1));
    assertEquals(2, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // hide
    this.compositeFreezeLayer.doCommand(new MultiColumnHideCommand(this.compositeFreezeLayer, new int[] { 2, 3, 4 }));
    assertEquals(2, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(0, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // show again
    this.compositeFreezeLayer.doCommand(new ShowAllColumnsCommand());
    assertEquals(2, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    reset();
}
Also used : ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) FreezeColumnCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 7 with ShowAllColumnsCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.

the class ShowAllColumnsCommandTest method testHideColumnCommand.

@Test
public void testHideColumnCommand() {
    Assert.assertEquals(3, this.columnHideShowLayer.getColumnCount());
    this.columnHideShowLayer.doCommand(new ShowAllColumnsCommand());
    Assert.assertEquals(5, this.columnHideShowLayer.getColumnCount());
    Assert.assertEquals(4, this.columnHideShowLayer.getColumnIndexByPosition(0));
    Assert.assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
    Assert.assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(2));
    Assert.assertEquals(2, this.columnHideShowLayer.getColumnIndexByPosition(3));
    Assert.assertEquals(3, this.columnHideShowLayer.getColumnIndexByPosition(4));
}
Also used : ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) Test(org.junit.Test)

Example 8 with ShowAllColumnsCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.

the class PreserveSelectionModelStructuralChangeEventHandlerTest method shouldRemovePartialSplitCellSelectionOnColumnDelete.

@Test
public void shouldRemovePartialSplitCellSelectionOnColumnDelete() {
    assertTrue("selection is not empty", this.selectionLayer.getSelectedCells().isEmpty());
    this.nattable.doCommand(new SelectCellCommand(this.nattable, 1, 1, false, false));
    assertEquals(1, this.selectionLayer.getSelectedCells().size());
    this.nattable.doCommand(new SelectCellCommand(this.nattable, 5, 2, true, false));
    Collection<ILayerCell> selectedCells = this.selectionLayer.getSelectedCells();
    assertEquals(10, selectedCells.size());
    boolean[] found = new boolean[5];
    for (ILayerCell cell : selectedCells) {
        if (cell.getColumnPosition() >= 5) {
            fail("wrong column position selected");
        } else {
            found[cell.getColumnPosition()] = true;
        }
    }
    for (int i = 0; i < found.length; i++) {
        assertTrue("columnPosition " + i + " not selected", found[i]);
    }
    this.nattable.doCommand(new MultiColumnHideCommand(this.nattable, new int[] { 2, 4 }));
    selectedCells = this.selectionLayer.getSelectedCells();
    assertEquals(6, selectedCells.size());
    found = new boolean[3];
    for (ILayerCell cell : selectedCells) {
        if (cell.getColumnPosition() >= 3) {
            fail("wrong column position selected");
        } else {
            found[cell.getColumnPosition()] = true;
        }
    }
    for (int i = 0; i < found.length; i++) {
        assertTrue("columnPosition " + i + " not selected", found[i]);
    }
    // insert again to verify the column position shift
    this.nattable.doCommand(new ShowAllColumnsCommand());
    selectedCells = this.selectionLayer.getSelectedCells();
    assertEquals(6, selectedCells.size());
    found = new boolean[5];
    for (ILayerCell cell : selectedCells) {
        if (cell.getColumnPosition() >= 5) {
            fail("wrong column position selected");
        } else {
            found[cell.getColumnPosition()] = true;
        }
    }
    for (int i = 0; i < found.length; i++) {
        if (i == 0 || i == 2 || i == 4) {
            assertTrue("columnPosition " + i + " not selected", found[i]);
        }
    }
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 9 with ShowAllColumnsCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.

the class CompositeFreezeLayerHideShowTest method testFreezeHideShowColumnBothRegionsFreezeAll.

@Test
public void testFreezeHideShowColumnBothRegionsFreezeAll() {
    // freeze
    this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 1));
    assertEquals(2, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // hide
    this.compositeFreezeLayer.doCommand(new MultiColumnHideCommand(this.compositeFreezeLayer, new int[] { 0, 1, 2 }));
    assertEquals(0, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(2, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // show again
    this.compositeFreezeLayer.doCommand(new ShowAllColumnsCommand());
    assertEquals(0, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(5, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    reset();
}
Also used : ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) FreezeColumnCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 10 with ShowAllColumnsCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.

the class CompositeFreezeLayerHideShowTest method testFreezeHideShowColumnBothRegions.

@Test
public void testFreezeHideShowColumnBothRegions() {
    // freeze
    this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 1));
    assertEquals(2, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // hide
    this.compositeFreezeLayer.doCommand(new MultiColumnHideCommand(this.compositeFreezeLayer, new int[] { 0, 3 }));
    assertEquals(1, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(0, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(2, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(1, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(100, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // show again
    this.compositeFreezeLayer.doCommand(new ShowAllColumnsCommand());
    assertEquals(2, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    reset();
}
Also used : ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) FreezeColumnCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Aggregations

ShowAllColumnsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand)17 Test (org.junit.Test)16 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)14 FreezeColumnCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand)12 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)6 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)2 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1