Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Undo/Redo model property
Undo/Redo model property [message #1732832] Fri, 20 May 2016 14:46 Go to next message
Nemanja Bjelica is currently offline Nemanja BjelicaFriend
Messages: 14
Registered: October 2015
Junior Member
Hi guys,

I'm new to the GEF4. I've created an editor with two different shapes, and I've added a property view with several options such as position, length etc...
Now, when I change the property, I want to be able to undo it. I've added OnType policy and binded keyboard shortcuts for undo/redo (in a similar fashion as http://fbenoit.blogspot.rs/2015/11/gef4-tutorial-part-6-undo-redo.html), but I can't undo property change.

Can someone try to explain how this can be done? I'm looking at the Logo example and I've done pretty much the same design for firing property change events, updating the model etc., but I'm missing a step. Do I have to create SetPropertyValueOperation (can't find it in Logo example) and call its execute method to put it on the operation stack or is this something that GEF does by itself?

Thanks,
Beli
Re: Undo/Redo model property [message #1732839 is a reply to message #1732832] Fri, 20 May 2016 08:38 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 244
Registered: July 2009
Location: Lünen
Senior Member
We provide a specific UndoablePropertySheetPage for this purpose. Take a look at MvcUiModule as well as AbstractFXView to see how its bound and used.
Re: Undo/Redo model property [message #1732988 is a reply to message #1732832] Mon, 23 May 2016 14:46 Go to previous messageGo to next message
Nemanja Bjelica is currently offline Nemanja BjelicaFriend
Messages: 14
Registered: October 2015
Junior Member
Alexander, thanks for reply, I really appreciate your time.

I didn't mention, I'am using an old version, 0.1.0201506081138. I've looked into classes you mention. Basically, I've added piece of code (where property sheet page is created) from FXEditor - getAdapter method, into my editor.
Also, I've looked into MvcUiModule also, but I can't successfully call bindIPropertySheetPageFactory with old version of the code. Currently, I have an empty properties view and I don't know how to link it with my properties.

Is there a way to achieve this undo/redo mechanism for properties with the version I have? Could you provide me with some steps?

Thanks
Re: Undo/Redo model property [message #1733003 is a reply to message #1732988] Mon, 23 May 2016 09:48 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 244
Registered: July 2009
Location: Lünen
Senior Member
The approach was very similar with 0.1.0, only that the PropertySheetPage was not injected (for which the IPropertySheetFactory is now used).

You need to overwrite getAdapter() within your editor to return an UndoablePropertySheetPage. You will have to pass in a UndoRedoActionGroup to create it, which has to use the undo context of the FXDomain. It should be relatively straight-forward.
Re: Undo/Redo model property [message #1733111 is a reply to message #1732988] Tue, 24 May 2016 13:09 Go to previous message
Nemanja Bjelica is currently offline Nemanja BjelicaFriend
Messages: 14
Registered: October 2015
Junior Member
Alexander, once again, thanks for your time. I've managed to do it.
Previous Topic:[GEF4] Disable default selection policy
Next Topic:[GEF4] GEF4/Zest graph in an SWT Composite?
Goto Forum:
  


Current Time: Wed Apr 24 16:40:41 GMT 2024

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

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

Back to the top