Diagram diagram = getDiagramToOpen();
if (diagram == null) {
diagram = intializeNewDiagram();
}
URI uri = EcoreUtil.getURI(diagram);
String editorName = uri.lastSegment() + '#'
+ diagram.eResource().getContents().indexOf(diagram);
IEditorInput editorInput = new URIEditorInput(uri, editorName);
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
page.openEditor(editorInput, getEditorID());