Search in sources :

Example 86 with Element

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

the class PythonSdkAdditionalData method savePaths.

private static void savePaths(Element rootElement, Set<SimpleProjectRoot> paths, String root, String element) {
    for (SimpleProjectRoot addedPath : paths) {
        final Element child = new Element(root);
        child.setAttribute(element, addedPath.getUrl());
        rootElement.addContent(child);
    }
}
Also used : SimpleProjectRoot(com.intellij.openapi.projectRoots.impl.SimpleProjectRoot) Element(org.jdom.Element)

Example 87 with Element

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

the class JUnitConfigurationTest method testSearchScope.

public void testSearchScope() throws Exception {
    JUnitConfiguration foo = new JUnitConfiguration("foo", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
    Element element = JdomKt.loadElement("<configuration default=\"false\" name=\"DjangoTests (1.6)\" type=\"JUnit\" factoryName=\"JUnit\">\n" + "    <option name=\"TEST_SEARCH_SCOPE\">\n" + "      <value defaultName=\"moduleWithDependencies\" />\n" + "    </option>\n" + "  </configuration>");
    foo.readExternal(element);
    assertEquals(TestSearchScope.MODULE_WITH_DEPENDENCIES, foo.getPersistentData().getScope());
}
Also used : Element(org.jdom.Element)

Example 88 with Element

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

the class MavenJDOMUtilTest method readValue.

private String readValue(String xml, String valuePath) throws IOException {
    VirtualFile f = createProjectSubFile("foo.xml", xml);
    Element el = MavenJDOMUtil.read(f, new MavenJDOMUtil.ErrorHandler() {

        @Override
        public void onReadError(IOException e) {
            throw new RuntimeException(e);
        }

        @Override
        public void onSyntaxError() {
            fail("syntax error");
        }
    });
    return MavenJDOMUtil.findChildValueByPath(el, valuePath);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Element(org.jdom.Element) IOException(java.io.IOException)

Example 89 with Element

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

the class ExternalResourceManagerExImpl method getState.

@Nullable
@Override
public Element getState() {
    Element element = new Element("state");
    Set<String> urls = new TreeSet<>();
    for (Map<String, String> map : myResources.values()) {
        urls.addAll(map.keySet());
    }
    for (String url : urls) {
        if (url == null) {
            continue;
        }
        String location = getResourceLocation(url);
        if (location == null) {
            continue;
        }
        Element e = new Element(RESOURCE_ELEMENT);
        e.setAttribute(URL_ATTR, url);
        e.setAttribute(LOCATION_ATTR, location.replace(File.separatorChar, '/'));
        element.addContent(e);
    }
    myIgnoredResources.removeAll(myStandardIgnoredResources);
    for (String ignoredResource : myIgnoredResources) {
        Element e = new Element(IGNORED_RESOURCE_ELEMENT);
        e.setAttribute(URL_ATTR, ignoredResource);
        element.addContent(e);
    }
    if (myDefaultHtmlDoctype != null && !HTML5_DOCTYPE_ELEMENT.equals(myDefaultHtmlDoctype)) {
        Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
        e.setText(myDefaultHtmlDoctype);
        element.addContent(e);
    }
    if (myXMLSchemaVersion != XMLSchemaVersion.XMLSchema_1_0) {
        Element e = new Element(XML_SCHEMA_VERSION);
        e.setText(myXMLSchemaVersion.toString());
        element.addContent(e);
    }
    if (myCatalogPropertiesFile != null) {
        Element properties = new Element(CATALOG_PROPERTIES_ELEMENT);
        properties.setText(myCatalogPropertiesFile);
        element.addContent(properties);
    }
    ReplacePathToMacroMap macroReplacements = new ReplacePathToMacroMap();
    PathMacrosImpl.getInstanceEx().addMacroReplacements(macroReplacements);
    macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive);
    return element;
}
Also used : ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap) Element(org.jdom.Element) Nullable(org.jetbrains.annotations.Nullable)

Example 90 with Element

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

the class CutCopyPasteSupport method loadComponentsToPaste.

private static boolean loadComponentsToPaste(final GuiEditor editor, final String serializedComponents, final TIntArrayList xs, final TIntArrayList ys, final ArrayList<RadComponent> componentsToPaste) {
    final PsiPropertiesProvider provider = new PsiPropertiesProvider(editor.getModule());
    try {
        //noinspection HardCodedStringLiteral
        final Document document = SAX_BUILDER.build(new StringReader(serializedComponents), "UTF-8");
        final Element rootElement = document.getRootElement();
        if (!rootElement.getName().equals(ELEMENT_SERIALIZED)) {
            return false;
        }
        final List children = rootElement.getChildren();
        for (final Object aChildren : children) {
            final Element e = (Element) aChildren;
            // we need to add component to a container in order to read them
            final LwContainer container = new LwContainer(JPanel.class.getName());
            final String parentLayout = e.getAttributeValue(ATTRIBUTE_PARENT_LAYOUT);
            if (parentLayout != null) {
                container.setLayoutManager(parentLayout);
            }
            final int x = Integer.parseInt(e.getAttributeValue(ATTRIBUTE_X));
            final int y = Integer.parseInt(e.getAttributeValue(ATTRIBUTE_Y));
            xs.add(x);
            ys.add(y);
            final Element componentElement = (Element) e.getChildren().get(0);
            final LwComponent lwComponent = LwContainer.createComponentFromTag(componentElement);
            container.addComponent(lwComponent);
            lwComponent.read(componentElement, provider);
            // pasted components should have no bindings
            FormEditingUtil.iterate(lwComponent, new FormEditingUtil.ComponentVisitor<LwComponent>() {

                public boolean visit(final LwComponent c) {
                    if (c.getBinding() != null && FormEditingUtil.findComponentWithBinding(editor.getRootContainer(), c.getBinding()) != null) {
                        c.setBinding(null);
                    }
                    c.setId(FormEditingUtil.generateId(editor.getRootContainer()));
                    return true;
                }
            });
            final ClassLoader loader = LoaderFactory.getInstance(editor.getProject()).getLoader(editor.getFile());
            final RadComponent radComponent = XmlReader.createComponent(editor, lwComponent, loader, editor.getStringDescriptorLocale());
            componentsToPaste.add(radComponent);
        }
    } catch (Exception e) {
        return false;
    }
    return true;
}
Also used : Element(org.jdom.Element) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) LwContainer(com.intellij.uiDesigner.lw.LwContainer) Document(org.jdom.Document) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.TIntArrayList) List(java.util.List) LwComponent(com.intellij.uiDesigner.lw.LwComponent)

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