cbridgha | b4a2da0 | 2004-11-24 13:10:41 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
jlanuti | 4df6c74 | 2005-12-01 21:54:48 +0000 | [diff] [blame] | 2 | * Copyright (c) 2003, 2005 IBM Corporation and others. |
cbridgha | b4a2da0 | 2004-11-24 13:10:41 +0000 | [diff] [blame] | 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 |
jlanuti | 4df6c74 | 2005-12-01 21:54:48 +0000 | [diff] [blame] | 7 | * |
cbridgha | b4a2da0 | 2004-11-24 13:10:41 +0000 | [diff] [blame] | 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.wst.common.internal.emfworkbench.edit; |
| 12 | |
| 13 | |
| 14 | |
| 15 | import org.eclipse.emf.common.command.Command; |
| 16 | import org.eclipse.wst.common.internal.emfworkbench.integration.AbstractEditModelCommand; |
| 17 | import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelCommand; |
| 18 | |
| 19 | /** |
| 20 | * Insert the type's description here. Creation date: (05/22/01 8:58:24 AM) |
| 21 | * |
| 22 | * @author: Administrator |
| 23 | */ |
| 24 | public class InvertedCommand extends AbstractEditModelCommand { |
| 25 | public InvertedCommand(Command targetCommand) { |
| 26 | super(targetCommand); |
| 27 | } |
| 28 | |
| 29 | public boolean canExecute() { |
| 30 | return getTarget().canUndo(); |
| 31 | } |
| 32 | |
| 33 | public boolean canUndo() { |
| 34 | return getTarget().canExecute(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Does nothing |
| 39 | */ |
| 40 | public void execute() { |
cbridgha | a76fed7 | 2005-02-07 16:02:19 +0000 | [diff] [blame] | 41 | //does nothing |
cbridgha | b4a2da0 | 2004-11-24 13:10:41 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /** |
| 45 | * getEditModelCommand method comment. |
| 46 | */ |
| 47 | public EditModelCommand getEditModelCommand() { |
| 48 | return ((AbstractEditModelCommand) getTarget()).getEditModelCommand(); |
| 49 | } |
| 50 | |
| 51 | protected int inversionDepth() { |
| 52 | if (getEditModelCommand() == getTarget()) |
| 53 | return 1; |
| 54 | return ((InvertedCommand) getTarget()).inversionDepth() + 1; |
| 55 | } |
| 56 | |
| 57 | protected String labelPrefix() { |
| 58 | return inversionDepth() % 2 == 1 ? "Undo " : "Redo ";//$NON-NLS-2$//$NON-NLS-1$ |
| 59 | } |
| 60 | |
| 61 | public void redo() { |
| 62 | getTarget().undo(); |
| 63 | } |
| 64 | |
| 65 | public void undo() { |
| 66 | getTarget().redo(); |
| 67 | } |
jlanuti | 4df6c74 | 2005-12-01 21:54:48 +0000 | [diff] [blame] | 68 | } |