Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 285144

Summary: DragEditPartsTracker forgets to unwrap created CompoundCommand
Product: [Tools] GEF Reporter: Mathieu Veurman <mveurman>
Component: GEF-Legacy GEF (MVC)Assignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: ahunter.eclipse, mromijn, mveurman, nyssen
Version: 3.5   
Target Milestone: 3.6.0 (Helios) M7   
Hardware: All   
OS: All   
Whiteboard:

Description Mathieu Veurman CLA 2009-07-30 08:50:38 EDT
Build ID:  I20090611-1540

The method getCommand() in org.eclipse.gef.tools.DragEditPartsTracker creates a CompoundCommand, but forgets to call unwrap() on it before returning it.

We're supplying a view to our end users that lists the current command stack to the user in a tree. Some MOVE commands that are a result of the DragEditPartsTracker are CompoundCommands with just 1 command in them. unwrap() normally would return the simplest form that is equivalent, and removes this unnecessary nesting.

The change is very easy. Change the last statement of getCommand() from
	return command;
into
	return command.unwrap();


Workaround:
There is a workaround by overriding getDragTracker(Request request) in every edit part you have:

    @Override
    public DragTracker getDragTracker(Request request) {
        return new org.eclipse.gef.tools.DragEditPartsTracker(this) {
            @Override
            protected Command getCommand() {
                Command command = super.getCommand();
                if (command instanceof CompoundCommand) {
                    return ((CompoundCommand)command).unwrap();
                }
                return command;
            }
        };
    }
Comment 1 Alexander Nyßen CLA 2010-04-09 10:14:48 EDT
Changes committed to cvs HEAD.
Comment 2 Anthony Hunter CLA 2010-04-09 11:11:53 EDT
Do not forget to update the copyright header to 2010 to indicate a change made in 2010.
Comment 3 Alexander Nyßen CLA 2010-04-09 11:14:47 EDT
Done.