Search in sources :

Example 36 with Element

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

the class ManifestBuilder method getManifestEntries.

private static Map<String, String> getManifestEntries(Element manifestEntries) {
    boolean hasManifestEntries = manifestEntries != null && manifestEntries.getContentSize() > 0;
    Map<String, String> entries = hasManifestEntries ? new LinkedHashMap<>(manifestEntries.getContentSize()) : Collections.emptyMap();
    if (hasManifestEntries) {
        for (Element element : manifestEntries.getChildren()) {
            entries.put(element.getName(), element.getTextTrim());
        }
    }
    return entries;
}
Also used : Element(org.jdom.Element)

Example 37 with Element

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

the class ManifestBuilder method build.

@NotNull
public java.util.jar.Manifest build() throws ManifestBuilderException {
    try {
        Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(myMavenProject);
        final Element mavenArchiveConfiguration = mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null;
        if (mavenArchiveConfiguration == null)
            return getDefaultManifest(Collections.emptyMap());
        final Element manifestEntries = mavenArchiveConfiguration.getChild("manifestEntries");
        Map<String, String> entries = getManifestEntries(manifestEntries);
        final Element manifestConfiguration = mavenArchiveConfiguration.getChild("manifest");
        final Manifest configuredManifest = getConfiguredManifest(myMavenProject, manifestConfiguration, entries);
        if (!entries.isEmpty()) {
            addManifestEntries(configuredManifest, entries);
        }
        addCustomManifestSections(configuredManifest, mavenArchiveConfiguration);
        Manifest finalManifest = getDefaultManifest(entries);
        // merge configured manifest
        merge(finalManifest, configuredManifest);
        // merge user supplied manifest
        final Manifest userSuppliedManifest = getUserSuppliedManifest(mavenArchiveConfiguration);
        merge(finalManifest, userSuppliedManifest);
        return finalManifest;
    } catch (ManifestException e) {
        throw new ManifestBuilderException(e);
    }
}
Also used : Element(org.jdom.Element) Manifest(org.codehaus.plexus.archiver.jar.Manifest) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with Element

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

the class ManifestBuilder method addCustomManifestSections.

private static void addCustomManifestSections(@NotNull Manifest manifest, @NotNull Element mavenArchiveConfiguration) throws ManifestException {
    for (Element section : MavenJDOMUtil.findChildrenByPath(mavenArchiveConfiguration, "manifestSections", "manifestSection")) {
        Manifest.Section theSection = new Manifest.Section();
        final String sectionName = MavenJDOMUtil.findChildValueByPath(section, "name");
        theSection.setName(sectionName);
        final Element manifestEntries = section.getChild("manifestEntries");
        Map<String, String> entries = getManifestEntries(manifestEntries);
        if (!entries.isEmpty()) {
            for (Map.Entry<String, String> entry : entries.entrySet()) {
                Attribute attr = new Attribute(entry.getKey(), entry.getValue());
                theSection.addConfiguredAttribute(attr);
            }
        }
        manifest.addConfiguredSection(theSection);
    }
}
Also used : Attribute(org.codehaus.plexus.archiver.jar.Manifest.Attribute) Element(org.jdom.Element) Manifest(org.codehaus.plexus.archiver.jar.Manifest) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 39 with Element

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

the class ManifestBuilder method getClasspath.

@NotNull
public static String getClasspath(@NotNull MavenProject mavenProject) {
    Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(mavenProject);
    final Element mavenArchiveConfiguration = mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null;
    final Element manifestConfiguration = mavenArchiveConfiguration != null ? mavenArchiveConfiguration.getChild("manifest") : null;
    final ManifestImporter manifestImporter = ManifestImporter.getManifestImporter(mavenProject.getPackaging());
    return manifestImporter.getClasspath(mavenProject, manifestConfiguration);
}
Also used : Element(org.jdom.Element) ManifestImporter(org.jetbrains.idea.maven.importing.ManifestImporter) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with Element

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

the class SaveFormAsTemplateHandler method getTemplateText.

@Override
public String getTemplateText(final PsiFile file, final String fileText, final String nameWithoutExtension) {
    if (StdFileTypes.GUI_DESIGNER_FORM.equals(file.getFileType())) {
        LwRootContainer rootContainer = null;
        try {
            rootContainer = Utils.getRootContainer(fileText, null);
        } catch (Exception ignored) {
        }
        if (rootContainer != null && rootContainer.getClassToBind() != null) {
            try {
                Element document = JdomKt.loadElement(fileText);
                Attribute attribute = document.getAttribute(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS);
                attribute.detach();
                return JDOMUtil.write(document, CodeStyleSettingsManager.getSettings(file.getProject()).getLineSeparator());
            } catch (Exception ignored) {
            }
        }
    }
    return null;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) LwRootContainer(com.intellij.uiDesigner.lw.LwRootContainer)

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