super.setInput(input);
// Hook a transaction exception handler so we can get diagnostics about EMF validation errors.
getEditingDomainListener();
BasicCommandStack basicCommandStack = (BasicCommandStack) getEditingDomain().getCommandStack();
if (input instanceof DiagramEditorInput) {
ResourceSet resourceSet = getEditingDomain().getResourceSet();
Bpmn2ResourceImpl bpmnResource = (Bpmn2ResourceImpl) resourceSet.createResource(modelUri,
"org.eclipse.bpmn2.content-type.xml");
resourceSet.setURIConverter(new ProxyURIConverterImplExtension());
modelHandler = ModelHandlerLocator.createModelHandler(modelUri, bpmnResource);
ModelHandlerLocator.put(diagramUri, modelHandler);
try {
if (modelFile.exists()) {
bpmnResource.load(null);
} else {
doSave(null);
}
} catch (IOException e) {
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
ErrorUtils.showErrorWithLogging(status);
}
basicCommandStack.execute(new RecordingCommand(getEditingDomain()) {
@Override
protected void doExecute() {
importDiagram();
}
});
}
basicCommandStack.saveIsDone();
}