Changing the domain model programmatically [message #675765] |
Wed, 01 June 2011 12:57  |
Eclipse User |
|
|
|
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 #677687 is a reply to message #675765] |
Thu, 09 June 2011 07:05   |
Eclipse User |
|
|
|
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] |
Wed, 06 June 2012 02:31   |
Eclipse User |
|
|
|
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 13:20   |
Eclipse User |
|
|
|
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] |
Thu, 07 June 2012 03:38   |
Eclipse User |
|
|
|
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 06:30  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.04556 seconds