|Re: Help with Transactional Editing Domain and Modal Dialogs [message #1059514 is a reply to message #1059510]
||Mon, 20 May 2013 08:13
| Ed Merks
Registered: July 2009
On 20/05/2013 9:58 AM, Jon Buck wrote:
> Hi Ed,
> Thanks very much for your reply, answers to your comments below:
> What did you do for OK? Did you turn it into a command somehow and
> execute that so that the command stack state is valid?
> [JB] So to answer the question I should mention that the source object
> is being passed into the dialog and then I am using EMF Databinding to
> bind the ui controls to the model and I was under the impression that
> databinding is doing the right thing when making changes to the model..
That depends if you're using the EMFEditProperties, but if so, that will
execute commands for each change and you'd need to call undo enough
times on the command stack to deal with cancel...
> so for OK I just end the recording allowing the changes made within
> the dialog to remain...
> I don't know the transactional framework well, but it does support the
> notion of rollback when command execution fails, so my sense is that
> you need to do all this as part of executing a command and in the case
> of cancel, throw and exception that will cause a rollback.
> [JB] This sounds reasonable however where would it rollback to?
To the start of the command's execution...
> as I am using databinding every change in the UI controls invokes a
> change in the model so there could be n number of individual changes
> taking place as the user types a value in a text field, or makes a
> choice in a list etc.
Yes, but given that you've executed commands, I imagine you should be
undoing those so that the command stack has no trace of the canceled
> Somehow you need to be doing the changes as part of a command so that
> it either is properly recorded in an undoable way on the command stack
> or is rolled back...
> [JB] Yes completely agree and believe that I am doing that as I am
> making use of EMF DataBinding within the dialog, I have also double
> checked that the correct editing domain is being passed into the
> EMFEditProperties objects within the bindings...
Yes, it makes commands for you, but you'd need to undo those commands,
not simply change the model's state back with direct model changes...
So you might add a command stack listener that listens for how many
commands are executed from when the dialog is opened up to before cancel
is pressed and then call undo that number of times if cancel is pressed.
Powered by FUDForum
. Page generated in 0.01793 seconds