Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Which command framework should be used preferably?
Which command framework should be used preferably? [message #1807085] Wed, 22 May 2019 11:11 Go to next message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
Hello,

I'm referring to this documentation page : Editing domains and commands

Particularly, I just noticed that this note was added :
"Note: Avoid to use GMF packages if your plugin doesn't need to depend on GMF. Use EMF transactional commands instead."

As I used commands inherited from AbstractTransactionnalCommand in my code I would know what is the risk, and why I should prefer the EMF transctional command.

And as there is no example of that in the doc, is this refer to RecordingCommand for example or other kind of commands?

Thank you for reading.

Regards.

Yoann.

Re: Which command framework should be used preferably? [message #1807087 is a reply to message #1807085] Wed, 22 May 2019 11:37 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 913
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
Re: Which command framework should be used preferably? [message #1807268 is a reply to message #1807087] Mon, 27 May 2019 09:59 Go to previous message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
Hello Camille,

Until now, GMF Commands have my favour in most cases, and if needed, I wrapped them thanks to GMFToEMFCommandWrapper.

Thanks for the explanations and your advices.

Yoann.
Previous Topic:Message Position
Next Topic:applied stereotypes doesn't show up after applying a registered profile
Goto Forum:
  


Current Time: Mon Dec 16 02:34:32 GMT 2019

Powered by FUDForum. Page generated in 0.02397 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top