Search in sources :

Example 1 with ExtendClass

use of com.intellij.util.xml.ExtendClass 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;
}
Also used : ExtendClass(com.intellij.util.xml.ExtendClass) TreeClassChooser(com.intellij.ide.util.TreeClassChooser) DomElement(com.intellij.util.xml.DomElement) ActionListener(java.awt.event.ActionListener) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ActionEvent(java.awt.event.ActionEvent) ClassFilter(com.intellij.ide.util.ClassFilter) GenericDomValue(com.intellij.util.xml.GenericDomValue)

Aggregations

ClassFilter (com.intellij.ide.util.ClassFilter)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 DomElement (com.intellij.util.xml.DomElement)1 ExtendClass (com.intellij.util.xml.ExtendClass)1 GenericDomValue (com.intellij.util.xml.GenericDomValue)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1