KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > command > OverrideableCommand


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: OverrideableCommand.java,v 1.2 2005/06/08 06:17:05 nickb Exp $
16  */

17 package org.eclipse.emf.edit.command;
18
19
20 import java.util.Collection JavaDoc;
21
22 import org.eclipse.emf.common.command.Command;
23
24
25 /**
26  * This represents a command that can be overridden by another command.
27  * The intended use of this is that an overrideable command should call
28  * {@link org.eclipse.emf.edit.domain.EditingDomain#createOverrideCommand EditingDomain.createOverrideCommand}
29  * in its constructor to set up the override command.
30  * All its {@link Command} methods should then be guarded as follows:
31  * <pre>
32  * public void execute()
33  * {
34  * if (getOverride() != null)
35  * {
36  * getOverride().execute();
37  * }
38  * else
39  * {
40  * doExecute();
41  * }
42  * }
43  * </pre>
44  * The contract with the overriding command is that the overrideable command will implement all its
45  * methods in corresponding doXxx methods, e.g., execute() is implemented in doExecute(), so that the
46  * overriding command can call back to the overrideable command's doXxx methods if it wants to extend
47  * rather than replace the original implementation.
48  * {@link AbstractOverrideableCommand} provides a convienient base implementation for overrideable commands.
49  */

50 public interface OverrideableCommand extends Command
51 {
52   /**
53    * This returns the command that overrides this command.
54    */

55   Command getOverride();
56
57   /**
58    * This sets the command that overrides this command.
59    */

60   void setOverride(Command overrideCommand);
61
62   /**
63    * This is overrideable command's implementation of canExecute.
64    */

65   boolean doCanExecute();
66
67   /**
68    * This is overrideable command's implementation of execute.
69    */

70   void doExecute();
71
72   /**
73    * This is overrideable command's implementation of canUndo.
74    */

75   boolean doCanUndo();
76
77   /**
78    * This is overrideable command's implementation of undo.
79    */

80   void doUndo();
81
82   /**
83    * This is overrideable command's implementation of redo.
84    */

85   void doRedo();
86
87   /**
88    * This is overrideable command's implementation of getResult.
89    */

90   Collection JavaDoc doGetResult();
91
92   /**
93    * This is overrideable command's implementation of getAffectedObjects.
94    */

95   Collection JavaDoc doGetAffectedObjects();
96
97   /**
98    * This is overrideable command's implementation of getLabel.
99    */

100   String JavaDoc doGetLabel();
101
102   /**
103    * This is overrideable command's implementation of getDescription.
104    */

105   String JavaDoc doGetDescription();
106
107   /**
108    * This is overrideable command's implementation of dispose.
109    */

110   void doDispose();
111 }
112
Popular Tags