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;
}
Aggregations