public final void save() { // System.out.println("Content: save: Info=" + info.toString() + " Data=" + this.toString() + " // Data.Data=" + data.toString()); XmlWriter xml = new XmlWriter(); xml.openTag("content"); saveContent(xml); xml.openTag("info"); info.save(xml); xml.closeTag(); xml.closeTag(); try { IFolder folder = data.getFolder(); ResourceUtil.createFolderAndParents(folder); IFile file = folder.getFile("content.xml"); ByteArrayInputStream stream = new ByteArrayInputStream(xml.getXML().getBytes()); if (!file.exists()) file.create(stream, true, null); else file.setContents(stream, 0, null); } catch (Throwable t) { if (Log.error(this)) Log.error(this, "Unable to save data content", t); } }
public boolean open() { super.open("DataOrganizer", MyDialog.FLAGS_MODAL_DIALOG); if (ok) { File config = new File( net.lecousin.framework.application.Application.deployPath, "recentWorkspaces.xml"); XmlWriter xml = new XmlWriter(); xml.openTag("dataorganizer_workpsaces"); xml.openTag("workspace") .addAttribute("location", selectedDir) .addAttribute("language", selectedLang) .closeTag(); for (Pair<String, Integer> p : recent) { if (p.getValue1().equals(selectedDir)) continue; xml.openTag("workspace") .addAttribute("location", p.getValue1()) .addAttribute("language", p.getValue2()) .closeTag(); } xml.closeTag(); try { xml.writeToFile(config.getAbsolutePath()); } catch (IOException e) { // skip } } return ok; }