Bug 86244 - IOperationHistory#closeOperation should only add the operation to the undo stack if it is valid
Summary: IOperationHistory#closeOperation should only add the operation to the undo st...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-23 06:30 EST by Dirk Baeumer CLA
Modified: 2005-03-30 15:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2005-02-23 06:30:07 EST
The problem is that executing the operation passed to open operation might not
be executed successful. However clients should close an operation even if it
failed from what I interpret into the API.
Comment 1 Dirk Baeumer CLA 2005-02-23 06:34:03 EST
Checking the operation will not work for the refactoring case since the actual
undo object will only be available after refactoring has closed the operation.
So closeOperation should provide a paramter to indicate success or failure.
Comment 2 Susan McCourt CLA 2005-02-23 13:52:48 EST
Ideally, the sequence after an open/close should be similar to that of an 
execute.  Since open/close leaves the client in charge of executing, it's 
reasonable for the close operation to specify whether there was success or 
failure.

One difference is that execute checks the operation's #canUndo before adding 
it to the history (see bug #84444), but in this case you do not want this 
behavior.  To summarize:

- you would like a boolean parameter on closeOperation to indicate whether the 
operation successfully executed.
- if this parameter is false (failure) than the history should send an 
OPERATION_NOT_OK notification instead of a DONE notification.
- if this parameter is true (success) than the history should send a DONE 
notification.
- if this parameter is true, than the history should add the operation to the 
undo history and send an OPERATION_ADDED notification, **independent of the 
#canUndo state of the operation**

This last part seems inconsistent with bug #84444 and I'd rather treat the 
operation similarly to #execute, but if there is no way for you to work around 
this, i can accept it, since this whole API is for legacy integration.

Please confirm.
Comment 3 Dirk Baeumer CLA 2005-02-24 05:35:21 EST
Susan, 

you are correct. This is inconsistent to bug 84444 and we should try to make it
more consistent.

The problem in the old refactoring API is that when I get the performed call
which must call the closeOperation method I don't have the undo object yet.

To make this API more consistent I propose to add two extra parameters to
closeOperation:

- executionSuccessful: a specified by you
- addToUndoStack: if this one is true the operation is added to the undo
  history and the framework will do the canUndo verification. If false, nothing
  is added. The parameter will be ignored if executionSuccessful is false.

The refactoring framework will push the operation onto the undo stack when it
receives the corresponding addUndo call by forwarding it to IOperationHistory#add.
Comment 4 Susan McCourt CLA 2005-02-24 12:16:32 EST
This seems reasonable.  I will implement as suggested.

(avoiding the temptation to say...hmmm...should #execute then also take a 
parameter for whether to add to the stack?...)  ;-)
Comment 5 Dirk Baeumer CLA 2005-02-24 12:21:14 EST
Having this for #execute would make sense, but adding it seems to a overkill. If
someone doesn't want to add it to the history during execute he can use open/close.
Comment 6 Susan McCourt CLA 2005-02-24 12:40:37 EST
Agree it's overkill for now.  Execute was first added to the API to support 
older frameworks such as GEF and EMF commands who had no #add protocol and 
always implied an add inside the execute.

If it's needed later, someone can request it.  I'll implement close as you 
suggest.  Will annotate this bug when it's committed.
Comment 7 Susan McCourt CLA 2005-02-26 11:00:25 EST
Implemented for I20050301 and beyond.  Released to HEAD on 2/25/2005.
Comment 8 Susan McCourt CLA 2005-03-27 14:41:22 EST
this bug has been fixed in M6 cycle.
Comment 9 Susan McCourt CLA 2005-03-30 15:01:26 EST
verified on I20050330-0500