*/
protected Diagram intializeNewDiagram() throws ExecutionException {
Diagram d = ViewService.createDiagram(getDiagramDomainElement(),
getDiagramKind(), getPreferencesHint());
if (d == null) {
throw new ExecutionException("Can't create diagram of '"
+ getDiagramKind() + "' kind");
}
diagramFacet.setDiagramLink(d);
assert diagramFacet.eResource() != null;
diagramFacet.eResource().getContents().add(d);
EObject container = diagramFacet.eContainer();
while (container instanceof View) {
((View) container).persist();
container = container.eContainer();
}
try {
new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor)
throws CoreException, InvocationTargetException,
InterruptedException {
try {
for (Iterator it = diagramFacet.eResource()
.getResourceSet().getResources().iterator(); it
.hasNext();) {
Resource nextResource = (Resource) it.next();
if (nextResource.isLoaded()
&& !getEditingDomain().isReadOnly(
nextResource)) {
nextResource
.save(eu.admire.visual.pmml._40.diagram.part.PMMLDiagramEditorUtil
.getSaveOptions());
}
}
} catch (IOException ex) {
throw new InvocationTargetException(ex,
"Save operation failed");
}
}
}.run(null);
} catch (InvocationTargetException e) {
throw new ExecutionException("Can't create diagram of '"
+ getDiagramKind() + "' kind", e);
} catch (InterruptedException e) {
throw new ExecutionException("Can't create diagram of '"
+ getDiagramKind() + "' kind", e);
}
return d;
}