private void collectAllMatchesBelow(AbstractTextSearchResult result, Set<Match> set, ITreeContentProvider cp, Object[] elements) { for (Object element : elements) { Match[] matches = getDisplayedMatches(element); for (Match match : matches) { set.add(match); } Object[] children = cp.getChildren(element); collectAllMatchesBelow(result, set, cp, children); } }
private void collectAllMatchesBelow(AbstractTextSearchResult result, Set set, ITreeContentProvider cp, Object[] elements) { for (int j = 0; j < elements.length; j++) { Match[] matches = getDisplayedMatches(elements[j]); for (int i = 0; i < matches.length; i++) { set.add(matches[i]); } Object[] children = cp.getChildren(elements[j]); collectAllMatchesBelow(result, set, cp, children); } }
/** * Note: this is internal API and should not be called from clients outside * of the search plug-in. * <p> * Removes the currently selected match. Does nothing if no match is * selected. * </p> */ public void internalRemoveSelected() { AbstractTextSearchResult result = getInput(); if (result == null) return; StructuredViewer viewer = getViewer(); IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); HashSet set = new HashSet(); if (viewer instanceof TreeViewer) { ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider(); collectAllMatchesBelow(result, set, cp, selection.toArray()); } else { collectAllMatches(set, selection.toArray()); } Match[] matches = new Match[set.size()]; set.toArray(matches); result.removeMatches(matches); }
/** * Note: this is internal API and should not be called from clients outside * of the search plug-in. * <p> * Removes the currently selected match. Does nothing if no match is * selected. * </p> * * @noreference This method is not intended to be referenced by clients. */ public void internalRemoveSelected() { AbstractTextSearchResult result = getInput(); if (result == null) return; StructuredViewer viewer = getViewer(); IStructuredSelection selection = viewer.getStructuredSelection(); HashSet<Match> set = new HashSet<>(); if (viewer instanceof TreeViewer) { ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider(); collectAllMatchesBelow(result, set, cp, selection.toArray()); } else { collectAllMatches(set, selection.toArray()); } navigateNext(true); Match[] matches = new Match[set.size()]; set.toArray(matches); result.removeMatches(matches); }