Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF + EMF + commandstack
GMF + EMF + commandstack [message #212570] Tue, 02 December 2008 13:27 Go to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 866
Registered: July 2009
Senior Member
Hello,

I have followed the tutorial to integrate EMF and GMF generated editors.
Now, I run into this is issue that when I edit in the diagram editor,
the domain is not "dirty" so saving etc.. is not possible. (Although
elements get added to the domain model). On the other hand when I edit
in the EMF editor, the model is set "dirty" and therefor can be saved.
(and all other facilities).

I have looked into this issue, to track the problem, and I think the
following snippet in DiagramEditor is the culprit.

[DiagramEditor]

if (editDomain != null) {
CommandStack stack = editDomain.getCommandStack();

if (stack != null) {
// dispose the old stack
stack.dispose();
}

// create and assign the new stack
DiagramCommandStack diagramStack = new DiagramCommandStack(
getDiagramEditDomain());
....


Now, as you can see a new commandstack is installed, while the command
stack listener which sets the "dirty" property is added on a command
stack installed earlier (In initializedEditingDomain in the EMF Editor).
So this explains my issue.


[MyEMFEditor]
domain.getCommandStack().addCommandStackListener(cmdListener );


The question now is, how to solve this. This issue is not new, as I see
some posts here and there. One posts suggests defining the editing
domain in the EMF editor. I am not sure how this will solve the problem.

I guess, I could install the cmd listener after the new CommandStack is
installed?, But what puzzles me, is why would the GMF code allow an
auxillary editing domain, and then throwing away it's command stack?

Perhaps, some sort of command stack registry, would be a good solution
to have a unique commandstack for EMF and GMF editors respectively?
(This would likely also address the issue of undo/redo accross different
editor types).

Some guidance is most welcome.
Thank You, Christophe Bouhier
Re: GMF + EMF + commandstack [message #212609 is a reply to message #212570] Wed, 03 December 2008 06:24 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Christophe,

I've checked combined (GMF+EMF on different tabs) TopicMapEditor from the
article and it starts being dirty if I mode any node on a diagram.

Anyway, important place in a code is generated ???DocumentProvider.ResourceSetModificationListener
- this class is responsible for listening for a notifications from EMF Resources.modified
property. You can try to debug this code to see why it is not working.

In general to make it working you have to have ensure all the resources loaded
by corresponding ResourceSet has "trackingModification" property set to true
(see generated ???DocumentProvider.createEditingDomain() method). AFAICSee
???Editor.initializeEditingDomain() is not setting trackingModification =
true for any loaded resources, so as an option you can copy appropriate code
from ???DocumentProvider.createEditingDomain() to ???Editor.initializeEditingDomain().

-----------------
Alex Shatalin
Re: GMF + EMF + commandstack [message #212712 is a reply to message #212609] Thu, 04 December 2008 00:29 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 866
Registered: July 2009
Senior Member
Hi Alex,

Thank you for your response. My problem is solved, it was related
to the method isDirty() still in the multipage editor. So removing
this (and letting each editor part respond), solved the problem.

I did learn a bit on resources, notification and commandstacks ;-)
Cheers / Christophe



Alex Shatalin wrote:
> Hello Christophe,
>
> I've checked combined (GMF+EMF on different tabs) TopicMapEditor from
> the article and it starts being dirty if I mode any node on a diagram.
>
> Anyway, important place in a code is generated
> ???DocumentProvider.ResourceSetModificationListener - this class is
> responsible for listening for a notifications from EMF
> Resources.modified property. You can try to debug this code to see why
> it is not working.
>
> In general to make it working you have to have ensure all the resources
> loaded by corresponding ResourceSet has "trackingModification" property
> set to true (see generated ???DocumentProvider.createEditingDomain()
> method). AFAICSee ???Editor.initializeEditingDomain() is not setting
> trackingModification = true for any loaded resources, so as an option
> you can copy appropriate code from
> ???DocumentProvider.createEditingDomain() to
> ???Editor.initializeEditingDomain().
>
> -----------------
> Alex Shatalin
>
>
Re: GMF + EMF + commandstack [message #758462 is a reply to message #212712] Wed, 23 November 2011 06:25 Go to previous messageGo to next message
vinny503 Missing name is currently offline vinny503 Missing name
Messages: 156
Registered: August 2011
Senior Member
Hi,

I see you have mentioned isDirty() method in this post, Please let me know where exactly this method comes, When I search in the entire project I did not find this method.

Regards,
Vinay
Re: GMF + EMF + commandstack [message #758719 is a reply to message #212609] Thu, 24 November 2011 06:32 Go to previous message
vinny503 Missing name is currently offline vinny503 Missing name
Messages: 156
Registered: August 2011
Senior Member
Hi,

I am able to find initializeEditingDomain method in xxxEditor.java file, Please let me know where does it exists ?

Regards,
Vinay
Previous Topic:How to know the size of the Diagram
Next Topic:How do I pre-populate a sub-diagram?
Goto Forum:
  


Current Time: Sat Apr 19 18:34:23 EDT 2014

Powered by FUDForum. Page generated in 0.03126 seconds