Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » "Diagram is not present" message when opening 2nd Editor(GMFResource not being updated correctly)
"Diagram is not present" message when opening 2nd Editor [message #989779] Fri, 07 December 2012 12:29 Go to next message
Jim Clark is currently offline Jim Clark
Messages: 4
Registered: November 2012
Junior Member
I've been following several guides on how to create multiple editors for a single model - primarily http://wiki.eclipse.org/Diagram_Partitioning.

I have 1 editor for the model root and another for a node that gets opened on double click of the node.
The editors work well in isolation but I have an issue when I invoke the Open Behaviour on the node.

If I create a new diagram (root editor) then add two nodes and double click the first the node editor opens fine.
If I switch back to the root editor and double click the second node then I get the message "Cannot open input element. Reason: Diagram is not present in resource".

The message comes from my generated XXXDocumentProvider (Which has been modified to use a shared editing domain according to codeDOTgoogleDOTcom/p/gmftools/wiki/SharedEditingDomain).
When the first node editor is opened the DiagramImpl is in the GMFResource.
When the Second node editor is opened the DiagramImpl is NOT in the GMFResource.

If I save the root editor before opening the second node editor it open without error.

If I close the 1st node editor before opening the 2nd it will open without error. I would guess that this is because closing the 1st node editor triggers the save event that cleans up the model.

Any suggestions on what might be wrong or how best to investigate this further?
Re: "Diagram is not present" message when opening 2nd Editor [message #990049 is a reply to message #989779] Mon, 10 December 2012 11:27 Go to previous messageGo to next message
Jim Clark is currently offline Jim Clark
Messages: 4
Registered: November 2012
Junior Member
I've continued to investigate this and think I understand the problem but still looking for a solution.

Although it's a tricky area to debug this is what I've found:
Starting with the Root element editor open and a Node editor open.
Add additional node in the root editor and double click to open the Node editor.
This new node editor will share the same resource instance as the existing editors.
The open action triggers a save of the underlying resource.
This save will update the resource object (in a ResourceSyncJobs).
These are added to the workspace jobs and so wont run until after the OpenAction is complete.
OpenAction continues to open the new editor with a URI for the new node in the existing resource that hasn't yet been updated.
This causes the RuntimeException in the setDocumentContent method of the Node DocumentProvider.

This doesn't happen with the first open of the Node editor as the resource is loaded from the file (which has been saved) and doesn't need to be updated by the sync operation.

Now trying to workout how to schedual opening the editor after the sync jobs have completed.
Re: "Diagram is not present" message when opening 2nd Editor [message #990206 is a reply to message #989779] Tue, 11 December 2012 06:58 Go to previous message
Jim Clark is currently offline Jim Clark
Messages: 4
Registered: November 2012
Junior Member
As ever, when you see the problem you wonder why you didn't spot it straight away.

The problem was simply that my editingDomainIDs didn't match. Understandably fixing this fixes the issue.
Previous Topic:Only a type can be imported.
Next Topic:Default value of node attribute
Goto Forum:
  


Current Time: Wed Apr 16 00:43:49 EDT 2014

Powered by FUDForum. Page generated in 0.01596 seconds