Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to remove a transaction from TransactionalEditingDomain
How to remove a transaction from TransactionalEditingDomain [message #1625289] Fri, 20 February 2015 09:22 Go to next message
Rahul Dev Mishra is currently offline Rahul Dev MishraFriend
Messages: 11
Registered: July 2013
Location: Bangalore, India
Junior Member
Hello All,

I am developing a feature with the help of EMF wherein after the feature is invoked i should be able to undo and redo.

However now within this feature I have to use another TransactionalEditingDomain & RecordingCommand inside
Display.getDefault().asyncExec(new Runnable() {
.......code goes in here.....
});

So now when I perform Undo, first time nothing happens and then when I perform the second Undo, then the actual feature is undone. This happens for the obvious reason that I have used another RecordingCommand.

Now I would like to remove the last RecordingCommand from the command stack so that with a single undo, the feature is undone.

So could anybody please help me out in removing the last recording command.

Thanks & Regards,
Rahul

[Updated on: Fri, 20 February 2015 09:23]

Report message to a moderator

Re: How to remove a transaction from TransactionalEditingDomain [message #1625616 is a reply to message #1625289] Fri, 20 February 2015 14:11 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Rahul,

See some replies in-line, below.

HTH,

Christian


On 2015-02-20 09:22:25 +0000, Rahul Dev Mishra said:

> Hello All,
>
> I am developing a feature with the help of EMF wherein after the
> feature is invoked i should be able to undo and redo.

EMF is generally very good at undo and redo, yes.


> However now within this feature I have to use another
> TransactionalEditingDomain & RecordingCommand inside
> Display.getDefault().asyncExec(new Runnable() {
> .......code goes in here.....
> });

Why do you have to use a second editing domain? What does this command
do? Why does it have to be run asynchronously? Asynchronously
executing commands on the command stack or operation history is almost
never a good idea. Commands should be invoked in direct response to a
user request (button press, menu action, keystroke).

It sounds like this additional command that you are executing should be
a trigger command (provided by a transaction pre-commit listener) since
you seem to be using transactions. And wouldn't it already be running
on the UI thread because it is in response to a user action?


> So now when I perform Undo, first time nothing happens and then when I
> perform the

Why does the first undo not change anything? If that command didn't
change anything and if it therefore doesn't undo any changes, then it
shouldn't be on the command stack or operation history in the first
place.


> second Undo, then the actual feature is undone. This happens for the
> obvious reason that I have used another RecordingCommand.

Right, because that recording command isn't properly composed with the
changes that came before it into a single undoable unit.


> Now I would like to remove the last RecordingCommand from the command
> stack so that with a single undo, the feature is undone.

No, I think you need to take a step back and find out how to avoid
putting that command on the stack in the first place.


> Thanks & Regards,
> Rahul
Previous Topic:EMF: Pupulating ordered list of "scatterd" items
Next Topic:Eclipse not starting
Goto Forum:
  


Current Time: Wed Apr 24 23:06:28 GMT 2024

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

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

Back to the top