Search in sources :

Example 1 with UnexpectedFormElementException

use of com.intellij.uiDesigner.compiler.UnexpectedFormElementException in project intellij-community by JetBrains.

the class FormWordsScanner method processWords.

@Override
public void processWords(CharSequence fileText, final Processor<WordOccurrence> processor) {
    super.processWords(fileText, processor);
    try {
        LwRootContainer container = Utils.getRootContainer(fileText.toString(), null);
        String className = container.getClassToBind();
        if (className != null) {
            processClassAndPackagesNames(className, processor);
        }
        FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() {

            WordOccurrence occurence;

            public boolean visit(IComponent iComponent) {
                String componentClassName = iComponent.getComponentClassName();
                processClassAndPackagesNames(componentClassName, processor);
                final String binding = iComponent.getBinding();
                if (binding != null) {
                    if (occurence == null)
                        occurence = new WordOccurrence(binding, 0, binding.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
                    else
                        occurence.init(binding, 0, binding.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
                    processor.process(occurence);
                }
                return true;
            }
        });
    } catch (AlienFormFileException | JDOMParseException | UnexpectedFormElementException ex) {
    // ignore
    } catch (Exception e) {
        LOG.error("Error indexing form file", e);
    }
}
Also used : JDOMParseException(org.jdom.input.JDOMParseException) WordOccurrence(com.intellij.lang.cacheBuilder.WordOccurrence) IComponent(com.intellij.uiDesigner.lw.IComponent) AlienFormFileException(com.intellij.uiDesigner.compiler.AlienFormFileException) LwRootContainer(com.intellij.uiDesigner.lw.LwRootContainer) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) UnexpectedFormElementException(com.intellij.uiDesigner.compiler.UnexpectedFormElementException) AlienFormFileException(com.intellij.uiDesigner.compiler.AlienFormFileException) JDOMParseException(org.jdom.input.JDOMParseException) UnexpectedFormElementException(com.intellij.uiDesigner.compiler.UnexpectedFormElementException)

Example 2 with UnexpectedFormElementException

use of com.intellij.uiDesigner.compiler.UnexpectedFormElementException in project intellij-community by JetBrains.

the class LwRootContainer method read.

public void read(final Element element, final PropertiesProvider provider) throws Exception {
    if (element == null) {
        throw new IllegalArgumentException("element cannot be null");
    }
    if (!Utils.FORM_NAMESPACE.equals(element.getNamespace().getURI())) {
        throw new AlienFormFileException();
    }
    if (!"form".equals(element.getName())) {
        throw new UnexpectedFormElementException("unexpected element: " + element);
    }
    setId("root");
    myClassToBind = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS);
    // Constraints and properties
    for (Iterator i = element.getChildren().iterator(); i.hasNext(); ) {
        final Element child = (Element) i.next();
        if (child.getName().equals(UIFormXmlConstants.ELEMENT_BUTTON_GROUPS)) {
            readButtonGroups(child);
        } else if (child.getName().equals(UIFormXmlConstants.ELEMENT_INSPECTION_SUPPRESSIONS)) {
            readInspectionSuppressions(child);
        } else {
            final LwComponent component = createComponentFromTag(child);
            addComponent(component);
            component.read(child, provider);
        }
    }
    myMainComponentBinding = element.getAttributeValue("stored-main-component-binding");
}
Also used : Element(org.jdom.Element) Iterator(java.util.Iterator) AlienFormFileException(com.intellij.uiDesigner.compiler.AlienFormFileException) UnexpectedFormElementException(com.intellij.uiDesigner.compiler.UnexpectedFormElementException)

Example 3 with UnexpectedFormElementException

use of com.intellij.uiDesigner.compiler.UnexpectedFormElementException in project intellij-community by JetBrains.

the class LwSplitPane method readConstraintsForChild.

protected void readConstraintsForChild(final Element element, final LwComponent component) {
    final Element constraintsElement = LwXmlReader.getRequiredChild(element, "constraints");
    final Element splitterChild = LwXmlReader.getRequiredChild(constraintsElement, "splitpane");
    final String position = LwXmlReader.getRequiredString(splitterChild, "position");
    if ("left".equals(position)) {
        component.setCustomLayoutConstraints(POSITION_LEFT);
    } else if ("right".equals(position)) {
        component.setCustomLayoutConstraints(POSITION_RIGHT);
    } else {
        throw new UnexpectedFormElementException("unexpected position: " + position);
    }
}
Also used : Element(org.jdom.Element) UnexpectedFormElementException(com.intellij.uiDesigner.compiler.UnexpectedFormElementException)

Example 4 with UnexpectedFormElementException

use of com.intellij.uiDesigner.compiler.UnexpectedFormElementException in project intellij-community by JetBrains.

the class LwContainer method readLayout.

/**
   * 'xy' or 'grid'
   */
protected final void readLayout(final Element element) {
    myLayoutManager = element.getAttributeValue("layout-manager");
    if ("xy".equals(element.getName())) {
        myLayoutSerializer = XYLayoutSerializer.INSTANCE;
    } else if ("grid".equals(element.getName())) {
        createLayoutSerializer();
    } else {
        throw new UnexpectedFormElementException("unexpected element: " + element);
    }
    myLayoutSerializer.readLayout(element, this);
}
Also used : UnexpectedFormElementException(com.intellij.uiDesigner.compiler.UnexpectedFormElementException)

Aggregations

UnexpectedFormElementException (com.intellij.uiDesigner.compiler.UnexpectedFormElementException)4 AlienFormFileException (com.intellij.uiDesigner.compiler.AlienFormFileException)2 Element (org.jdom.Element)2 WordOccurrence (com.intellij.lang.cacheBuilder.WordOccurrence)1 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)1 IComponent (com.intellij.uiDesigner.lw.IComponent)1 LwRootContainer (com.intellij.uiDesigner.lw.LwRootContainer)1 Iterator (java.util.Iterator)1 JDOMParseException (org.jdom.input.JDOMParseException)1