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