/** Filters the list of elements according to the pattern entered into the text entry field. */ public void filter(boolean forceUpdate) { int k = 0; String text = fText.getText(); if (!forceUpdate && text.equals(fRememberedMatchText)) return; fRememberedMatchText = text; StringMatcher matcher = new StringMatcher(text + "*", fIgnoreCase, false); // $NON-NLS-1$ for (int i = 0; i < fElements.length; i++) { if (matcher.match(fRenderedStrings[i])) { fFilteredElements[k] = i; k++; } } fFilteredElements[k] = -1; updateListWidget(fFilteredElements, k); }
private boolean matchQualifiedName(ITypeInfo info) { IQualifiedTypeName qualifiedName = info.getQualifiedTypeName(); if (fSegmentMatchers.length != qualifiedName.segmentCount()) return false; if (fMatchGlobalNamespace) { // must match global namespace (eg ::foo) if (qualifiedName.segment(0).length() > 0) return false; } boolean matchFound = true; int max = Math.min(fSegmentMatchers.length, qualifiedName.segmentCount()); for (int i = 0; i < max; ++i) { StringMatcher matcher = fSegmentMatchers[i]; String name = qualifiedName.segment(i); if (name == null || !matcher.match(name)) { matchFound = false; break; } } return matchFound; }
/* * @see FilteredList.FilterMatcher#match(Object) */ public boolean match(Object element) { if (!(element instanceof ITypeInfo)) return false; ITypeInfo info = (ITypeInfo) element; IQualifiedTypeName qualifiedName = info.getQualifiedTypeName(); if (fVisibleTypes != null && !fVisibleTypes.contains(new Integer(info.getCElementType()))) return false; if (!fShowLowLevelTypes && qualifiedName.isLowLevel()) return false; if (fSegmentMatchers.length == 1 && !fMatchGlobalNamespace) return fNameMatcher.match(qualifiedName.getName()); return matchQualifiedName(info); }