Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [GEF5] EMF Commands and Undo/Redo(Policies and Operations calls to doSomethingOnTheContent methods of IContentParts)
[GEF5] EMF Commands and Undo/Redo [message #1791234] Tue, 26 June 2018 12:54 Go to next message
Patrick Muscat is currently offline Patrick MuscatFriend
Messages: 4
Registered: May 2018
Junior Member
Hello,

We are using EMF model for common objets: Node, Port (for anchorage) and Edge. GEF5 is used inside our software based on Eclipse oxygen. An EditingDomain (EMF) is set up to manage changes, dirty MPart, Undo/redo.

There is no problem with simple changes, for example, when the user resize or move a Node, there is one and only one Command. One Ctrl-Z is enough for undoing. When the user moves the upper left corner, there are two Commands and two Ctrl-Z are necessary to undo one action.

These are simple examples but when changes are a bit more complicated it becomes innaceptable for the user. For example, a Node with 3 Ports and 3 Edges is suppressed it produces a lot (3 + 3 + 3 + 3 + 1) Commands and as much Ctrl-Z to undo one simple deletion. Commands are created and executed during the doSomethingOnTheContent methods. In this example; each Edge is detached from its anchorages, removed from the RootPart then each Ports are removed from their Node and the Node is removed from the RootPart.

A simple case: when removing a Part from its parent, the oldContentChildren is controlled to be sure we can remove the child, then the method doRemoveContentChild is called (where the data is really modified by the EMF Command) and finally the newContentChildren is controlled to ensure that the child has been removed.

We are new to GEF5, so is our approach the good one or is there a better solution ? Does someone faced this problem and is ok to share some advices ?

We use the HistoricizingDomain but not its IOperationHistory. Do we have to override the doGetContentChildren methods to bypass GEF5 content controls (FIXME!) or the best approach will be in the EMF EditingDomain and a custom CommandStack ?
Re: [GEF5] EMF Commands and Undo/Redo [message #1791880 is a reply to message #1791234] Fri, 06 July 2018 12:59 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 163
Registered: March 2015
Senior Member
Hi Patrick,

as you already figured, GEF makes use of the operation history provided by Eclipse. Moreover, the HistoricizingDomain implements a transaction concept, i.e. all operations are added to one composite operation that is called the "transaction". Only when interaction finishes (no more interleaving gestures / handler processing stops), the transaction operation is put onto the operation history and a new transaction operation is created.

What about the other operations executed in the context of GEF? ResizeVisualOperation, TransformVisualOperation, etc. they are not present on the EMF command stack, are they?

In order to make undo work nicely, you need to combine the individual operations/commands that are executed as part of a user interaction.

You could do it the other way around, i.e. let GEF manage the operations and just execute the commands like you already do. Undo would need to work on the Eclipse operation history then.

Maybe you can achieve something similar by utilising EMF CompoundCommand. We do not have an example for EMF command stack integration, but we can try to help here. However, I currently do not know the specifics w.r.t. EMF.

h2h
Matthias
Re: [GEF5] EMF Commands and Undo/Redo [message #1791883 is a reply to message #1791880] Fri, 06 July 2018 13:24 Go to previous messageGo to next message
Patrick Muscat is currently offline Patrick MuscatFriend
Messages: 4
Registered: May 2018
Junior Member
Hello Matthias,

Thank you for your response, I was writing the description of what we did and it corresponds exactly to your suggestion:

The second solution has been chosen. An EMF "transaction" is being build during all Policies (and their Operations) executions. The "transaction" is an EMF CompoundCommand which contains EMF commands and IUndoableOperations, it permits its execution on the EditingDomain for EMF undo/redo process => one user action corresponds to one undo/redo. This "transaction" acts like an intermediate EMF CommandStack with execute/undo/redo methods but also an "append" method to add Operations done by Policies.

There are "already executed" commands: the one done to comply with GEF5 MVC FX controls done before and after calls to doSomethingOnTheModel methods of IContentParts. This is the trick, the EMF Command Stack has been modified to accept already executed commands but must act like it executes them. Then, undo/redo are in the normal process, the "transaction" forwards undo/redo calls to its EMF Commands which are not intended to be undone during doSomethingReverseOnTheModel and its Operations. The EMF CommandStack state (undoing/redoing) is accessible during the doSomethingReverseOnTheModel methods to avoid stacking again already stacked Commands.

No, SomethingVisualOperation does not generate EMF Commands, only Content changes produce EMF Commands, typically add/remove/attach/detach on different levels of IContentParts.

It works so far :) there will be some particular cases to manage...

[Updated on: Fri, 06 July 2018 13:33]

Report message to a moderator

Re: [GEF5] EMF Commands and Undo/Redo [message #1793609 is a reply to message #1791883] Sat, 11 August 2018 14:17 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 163
Registered: March 2015
Senior Member
Hi Patrick,

I am pleased that you have been able to solve your problem in a satisfactory manner. Do not hesitate to ask further questions if need be. Then, we can continue the discussion here.

Best regards,
Matthias
Previous Topic:GEF5 + e(fx)clipse // Problem DragNDrop Shapes (Double Click ?)
Next Topic:JavaFX Line vs GEF Geometry Line
Goto Forum:
  


Current Time: Sun Sep 23 02:42:47 GMT 2018

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

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

Back to the top