use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method doTest.
private void doTest() throws PatternSyntaxException {
// Register call back
final ILayerListener listener = new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof SearchEvent) {
// Check event, coordinate should be in composite layer
// coordinates
SearchEvent searchEvent = (SearchEvent) event;
if (SearchGridCommandHandlerTest.this.expected != null) {
assertEquals(SearchGridCommandHandlerTest.this.expected.columnPosition, searchEvent.getCellCoordinate().getColumnPosition());
assertEquals(SearchGridCommandHandlerTest.this.expected.rowPosition, searchEvent.getCellCoordinate().getRowPosition());
} else {
assertNull(searchEvent.getCellCoordinate());
}
}
}
};
this.gridLayer.addLayerListener(listener);
try {
SelectionLayer selectionLayer = this.gridLayer.getBodyLayer().getSelectionLayer();
final GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(this.configRegistry, this.isWrapSearch, this.isColumnFirst);
final SearchCommand searchCommand = new SearchCommand(this.searchText, selectionLayer, gridSearchStrategy, this.isForward ? ISearchDirection.SEARCH_FORWARD : ISearchDirection.SEARCH_BACKWARDS, this.isWrapSearch, this.isCaseSensitive, this.isWholeWord, this.isIncremental, this.isRegex, this.isIncludeCollapsed, new CellValueAsStringComparator<>());
this.commandHandler.doCommand(selectionLayer, searchCommand);
final PositionCoordinate searchResultCellCoordinate = this.commandHandler.getSearchResultCellCoordinate();
if (this.expected != null) {
assertEquals(this.expected.columnPosition, searchResultCellCoordinate.columnPosition);
assertEquals(this.expected.rowPosition, searchResultCellCoordinate.rowPosition);
assertEquals(1, selectionLayer.getSelectedCellPositions().length);
assertEquals(this.expected.columnPosition, selectionLayer.getSelectedCellPositions()[0].columnPosition);
assertEquals(this.expected.rowPosition, selectionLayer.getSelectedCellPositions()[0].rowPosition);
} else {
assertNull(searchResultCellCoordinate);
}
} finally {
this.gridLayer.removeLayerListener(listener);
}
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate 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.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindTextInGrid.
@Test
public void shouldFindTextInGrid() {
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);
doTest();
this.isForward = false;
this.searchText = "[2,3]";
this.expected = new PositionCoordinate(null, 2, 3);
doTest();
this.searchText = "[2,4]";
this.expected = null;
doTest();
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindWholeWordInGrid.
@Test
public void shouldFindWholeWordInGrid() {
this.isForward = true;
this.isWrapSearch = false;
this.isCaseSensitive = false;
this.isWholeWord = true;
this.isIncremental = false;
this.isRegex = false;
this.isIncludeCollapsed = false;
this.isColumnFirst = true;
this.searchText = "[2,4]";
this.expected = new PositionCoordinate(null, 2, 4);
doTest();
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class ColumnSearchStrategyTest method shouldAccessCellsInSelectedColumn.
@Test
public void shouldAccessCellsInSelectedColumn() {
// Choose three columns for searching
ColumnSearchStrategy columnSearchStrategy = new ColumnSearchStrategy(new int[] { 2, 5, 8 }, this.configRegistry);
columnSearchStrategy.setComparator(new CellValueAsStringComparator<>());
PositionCoordinate[] cellsToSearch = columnSearchStrategy.getColumnCellsToSearch(this.layer);
PositionCoordinate cell = cellsToSearch[0];
assertEquals(2, cell.columnPosition);
cell = cellsToSearch[5];
assertEquals(5, cell.columnPosition);
cell = cellsToSearch[10];
assertEquals(8, cell.columnPosition);
assertEquals(15, cellsToSearch.length);
assertEquals(0, this.gridLayer.getBodyLayer().getSelectionLayer().getSelectedCells().size());
}
Aggregations