private void open() throws PartInitException { ModelMerger merger = new ModelMerger(inputFile); try { merger.initModel(); } catch (Exception e) { e.printStackTrace(); } model = merger.getMergedModel(); if (model == null) throw new PartInitException( "Can not load model from file :" + inputFile.getFullPath().toString()); dpage.setModel(model); epage.setModel(model); if (merger.isDirty()) { dpage.setDirty(true); } }
@Override public void doSave(IProgressMonitor monitor) { try { CompositeMap map = ModelUtil.toCompositeMap(model); String xml = BaseBmGenerator.xml_header + map.toXML(); ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out, "UTF-8")); bw.write(xml); bw.close(); inputFile.setContents(new ByteArrayInputStream(out.toByteArray()), true, false, monitor); out.close(); dpage.setDirty(false); } catch (Exception e) { e.printStackTrace(); } }
@Override public void doSaveAs() { dpage.setDirty(false); }