use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand in project nebula.widgets.nattable by eclipse.
the class RowSelectionTest method shouldUpdateAnchorIfDeselected.
@Test
public void shouldUpdateAnchorIfDeselected() {
// start from a clear selection state
this.selectionLayer.clear();
this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 0, 2, true, false));
this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 0, 4, true, false));
assertEquals(0, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(2, this.selectionLayer.getSelectionAnchor().getRowPosition());
for (int row = 2; row <= 4; row++) {
assertTrue("row " + row + " not fully selected", this.selectionLayer.isRowPositionFullySelected(row));
}
// deselect row 2
this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 0, 2, false, true));
assertEquals(0, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
assertFalse("row 2 fully selected", this.selectionLayer.isRowPositionFullySelected(2));
for (int row = 3; row <= 4; row++) {
assertTrue("row " + row + " not fully selected", this.selectionLayer.isRowPositionFullySelected(row));
}
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand 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.SelectRowsCommand in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method shouldPreserveRowSelectionOnSort.
@Test
public void shouldPreserveRowSelectionOnSort() throws Exception {
assertEquals(0, this.selectionLayer.getFullySelectedRowPositions().length);
// Unsorted order - Ford motor at top
assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 1).toString());
assertEquals("A Alphabet Co.", this.nattable.getDataValueByPosition(2, 2).toString());
assertEquals("C General Electric Co", this.nattable.getDataValueByPosition(2, 3).toString());
// Select 'Ford Motor'
this.nattable.doCommand(new SelectRowsCommand(this.nattable, 1, 1, false, false));
assertEquals("B Ford Motor", getSelected().getSecurity_description());
// Sort
this.nattable.doCommand(new SortColumnCommand(this.nattable, 2, false));
// Sorted order - Alphabet co. at top
assertEquals("A Alphabet Co.", this.nattable.getDataValueByPosition(2, 1).toString());
assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 2).toString());
assertEquals("C General Electric Co", this.nattable.getDataValueByPosition(2, 3).toString());
// Ford motor still selected
assertEquals("B Ford Motor", getSelected().getSecurity_description());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method shouldPreserveRowSelectionOnDataUpdates.
@Test
public void shouldPreserveRowSelectionOnDataUpdates() throws Exception {
assertEquals(0, this.selectionLayer.getFullySelectedRowPositions().length);
this.nattable.doCommand(new SelectRowsCommand(this.nattable, 1, 1, false, false));
assertEquals(1, this.selectionLayer.getFullySelectedRowPositions().length);
// Ford motor at top and selected
assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 1).toString());
assertEquals("B Ford Motor", getSelected().getSecurity_description());
this.eventListFixture.add(0, RowDataFixture.getInstance("Tata motors", "A"));
// Event layer will conflate list change events
Thread.sleep(100);
// Tata motors at top but Ford motors still selected
assertEquals("Tata motors", this.nattable.getDataValueByPosition(2, 1).toString());
assertEquals("B Ford Motor", getSelected().getSecurity_description());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method onlySelectRowEventsFired.
@Test
public void onlySelectRowEventsFired() {
this.nattable.addLayerListener(new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellSelectionEvent) {
fail("CellSelectionEvent fired for row selection");
}
}
});
this.nattable.doCommand(new SelectRowsCommand(this.selectionLayer, 0, 0, false, false));
// the second call first clears the selection and then applies the new
// one clearing by default also fires a CellSelectionEvent with negative
// values
this.nattable.doCommand(new SelectRowsCommand(this.selectionLayer, 0, 3, false, false));
}
Aggregations