Bug 160541 - When commands are executed using DefaultOperationHistory, unapproved commands will not be executed and CommandResult including IStatus will not be set
Summary: When commands are executed using DefaultOperationHistory, unapproved commands...
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 1.0.2   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: 1.0.2   Edit
Assignee: Wayne CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-10-11 15:26 EDT by Wayne CLA
Modified: 2010-07-19 21:55 EDT (History)
1 user (show)

See Also:


Attachments
Patch for gmf.runtime.common.core (3.49 KB, patch)
2006-10-11 15:27 EDT, Wayne CLA
no flags Details | Diff
Patch for gmf.runtime.emf.commands.core (2.88 KB, patch)
2006-10-11 15:28 EDT, Wayne CLA
no flags Details | Diff
Patch for gmf.tests.runtime.common.core (2.23 KB, patch)
2006-10-11 15:29 EDT, Wayne CLA
no flags Details | Diff
FileModificationApprover - replaces FileModificationApprover from previous patch (2.10 KB, patch)
2006-10-11 16:04 EDT, Wayne CLA
no flags Details | Diff
common.core, emf.commands.core, common.core tests (13.63 KB, patch)
2006-10-12 15:16 EDT, Wayne CLA
no flags Details | Diff
Patch with imports added back (11.85 KB, patch)
2006-10-12 18:23 EDT, Wayne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wayne CLA 2006-10-11 15:26:32 EDT
In org.eclipse.core.commands.operations.DefaultOperationHistory.execute(),

IStatus status = getExecuteApproval(operation, info);

and the status is returned right away without calling execute, so command result will be null because execute was not called on org.eclipse.gmf.runtime.common.core.command.ICommand, and execute is expected to call setResult.

We should have a default result, with a default status of IOperationHistory.OPERATION_INVALID_STATUS.  Furthermore, the FileModificationApprover can update the CommandResult of ICommands accordingly.

The three attached patches will resolve the issue.
Comment 1 Wayne CLA 2006-10-11 15:27:43 EDT
Created attachment 51793 [details]
Patch for gmf.runtime.common.core
Comment 2 Wayne CLA 2006-10-11 15:28:33 EDT
Created attachment 51794 [details]
Patch for gmf.runtime.emf.commands.core
Comment 3 Wayne CLA 2006-10-11 15:29:20 EDT
Created attachment 51797 [details]
Patch for gmf.tests.runtime.common.core
Comment 4 Anthony Hunter CLA 2006-10-11 15:51:01 EDT
Linda, can you review these changes?
Comment 5 Wayne CLA 2006-10-11 16:04:25 EDT
Created attachment 51800 [details]
FileModificationApprover - replaces FileModificationApprover from previous patch
Comment 6 Linda Damus CLA 2006-10-11 16:25:56 EDT
I think that the proposed fix is not suitable for the 1.0.2 release because it changes the expected return value of ICommand#getCommandResult().  This is an API change that may break existing clients who are using the operation history and command APIs correctly. The problem is illustrated by the fact that the unit tests had to be modified to accomodate this change.  Clients expecting a null command result when the command has not been executed will now find that there is a command result. 

Clients are required to check that the command result is not null before using it.  Null is the expected return value from ICommand#getCommandResult() when the command has not been executed, which is the case when operation approvers reject the operation.
Comment 7 Wayne CLA 2006-10-12 15:16:50 EDT
Created attachment 51881 [details]
common.core, emf.commands.core, common.core tests

Alternative version.

CommandResult is not set initially.
Comment 8 Linda Damus CLA 2006-10-12 16:52:09 EDT
Patch 51881 looks better to me.  It narrows the change in command behaviour to the specific bug we need to fix, which is that some clients need a return result (with status) on the command when the command fails file validation.  

I noticed that some of the imports (used by javadocs) were removed.  They probably need to be there, or the javadocs would have to be updated to use fully qualified names.
Comment 9 Wayne CLA 2006-10-12 18:23:00 EDT
Created attachment 51903 [details]
Patch with imports added back
Comment 10 Anthony Hunter CLA 2006-10-13 17:24:51 EDT
Committed to R1_0_maintenance
Comment 11 Eclipse Webmaster CLA 2010-07-19 21:55:47 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Common was the original product and component for this bug