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