Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Changing the domain model programmatically
Changing the domain model programmatically [message #675765] Wed, 01 June 2011 08:57 Go to next message
Thomas Buchmann is currently offline Thomas Buchmann
Messages: 53
Registered: November 2010
Member
Hello,

i want to add an action to my generated editor that performs complex changes of the underlying domain model. Therefore, i wrote a command that implements the org.eclipse.emf.common.command.Command Interface.

Within the corresponding Action, this command is executed on the command stack of the TransactionalEditingDomain which is associated to my GMF Editor. The command is executed and no exception is thrown but the model seems to remain unchanged...

Regards,
Thomas
Re: Changing the domain model programmatically [message #677015 is a reply to message #675765] Tue, 07 June 2011 06:35 Go to previous messageGo to next message
Thomas Buchmann is currently offline Thomas Buchmann
Messages: 53
Registered: November 2010
Member
any ideas??
Re: Changing the domain model programmatically [message #677461 is a reply to message #677015] Wed, 08 June 2011 11:08 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael Istria
Messages: 745
Registered: July 2009
Location: Grenoble, France
Senior Member
Le 07/06/2011 12:35, bkunlimited a écrit :
> any ideas??

What about? I did not see any question in your previous mail :)
--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Eclipse Community Award 2011: Best Modeling Tool
Re: Changing the domain model programmatically [message #677687 is a reply to message #675765] Thu, 09 June 2011 03:05 Go to previous messageGo to next message
Thomas Buchmann is currently offline Thomas Buchmann
Messages: 53
Registered: November 2010
Member
bkunlimited wrote on Wed, 01 June 2011 08:57

Within the corresponding Action, this command is executed on the command stack of the TransactionalEditingDomain which is associated to my GMF Editor. The command is executed and no exception is thrown but the model seems to remain unchanged...


The question is: How can the domain model remain unchanged although the command executes?

Within the execute method of the command, model elements are deleted (by calling EcoreUtil.remove()). So my assumption was that after a successful execution, those model elements should be gone and the editor should be in a dirty state. Obviously this assumption is wrong and i'm wondering how one would implement the desired behaviour in a correct "GMF"-like way.

Re: Changing the domain model programmatically [message #882190 is a reply to message #675765] Tue, 05 June 2012 22:31 Go to previous messageGo to next message
Oskar van Rest is currently offline Oskar van Rest
Messages: 12
Registered: February 2012
Junior Member
I think your approach actually does update the semantic/domain model (at least, it does for me). It just doesn't update anything in the GMF editor or the notation model.

I'm currently experiencing the same problem and I have no idea how to solve it. Any help would be appreciated.

I expected that GMF would react on changes in the semantic model, but apparently, it doesn't. I think there are many use cases for such a feature.
Re: Changing the domain model programmatically [message #882444 is a reply to message #882190] Wed, 06 June 2012 09:20 Go to previous messageGo to next message
Manuel Ihlenfeld is currently offline Manuel Ihlenfeld
Messages: 6
Registered: June 2012
Junior Member
Oskar,

GMF actually reacts to changes in the semantic model. GMF uses
CanonicalEditPolicies to synchronize the diagram with the samantic model.
They should have been generated in the edit.policies package of your
diagram project.

In the xxx.gmfgen file, the element "Gen Diagram XXXDiagramEditPart" has
the property "Synchronized". Can you check whether it is set to true?

Regards,
Manuel
Re: Changing the domain model programmatically [message #882721 is a reply to message #882444] Wed, 06 June 2012 23:38 Go to previous messageGo to next message
Oskar van Rest is currently offline Oskar van Rest
Messages: 12
Registered: February 2012
Junior Member
Hi Manuel,

Thanks for your quick reply. It all makes sense now.
My generated GMF editor has errors in the code that takes care of the CanonicalEditPolicies, because of bug 352271 (sorry, can't post links).

I've always been ignoring these errors because my editors seemed to work fine, and therefore didn't really link it to the above problems.

According to the bug report, a temporarily workaround has been committed. Do you maybe know what update site I should use if I want a GMF version that includes this workaround?
I just updated GMF to the latest version (4.2.0), but that didn't make a difference.

Cheers,
Oskar
Re: Changing the domain model programmatically [message #883253 is a reply to message #675765] Fri, 08 June 2012 02:30 Go to previous message
Oskar van Rest is currently offline Oskar van Rest
Messages: 12
Registered: February 2012
Junior Member
aha.. so the only thing this workaround does is replacing calls to the non-existing methods (the errors) with "Collections.emptyList()", something that can easily be done manually.
However, it doesn't really solve my problem. When I programmatically add/remove phantom nodes, they will only show up in the diagram once I also add/remove non-phantom nodes.

Unfortunately, the bug will only be revisited in GMF 3.0.
Previous Topic:GMF Editor without the diagram file created
Next Topic:Initialize programmatically created nodes
Goto Forum:
  


Current Time: Fri Aug 29 10:17:26 EDT 2014

Powered by FUDForum. Page generated in 0.02375 seconds