Bug 150391 - checking canRedo() for wrapped GEF commands
Summary: checking canRedo() for wrapped GEF commands
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major
Target Milestone: 1.0.1   Edit
Assignee: Alex Boyko CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-07-12 10:28 EDT by Christian Vogt CLA
Modified: 2010-07-19 12:29 EDT (History)
1 user (show)

See Also:


Attachments
possible fix - attempt 1 (3.50 KB, patch)
2006-08-22 16:38 EDT, Alex Boyko CLA
no flags Details | Diff
possible fix - CommandProxy also uses utility (4.25 KB, patch)
2006-08-22 17:11 EDT, Alex Boyko CLA
no flags Details | Diff
update (4.24 KB, patch)
2006-08-23 09:08 EDT, Alex Boyko CLA
no flags Details | Diff
patch for CreateViewAndOptionallyElementCommand (944 bytes, patch)
2006-09-19 16:37 EDT, Alex Boyko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Vogt CLA 2006-07-12 10:28:53 EDT
In my scenario when DeferredCreateConnectionViewAndElementCommand.canRedo() is called, the wrapped GEF command has the following general structure:

CompoundCommand
 - ICommandProxy
  - CompositeCommand
   - SemanticCreateCommand 
    - Subclass of CreateRelationshipCommand

For CreateRelationshipCommand canExecute() returns false because the target of the relationship does not exist until part of the operation (not shown in the above structure) were to be redone first, but canRedo() returns true. The command should be redoable but this is not happening.

Checking whether the wrapped command can be executed does not mean that it can be redone, or viseversa. The wrapped command may be a composite command N levels deep, and within this tree of commands are IUndoableOperations which provide a canRedo() method. For these commands canRedo() may return true and canExecute() return false.

There seems to be many areas where GEF commands are being wrapped and canRedo is handled differently (eg.CommandProxy checks if the wrapped command can be Undone to allow redo).

By looking at org.eclipse.gef.commands.CommandStack.canRedo(), it would seem that GEF assumes that any command that is undoable is also redoable, because CommandStack.canRedo() returns true if a command is on the redoable stack.

Perhaps a utility to travel the compound, composite, and standard wrapper commands could be utilized to check if the command is redoable.
Comment 1 Alex Boyko CLA 2006-08-22 16:38:21 EDT
Created attachment 48410 [details]
possible fix - attempt 1

Here is a possible fix with the utility method that checks whether commands wrapped inside the GEF command (or GMF command derived from GEF command) are redoable, i.e. a way to determine redoability correctly for GEF CompoundCommand and GMF IProxyCommand (a GEF-type wrapper for GMF command).
Utility is used in DeferredCreateConnectionViewAndElementCommand #canRedo method.
Comment 2 Christian Vogt CLA 2006-08-22 16:55:17 EDT
Utility should also be used in CommandProxy.canRedo()
Comment 3 Alex Boyko CLA 2006-08-22 17:11:22 EDT
Created attachment 48419 [details]
possible fix - CommandProxy also uses utility

Added utility usage for CommandProxy.canRedo() as suggested.
Comment 4 Alex Boyko CLA 2006-08-23 09:08:30 EDT
Created attachment 48453 [details]
update

Noticed that to check GEF's command redoability a canUndo() should be called instead of canExecute
Comment 5 Alex Boyko CLA 2006-08-25 16:55:54 EDT
Reviewed by Mohammed, commited by Cherie. Marking as fixed.
Comment 6 Alex Boyko CLA 2006-09-19 16:36:01 EDT
The utility hasn't been applied to CreateViewAndOptionallyElementCommand #canRedo() method.
Comment 7 Alex Boyko CLA 2006-09-19 16:37:14 EDT
Created attachment 50513 [details]
patch for CreateViewAndOptionallyElementCommand

the patch for the command to which the utility hasn't been applied
Comment 8 Alex Boyko CLA 2006-09-20 13:28:55 EDT
Commited for 1.0.1 - marking as fixed
Comment 9 Eclipse Webmaster CLA 2010-07-19 12:29:50 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Diagram was the original product and component for this bug