Search in sources :

Example 11 with MultiRowHideCommand

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

the class CompositeFreezeLayerHideShowTest method testFreezeHideShowRowBothRegionsFreezeAll.

@Test
public void testFreezeHideShowRowBothRegionsFreezeAll() {
    // freeze
    this.compositeFreezeLayer.doCommand(new FreezeRowCommand(this.compositeFreezeLayer, 1));
    assertEquals(0, this.freezeLayer.getColumnCount());
    assertEquals(2, this.freezeLayer.getRowCount());
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(5, this.viewportLayer.getColumnCount());
    assertEquals(3, this.viewportLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
    // hide
    this.compositeFreezeLayer.doCommand(new MultiRowHideCommand(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(5, this.viewportLayer.getColumnCount());
    assertEquals(2, 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 ShowAllRowsCommand());
    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 : FreezeRowCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) ShowAllRowsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllRowsCommand) Test(org.junit.Test)

Example 12 with MultiRowHideCommand

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

the class CompositeFreezeLayerHideShowTest method testFreezeHideShowRowAllFrozenRegion.

@Test
public void testFreezeHideShowRowAllFrozenRegion() {
    // freeze
    this.compositeFreezeLayer.doCommand(new FreezeRowCommand(this.compositeFreezeLayer, 1));
    assertEquals(0, this.freezeLayer.getColumnCount());
    assertEquals(2, this.freezeLayer.getRowCount());
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(5, this.viewportLayer.getColumnCount());
    assertEquals(3, this.viewportLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
    // hide
    this.compositeFreezeLayer.doCommand(new MultiRowHideCommand(this.compositeFreezeLayer, new int[] { 0, 1 }));
    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(3, 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 ShowAllRowsCommand());
    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 : FreezeRowCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) ShowAllRowsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllRowsCommand) Test(org.junit.Test)

Example 13 with MultiRowHideCommand

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

the class HideSelectedRowsTest method shouldHideAllSelectedRows.

@Test
public void shouldHideAllSelectedRows() {
    // Select cells and rows
    new SelectRowCommandHandler(this.selectionLayer).selectRows(0, Arrays.asList(Integer.valueOf(2)), false, false, 2);
    this.selectionLayer.selectCell(0, 1, false, true);
    this.selectionLayer.selectCell(4, 4, false, true);
    // Hide selection
    this.selectionLayer.doCommand(new MultiRowHideCommand(this.selectionLayer, new int[] { 2, 0, 4 }));
    // Previously selected rows should be hidden
    Assert.assertTrue(this.rowHideShowLayer.isRowIndexHidden(2));
    Assert.assertTrue(this.rowHideShowLayer.isRowIndexHidden(0));
    Assert.assertTrue(this.rowHideShowLayer.isRowIndexHidden(4));
}
Also used : MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) Test(org.junit.Test)

Example 14 with MultiRowHideCommand

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

the class HideSelectedRowsTest method shouldHideSelectedRow.

@Test
public void shouldHideSelectedRow() {
    // Select row to hide
    new SelectRowCommandHandler(this.selectionLayer).selectRows(0, Arrays.asList(Integer.valueOf(2)), false, false, 2);
    // Hide row
    this.selectionLayer.doCommand(new MultiRowHideCommand(this.selectionLayer, 2));
    // The previously selected row should be hidden
    Assert.assertTrue(this.rowHideShowLayer.isRowIndexHidden(2));
    Assert.assertEquals(6, this.selectionLayer.getRowCount());
}
Also used : MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) Test(org.junit.Test)

Aggregations

MultiRowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand)14 Test (org.junit.Test)12 FreezeRowCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand)8 ShowAllRowsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllRowsCommand)8 ArrayList (java.util.ArrayList)1 RowDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent)1 RowInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent)1 RowReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand)1