Search in sources :

Example 6 with MultiColumnHideCommand

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

the class HideSelectedColumnsTest method shouldHideAllSelectedColumns.

@Test
public void shouldHideAllSelectedColumns() {
    // Select cells and columns
    new SelectColumnCommandHandler(this.selectionLayer).selectColumn(2, 0, false, true);
    this.selectionLayer.selectCell(1, 0, false, true);
    this.selectionLayer.selectCell(4, 4, false, true);
    // Hide selection
    this.selectionLayer.doCommand(new MultiColumnHideCommand(this.selectionLayer, new int[] { 2, 0, 4 }));
    // Previously selected columns should be hidden
    Assert.assertTrue(this.columnHideShowLayer.isColumnIndexHidden(2));
    Assert.assertTrue(this.columnHideShowLayer.isColumnIndexHidden(0));
    Assert.assertTrue(this.columnHideShowLayer.isColumnIndexHidden(4));
}
Also used : SelectColumnCommandHandler(org.eclipse.nebula.widgets.nattable.selection.SelectColumnCommandHandler) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 7 with MultiColumnHideCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand 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 8 with MultiColumnHideCommand

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

the class ReorderColumnEventTest method reorderMultipleNotConsecutiveColumnsInHiddenState.

@Test
public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
    DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(10, 10, 100, 20));
    NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer, 1000, 400, true);
    // Add listener
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    natTableFixture.addLayerListener(listenerFixture);
    assertEquals(10, natTableFixture.getColumnCount());
    // hide some columns
    natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture, new int[] { 2, 5, 8 }));
    assertEquals(7, natTableFixture.getColumnCount());
    List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
    int destinationPosition = 0;
    natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer.getColumnReorderLayer(), columnToMove, destinationPosition));
    // verify the event
    ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture.getReceivedEvent(ColumnReorderEvent.class);
    assertNotNull(event);
    assertTrue(StructuralChangeEventHelper.isReorder(event.getColumnDiffs()));
    assertEquals(7, natTableFixture.getColumnCount());
    assertEquals(0, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(3));
    assertEquals(1, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(4));
    assertEquals(2, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(6));
    assertEquals(3, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(7));
    assertEquals(4, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(0));
    assertEquals(5, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(1));
    assertEquals(6, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(2));
    assertEquals(7, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(5));
    assertEquals(8, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(8));
    assertEquals(9, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(9));
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 9 with MultiColumnHideCommand

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

the class ColumnChooserUtils method hideColumnPositions.

public static void hideColumnPositions(List<Integer> removedPositions, ColumnHideShowLayer hideShowLayer) {
    MultiColumnHideCommand hideCommand = new MultiColumnHideCommand(hideShowLayer, asIntArray(removedPositions));
    hideShowLayer.doCommand(hideCommand);
}
Also used : MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)

Example 10 with MultiColumnHideCommand

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

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsert.

@Test
public void shouldUpdateHiddenOnInsert() {
    DefaultBodyLayerStack body = this.grid.getBodyLayer();
    ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
    body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(7);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Also used : ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Aggregations

MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)20 Test (org.junit.Test)18 ShowAllColumnsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand)9 FreezeColumnCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand)8 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)5 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)4 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)4 ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)2 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 SelectColumnCommandHandler (org.eclipse.nebula.widgets.nattable.selection.SelectColumnCommandHandler)2 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)1 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.LayerListenerFixture)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)1 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)1