本文整理汇总了Java中com.intellij.ide.util.ClassFilter类的典型用法代码示例。如果您正苦于以下问题:Java ClassFilter类的具体用法?Java ClassFilter怎么用?Java ClassFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassFilter类属于com.intellij.ide.util包,在下文中一共展示了ClassFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseMainClassForProject
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
/** Ui for the user to pick the Main class. */
@NotNull
public TreeClassChooser chooseMainClassForProject() {
logger.info("Choosing main class for project.");
TreeClassChooser chooser;
Project project = new ObjectFinder().findCurrentProject();
while (true) {
TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(project);
GlobalSearchScope scope;
scope = GlobalSearchScope.moduleScope(module);
PsiClass ecClass = JavaPsiFacade.getInstance(project).findClass("", scope);
ClassFilter filter = createClassFilter();
chooser =
factory.createInheritanceClassChooser(
"Choose main class", scope, ecClass, null, filter);
chooser.showDialog();
if (chooser.getSelected() == null
|| chooser.getSelected().findMethodsByName("main", true).length > 0) {
logger.info("Choosing main class aborted.");
break;
}
}
logger.info("Main class chosen successfully.");
return chooser;
}
示例2: chooseAnnotation
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
private void chooseAnnotation(String title, JBList list) {
final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject)
.createNoInnerClassesScopeChooser("Choose " + title + " annotation", GlobalSearchScope.allScope(myProject), new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
return aClass.isAnnotationType();
}
}, null);
chooser.showDialog();
final PsiClass selected = chooser.getSelected();
if (selected == null) {
return;
}
final String qualifiedName = selected.getQualifiedName();
final DefaultListModel model = (DefaultListModel)list.getModel();
final int index = model.indexOf(qualifiedName);
if (index < 0) {
model.addElement(qualifiedName);
} else {
myList.setSelectedIndex(index);
}
}
示例3: createElement
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Override
protected DomElement createElement(final T context, final Editor editor, PsiFile file, final Project project) {
PsiClass selectedClass;
if (!ApplicationManager.getApplication().isUnitTestMode()) {
PsiClass baseClass = getBaseClass(context, project, myBaseClass);
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
.createInheritanceClassChooser(getChooserTitle(), GlobalSearchScope.allScope(project), baseClass, null, new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
return !aClass.isInterface() && !aClass.hasModifierProperty(PsiModifier.ABSTRACT);
}
});
chooser.showDialog();
selectedClass = chooser.getSelected();
}
else {
selectedClass = getBaseClass(context, project, myBaseClass == null ? CommonClassNames.JAVA_LANG_OBJECT : myBaseClass);
}
if (selectedClass == null) return null;
return createElement(context, editor, file, project, selectedClass);
}
示例4: showDialog
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Nullable
protected String showDialog() {
final ClassFilter.ClassFilterWithScope classFilter;
try {
classFilter = getFilter();
}
catch (NoFilterException e) {
final MessagesEx.MessageInfo info = e.getMessageInfo();
info.showNow();
return null;
}
final TreeClassChooser dialog = createClassChooser(classFilter);
configureDialog(dialog);
dialog.showDialog();
final PsiClass psiClass = dialog.getSelected();
if (psiClass == null) return null;
onClassChoosen(psiClass);
return psiClass.getQualifiedName();
}
示例5: createAppletClassBrowser
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
public static ClassBrowser createAppletClassBrowser(final Project project,
final ConfigurationModuleSelector moduleSelector) {
final String title = ExecutionBundle.message("choose.applet.class.dialog.title");
return new MainClassBrowser(project, moduleSelector, title) {
@Override
protected TreeClassChooser createClassChooser(ClassFilter.ClassFilterWithScope classFilter) {
final Module module = moduleSelector.getModule();
final GlobalSearchScope scope =
module == null ? GlobalSearchScope.allScope(myProject) : GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiClass appletClass = JavaPsiFacade.getInstance(project).findClass("java.applet.Applet", scope);
return TreeClassChooserFactory.getInstance(getProject())
.createInheritanceClassChooser(title, classFilter.getScope(), appletClass, false, false,
ConfigurationUtil.PUBLIC_INSTANTIATABLE_CLASS);
}
};
}
示例6: getFilter
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
protected ClassFilter.ClassFilterWithScope getFilter() throws NoFilterException {
final Module module = myModuleSelector.getModule();
final GlobalSearchScope scope;
if (module == null) {
scope = GlobalSearchScope.allScope(myProject);
}
else {
scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
}
final ClassFilter filter = createFilter(module);
return new ClassFilter.ClassFilterWithScope() {
public GlobalSearchScope getScope() {
return scope;
}
public boolean isAccepted(final PsiClass aClass) {
return filter == null || filter.isAccepted(aClass);
}
};
}
示例7: actionPerformed
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createWithInnerClassesScopeChooser(myChooserTitle,
GlobalSearchScope.projectScope(myProject),
new ClassFilter() {
public boolean isAccepted(PsiClass aClass) {
return aClass.getParent() instanceof PsiJavaFile || aClass.hasModifierProperty(PsiModifier.STATIC);
}
}, null);
if (mySelectedClass != null) {
chooser.selectDirectory(mySelectedClass.getContainingFile().getContainingDirectory());
}
chooser.showDialog();
mySelectedClass = chooser.getSelected();
if (mySelectedClass != null) {
setText(mySelectedClass.getQualifiedName());
}
}
示例8: createTreeClassChooser
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Override
protected TreeClassChooser createTreeClassChooser(@NotNull Project project,
@NotNull GlobalSearchScope scope,
@Nullable PsiClass initialSelection,
@NotNull final ClassFilter classFilter) {
final PsiClass baseClass = JavaPsiFacade.getInstance(project).findClass(myBaseClassName, ProjectScope.getAllScope(project));
if (baseClass == null) {
Messages.showErrorDialog(project, AndroidBundle.message("cant.find.class.error", myBaseClassName), CommonBundle.getErrorTitle());
return null;
}
return TreeClassChooserFactory.getInstance(project).createInheritanceClassChooser(
myDialogTitle, scope, baseClass, initialSelection, new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
if (aClass.getManager().areElementsEquivalent(aClass, baseClass)) {
return false;
}
return classFilter.isAccepted(aClass);
}
});
}
示例9: showDialog
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Override
protected String showDialog() {
Project project = getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
Module module = myModuleSelector.getModule();
if (module == null) {
Messages.showErrorDialog(project, ExecutionBundle.message("module.not.specified.error.text"), CommonBundle.getErrorTitle());
return null;
}
GlobalSearchScope scope =
myIncludeLibraryClasses ? module.getModuleWithDependenciesAndLibrariesScope(true) : module.getModuleWithDependenciesScope();
PsiClass initialSelection = facade.findClass(getText(), scope);
TreeClassChooser chooser = createTreeClassChooser(project, scope, initialSelection, new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
if (aClass.isInterface()) return false;
final PsiModifierList modifierList = aClass.getModifierList();
return modifierList == null || !modifierList.hasModifierProperty(PsiModifier.ABSTRACT);
}
});
if (chooser == null) return null;
chooser.showDialog();
PsiClass selClass = chooser.getSelected();
return selClass != null ? selClass.getQualifiedName() : null;
}
示例10: showDialog
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Override
protected String showDialog() {
ClassFilter.ClassFilterWithScope filter;
try {
filter = getFilter();
}
catch (MessageInfoException e) {
MessagesEx.MessageInfo message = e.getMessageInfo();
message.showNow();
return null;
}
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser("Choose Test Class", filter.getScope(), filter, null);
init(chooser);
chooser.showDialog();
PsiClass psiclass = chooser.getSelected();
if (psiclass == null) {
return null;
} else {
onClassChoosen(psiclass);
return psiclass.getQualifiedName();
}
}
示例11: getFilter
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
protected ClassFilter.ClassFilterWithScope getFilter() throws NoFilterException {
final ConfigurationModuleSelector moduleSelector = getModuleSelector();
final Module module = moduleSelector.getModule();
if (module == null) {
throw NoFilterException.moduleDoesntExist(moduleSelector);
}
final ClassFilter.ClassFilterWithScope classFilter;
try {
final JUnitConfiguration configurationCopy =
new JUnitConfiguration(ExecutionBundle.message("default.junit.configuration.name"), getProject(),
JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
applyEditorTo(configurationCopy);
classFilter = TestClassFilter
.create(configurationCopy.getTestObject().getSourceScope(), configurationCopy.getConfigurationModule().getModule());
}
catch (JUnitUtil.NoJUnitException e) {
throw NoFilterException.noJUnitInModule(module);
}
return classFilter;
}
示例12: DefracMainClassBrowser
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
public DefracMainClassBrowser(@NotNull final Project project,
@NotNull final ConfigurationModuleSelector moduleSelector) {
super(project, "Choose main class");
this.moduleSelector = moduleSelector;
this.classFilter = new ClassFilter.ClassFilterWithScope() {
@Override
public GlobalSearchScope getScope() {
return GlobalSearchScope.moduleScope(moduleSelector.getModule());
}
@Override
public boolean isAccepted(final PsiClass psiClass) {
return DefracRunUtil.isValidMainClass(moduleSelector.getModule(), psiClass);
}
};
}
示例13: addPatternFilter
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
protected void addPatternFilter() {
ClassFilterEditorAddDialog dialog = new ClassFilterEditorAddDialog(myProject, myPatternsHelpId);
dialog.show();
if (dialog.isOK()) {
String pattern = dialog.getPattern();
if (pattern != null) {
com.intellij.ui.classFilter.ClassFilter filter = createFilter(pattern);
myTableModel.addRow(filter);
int row = myTableModel.getRowCount() - 1;
myTable.getSelectionModel().setSelectionInterval(row, row);
myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true));
myTable.requestFocus();
}
}
}
示例14: showDialog
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Nullable
protected String showDialog() {
final ClassFilter.ClassFilterWithScope classFilter;
try {
classFilter = getFilter();
}
catch (NoFilterException e) {
final MessagesEx.MessageInfo info = e.getMessageInfo();
info.showNow();
return null;
}
final TreeClassChooser dialog = createClassChooser(classFilter);
configureDialog(dialog);
dialog.showDialog();
final PsiClass psiClass = dialog.getSelected();
if (psiClass == null) return null;
onClassChoosen(psiClass);
return JavaExecutionUtil.getRuntimeQualifiedName(psiClass);
}
示例15: showDialog
import com.intellij.ide.util.ClassFilter; //导入依赖的package包/类
@Override
protected String showDialog() {
ClassFilter.ClassFilterWithScope filter;
try {
filter = getFilter();
}
catch (MessageInfoException e) {
MessagesEx.MessageInfo message = e.getMessageInfo();
message.showNow();
return null;
}
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser("Choose Test Class", filter.getScope(), filter, null);
init(chooser);
chooser.showDialog();
PsiClass psiclass = chooser.getSelected();
if (psiclass == null) {
return null;
} else {
onClassChoosen(psiclass);
return JavaExecutionUtil.getRuntimeQualifiedName(psiclass);
}
}