|
Re: Open diagram [message #1052617 is a reply to message #1051849] |
Tue, 30 April 2013 09:57 |
Michael Golubev Messages: 383 Registered: July 2009 |
Senior Member |
|
|
Hello,
It is difficult to find the code which is at the same time:
- executed for opening an existing diagram
- and NOT executed for opening of just created diagram
because when we create the new one, we initialize the model part, save it, and then just open it as it is the existing one.
The XXXDocumentProvider#createDocument is a good starting point for any diagram opening.
Or may be non-generated org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor#doSetInput.
Below is partial stack trace similar to the one executed at every opening (Addlinked = your XXX here) -- any entries in this stack should be good to start looking at
AddlinkedDocumentProvider.createDocument(Object) line: 84
AddlinkedDocumentProvider.createElementInfo(Object) line: 72
AddlinkedDocumentProvider(AbstractDocumentProvider).connect(Object) line: 387
AddlinkedDiagramEditor(DiagramDocumentEditor).doSetInput(IEditorInput, boolean) line: 460
AddlinkedDiagramEditor(DiagramDocumentEditor).setInput(IEditorInput) line: 423
AddlinkedDiagramEditor(GraphicalEditor).init(IEditorSite, IEditorInput) line: 346
AddlinkedDiagramEditor(DiagramEditor).init(IEditorSite, IEditorInput) line: 653
AddlinkedDiagramEditor(DiagramDocumentEditor).init(IEditorSite, IEditorInput) line: 126
EditorReference.initialize(IWorkbenchPart) line: 324
HTH,
Michael
|
|
|
Re: Open diagram [message #1059305 is a reply to message #1052617] |
Fri, 17 May 2013 13:28 |
|
private IEditorPart openDiagram(String name) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = null;
try {
IFile diagramFile = project.getFile(name +".xxx_diagram");
// don't open a diagram if it doesn't exists
if (diagramFile.exists()) {
editor = page.openEditor (new FileEditorInput(diagramFile), "xxxYourDiagramEditorID", false);
}
} catch (PartInitException e) {
System.err.println("There is no Diagram called '" + name + "' (" + name + ".xxx_diagram");
//e.printStackTrace();
}
return editor;
}
What does openEditor:
Opens an editor on the given input.
If this page already has an editor open on the target input that editor is brought to the front; otherwise, a new editor is opened. Two editor inputs are considered the same if they equal. See Object.equals(Object) and IEditorInput. If activate == true the editor will be activated.
|
|
|
Powered by
FUDForum. Page generated in 0.04766 seconds