Search in sources :

Example 6 with GenericDomValue

use of com.intellij.util.xml.GenericDomValue 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)

Example 7 with GenericDomValue

use of com.intellij.util.xml.GenericDomValue in project intellij-community by JetBrains.

the class AntResolveInspection method checkDomElement.

protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
    if (element instanceof GenericDomValue) {
        final XmlElement valueElement = DomUtil.getValueElement(((GenericDomValue) element));
        if (valueElement != null) {
            checkReferences(valueElement, holder, element);
        }
    } else if (element instanceof AntDomTypeDef) {
        final AntDomTypeDef typeDef = (AntDomTypeDef) element;
        final List<String> errors = typeDef.getErrorDescriptions();
        if (!errors.isEmpty()) {
            final StringBuilder builder = new StringBuilder();
            builder.append(AntBundle.message("failed.to.load.types")).append(":");
            for (String error : errors) {
                builder.append("\n").append(error);
            }
            holder.createProblem(typeDef, builder.toString());
        }
    } else if (element instanceof AntDomCustomElement) {
        final AntDomCustomElement custom = (AntDomCustomElement) element;
        if (custom.getDefinitionClass() == null) {
            final AntDomNamedElement declaringElement = custom.getDeclaringElement();
            if (declaringElement instanceof AntDomTypeDef) {
                String failedMessage = AntBundle.message("using.definition.which.type.failed.to.load");
                final String error = custom.getLoadError();
                if (error != null) {
                    failedMessage = failedMessage + ": " + error;
                }
                holder.createProblem(custom, failedMessage);
            }
        }
    }
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement) SmartList(com.intellij.util.SmartList) GenericDomValue(com.intellij.util.xml.GenericDomValue)

Aggregations

GenericDomValue (com.intellij.util.xml.GenericDomValue)7 XmlElement (com.intellij.psi.xml.XmlElement)2 DomElement (com.intellij.util.xml.DomElement)2 NegatingComparable (com.intellij.codeInsight.completion.impl.NegatingComparable)1 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 LookupElementWeigher (com.intellij.codeInsight.lookup.LookupElementWeigher)1 ClassFilter (com.intellij.ide.util.ClassFilter)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 Project (com.intellij.openapi.project.Project)1 PsiElement (com.intellij.psi.PsiElement)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 XmlTag (com.intellij.psi.xml.XmlTag)1 XmlText (com.intellij.psi.xml.XmlText)1 StrutsPackage (com.intellij.struts2.dom.struts.strutspackage.StrutsPackage)1 SmartList (com.intellij.util.SmartList)1 DomFileElement (com.intellij.util.xml.DomFileElement)1 ExtendClass (com.intellij.util.xml.ExtendClass)1 GenericAttributeValue (com.intellij.util.xml.GenericAttributeValue)1 DomElementAnnotationsManager (com.intellij.util.xml.highlighting.DomElementAnnotationsManager)1 AbstractDomChildrenDescription (com.intellij.util.xml.reflect.AbstractDomChildrenDescription)1