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