01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.client;
17:
18: /**
19: * Encapsulates an action for later execution, often from a different context.
20: *
21: * <p>
22: * The Command interface provides a layer of separation between the code
23: * specifying some behavior and the code invoking that behavior. This separation
24: * aids in creating reusable code. For example, a
25: * {@link com.google.gwt.user.client.ui.MenuItem} can have a Command
26: * associated with it that it executes when the menu item is chosen by the user.
27: * Importantly, the code that constructed the Command to be executed when the
28: * menu item is invoked knows nothing about the internals of the MenuItem class
29: * and vice-versa.</p>
30: *
31: * <p> The Command interface is often implemented with an anonymous inner class.
32: * For example,
33: *
34: * <pre>
35: * Command sayHello = new Command() {
36: * public void execute() {
37: * Window.alert("Hello");
38: * }
39: * };
40: * sayHello.execute();
41: * </pre>
42: *
43: * </p>
44: */
45: public interface Command {
46:
47: /**
48: * Causes the Command to perform its encapsulated behavior.
49: */
50: void execute();
51: }
|