Search in sources :

Example 41 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class Palette method processItemElement.

private void processItemElement(@NotNull final Element itemElement, @NotNull final GroupItem group, final boolean skipExisting) {
    // Class name. It's OK if class does not exist.
    final String className = LwXmlReader.getRequiredString(itemElement, ATTRIBUTE_CLASS);
    if (skipExisting && getItem(className) != null) {
        return;
    }
    // Icon (optional)
    final String iconPath = LwXmlReader.getString(itemElement, ATTRIBUTE_ICON);
    // Tooltip text (optional)
    // can be null
    final String toolTipText = LwXmlReader.getString(itemElement, ATTRIBUTE_TOOLTIP_TEXT);
    boolean autoCreateBinding = LwXmlReader.getOptionalBoolean(itemElement, ATTRIBUTE_AUTO_CREATE_BINDING, false);
    boolean canAttachLabel = LwXmlReader.getOptionalBoolean(itemElement, ATTRIBUTE_CAN_ATTACH_LABEL, false);
    boolean isContainer = LwXmlReader.getOptionalBoolean(itemElement, ATTRIBUTE_IS_CONTAINER, false);
    // Default constraint
    final GridConstraints constraints;
    final Element defaultConstraints = itemElement.getChild(ELEMENT_DEFAULT_CONSTRAINTS);
    if (defaultConstraints != null) {
        constraints = processDefaultConstraintsElement(defaultConstraints);
    } else {
        constraints = new GridConstraints();
    }
    final HashMap<String, StringDescriptor> propertyName2initialValue = new HashMap<>();
    {
        final Element initialValues = itemElement.getChild(ELEMENT_INITIAL_VALUES);
        if (initialValues != null) {
            for (final Object o : initialValues.getChildren(ELEMENT_PROPERTY)) {
                final Element e = (Element) o;
                final String name = LwXmlReader.getRequiredString(e, ATTRIBUTE_NAME);
                // TODO[all] currently all initial values are strings
                final StringDescriptor value = StringDescriptor.create(LwXmlReader.getRequiredString(e, ATTRIBUTE_VALUE));
                propertyName2initialValue.put(name, value);
            }
        }
    }
    final boolean removable = LwXmlReader.getOptionalBoolean(itemElement, ATTRIBUTE_REMOVABLE, true);
    final ComponentItem item = new ComponentItem(myProject, className, iconPath, toolTipText, constraints, propertyName2initialValue, removable, autoCreateBinding, canAttachLabel);
    item.setIsContainer(isContainer);
    addItem(group, item);
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) HashMap(java.util.HashMap) Element(org.jdom.Element) StringDescriptor(com.intellij.uiDesigner.lw.StringDescriptor)

Example 42 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class Palette method upgradeGroup.

private void upgradeGroup(final GroupItem group, final Element groupElement) {
    for (Element itemElement : groupElement.getChildren(ELEMENT_ITEM)) {
        if (itemElement.getAttributeValue(ATTRIBUTE_SINCE_VERSION, "").equals("2")) {
            processItemElement(itemElement, group, true);
        }
        final String className = LwXmlReader.getRequiredString(itemElement, ATTRIBUTE_CLASS);
        final ComponentItem item = getItem(className);
        if (item != null) {
            if (LwXmlReader.getOptionalBoolean(itemElement, ATTRIBUTE_AUTO_CREATE_BINDING, false)) {
                item.setAutoCreateBinding(true);
            }
            if (LwXmlReader.getOptionalBoolean(itemElement, ATTRIBUTE_CAN_ATTACH_LABEL, false)) {
                item.setCanAttachLabel(true);
            }
        }
    }
}
Also used : Element(org.jdom.Element)

Example 43 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class Palette method processDefaultConstraintsElement.

/**
   * Helper method.
   */
private static GridConstraints processDefaultConstraintsElement(@NotNull final Element element) {
    final GridConstraints constraints = new GridConstraints();
    // grid related attributes
    constraints.setVSizePolicy(LwXmlReader.getRequiredInt(element, ATTRIBUTE_VSIZE_POLICY));
    constraints.setHSizePolicy(LwXmlReader.getRequiredInt(element, ATTRIBUTE_HSIZE_POLICY));
    constraints.setAnchor(LwXmlReader.getRequiredInt(element, ATTRIBUTE_ANCHOR));
    constraints.setFill(LwXmlReader.getRequiredInt(element, ATTRIBUTE_FILL));
    // minimum size
    final Element minSizeElement = element.getChild(ELEMENT_MINIMUM_SIZE);
    if (minSizeElement != null) {
        constraints.myMinimumSize.width = LwXmlReader.getRequiredInt(minSizeElement, ATTRIBUTE_WIDTH);
        constraints.myMinimumSize.height = LwXmlReader.getRequiredInt(minSizeElement, ATTRIBUTE_HEIGHT);
    }
    // preferred size
    final Element prefSizeElement = element.getChild(ELEMENT_PREFERRED_SIZE);
    if (prefSizeElement != null) {
        constraints.myPreferredSize.width = LwXmlReader.getRequiredInt(prefSizeElement, ATTRIBUTE_WIDTH);
        constraints.myPreferredSize.height = LwXmlReader.getRequiredInt(prefSizeElement, ATTRIBUTE_HEIGHT);
    }
    // maximum size
    final Element maxSizeElement = element.getChild(ELEMENT_MAXIMUM_SIZE);
    if (maxSizeElement != null) {
        constraints.myMaximumSize.width = LwXmlReader.getRequiredInt(maxSizeElement, ATTRIBUTE_WIDTH);
        constraints.myMaximumSize.height = LwXmlReader.getRequiredInt(maxSizeElement, ATTRIBUTE_HEIGHT);
    }
    return constraints;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) Element(org.jdom.Element)

Example 44 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class IpnbEditorProvider method readState.

@NotNull
@Override
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
    final IpnbEditorState state = new IpnbEditorState(-1, 0);
    final Element child = sourceElement.getChild(SELECTED_CELL);
    state.setSelectedIndex(child == null ? 0 : Integer.parseInt(child.getAttributeValue(ID)));
    return state;
}
Also used : Element(org.jdom.Element) NotNull(org.jetbrains.annotations.NotNull)

Example 45 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class StudyMigrationTest method testFromThirdToForth.

@Test
public void testFromThirdToForth() throws JDOMException, IOException, StudySerializationUtils.StudyUnrecognizedFormatException {
    Element element = JdomKt.loadElement(getTestDataPath().resolve("3.xml"));
    assertThat(StudySerializationUtils.Xml.convertToForthVersion(element)).isEqualTo(getTestDataPath().resolve("4.xml"));
}
Also used : Element(org.jdom.Element) Test(org.junit.Test)

Aggregations

Element (org.jdom.Element)1994 BioPaxObject (org.vcell.pathway.BioPaxObject)143 ArrayList (java.util.ArrayList)141 NotNull (org.jetbrains.annotations.NotNull)103 IOException (java.io.IOException)102 Document (org.jdom.Document)102 Nullable (org.jetbrains.annotations.Nullable)98 List (java.util.List)84 File (java.io.File)78 GroupObject (org.vcell.pathway.GroupObject)75 VirtualFile (com.intellij.openapi.vfs.VirtualFile)67 JDOMException (org.jdom.JDOMException)57 Expression (cbit.vcell.parser.Expression)47 SAXBuilder (org.jdom.input.SAXBuilder)47 ExpressionException (cbit.vcell.parser.ExpressionException)45 Iterator (java.util.Iterator)45 PsiElement (com.intellij.psi.PsiElement)44 Attribute (org.jdom.Attribute)42 XMLOutputter (org.jdom.output.XMLOutputter)34 Namespace (org.jdom.Namespace)32