Skip to main content

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 09:32 Go to next message
Philipp El is currently offline Philipp ElFriend
Messages: 14
Registered: September 2012
Junior Member

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,
Re: Open diagram [message #1052617 is a reply to message #1051849] Tue, 30 April 2013 09:57 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member

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
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    

Re: Open diagram [message #1059305 is a reply to message #1052617] Fri, 17 May 2013 13:28 Go to previous message
Dan Tololoi is currently offline Dan TololoiFriend
Messages: 33
Registered: September 2012
Location: Iasi, Romania

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");
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: Sun Apr 05 04:10:12 GMT 2020

Powered by FUDForum. Page generated in 0.01739 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top