类org.eclipse.ui.dialogs.SearchPattern源码实例Demo

下面列出了怎么用org.eclipse.ui.dialogs.SearchPattern的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xtext-eclipse   文件: IXtextEObjectSearch.java
protected Predicate<IEObjectDescription> getSearchPredicate(final String stringPattern,
		final String typeStringPattern) {
	final Collection<String> namespaceDelimiters = IXtextSearchFilter.Registry.allNamespaceDelimiters();			
	final SearchPattern searchPattern = new SearchPattern();
	searchPattern.setPattern(stringPattern);
	final SearchPattern typeSearchPattern = new SearchPattern();
	typeSearchPattern.setPattern(typeStringPattern);
	final Collection<IXtextSearchFilter> registeredFilters = IXtextSearchFilter.Registry.allFilters();
	return new Predicate<IEObjectDescription>() {
		@Override
		public boolean apply(IEObjectDescription input) {
			if (isNameMatches(searchPattern, input, namespaceDelimiters)
					&& typeSearchPattern.matches(input.getEClass().getName())) {
				for (IXtextSearchFilter xtextSearchFilter : registeredFilters) {
					if (xtextSearchFilter.reject(input)) {
						return false;
					}
				}
				return true;
			}
			return false;
		}
	};
}
 
源代码2 项目: xds-ide   文件: SelectModulaSourceFileDialog.java
public SourceFileItemsFilter() {
    super(new SearchPattern() {
        @Override
        public void setPattern(String stringPattern) {
            if (!StringUtils.containsAny(stringPattern, new char[]{'*', '?'})) {
                stringPattern = "*"+stringPattern+"*"; //$NON-NLS-1$ //$NON-NLS-2$
            }
            // System.out.println("-- setPattern: \'" + stringPattern + '\'');
            super.setPattern(stringPattern);
        }
    });
    
    String patt = this.getPattern();
    myMatcher = new MyMatcher(patt+'*', false);
    isCompilationSetOnly = toggleCompilationSetOnlyAction.isChecked();
}
 
public ModuleItemsFilter() {
  super(new ModuleSearchPattern());

  /*
   * If there is no filter pattern present, initialize the pattern to '*'.
   * This has the nice property of pre-populating the dialog list with all
   * possible matches when it is first shown.
   */
  if (patternMatcher.getPattern() == null
      || patternMatcher.getPattern().length() == 0) {
    patternMatcher.setPattern("*");
  }

  // If a package pattern is present in the filter text, then set up
  // a packageMatcher to do matching based on the module's package.
  String stringPackage = ((ModuleSearchPattern) patternMatcher).getPackagePattern();
  if (stringPackage != null) {
    packageMatcher = new SearchPattern();
    packageMatcher.setPattern(stringPackage);
  } else {
    packageMatcher = null;
  }
}
 
源代码4 项目: xtext-eclipse   文件: IXtextEObjectSearch.java
protected boolean isNameMatches(SearchPattern searchPattern, IEObjectDescription eObjectDescription, Collection<String> namespaceDelimiters) {
	String qualifiedName = eObjectDescription.getQualifiedName().toString();
	if (qualifiedName!=null) {
		if(searchPattern.matches(qualifiedName)) {
			return true;
		}
		for(String namespaceDelimiter : namespaceDelimiters) {
			int index = qualifiedName.lastIndexOf(namespaceDelimiter); 
			if(index!=-1 && searchPattern.matches(qualifiedName.substring(index+1))) {
				return true;
			}
		}	
	}
	return false;
}
 
源代码5 项目: tlaplus   文件: FilteredItemsSelectionDialog.java
/**
 * Creates new instance of ItemsFilter.
 *
 * @param searchPattern
 *            the pattern to be used when filtering
 */
public ItemsFilter(SearchPattern searchPattern) {
	patternMatcher = searchPattern;
	String stringPattern = ""; //$NON-NLS-1$
	if (pattern != null && !pattern.getText().equals("*")) { //$NON-NLS-1$
		stringPattern = pattern.getText();
	}
	patternMatcher.setPattern(stringPattern);
}
 
源代码6 项目: Pydev   文件: MatchHelper.java
/**
 * Matches according to scopes.
 */
public static boolean matchItem(SearchPattern patternMatcher, IInfo info) {
    //We want to match the package name in the beggining too...
    String pattern = patternMatcher.getPattern();
    List<String> split = StringUtils.splitAndRemoveEmptyTrimmed(pattern, '.');
    if (split.size() <= 1) {
        if (pattern.endsWith(".")) {
            split.add("");
        } else {
            return patternMatcher.matches(info.getName());
        }
    }

    //Otherwise, we have more things to match... We could match something like:
    //django.AAA -- which should match all the modules that start with django and the tokens that have AAA.

    String declaringModuleName = info.getDeclaringModuleName();
    if (declaringModuleName == null || declaringModuleName.length() == 0) {
        return false;
    }
    List<String> moduleParts = StringUtils.splitAndRemoveEmptyTrimmed(declaringModuleName, '.');

    while (split.size() > 1) {
        String head = split.remove(0);
        SearchPattern headPattern = new SearchPattern();
        headPattern.setPattern(head);
        if (moduleParts.size() == 0) {
            return false; //we cannot match it anymore
        }
        if (!headPattern.matches(moduleParts.remove(0))) {
            return false;
        }
    }
    //if it got here, we've matched the module correctly... let's go on and check the name.

    SearchPattern tailPattern = new SearchPattern();
    tailPattern.setPattern(split.get(0));
    return tailPattern.matches(info.getName());
}
 
源代码7 项目: Pydev   文件: MatchHelper.java
/**
 * Checks if equals considering scopes.
 */
public static boolean equalsFilter(String thisPattern, String otherPattern) {
    return checkPatternSubparts(thisPattern, otherPattern, new ICallback2<Boolean, SearchPattern, SearchPattern>() {

        @Override
        public Boolean call(SearchPattern thisP, SearchPattern otherP) {
            if (!(thisP.equalsPattern(otherP))) {
                return false;
            }
            return true;
        }
    });
}
 
源代码8 项目: Pydev   文件: MatchHelper.java
/**
 * Checks if it's a sub-filter considering scopes.
 */
public static boolean isSubFilter(String thisPattern, String otherPattern) {
    return checkPatternSubparts(thisPattern, otherPattern, new ICallback2<Boolean, SearchPattern, SearchPattern>() {

        @Override
        public Boolean call(SearchPattern thisP, SearchPattern otherP) {
            if (!(thisP.isSubPattern(otherP))) {
                return false;
            }
            return true;
        }
    });
}
 
源代码9 项目: Pydev   文件: MatchHelper.java
private static boolean checkPatternSubparts(String thisPattern, String otherPattern,
        ICallback2<Boolean, SearchPattern, SearchPattern> check) {
    boolean thisEndsWithPoint = thisPattern.endsWith(".");
    boolean otherEndsWithPoint = otherPattern.endsWith(".");
    if (thisEndsWithPoint != otherEndsWithPoint) {
        return false;
    }

    List<String> thisSplit = StringUtils.splitAndRemoveEmptyNotTrimmed(thisPattern, '.');
    List<String> otherSplit = StringUtils.splitAndRemoveEmptyNotTrimmed(otherPattern, '.');

    if (thisEndsWithPoint) {
        thisSplit.add("");
    }
    if (otherEndsWithPoint) {
        otherSplit.add("");
    }

    if (thisSplit.size() != otherSplit.size()) {
        return false;
    }

    for (int i = 0; i < thisSplit.size(); i++) {
        String thisStr = thisSplit.get(i);
        String otherStr = otherSplit.get(i);
        SearchPattern thisP = new SearchPattern();
        thisP.setPattern(thisStr);

        SearchPattern otherP = new SearchPattern();
        otherP.setPattern(otherStr);
        if (!check.call(thisP, otherP)) {
            return false;
        }
    }
    return true;
}
 
public PipelineOptionsSelectionFilter() {
  super(
      new SearchPattern(SearchPattern.RULE_CAMELCASE_MATCH | SearchPattern.RULE_PATTERN_MATCH));
}
 
源代码11 项目: xtext-eclipse   文件: TypeChooser.java
public Filter(String pattern) {
	searchPattern = new SearchPattern();
	searchPattern.setPattern(pattern);
}
 
源代码12 项目: tlaplus   文件: FilteredItemsSelectionDialog.java
/**
 * Creates new instance of ItemsFilter.
 */
public ItemsFilter() {
	this(new SearchPattern());
}
 
public void testPatternMatch() throws Exception {
    SearchPattern patternMatcher = new SearchPattern();
    patternMatcher.setPattern("aa");

    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aa", null, null, null, null, 0, 0)));

    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", null, null, null, null, 0, 0)));

    assertFalse(MatchHelper.matchItem(patternMatcher, new ClassInfo("baaa", null, null, null, null, 0, 0)));

    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "coi.foo", null, null, null, 0, 0)));

    patternMatcher.setPattern("xx.aa");
    assertFalse(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "invalid.foo", null, null, null, 0, 0)));

    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "xx.foo", null, null, null, 0, 0)));

    patternMatcher.setPattern("xx.foo.aa");
    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "xx.foo.bar", null, null, null, 0, 0)));

    patternMatcher.setPattern("xx.foo.bar.aa");
    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "xx.foo.bar", null, null, null, 0, 0)));

    patternMatcher.setPattern("xx.foo.bar.aa.aa");
    assertFalse(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "xx.foo.bar", null, null, null, 0, 0)));

    patternMatcher.setPattern("xx.foo.ba.aa");
    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "xx.foo.bar", null, null, null, 0, 0)));

    patternMatcher.setPattern("xx.fo*o.ba.aa");
    assertTrue(MatchHelper.matchItem(patternMatcher, new ClassInfo("aaa", "xx.foo.bar", null, null, null, 0, 0)));

    patternMatcher.setPattern("coi*.intersection");
    assertTrue(MatchHelper.matchItem(patternMatcher,
            new ClassInfo("Intersection", "coilib50.basic.native", null, null, null, 0, 0)));

    patternMatcher.setPattern("coilib50.intersection");
    assertTrue(MatchHelper.matchItem(patternMatcher,
            new ClassInfo("Intersection", "coilib50.basic.native", null, null, null, 0, 0)));

    patternMatcher.setPattern("coilib50.");
    assertTrue(MatchHelper.matchItem(patternMatcher,
            new ClassInfo("Intersection", "coilib50.basic.native", null, null, null, 0, 0)));
}
 
源代码14 项目: tlaplus   文件: FilteredItemsSelectionDialog.java
/**
 * Checks whether the pattern's match rule is camel case.
 *
 * @return <code>true</code> if pattern's match rule is camel case,
 *         <code>false</code> otherwise
 */
public boolean isCamelCasePattern() {
	return patternMatcher.getMatchRule() == SearchPattern.RULE_CAMELCASE_MATCH;
}
 
 类所在包
 同包方法