use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldUngroupFirstAndLastSelectedColumn.
@Test
public void shouldUngroupFirstAndLastSelectedColumn() {
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, false, true));
final String columnGroupName = "Test Group 3";
this.handler.loadSelectedColumnsIndexesWithPositions();
this.handler.handleGroupColumnsCommand(columnGroupName);
// Test ungrouping first column
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, false, true));
this.handler.handleUngroupCommand();
Assert.assertEquals(1, getColumnIndexesInGroup(1).size());
Assert.assertEquals(1, getColumnIndexesInGroup(1).get(0).intValue());
Assert.assertEquals(0, this.selectionLayer.getColumnPositionByIndex(0));
Assert.assertEquals(2, this.selectionLayer.getColumnPositionByIndex(2));
Assert.assertEquals(1, this.selectionLayer.getColumnPositionByIndex(1));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class MultiRowResizeCommandTest method testMultiResizeWithDownscaleOnSelection.
@Test
public void testMultiResizeWithDownscaleOnSelection() {
GridLayer gridLayer = new DummyGridLayerStack();
IDpiConverter dpiConverter = new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
this.dpi = 120;
}
};
gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
setClientAreaProvider(gridLayer);
// select columns
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 3, 1, false, false));
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 4, 1, false, true));
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 5, 1, false, true));
// scaling enabled, therefore default height of 20 pixels is up scaled
// to 25
assertEquals(25, gridLayer.getRowHeightByPosition(2));
assertEquals(25, gridLayer.getRowHeightByPosition(3));
assertEquals(25, gridLayer.getRowHeightByPosition(4));
assertEquals(25, gridLayer.getRowHeightByPosition(5));
assertEquals(25, gridLayer.getRowHeightByPosition(6));
// select rows
gridLayer.doCommand(new SelectRowsCommand(gridLayer, 1, new int[] { 3, 4, 5 }, false, true, -1));
// resize one of the selected columns
RowResizeCommand columnResizeCommand = new RowResizeCommand(gridLayer, 3, 50, true);
gridLayer.doCommand(columnResizeCommand);
// command executed with down scaling enabled, therefore set height 50
// is first down scaled on setting the value and then up scaled to 50
// again on accessing the height
assertEquals(25, gridLayer.getRowHeightByPosition(2));
assertEquals(50, gridLayer.getRowHeightByPosition(3));
assertEquals(50, gridLayer.getRowHeightByPosition(4));
assertEquals(50, gridLayer.getRowHeightByPosition(5));
assertEquals(25, gridLayer.getRowHeightByPosition(6));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class MultiColumnResizeCommandTest method testMultiResizeWithoutDownscaleOnSelection.
@Test
public void testMultiResizeWithoutDownscaleOnSelection() {
DummyGridLayerStack gridLayer = new DummyGridLayerStack();
IDpiConverter dpiConverter = new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
this.dpi = 120;
}
};
gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
setClientAreaProvider(gridLayer);
// scaling enabled, therefore default width of 100 pixels is up scaled
// to 125
assertEquals(125, gridLayer.getColumnWidthByPosition(2));
assertEquals(125, gridLayer.getColumnWidthByPosition(3));
assertEquals(125, gridLayer.getColumnWidthByPosition(4));
assertEquals(125, gridLayer.getColumnWidthByPosition(5));
assertEquals(125, gridLayer.getColumnWidthByPosition(6));
// select columns
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 3, 1, false, false));
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 4, 1, false, true));
gridLayer.doCommand(new SelectColumnCommand(gridLayer, 5, 1, false, true));
// resize one of the selected columns
ColumnResizeCommand columnResizeCommand = new ColumnResizeCommand(gridLayer, 3, 150);
gridLayer.doCommand(columnResizeCommand);
// command executed with down scaling disabled, therefore set width 150
// is up scaled to 188
assertEquals(125, gridLayer.getColumnWidthByPosition(2));
assertEquals(188, gridLayer.getColumnWidthByPosition(3));
assertEquals(188, gridLayer.getColumnWidthByPosition(4));
assertEquals(188, gridLayer.getColumnWidthByPosition(5));
assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnSelectionTest method onlyOneCellSelectedAtAnyTime.
@Test
public void onlyOneCellSelectedAtAnyTime() {
this.selectionLayer.getSelectionModel().setMultipleSelectionAllowed(false);
this.selectionLayer.clear();
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, true));
Collection<PositionCoordinate> cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
assertEquals(1, cells.size());
assertEquals(1, this.selectionLayer.getSelectedColumnPositions().length);
assertEquals(1, this.selectionLayer.getSelectedColumnPositions()[0]);
assertEquals(1, this.selectionLayer.getSelectedRowCount());
// select another column with control mask
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, false, true));
cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
assertEquals(1, cells.size());
assertEquals(1, this.selectionLayer.getSelectedColumnPositions().length);
assertEquals(2, this.selectionLayer.getSelectedColumnPositions()[0]);
assertEquals(1, this.selectionLayer.getSelectedRowCount());
// select additional columns with shift mask
// only the last column should be selected afterwards
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 5, 0, true, false));
cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
assertEquals(1, cells.size());
assertEquals(1, this.selectionLayer.getSelectedColumnPositions().length);
assertEquals(5, this.selectionLayer.getSelectedColumnPositions()[0]);
assertEquals(1, this.selectionLayer.getSelectedRowCount());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnSelectionTest method shouldUpdateAnchorIfDeselected.
@Test
public void shouldUpdateAnchorIfDeselected() {
// start from a clear selection state
this.selectionLayer.clear();
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, true, false));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 4, 0, true, false));
assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getRowPosition());
for (int col = 2; col <= 4; col++) {
assertTrue("column " + col + " not fully selected", this.selectionLayer.isColumnPositionFullySelected(col));
}
// deselect column 2
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, false, true));
assertEquals(3, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getRowPosition());
assertFalse("column 2 fully selected", this.selectionLayer.isColumnPositionFullySelected(2));
for (int col = 3; col <= 4; col++) {
assertTrue("column " + col + " not fully selected", this.selectionLayer.isColumnPositionFullySelected(col));
}
}
Aggregations