コード例 #1
0
ファイル: SelectionList.java プロジェクト: zhaog/cdt
 /** 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);
 }
コード例 #2
0
    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;
    }
コード例 #3
0
    /*
     * @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);
    }