use of org.eclipse.nebula.widgets.nattable.search.command.SearchCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testUnhideOnSearch.
@Test
public void testUnhideOnSearch() {
this.treeLayer.setExpandOnSearch(false);
this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
assertEquals(10, this.treeLayer.getRowCount());
assertEquals(1, this.treeLayer.collapsedNodes.size());
HierarchicalTreeNode node = this.treeLayer.collapsedNodes.iterator().next();
assertEquals(2, node.columnIndex);
assertEquals(9, node.rowIndex);
assertNotNull(node.rowObject);
assertEquals(10, this.treeLayer.getHiddenRowIndexes().iterator().next().intValue());
// search for the collapsed row
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(configRegistry, false, true);
SearchCommand searchCommand = new SearchCommand("sing", this.selectionLayer, gridSearchStrategy, ISearchDirection.SEARCH_FORWARD, false, false, false, false, false, false, new CellValueAsStringComparator<>());
this.treeLayer.doCommand(searchCommand);
assertEquals(11, this.treeLayer.getRowCount());
assertEquals(1, this.treeLayer.collapsedNodes.size());
node = this.treeLayer.collapsedNodes.iterator().next();
assertEquals(2, node.columnIndex);
assertEquals(9, node.rowIndex);
assertNotNull(node.rowObject);
assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
use of org.eclipse.nebula.widgets.nattable.search.command.SearchCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandAllLevelsOnSearchWithoutLevelHeader.
@Test
public void testExpandAllLevelsOnSearchWithoutLevelHeader() {
this.treeLayer.setShowTreeLevelHeader(false);
this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
this.treeLayer.doCommand(new TreeExpandCollapseCommand(6, 0));
assertEquals(7, this.treeLayer.getRowCount());
assertEquals(2, this.treeLayer.collapsedNodes.size());
assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
// search for the collapsed row
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(configRegistry, false, true);
SearchCommand searchCommand = new SearchCommand("sing", this.selectionLayer, gridSearchStrategy, ISearchDirection.SEARCH_FORWARD, false, false, false, false, false, false, new CellValueAsStringComparator<>());
this.treeLayer.doCommand(searchCommand);
assertEquals(11, this.treeLayer.getRowCount());
assertEquals(0, this.treeLayer.collapsedNodes.size());
assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
use of org.eclipse.nebula.widgets.nattable.search.command.SearchCommand 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.command.SearchCommand in project nebula.widgets.nattable by eclipse.
the class SearchDialog method doFind0.
private void doFind0(final boolean isIncremental, final String text) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
@Override
public void run() {
PositionCoordinate previous = new PositionCoordinate(SearchDialog.this.selections.peek().pos);
try {
final SearchCommand searchCommand = createSearchCommand(text, isIncremental);
final SearchEventListener searchEventListener = new SearchEventListener();
searchCommand.setSearchEventListener(searchEventListener);
SearchDialog.this.natTable.doCommand(searchCommand);
if (searchEventListener.pos == null) {
// Beep and show status if not found
// $NON-NLS-1$
SearchDialog.this.statusLabel.setText(Messages.getString("Search.textNotFound"));
getShell().getDisplay().beep();
} else {
SelectionItem selection = new SelectionItem(text, searchEventListener.pos);
SearchDialog.this.selections.push(selection);
if (!isIncremental) {
resetIncrementalSelections();
}
// Beep and show status if wrapped
if (previous != null && previous.columnPosition > -1) {
int columnDelta = selection.pos.columnPosition - previous.columnPosition;
int rowDelta = selection.pos.rowPosition - previous.rowPosition;
if (!SearchDialog.this.forwardValue) {
columnDelta = -columnDelta;
rowDelta = -rowDelta;
}
int primaryDelta = SearchDialog.this.columnFirstValue ? columnDelta : rowDelta;
int secondaryDelta = SearchDialog.this.columnFirstValue ? rowDelta : columnDelta;
if (primaryDelta < 0 || !isIncremental && primaryDelta == 0 && secondaryDelta <= 0) {
// $NON-NLS-1$
SearchDialog.this.statusLabel.setText(Messages.getString("Search.wrappedSearch"));
getShell().getDisplay().beep();
}
}
}
if (!isIncremental) {
updateFindHistory();
}
} catch (PatternSyntaxException e) {
SearchDialog.this.statusLabel.setText(e.getLocalizedMessage());
SearchDialog.this.statusLabel.setForeground(JFaceColors.getErrorText(SearchDialog.this.statusLabel.getDisplay()));
getShell().getDisplay().beep();
}
}
});
}
use of org.eclipse.nebula.widgets.nattable.search.command.SearchCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testExpandOnSearch.
@Test
public void testExpandOnSearch() {
this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
assertEquals(10, this.treeLayer.getRowCount());
assertEquals(1, this.treeLayer.collapsedNodes.size());
HierarchicalTreeNode node = this.treeLayer.collapsedNodes.iterator().next();
assertEquals(2, node.columnIndex);
assertEquals(9, node.rowIndex);
assertNotNull(node.rowObject);
assertEquals(10, this.treeLayer.getHiddenRowIndexes().iterator().next().intValue());
// search for the collapsed row
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(configRegistry, false, true);
SearchCommand searchCommand = new SearchCommand("sing", this.selectionLayer, gridSearchStrategy, ISearchDirection.SEARCH_FORWARD, false, false, false, false, false, false, new CellValueAsStringComparator<>());
this.treeLayer.doCommand(searchCommand);
assertEquals(11, this.treeLayer.getRowCount());
assertEquals(0, this.treeLayer.collapsedNodes.size());
assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
Aggregations