View Javadoc

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.cmd;
17  
18  /**
19   * <p>
20   * Definition of an interface to be implemented by {@link Command} objects that
21   * are interested in the point of time they are passed to a {@link CommandQueue}
22   * .
23   * </p>
24   * <p>
25   * This interface is evaluated by implementations of the
26   * {@link CommandQueue#execute(Command)} method. If the {@code Command} object
27   * to be executed implements this interface, the {@code onSchedule()} method is
28   * invoked. Invocation of this method happens in the same thread that has called
29   * the {@code execute()} method. This is usually the event dispatch thread in
30   * typical GUI applications, when a user triggered an action, which causes the
31   * execution of a command.
32   * </p>
33   * <p>
34   * The idea behind this interface is that often some initialization has to be
35   * performed before the actual execution of a command in a background thread. An
36   * example of such an initialization is changing the status of UI controls
37   * affected by the current command. This has typically to be done in the event
38   * dispatch thread, immediately after the invocation of the action that caused
39   * the execution of this command. By implementing this interface this
40   * initialization logic can be placed in the {@code Command} implementation
41   * itself and need not to be implemented somewhere else.
42   * </p>
43   *
44   * @author Oliver Heger
45   * @version $Id: ScheduleAware.java 205 2012-01-29 18:29:57Z oheger $
46   */
47  public interface ScheduleAware
48  {
49      /**
50       * Notifies this object that it was passed to a {@code CommandQueue} for
51       * execution. This method is invoked by the
52       * {@link CommandQueue#execute(Command)} method (in the current thread).
53       *
54       * @param queue the {@code CommandQueue} to which this object was passed
55       */
56      void commandScheduled(CommandQueue queue);
57  }