|
Re: Which command framework should be used preferably? [message #1807087 is a reply to message #1807085] |
Wed, 22 May 2019 11:37 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi Yoann,
Specifically for Papyrus, EMF Commands and GMF Commands are now pretty much on the same level (Anything manipulating the model can use EMF Transaction or GMF Runtime Commands). The relationship between Commands Stacks (GEF, GMF and EMF) and Eclipse OperationHistory have always been a little bit chaotic, so I'd still recommend using the EditingDomain's EMF CommandStack to execute commands (So you'd have to wrap a GMF Command in EMF Commands); that's the most reliable option (Eclipse OperationHistory and GMF CommandStack are more powerful in that they can discriminate commands based on their Undo Context or Affect Resource, but in general that introduces a high risk for breaking Undo/Redo and Papyrus won't always handle that properly)
Alternatively, you can use the DiagramCommandStack to execute GMF Commands (Wrapped in GEF Command through ICommandProxy). That's mostly useful when you don't know if the Command will actually modify the model (i.e. when you don't need Undo/Redo support, e.g. when navigating a link or opening an external URL)
It also depends on the context, e.g. if you have access to a DiagramCommandStack or if you only have the EMF CommandStack. The EMF Command Stack is present as soon as the model is loaded, but the Diagram Command Stack is related to the Diagram Editor, i.e. only when the Diagram is open. But in any case, you can wrap a GMF Command in a GMFToEMFCommandWrapper and just execute that on the EMF Command Stack.
When unsure, just try both approaches and see if Undo/Redo works as expected :)
HTH,
Camille
Camille Letavernier
|
|
|
|
Powered by
FUDForum. Page generated in 0.03482 seconds