use of org.jdom.Document in project intellij-community by JetBrains.
the class DotProjectFileHelper method saveDotProjectFile.
public static void saveDotProjectFile(@NotNull Module module, @NotNull String storageRoot) throws IOException {
try {
Document doc;
if (ModuleType.get(module) instanceof JavaModuleType) {
doc = JDOMUtil.loadDocument(DotProjectFileHelper.class.getResource("template.project.xml"));
} else {
doc = JDOMUtil.loadDocument(DotProjectFileHelper.class.getResource("template.empty.project.xml"));
}
doc.getRootElement().getChild(EclipseXml.NAME_TAG).setText(module.getName());
final File projectFile = new File(storageRoot, EclipseXml.PROJECT_FILE);
if (!FileUtil.createIfDoesntExist(projectFile)) {
return;
}
EclipseJDOMUtil.output(doc.getRootElement(), projectFile, module.getProject());
ApplicationManager.getApplication().runWriteAction(() -> {
LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(projectFile.getPath()));
});
} catch (JDOMException e) {
LOG.error(e);
}
}
use of org.jdom.Document in project intellij-community by JetBrains.
the class EclipseUserLibrariesHelper method appendProjectLibraries.
public static void appendProjectLibraries(final Project project, @Nullable final File userLibrariesFile) throws IOException {
if (userLibrariesFile == null)
return;
if (userLibrariesFile.exists() && !userLibrariesFile.isFile())
return;
final File parentFile = userLibrariesFile.getParentFile();
if (parentFile == null)
return;
if (!parentFile.isDirectory()) {
if (!parentFile.mkdir())
return;
}
final Element userLibsElement = new Element("eclipse-userlibraries");
final List<Library> libraries = new ArrayList<>(Arrays.asList(ProjectLibraryTable.getInstance(project).getLibraries()));
ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraries());
for (Library library : libraries) {
Element libElement = new Element("library");
libElement.setAttribute("name", library.getName());
writeUserLibrary(library, libElement);
userLibsElement.addContent(libElement);
}
JDOMUtil.writeDocument(new Document(userLibsElement), userLibrariesFile, "\n");
}
use of org.jdom.Document in project zaproxy by zaproxy.
the class DriverConfiguration method write.
public void write() {
final Document doc = new Document();
final Element root = new Element("driverConfiguration");
doc.addContent(root);
for (int i = 0; i < names.size(); i++) {
final Element driver = new Element("driver");
root.addContent(driver);
final Element name = new Element("name");
driver.addContent(name);
name.addContent(names.get(i));
final Element path = new Element("path");
driver.addContent(path);
path.addContent(paths.get(i));
final Element slot = new Element("slot");
driver.addContent(slot);
slot.addContent(slots.get(i).toString());
final Element slotListIndex = new Element("slotListIndex");
driver.addContent(slotListIndex);
slotListIndex.addContent(slotListIndexes.get(i).toString());
}
try {
final OutputStream fileOutputStream = new BufferedOutputStream(new FileOutputStream(file));
final XMLOutputter out = new XMLOutputter();
out.output(doc, fileOutputStream);
fileOutputStream.close();
} catch (final FileNotFoundException e) {
JOptionPane.showMessageDialog(null, new String[] { "Error accessing key store: ", e.toString() }, "Error", JOptionPane.ERROR_MESSAGE);
logger.error(e.getMessage(), e);
} catch (final IOException e) {
JOptionPane.showMessageDialog(null, new String[] { "Error accessing key store: ", e.toString() }, "Error", JOptionPane.ERROR_MESSAGE);
logger.error(e.getMessage(), e);
}
setChanged();
notifyObservers();
}
use of org.jdom.Document in project intellij-community by JetBrains.
the class TaskSettingsTest method testCarriageReturnInFormat.
public void testCarriageReturnInFormat() throws Exception {
TaskRepository repository = new YouTrackRepository();
String format = "foo \n bar";
repository.setCommitMessageFormat(format);
((TaskManagerImpl) myTaskManager).setRepositories(Collections.singletonList(repository));
TaskManagerImpl.Config config = ((TaskManagerImpl) myTaskManager).getState();
Element element = XmlSerializer.serialize(config);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
JDOMUtil.writeDocument(new Document(element), stream, "\n");
Element element1 = JDOMUtil.load(new ByteArrayInputStream(stream.toByteArray()));
TaskManagerImpl.Config deserialize = XmlSerializer.deserialize(element1, TaskManagerImpl.Config.class);
((TaskManagerImpl) myTaskManager).loadState(deserialize);
TaskRepository[] repositories = myTaskManager.getAllRepositories();
assertEquals(format, repositories[0].getCommitMessageFormat());
}
use of org.jdom.Document in project intellij-community by JetBrains.
the class XsltDocumentationProvider method getDocumentationDocument.
private Document getDocumentationDocument() throws IOException, JDOMException {
Document d = com.intellij.reference.SoftReference.dereference(myDocument);
if (d == null) {
d = new SAXBuilder().build(XsltSupport.class.getResource("resources/documentation.xml"));
myDocument = new SoftReference<>(d);
}
return d;
}
Aggregations