blob: 2bbcb111d0431b728535eecaca51d9cfcde05ea6 [file] [log] [blame]
cbridghab4a2da02004-11-24 13:10:41 +00001/*******************************************************************************
jlanuti4df6c742005-12-01 21:54:48 +00002 * Copyright (c) 2003, 2005 IBM Corporation and others.
cbridghab4a2da02004-11-24 13:10:41 +00003 * 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
jlanuti4df6c742005-12-01 21:54:48 +00007 *
cbridghab4a2da02004-11-24 13:10:41 +00008 * 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() {
cbridghaa76fed72005-02-07 16:02:19 +000041 //does nothing
cbridghab4a2da02004-11-24 13:10:41 +000042 }
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 }
jlanuti4df6c742005-12-01 21:54:48 +000068}