use of org.eclipse.emf.ecore.xmi.impl.XMIHelperImpl in project statecharts by Yakindu.
the class ShadowModelValidationJob method cloneResource.
protected void cloneResource(final IProgressMonitor monitor, final Resource shadowResource) throws ExecutionException {
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(TransactionUtil.getEditingDomain(resource), "", null) {
@Override
protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
try {
XMISaveImpl saver = new XMISaveImpl(new XMIHelperImpl((XMLResource) resource));
saver.save((XMLResource) resource, bout, Collections.emptyMap());
bout.flush();
} catch (Throwable t) {
return CommandResult.newErrorCommandResult(t.getMessage());
}
return CommandResult.newOKCommandResult();
}
};
cmd.execute(monitor, null);
try {
shadowResource.load(new ByteArrayInputStream(bout.toByteArray()), Collections.emptyMap());
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations