use of com.intellij.ide.util.ClassFilter in project intellij-community by JetBrains.
the class ClassBrowser method showDialog.
@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();
}
use of com.intellij.ide.util.ClassFilter in project intellij-plugins by JetBrains.
the class OsmorcFacetManifestGenerationEditorTab method onBundleActivatorSelect.
private void onBundleActivatorSelect() {
Project project = myEditorContext.getProject();
PsiClass activatorClass = OsgiPsiUtil.getActivatorClass(project);
ClassFilter filter = new TreeJavaClassChooserDialog.InheritanceJavaClassFilterImpl(activatorClass, false, true, null);
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesScope(myEditorContext.getModule());
TreeJavaClassChooserDialog dialog = new TreeJavaClassChooserDialog(OsmorcBundle.message("facet.editor.select.bundle.activator"), project, scope, filter, null);
dialog.showDialog();
PsiClass psiClass = dialog.getSelected();
if (psiClass != null) {
myBundleActivator.setText(psiClass.getQualifiedName());
}
}
use of com.intellij.ide.util.ClassFilter in project intellij-community by JetBrains.
the class PsiClassControl method initReferenceEditorWithBrowseButton.
protected static <T extends JPanel> T initReferenceEditorWithBrowseButton(final T boundedComponent, final ReferenceEditorWithBrowseButton editor, final EditorTextFieldControl control) {
boundedComponent.removeAll();
boundedComponent.add(editor);
final GlobalSearchScope resolveScope = control.getDomWrapper().getResolveScope();
editor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final DomElement domElement = control.getDomElement();
ExtendClass extend = domElement.getAnnotation(ExtendClass.class);
PsiClass baseClass = null;
ClassFilter filter = null;
if (extend != null) {
baseClass = JavaPsiFacade.getInstance(control.getProject()).findClass(extend.value(), resolveScope);
if (extend.instantiatable()) {
filter = ClassFilter.INSTANTIABLE;
}
}
PsiClass initialClass = null;
if (domElement instanceof GenericDomValue) {
final Object value = ((GenericDomValue) domElement).getValue();
if (value instanceof PsiClass)
initialClass = (PsiClass) value;
}
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(control.getProject()).createInheritanceClassChooser(UIBundle.message("choose.class"), resolveScope, baseClass, initialClass, filter);
chooser.showDialog();
final PsiClass psiClass = chooser.getSelected();
if (psiClass != null) {
control.setValue(psiClass.getQualifiedName());
}
}
});
return boundedComponent;
}
use of com.intellij.ide.util.ClassFilter in project intellij-community by JetBrains.
the class CreateClassMappingAction method createElement.
@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);
}
use of com.intellij.ide.util.ClassFilter in project intellij-community by JetBrains.
the class UiUtils method createTreeClassChooserList.
public static JPanel createTreeClassChooserList(final Collection<String> collection, String borderTitle, final String chooserTitle, String... ancestorClasses) {
final ClassFilter filter;
if (ancestorClasses.length == 0) {
filter = ClassFilter.ALL;
} else {
filter = new SubclassFilter(ancestorClasses);
}
final JPanel optionsPanel = new JPanel(new BorderLayout());
final JBList list = new JBList(collection);
final JPanel panel = ToolbarDecorator.createDecorator(list).disableUpDownActions().setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton anActionButton) {
final DataContext dataContext = DataManager.getInstance().getDataContext(list);
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project).createNoInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, 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);
collection.add(qualifiedName);
} else {
list.setSelectedIndex(index);
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton anActionButton) {
collection.remove(list.getSelectedValue());
ListUtil.removeSelectedItems(list);
}
}).createPanel();
panel.setPreferredSize(JBUI.size(150, 100));
optionsPanel.setBorder(IdeBorderFactory.createTitledBorder(borderTitle, false, JBUI.insetsTop(10)));
optionsPanel.add(panel);
return optionsPanel;
}
Aggregations