View | Details | Raw Unified | Return to bug 150391 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/diagram/ui/commands/DeferredCreateConnectionViewAndElementCommand.java (-1 / +1 lines)
Lines 161-167 Link Here
161
	}
161
	}
162
162
163
	public boolean canRedo() {
163
	public boolean canRedo() {
164
		return command != null && command.canExecute();
164
		return CommandUtilities.canRedo(command);
165
	}
165
	}
166
166
167
	/**
167
	/**
(-)src/org/eclipse/gmf/runtime/diagram/ui/commands/CommandUtilities.java (+70 lines)
Added Link Here
1
/******************************************************************************
2
 * Copyright (c) 2006, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation 
10
 ****************************************************************************/
11
12
package org.eclipse.gmf.runtime.diagram.ui.commands;
13
14
import java.util.Iterator;
15
16
import org.eclipse.core.commands.operations.IUndoableOperation;
17
import org.eclipse.gef.commands.Command;
18
import org.eclipse.gef.commands.CompoundCommand;
19
20
/**
21
 * Class containing commands utility methods.
22
 * 
23
 * @author aboyko
24
 *
25
 */
26
public class CommandUtilities {
27
	
28
	/**
29
	 * This utility function determines whether the command is redoable.
30
	 * Since GEF commands API doesn't support for canRedo method, this
31
	 * utility will help to travel through the contents of GEF wrapper
32
	 * commands and determine redoability of the GEF command based on
33
	 * the redoability of the commands it contains.
34
	 * 
35
	 * @param command The command to be examined
36
	 * @return <code>true</code> if the passed command is redoable
37
	 */
38
	public static boolean canRedo(Command command)
39
	{
40
		if (command == null)
41
			return false;
42
		
43
		if (command instanceof IUndoableOperation)
44
		{
45
			return ((IUndoableOperation) command).canRedo();
46
		}
47
		else if (command instanceof CompoundCommand)
48
		{
49
			for ( Iterator iter = ((CompoundCommand)command).getCommands().iterator(); iter.hasNext(); )
50
			{
51
				try
52
				{
53
					if (!canRedo((Command)iter.next()))
54
						return false;
55
				}
56
				catch (ClassCastException e)
57
				{
58
					return false;
59
				}
60
			}
61
			return true;
62
		}
63
		else if (command instanceof ICommandProxy)
64
		{
65
			return ((ICommandProxy)command).getICommand().canRedo();
66
		}
67
		return command.canExecute();
68
	}
69
70
}

Return to bug 150391