use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate 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);
}
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindTextInGridAfterWrapping.
@Test
public void shouldFindTextInGridAfterWrapping() {
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,2]";
this.expected = new PositionCoordinate(null, 2, 2);
doTest();
this.isForward = false;
this.isWrapSearch = false;
this.searchText = "[2,4]";
this.expected = null;
doTest();
this.isWrapSearch = true;
this.expected = new PositionCoordinate(null, 2, 4);
doTest();
selectCell(0, 0);
final int columnCount = this.gridLayer.getBodyLayer().getColumnCount();
final int rowCount = this.gridLayer.getBodyLayer().getRowCount();
this.searchText = "[" + String.valueOf(columnCount - 1) + ",";
this.expected = new PositionCoordinate(null, columnCount - 1, rowCount - 1);
doTest();
this.isForward = true;
this.searchText = "[0,";
this.expected = new PositionCoordinate(null, 0, 0);
doTest();
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindTextInGridNonIncrementally.
@Test
public void shouldFindTextInGridNonIncrementally() {
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 = "[";
this.expected = new PositionCoordinate(null, 2, 3);
doTest();
this.searchText = "[2";
this.expected = new PositionCoordinate(null, 2, 4);
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 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();
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method shouldFindTextInGridIncrementally.
@Test
public void shouldFindTextInGridIncrementally() {
this.isForward = true;
this.isWrapSearch = false;
this.isCaseSensitive = false;
this.isWholeWord = false;
this.isIncremental = true;
this.isRegex = false;
this.isIncludeCollapsed = false;
this.isColumnFirst = true;
this.searchText = "[";
this.expected = new PositionCoordinate(null, 2, 2);
doTest();
this.searchText = "[2";
this.expected = new PositionCoordinate(null, 2, 2);
doTest();
this.searchText = "[2,";
this.expected = new PositionCoordinate(null, 2, 2);
doTest();
this.searchText = "[2,4";
this.expected = new PositionCoordinate(null, 2, 4);
doTest();
this.isForward = false;
this.searchText = "[";
this.expected = new PositionCoordinate(null, 2, 4);
doTest();
this.searchText = "[2";
this.expected = new PositionCoordinate(null, 2, 4);
doTest();
this.searchText = "[2,";
this.expected = new PositionCoordinate(null, 2, 4);
doTest();
this.searchText = "[2,2";
this.expected = new PositionCoordinate(null, 2, 2);
doTest();
}
Aggregations