Search in sources :

Example 91 with Element

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

the class MetaManager method loadDocument.

@Override
protected void loadDocument(Element rootElement) throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    Map<MetaModel, List<String>> modelToMorphing = new HashMap<>();
    for (Element element : rootElement.getChildren(META)) {
        loadModel(classLoader, element, modelToMorphing);
    }
    for (Element element : rootElement.getChild(PALETTE).getChildren(GROUP)) {
        loadGroup(element);
    }
    Element wrapInElement = rootElement.getChild(WRAP_IN);
    if (wrapInElement != null) {
        for (Element element : wrapInElement.getChildren(ITEM)) {
            myWrapModels.add(myTag2Model.get(element.getAttributeValue("tag")));
        }
    }
    for (Map.Entry<MetaModel, List<String>> entry : modelToMorphing.entrySet()) {
        MetaModel meta = entry.getKey();
        List<MetaModel> morphingModels = new ArrayList<>();
        for (String tag : entry.getValue()) {
            MetaModel morphingModel = myTag2Model.get(tag);
            if (morphingModel != null) {
                morphingModels.add(morphingModel);
            }
        }
        if (!morphingModels.isEmpty()) {
            meta.setMorphingModels(morphingModels);
        }
    }
}
Also used : HashMap(java.util.HashMap) Element(org.jdom.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 92 with Element

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

the class MetaManager method loadModel.

@NotNull
@SuppressWarnings("unchecked")
protected MetaModel loadModel(ClassLoader classLoader, Element element, Map<MetaModel, List<String>> modelToMorphing) throws Exception {
    String modelValue = element.getAttributeValue("model");
    Class<RadComponent> model = modelValue == null ? null : (Class<RadComponent>) classLoader.loadClass(modelValue);
    String target = element.getAttributeValue("class");
    String tag = element.getAttributeValue(TAG);
    MetaModel meta = createModel(model, target, tag);
    String layout = element.getAttributeValue("layout");
    if (layout != null) {
        meta.setLayout((Class<RadLayout>) classLoader.loadClass(layout));
    }
    String delete = element.getAttributeValue("delete");
    if (delete != null) {
        meta.setDelete(Boolean.parseBoolean(delete));
    }
    Element presentation = element.getChild("presentation");
    if (presentation != null) {
        meta.setPresentation(presentation.getAttributeValue("title"), presentation.getAttributeValue("icon"));
    }
    Element palette = element.getChild("palette");
    if (palette != null) {
        meta.setPaletteItem(createPaletteItem(palette));
    }
    Element creation = element.getChild("creation");
    if (creation != null) {
        meta.setCreation(creation.getTextTrim());
    }
    Element properties = element.getChild("properties");
    if (properties != null) {
        loadProperties(meta, properties);
    }
    Element morphing = element.getChild("morphing");
    if (morphing != null) {
        modelToMorphing.put(meta, StringUtil.split(morphing.getAttribute("to").getValue(), " "));
    }
    loadOther(meta, element);
    if (tag != null) {
        myTag2Model.put(tag, meta);
    }
    if (target != null) {
        myTarget2Model.put(target, meta);
    }
    return meta;
}
Also used : Element(org.jdom.Element) NotNull(org.jetbrains.annotations.NotNull)

Example 93 with Element

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

the class StudyTaskManager method getState.

@Nullable
@Override
public Element getState() {
    if (myCourse == null) {
        return null;
    }
    Element el = new Element("taskManager");
    Element courseElement = new Element(StudySerializationUtils.Xml.MAIN_ELEMENT);
    XmlSerializer.serializeInto(this, courseElement);
    el.addContent(courseElement);
    return el;
}
Also used : Element(org.jdom.Element) Nullable(org.jetbrains.annotations.Nullable)

Example 94 with Element

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

the class SpellCheckerSettings method getState.

@Override
@SuppressWarnings({ "ConstantConditions" })
public Element getState() {
    if (myBundledDisabledDictionariesPaths.isEmpty() && myDictionaryFoldersPaths.isEmpty() && myDisabledDictionariesPaths.isEmpty()) {
        return null;
    }
    final Element element = new Element(SPELLCHECKER_MANAGER_SETTINGS_TAG);
    // bundled
    element.setAttribute(BUNDLED_DICTIONARIES_ATTR_NAME, String.valueOf(myBundledDisabledDictionariesPaths.size()));
    Iterator<String> iterator = myBundledDisabledDictionariesPaths.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        element.setAttribute(BUNDLED_DICTIONARY_ATTR_NAME + i, iterator.next());
        i++;
    }
    // user
    element.setAttribute(FOLDERS_ATTR_NAME, String.valueOf(myDictionaryFoldersPaths.size()));
    for (int j = 0; j < myDictionaryFoldersPaths.size(); j++) {
        element.setAttribute(FOLDER_ATTR_NAME + j, myDictionaryFoldersPaths.get(j));
    }
    element.setAttribute(DICTIONARIES_ATTR_NAME, String.valueOf(myDisabledDictionariesPaths.size()));
    iterator = myDisabledDictionariesPaths.iterator();
    i = 0;
    while (iterator.hasNext()) {
        element.setAttribute(DICTIONARY_ATTR_NAME + i, iterator.next());
        i++;
    }
    return element;
}
Also used : Element(org.jdom.Element)

Example 95 with Element

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

the class NodeRendererSettings method getState.

@Override
@SuppressWarnings({ "HardCodedStringLiteral" })
public Element getState() {
    final Element element = new Element("NodeRendererSettings");
    if (myHexRenderer.isEnabled()) {
        JDOMExternalizerUtil.writeField(element, HEX_VIEW_ENABLED, "true");
    }
    if (!areAlternateCollectionViewsEnabled()) {
        JDOMExternalizerUtil.writeField(element, ALTERNATIVE_COLLECTION_VIEW_ENABLED, "false");
    }
    try {
        element.addContent(writeRenderer(myArrayRenderer));
        element.addContent(writeRenderer(myToStringRenderer));
        element.addContent(writeRenderer(myClassRenderer));
        element.addContent(writeRenderer(myPrimitiveRenderer));
        if (myCustomRenderers.getRendererCount() > 0) {
            final Element custom = new Element(CUSTOM_RENDERERS_TAG_NAME);
            element.addContent(custom);
            myCustomRenderers.writeExternal(custom);
        }
    } catch (WriteExternalException e) {
    // ignore
    }
    return element;
}
Also used : PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element)

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