blob: 8a5a1d9914574642a6b8b348b6b8809cf509383c [file] [log] [blame]
cbridghab4a2da02004-11-24 13:10:41 +00001/*******************************************************************************
2 * Copyright (c) 2003, 2004 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 *******************************************************************************/
11package org.eclipse.wst.common.internal.emfworkbench.edit;
12
13
14
15import org.eclipse.emf.common.command.Command;
16import org.eclipse.wst.common.internal.emfworkbench.integration.AbstractEditModelCommand;
17import 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 */
24public 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() {
41 }
42
43 /**
44 * getEditModelCommand method comment.
45 */
46 public EditModelCommand getEditModelCommand() {
47 return ((AbstractEditModelCommand) getTarget()).getEditModelCommand();
48 }
49
50 protected int inversionDepth() {
51 if (getEditModelCommand() == getTarget())
52 return 1;
53 return ((InvertedCommand) getTarget()).inversionDepth() + 1;
54 }
55
56 protected String labelPrefix() {
57 return inversionDepth() % 2 == 1 ? "Undo " : "Redo ";//$NON-NLS-2$//$NON-NLS-1$
58 }
59
60 public void redo() {
61 getTarget().undo();
62 }
63
64 public void undo() {
65 getTarget().redo();
66 }
67}