private Process create(IFile file) throws CoreException { Process process = null; try { JAXBContext context = JAXBContext.newInstance(Process.class); Unmarshaller unmarshaller = context.createUnmarshaller(); File location = new File(file.getLocationURI()); FileReader reader = new FileReader(location); process = (Process) unmarshaller.unmarshal(reader); ModelHelper.processModel(process, location); ModelHelper.buildCascade(process); } catch (Exception e) { process = new Process(); } return process; }
@Override public void doSave(IProgressMonitor monitor) { try { JAXBContext context = JAXBContext.newInstance(Process.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "GBK"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); IFile file = ((IFileEditorInput) getEditorInput()).getFile(); File location = new File(file.getLocationURI()); marshaller.marshal(model, location); ModelHelper.processXML((Process) this.model, location); getCommandStack().markSaveLocation(); } catch (Exception e) { e.printStackTrace(); } }