1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.gui.builder.action;
17
18 import net.sf.jguiraffe.gui.builder.event.BuilderEvent;
19
20 /**
21 * <p>
22 * Definition of an interface for the task of an action.
23 * </p>
24 * <p>
25 * Each <code>{@link FormAction}</code> object is associated with a target
26 * object, which will be called when the action is triggered. The default
27 * implementations support different types or target objects. One possibility is
28 * that the target object implements this interface. It defines a single
29 * <code>run()</code> method that expects the event object, which triggered
30 * the action, as argument.
31 * </p>
32 * <p>
33 * Action can also deal with plain <code>Runnable</code> objects. If the logic
34 * behind an action does not care about the triggering event, using just a
35 * <code>Runnable</code> may be easier.
36 * </p>
37 *
38 * @author Oliver Heger
39 * @version $Id: ActionTask.java 205 2012-01-29 18:29:57Z oheger $
40 * @see FormAction
41 */
42 public interface ActionTask
43 {
44 /**
45 * Implements the logic behind an action. This method will be called when an
46 * action is triggered (when its <code>execute()</code> method is
47 * invoked). The passed in parameters can be used to further distinguish the
48 * operations to perform.
49 *
50 * @param action the calling action
51 * @param event the event that triggered the action
52 */
53 void run(FormAction action, BuilderEvent event);
54 }