rolling back model changes [message #1082927] |
Fri, 09 August 2013 04:07  |
Eclipse User |
|
|
|
Hi,
eTrice has diagram editors based on Graphiti.
We use property dialogs wrapped in custom features to change properties of the underlying domain model objects.
In case the dialog was canceled the custom feature returns false for hasDoneChanges.
I'm quite sure that in an earlier version also the model changes that have been applied (despite hasDoneChanges returned false)
have been rolled back by the framework (the wrapping RecordingCommand has this capability).
Unfortunately I can't tell in which version I've tested this successfully. We also have no unit test for that since that would
require SWTBot which we don't use. I've tested with 10.0, 9.2 and 9.0 but always observed that changes were not rolled back.
Is it possible that this is a regression in Graphiti?
Or was a roll back behavior never intended for this case and the Graphiti client has to care about that?
Thanks,
Henrik
|
|
|
Re: rolling back model changes [message #1092897 is a reply to message #1082927] |
Fri, 23 August 2013 05:51   |
Eclipse User |
|
|
|
If I understand you right, your feature does some changes, then gets canceled by the user, and you return false in the hasDoneChanges() method? If so, I doubt this ever worked.
The hasDoneChanges() method is used to determine whether to put the command in undo/redo stack, and has no effect on the command execution. If you want to cancel an already running feature, and want the framework to undo your changes, you must throw an OperationCanceledException, and then Graphiti (EMF transaction really) will undo the changes for you.
This has the collateral effect that an info log entry will be created in the error log (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=411129), but hopefully that soon will be optional.
|
|
|
Re: rolling back model changes [message #1092905 is a reply to message #1082927] |
Fri, 23 August 2013 06:03   |
Eclipse User |
|
|
|
If I understand you right, your feature does some changes, then gets canceled by the user, and you return false in the hasDoneChanges() method? If so, I doubt this ever worked.
The hasDoneChanges() method is used to determine whether to put the command in undo/redo stack, and has no effect on the command execution. If you want to cancel an already running feature, and want the framework to undo your changes, you must throw an OperationCanceledException, and then Graphiti (EMF transaction really) will undo the changes for you.
This has the collateral effect that an info log entry will be created in the error log (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=411129), but hopefully that soon will be optional.
|
|
|
Re: rolling back model changes [message #1092906 is a reply to message #1082927] |
Fri, 23 August 2013 06:04   |
Eclipse User |
|
|
|
If I understand you right, your feature does some changes, then gets canceled by the user, and you return false in the hasDoneChanges() method? If so, I doubt this ever worked.
The hasDoneChanges() method is used to determine whether to put the command in undo/redo stack, and has no effect on the command execution. If you want to cancel an already running feature, and want the framework to undo your changes, you must throw an OperationCanceledException, and then Graphiti (EMF transaction really) will undo the changes for you.
This has the collateral effect that an info log entry will be created in the error log (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=411129), but hopefully that soon will be optional.
|
|
|
Re: rolling back model changes [message #1093765 is a reply to message #1092906] |
Sat, 24 August 2013 12:30  |
Eclipse User |
|
|
|
Hi Henrik,
We are doing exactly the same thing in the eclipse BPMN2 Modeler project (i.e. using a modal dialog for configuring model elements). Since submitting this feature request, I've rethought some of this behavior and have found the best way to handle this is to create a nested transaction within the dialog. Have a look at the AbstractObjectEditingDialog class in the BPMN2 Modeler git repository.
HTH,
Bob
|
|
|
Powered by
FUDForum. Page generated in 0.12360 seconds