use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class DefaultBodyLayerStackTest method hideColumnsAndReorder.
/*
* Data Layer: 0 1 2 3 4 5 6 7 8 9
* -----------------------------------------------------
*/
@Test
public void hideColumnsAndReorder() throws Exception {
// Hide 3, 4
this.layerStack.doCommand(new ColumnHideCommand(this.layerStack, 3));
this.layerStack.doCommand(new ColumnHideCommand(this.layerStack, 3));
assertEquals(0, this.layerStack.getColumnIndexByPosition(0));
assertEquals(1, this.layerStack.getColumnIndexByPosition(1));
assertEquals(2, this.layerStack.getColumnIndexByPosition(2));
assertEquals(5, this.layerStack.getColumnIndexByPosition(3));
assertEquals(6, this.layerStack.getColumnIndexByPosition(4));
assertEquals(7, this.layerStack.getColumnIndexByPosition(5));
assertEquals(8, this.layerStack.getColumnIndexByPosition(6));
assertEquals(9, this.layerStack.getColumnIndexByPosition(7));
assertEquals(-1, this.layerStack.getColumnIndexByPosition(8));
// Reorder 0 -> 4
this.layerStack.doCommand(new ColumnReorderCommand(this.layerStack, 0, 4));
assertEquals(1, this.layerStack.getColumnIndexByPosition(0));
assertEquals(2, this.layerStack.getColumnIndexByPosition(1));
assertEquals(5, this.layerStack.getColumnIndexByPosition(2));
assertEquals(0, this.layerStack.getColumnIndexByPosition(3));
assertEquals(6, this.layerStack.getColumnIndexByPosition(4));
assertEquals(7, this.layerStack.getColumnIndexByPosition(5));
assertEquals(8, this.layerStack.getColumnIndexByPosition(6));
assertEquals(9, this.layerStack.getColumnIndexByPosition(7));
assertEquals(-1, this.layerStack.getColumnIndexByPosition(8));
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class DefaultBodyLayerStackTest method resizeAColumnAndHideIt.
@Test
public void resizeAColumnAndHideIt() throws Exception {
assertEquals(10, this.layerStack.getColumnCount());
assertEquals(1000, this.layerStack.getWidth());
// Resize 2
this.layerStack.doCommand(new ColumnResizeCommand(this.layerStack, 2, 500));
assertEquals(1400, this.layerStack.getWidth());
assertEquals(1, this.layerStack.getColumnIndexByPosition(1));
assertEquals(100, this.layerStack.getColumnWidthByPosition(1));
assertEquals(100, this.layerStack.getStartXOfColumnPosition(1));
assertEquals(2, this.layerStack.getColumnIndexByPosition(2));
assertEquals(500, this.layerStack.getColumnWidthByPosition(2));
assertEquals(200, this.layerStack.getStartXOfColumnPosition(2));
assertEquals(3, this.layerStack.getColumnIndexByPosition(3));
assertEquals(100, this.layerStack.getColumnWidthByPosition(3));
assertEquals(700, this.layerStack.getStartXOfColumnPosition(3));
// Hide 2
this.layerStack.doCommand(new ColumnHideCommand(this.layerStack, 2));
assertEquals(9, this.layerStack.getColumnCount());
assertEquals(1, this.layerStack.getColumnIndexByPosition(1));
assertEquals(100, this.layerStack.getColumnWidthByPosition(1));
assertEquals(100, this.layerStack.getStartXOfColumnPosition(1));
assertEquals(3, this.layerStack.getColumnIndexByPosition(2));
assertEquals(100, this.layerStack.getColumnWidthByPosition(2));
assertEquals(200, this.layerStack.getStartXOfColumnPosition(2));
assertEquals(4, this.layerStack.getColumnIndexByPosition(3));
assertEquals(100, this.layerStack.getColumnWidthByPosition(3));
assertEquals(300, this.layerStack.getStartXOfColumnPosition(3));
assertEquals(9, this.layerStack.getColumnIndexByPosition(8));
assertEquals(100, this.layerStack.getColumnWidthByPosition(8));
assertEquals(800, this.layerStack.getStartXOfColumnPosition(8));
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class HideSelectedColumnsTest method shouldHideColumnForSelectedCell.
@Test
public void shouldHideColumnForSelectedCell() {
// Select cell in column we want to hide
this.selectionLayer.setSelectedCell(3, 0);
// Hide selection
this.selectionLayer.doCommand(new ColumnHideCommand(this.selectionLayer, 3));
// The previously selected column should be hidden
Assert.assertTrue(this.columnHideShowLayer.isColumnIndexHidden(3));
Assert.assertEquals(4, this.selectionLayer.getColumnCount());
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class PreserveSelectionModelStructuralChangeEventHandlerTest method shouldRemoveCellSelectionOnColumnDelete.
@Test
public void shouldRemoveCellSelectionOnColumnDelete() {
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, 1, 2, false, true));
assertEquals(2, this.selectionLayer.getSelectedCells().size());
this.nattable.doCommand(new ColumnHideCommand(this.nattable, 1));
Collection<ILayerCell> selectedCells = this.selectionLayer.getSelectedCells();
assertEquals(0, selectedCells.size());
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class PreserveSelectionModelStructuralChangeEventHandlerTest method shouldRemovePartialCellSelectionOnColumnDelete.
@Test
public void shouldRemovePartialCellSelectionOnColumnDelete() {
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, 1, 2, false, true));
this.nattable.doCommand(new SelectCellCommand(this.nattable, 2, 1, false, true));
this.nattable.doCommand(new SelectCellCommand(this.nattable, 2, 2, false, true));
assertEquals(4, this.selectionLayer.getSelectedCells().size());
this.nattable.doCommand(new ColumnHideCommand(this.nattable, 1));
Collection<ILayerCell> selectedCells = this.selectionLayer.getSelectedCells();
assertEquals(2, selectedCells.size());
// moved to the left
for (ILayerCell cell : selectedCells) {
assertEquals(0, cell.getColumnPosition());
}
// insert again to verify the column position shift
this.nattable.doCommand(new ShowAllColumnsCommand());
// the deselected cells shouldn't get automatically selected again
selectedCells = this.selectionLayer.getSelectedCells();
assertEquals(2, selectedCells.size());
// moved to the right
for (ILayerCell cell : selectedCells) {
assertEquals(1, cell.getColumnPosition());
}
}
Aggregations