use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class RowSelectionTest method shouldNotIncludeDeselectedCellsWithCtrlModifier.
@Test
public void shouldNotIncludeDeselectedCellsWithCtrlModifier() {
// test a previous bug where single deselected cells where added to the
// selection with following modifier selections
// start from a clear selection state
this.selectionLayer.clear();
// select a single cell
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 0, 2, false, false));
// deselect the cell again
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 0, 2, false, true));
// trigger selection of row 4 with ctrl
this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 0, 4, false, true));
assertEquals(0, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(4, this.selectionLayer.getSelectionAnchor().getRowPosition());
assertFalse("[0, 2] is selected", this.selectionLayer.isCellPositionSelected(0, 2));
assertTrue("row 4 not fully selected", this.selectionLayer.isRowPositionFullySelected(4));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class GridSearchStrategyTest method shouldFindAllCellsWithValue.
@Test
public void shouldFindAllCellsWithValue() {
GridSearchStrategy gridStrategy = new GridSearchStrategy(this.configRegistry, true, ISearchDirection.SEARCH_BACKWARDS, true);
gridStrategy.setComparator(new CellValueAsStringComparator<>());
gridStrategy.setContextLayer(this.selectionLayer);
gridStrategy.setCaseSensitive(true);
gridStrategy.setWrapSearch(true);
PositionCoordinate searchResult = gridStrategy.executeSearch("Body");
assertEquals(0, searchResult.columnPosition);
assertEquals(0, searchResult.rowPosition);
// Simulate selecting the search result
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, searchResult.columnPosition, searchResult.rowPosition, false, false));
searchResult = gridStrategy.executeSearch("Body");
assertEquals(4, searchResult.columnPosition);
assertEquals(4, searchResult.rowPosition);
// Simulate selecting the search result
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, searchResult.columnPosition, searchResult.rowPosition, false, false));
searchResult = gridStrategy.executeSearch("Body");
assertEquals(3, searchResult.columnPosition);
assertEquals(3, searchResult.rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class SelectionSearchStrategyTest method shouldOnlySearchWhatIsSelected.
@Test
public void shouldOnlySearchWhatIsSelected() {
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 1, 4, false, true));
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 2, 2, false, true));
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 3, 4, false, true));
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 5, 4, false, true));
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 6, 2, false, true));
assertEquals(5, this.selectionLayer.getSelectedCellPositions().length);
SelectionSearchStrategy selectionStrategy = new SelectionSearchStrategy(this.configRegistry);
selectionStrategy.setWrapSearch(true);
selectionStrategy.setComparator(new CellValueAsStringComparator<>());
selectionStrategy.setContextLayer(this.selectionLayer);
assertNull(selectionStrategy.executeSearch("[0,1]"));
assertNotNull(selectionStrategy.executeSearch(CELL_VALUE));
assertNotNull(selectionStrategy.executeSearch(CELL_VALUE));
assertNull(selectionStrategy.executeSearch("[5,0]"));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class CellSelectionTest method shouldReturnTheCorrectCountOfSelectedCells.
/**
* Selected cells are (col,row): (2,3),(4,1),(1,0),(9,9)
*/
@Test
public void shouldReturnTheCorrectCountOfSelectedCells() {
this.selectionLayer.clear();
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 2, 3, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 4, 1, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 1, 0, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 9, 9, false, true));
PositionCoordinate[] cells = this.selectionLayer.getSelectedCellPositions();
Assert.assertEquals(4, cells.length);
// (1, 0)
Assert.assertEquals(1, cells[0].columnPosition);
Assert.assertEquals(0, cells[0].rowPosition);
// (2, 3)
Assert.assertEquals(2, cells[1].columnPosition);
Assert.assertEquals(3, cells[1].rowPosition);
// (4, 1)
Assert.assertEquals(4, cells[2].columnPosition);
Assert.assertEquals(1, cells[2].rowPosition);
// (9, 9)
Assert.assertEquals(9, cells[3].columnPosition);
Assert.assertEquals(9, cells[3].rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderLayerSelectionTest method willSelectBodyCellAndShouldHaveColumnHeaderSelected.
@Test
public void willSelectBodyCellAndShouldHaveColumnHeaderSelected() {
// Select body cell
// The column position is a grid layer position
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 2, 2, false, false));
// Get column header cell corresponding to the selected body cell
ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
// The column position is 1 because it takes into account the offset of
// the row header
ILayerCell cell = columnHeaderLayer.getCellByPosition(1, 0);
// Assert the cell is in selected state
assertEquals(DisplayMode.SELECT, cell.getDisplayMode());
}
Aggregations