use of org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindTextInSelectionWithoutWrap.
@Test
public void shouldFindTextInSelectionWithoutWrap() {
// select all
this.gridLayer.doCommand(new SelectAllCommand());
this.isForward = true;
this.isWrapSearch = false;
this.isCaseSensitive = false;
this.isWholeWord = false;
this.isIncremental = false;
this.isRegex = false;
this.isIncludeCollapsed = false;
this.isColumnFirst = true;
this.searchText = "[2,4]";
this.expected = new PositionCoordinate(null, 2, 4);
doTestOnSelection();
this.isForward = false;
this.searchText = "[2,3]";
this.expected = new PositionCoordinate(null, 2, 3);
doTestOnSelection();
this.searchText = "[2,4]";
this.expected = null;
doTestOnSelection();
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand in project nebula.widgets.nattable by eclipse.
the class AutoResizeColumnsTest method autoResizeOneColumn.
/**
* These sequence of actions were causing a nasty bug in AutoResize
*/
@Test
public void autoResizeOneColumn() throws Exception {
GridLayer gridLayer = new DummyGridLayerStack();
setClientAreaProvider(gridLayer);
// Resize column
gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 2, 10));
assertEquals(10, gridLayer.getColumnWidthByPosition(2));
// Auto resize the one column
InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(gridLayer, 2, this.configRegistry, this.gcFactory);
gridLayer.doCommand(command);
// Note: the actual resized width is platform specific (font
// dependency),
// hence we can't compare against a fixed value.
int columnWidth = gridLayer.getColumnWidthByPosition(2);
assertTrue(columnWidth > 10);
// Reorder columns
gridLayer.doCommand(new ColumnReorderCommand(gridLayer, 2, 1));
assertEquals(columnWidth, gridLayer.getColumnWidthByPosition(1));
// Select all columns
gridLayer.doCommand(new SelectAllCommand());
// Resize all selected columns
command = new InitializeAutoResizeColumnsCommand(gridLayer, 1, this.configRegistry, this.gcFactory);
gridLayer.doCommand(command);
for (int columnPosition = 1; columnPosition <= 20; columnPosition++) {
assertTrue("column " + columnPosition + " should have been resized, but it is still its original width", gridLayer.getColumnWidthByPosition(columnPosition) != 100);
}
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand in project nebula.widgets.nattable by eclipse.
the class SelectionSearchStrategyTest method shouldSearchSelectionBackwards.
@Test
public void shouldSearchSelectionBackwards() {
// Select entire grid
this.gridLayer.doCommand(new SelectAllCommand());
assertEquals(50, this.selectionLayer.getSelectedCells().size());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getRowPosition());
SelectionSearchStrategy selectionStrategy = new SelectionSearchStrategy(this.configRegistry);
selectionStrategy.setWrapSearch(true);
selectionStrategy.setComparator(new CellValueAsStringComparator<>());
selectionStrategy.setContextLayer(this.selectionLayer);
// the selection anchor is already in the first cell,
// therefore the search result will return the second row in the first
// column
PositionCoordinate positionCoordinate = selectionStrategy.executeSearch(CELL_VALUE);
assertEquals(0, positionCoordinate.columnPosition);
assertEquals(1, positionCoordinate.rowPosition);
// selection stays unchanged, only the selection anchor moves
assertEquals(50, this.selectionLayer.getSelectedCells().size());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(1, this.selectionLayer.getSelectionAnchor().getRowPosition());
// Should find last cell
selectionStrategy = new SelectionSearchStrategy(this.configRegistry, ISearchDirection.SEARCH_BACKWARDS, true);
selectionStrategy.setWrapSearch(true);
selectionStrategy.setComparator(new CellValueAsStringComparator<>());
selectionStrategy.setContextLayer(this.selectionLayer);
// one backwards will find the first cell in the grid
positionCoordinate = selectionStrategy.executeSearch(CELL_VALUE);
assertEquals(0, positionCoordinate.columnPosition);
assertEquals(0, positionCoordinate.rowPosition);
// selection stays unchanged, only the selection anchor moves
assertEquals(50, this.selectionLayer.getSelectedCells().size());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(0, this.selectionLayer.getSelectionAnchor().getRowPosition());
// second backwards will find the last cell
positionCoordinate = selectionStrategy.executeSearch(CELL_VALUE);
assertEquals(9, positionCoordinate.columnPosition);
assertEquals(4, positionCoordinate.rowPosition);
// selection stays unchanged, only the selection anchor moves
assertEquals(50, this.selectionLayer.getSelectedCells().size());
assertEquals(9, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(4, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand in project nebula.widgets.nattable by eclipse.
the class SelectionSearchStrategyTest method shouldNotWrap.
@Test
public void shouldNotWrap() {
this.gridLayer.doCommand(new SelectAllCommand());
this.selectionLayer.moveSelectionAnchor(9, 4);
assertEquals(50, this.selectionLayer.getSelectedCells().size());
assertEquals(9, this.selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(4, this.selectionLayer.getSelectionAnchor().getRowPosition());
SelectionSearchStrategy selectionStrategy = new SelectionSearchStrategy(this.configRegistry);
selectionStrategy.setComparator(new CellValueAsStringComparator<>());
selectionStrategy.setContextLayer(this.selectionLayer);
PositionCoordinate positionCoordinate = selectionStrategy.executeSearch(CELL_VALUE);
assertNull(positionCoordinate);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindTextInSelectionWithWrap.
@Test
public void shouldFindTextInSelectionWithWrap() {
// select all
this.gridLayer.doCommand(new SelectAllCommand());
this.isForward = true;
this.isWrapSearch = true;
this.isCaseSensitive = false;
this.isWholeWord = false;
this.isIncremental = false;
this.isRegex = false;
this.isIncludeCollapsed = false;
this.isColumnFirst = true;
this.searchText = "[2,4]";
this.expected = new PositionCoordinate(null, 2, 4);
doTestOnSelection();
this.isForward = false;
this.searchText = "[2,3]";
this.expected = new PositionCoordinate(null, 2, 3);
doTestOnSelection();
this.searchText = "[2,4]";
this.expected = new PositionCoordinate(null, 2, 4);
doTestOnSelection();
}
Aggregations