use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class RuntimeModulesGenerateConfigTask method getClonedRootElementOfMainConfigFile.
@Nullable
private static Element getClonedRootElementOfMainConfigFile(final String filePath) {
final VirtualFile configFile = LocalFileSystem.getInstance().findFileByPath(filePath);
if (configFile != null) {
try {
final Document document = JDOMUtil.loadDocument(configFile.getInputStream());
final Element clonedRootElement = document.clone().getRootElement();
if (clonedRootElement.getName().equals(FLEX_CONFIG)) {
return clonedRootElement;
}
} catch (JDOMException ignored) {
/*ignore*/
} catch (IOException ignored) {
/*ignore*/
}
}
return null;
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class FlashBuilderProjectLoadUtil method loadInfoFromDotActionScriptPropertiesFile.
private static void loadInfoFromDotActionScriptPropertiesFile(final FlashBuilderProject project, final VirtualFile dotProjectFile, final Map<String, String> pathReplacementMap) {
final VirtualFile dir = dotProjectFile.getParent();
assert dir != null;
final VirtualFile dotActionScriptPropertiesFile = dir.findChild(FlashBuilderImporter.DOT_ACTION_SCRIPT_PROPERTIES);
if (dotActionScriptPropertiesFile != null) {
try {
final Element actionScriptPropertiesElement = JDOMUtil.load(dotActionScriptPropertiesFile.getInputStream());
if (!ACTION_SCRIPT_PROPERTIES_TAG.equals(actionScriptPropertiesElement.getName()))
return;
loadMainClassName(project, actionScriptPropertiesElement);
final Element compilerElement = actionScriptPropertiesElement.getChild(COMPILER_TAG);
if (compilerElement != null) {
loadProjectType(project, dotProjectFile, compilerElement);
loadSourcePaths(project, compilerElement);
loadOutputFolderPath(project, compilerElement);
loadTargetPlayerVersion(project, compilerElement);
loadAdditionalCompilerArguments(project, compilerElement);
project.setUseHtmlWrapper("true".equals(compilerElement.getAttributeValue(HTML_GENERATE_ATTR)));
loadDependenciesAndCheckIfSdkUsed(project, compilerElement, pathReplacementMap);
if (project.isSdkUsed()) {
loadSdkName(project, compilerElement);
}
}
if (project.getOutputType() == OutputType.Application) {
loadApplications(project, actionScriptPropertiesElement);
loadModules(project, actionScriptPropertiesElement);
loadCssFilesToCompile(project, actionScriptPropertiesElement);
if (!project.isPureActionScript()) {
loadTheme(project, actionScriptPropertiesElement);
}
}
} catch (JDOMException ignored) {
/*ignore*/
} catch (IOException ignored) {
/*ignore*/
}
}
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class FlashBuilderProjectLoadUtil method loadProjectNameAndLinkedResources.
private static void loadProjectNameAndLinkedResources(final FlashBuilderProject project, final VirtualFile dotProjectFile) {
try {
final Element projectDescription = JDOMUtil.load(dotProjectFile.getInputStream());
if (!PROJECT_DESCRIPTION_TAG.equals(projectDescription.getName()))
return;
final String projectName = projectDescription.getChildText(NAME_TAG, projectDescription.getNamespace());
project.setName(StringUtil.notNullize(projectName, FlexBundle.message("unnamed")));
//noinspection unchecked
for (final Element linkedResourcesElement : projectDescription.getChildren(LINKED_RESOURCES_TAG, projectDescription.getNamespace())) {
//noinspection unchecked
for (final Element linkElement : linkedResourcesElement.getChildren(LINK_TAG, linkedResourcesElement.getNamespace())) {
final String linkName = linkElement.getChildText(NAME_TAG, linkElement.getNamespace());
final String linkLocation = linkElement.getChildText(LOCATION_TAG, linkElement.getNamespace());
if (!StringUtil.isEmptyOrSpaces(linkName) && !StringUtil.isEmptyOrSpaces(linkLocation)) {
project.addLinkedResource(linkName, FileUtil.toSystemIndependentName(linkLocation));
}
}
}
} catch (JDOMException ignored) {
/*ignore*/
} catch (IOException ignored) {
/*ignore*/
}
}
use of org.jdom.JDOMException in project beast-mcmc by beast-dev.
the class BeautiFrame method importFiles.
private void importFiles(File[] files) {
for (File file : files) {
if (file == null || file.getName().equals("")) {
JOptionPane.showMessageDialog(this, "Invalid file name", "Invalid file name", JOptionPane.ERROR_MESSAGE);
} else {
try {
BEAUTiImporter beautiImporter = new BEAUTiImporter(this, options);
beautiImporter.importFromFile(file);
setDirty();
// } catch (FileNotFoundException fnfe) {
// JOptionPane.showMessageDialog(this, "Unable to open file: File not found",
// "Unable to open file", JOptionPane.ERROR_MESSAGE);
} catch (IOException ioe) {
JOptionPane.showMessageDialog(this, "File I/O Error unable to read file: " + ioe.getMessage(), "Unable to read file", JOptionPane.ERROR_MESSAGE);
ioe.printStackTrace();
// there may be other files in the list so don't return
// return;
} catch (MissingBlockException ex) {
JOptionPane.showMessageDialog(this, "TAXON, DATA or CHARACTERS block is missing in Nexus file: " + ex, "Missing Block in Nexus File", JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
} catch (ImportException ime) {
JOptionPane.showMessageDialog(this, "Error parsing imported file: " + ime, "Error reading file", JOptionPane.ERROR_MESSAGE);
ime.printStackTrace();
} catch (JDOMException jde) {
JOptionPane.showMessageDialog(this, "Error parsing imported file: " + jde, "Error reading file", JOptionPane.ERROR_MESSAGE);
jde.printStackTrace();
}
}
}
if (!options.hasIdenticalTaxa()) {
// need this to refresh panels otherwise it will throw exception
setAllOptions();
dataPanel.selectAll();
dataPanel.unlinkTrees();
}
setAllOptions();
}
use of org.jdom.JDOMException in project che by eclipse.
the class EffectivePomWriter method addMavenNamespace.
/**
* method from org.apache.maven.plugins.help.AbstractEffectiveMojo
* Add a Pom/Settings namespaces to the effective XML content.
*
* @param effectiveXml not null the effective POM or Settings
* @param isPom if <code>true</code> add the Pom xsd url, otherwise add the settings xsd url.
* @return the content of the root element, i.e. <project/> or <settings/> with the Maven namespace or
* the original <code>effective</code> if an error occurred.
* @see #POM_XSD_URL
* @see #SETTINGS_XSD_URL
*/
protected static String addMavenNamespace(String effectiveXml, boolean isPom) {
SAXBuilder builder = new SAXBuilder();
try {
Document document = builder.build(new StringReader(effectiveXml));
Element rootElement = document.getRootElement();
// added namespaces
Namespace pomNamespace = Namespace.getNamespace("", "http://maven.apache.org/POM/4.0.0");
rootElement.setNamespace(pomNamespace);
Namespace xsiNamespace = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
rootElement.addNamespaceDeclaration(xsiNamespace);
if (rootElement.getAttribute("schemaLocation", xsiNamespace) == null) {
rootElement.setAttribute("schemaLocation", "http://maven.apache.org/POM/4.0.0 " + (isPom ? POM_XSD_URL : SETTINGS_XSD_URL), xsiNamespace);
}
ElementFilter elementFilter = new ElementFilter(Namespace.getNamespace(""));
for (Iterator<?> i = rootElement.getDescendants(elementFilter); i.hasNext(); ) {
Element e = (Element) i.next();
e.setNamespace(pomNamespace);
}
StringWriter w = new StringWriter();
Format format = Format.getPrettyFormat();
XMLOutputter out = new XMLOutputter(format);
out.output(document.getRootElement(), w);
return w.toString();
} catch (JDOMException e) {
return effectiveXml;
} catch (IOException e) {
return effectiveXml;
}
}
Aggregations