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