Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Open diagram
Open diagram [message #1051849] Mon, 29 April 2013 05:32 Go to next message
Philipp El is currently offline Philipp El
Messages: 14
Registered: September 2012
Junior Member
Hi,

where can i find the code if an existing diagram (but no new diagram) is opened!

A new diagram is opened in the XXXDiagramEditorUtil#createDiagram() but where opens an existing diagram?

Thank you very much!

Best regards,
Philipp
Re: Open diagram [message #1052617 is a reply to message #1051849] Tue, 30 April 2013 05:57 Go to previous messageGo to next message
Michael Golubev is currently offline Michael Golubev
Messages: 373
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 09:28 Go to previous message
Dan Tololoi is currently offline Dan Tololoi
Messages: 33
Registered: September 2012
Location: Iasi, Romania
Member

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.
Previous Topic:Calling class(methode) that is in different directory
Next Topic:EVL constraints
Goto Forum:
  


Current Time: Tue Sep 02 03:01:38 EDT 2014

Powered by FUDForum. Page generated in 0.02573 seconds