use of org.eclipse.nebula.widgets.nattable.search.strategy.SelectionSearchStrategy in project nebula.widgets.nattable by eclipse.
the class SearchDialog method createSearchCommand.
private SearchCommand createSearchCommand(String text, boolean isIncremental) {
this.forwardValue = this.forwardButton.getSelection();
this.allValue = this.allButton.getSelection();
this.caseSensitiveValue = this.caseSensitiveButton.getSelection();
this.wrapSearchValue = this.wrapSearchButton.getSelection();
this.wholeWordValue = this.wholeWordButton.getSelection();
this.incrementalValue = this.incrementalButton.getSelection();
this.regexValue = this.regexButton.getSelection();
// TODO
// includeCollapsedValue = includeCollapsedButton.getSelection();
this.columnFirstValue = this.columnFirstButton.getSelection();
String searchDirection = this.forwardValue ? ISearchDirection.SEARCH_FORWARD : ISearchDirection.SEARCH_BACKWARDS;
ISearchStrategy searchStrategy;
if (this.allValue) {
searchStrategy = new GridSearchStrategy(this.natTable.getConfigRegistry(), true, this.columnFirstValue);
} else {
searchStrategy = new SelectionSearchStrategy(this.natTable.getConfigRegistry(), this.columnFirstValue);
}
return new SearchCommand(text, this.natTable, searchStrategy, searchDirection, this.wrapSearchValue, this.caseSensitiveValue, !this.regexValue && this.wholeWordValue, !this.regexValue && this.allValue && isIncremental, this.regexValue, // includeCollapsedValue, comparator);
false, this.comparator);
}
use of org.eclipse.nebula.widgets.nattable.search.strategy.SelectionSearchStrategy in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method doTestOnSelection.
private void doTestOnSelection() 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 SelectionSearchStrategy gridSearchStrategy = new SelectionSearchStrategy(this.configRegistry, 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(50, selectionLayer.getSelectedCellPositions().length);
assertEquals(this.expected.columnPosition, selectionLayer.getSelectionAnchor().getColumnPosition());
assertEquals(this.expected.rowPosition, selectionLayer.getSelectionAnchor().getRowPosition());
} else {
assertNull(searchResultCellCoordinate);
}
} finally {
this.gridLayer.removeLayerListener(listener);
}
}
Aggregations