public void doFilter(String filterText) { fRefreshJob.cancel(); fRefreshJob.schedule(getRefreshJobDelay()); filterText= filterText.trim(); int index= filterText.indexOf("~"); //$NON-NLS-1$ StringMatcher labelMatcher= null; StringMatcher valueMatcher= null; if (index == -1) { labelMatcher= createStringMatcher(filterText); } else { if (index == 0 && !fExpectMultiWordValueMatch) { int i= 0; for (; i < filterText.length(); i++) { char ch= filterText.charAt(i); if (ch == ' ' || ch == '\t') { break; } } valueMatcher= createStringMatcher(filterText.substring(1, i)); labelMatcher= createStringMatcher(filterText.substring(i)); } else { labelMatcher= createStringMatcher(filterText.substring(0, index)); if (index < filterText.length()) valueMatcher= createStringMatcher(filterText.substring(index + 1)); } } fMatchFound= fRoot.filter(labelMatcher, fConcatAncestorLabels ? "" : null, valueMatcher); //$NON-NLS-1$ }
protected boolean filter(StringMatcher labelMatcher, String ancestorsLabel, StringMatcher valueMatcher) { String currentLabel= fLabel; if (ancestorsLabel != null) { ancestorsLabel+= ' ' + currentLabel; currentLabel= ancestorsLabel; } //check this node boolean valueMatched= valueMatcher == null || (fValueMatcher != null && fValueMatcher.valueMatches(this, valueMatcher)); boolean matched= valueMatched && (labelMatcher == null || labelMatcher.match(currentLabel)); if (matched) { if (!valueMatched) { // label matched, now filter only by value labelMatcher= null; matched= false; } else { setVisible(true, true); return true; } } //check children if (fChildren != null) { for (PreferenceTreeNode<?> child : fChildren) matched|= child.filter(labelMatcher, ancestorsLabel, valueMatcher); } setVisible(matched, fShowAllChildren); return matched; }