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.window;
17
18 import net.sf.jguiraffe.gui.builder.event.BuilderEvent;
19
20 /**
21 * <p>
22 * An event class used by the window builder framework to deliver event
23 * information related to windows.
24 * </p>
25 * <p>
26 * Events related to windows, e.g. window closing or iconifying, are also
27 * abstracted by the builder framework. This event class is used for this
28 * purpose. In addition to the event's source (usually the original library
29 * specific event object) a reference to the affected window object is provided.
30 * This reference is usually an object created by the platform specific window
31 * manager that implements the <code>Window</code> interface defined by the
32 * window builder framework.
33 * </p>
34 *
35 * @author Oliver Heger
36 * @version $Id: WindowEvent.java 205 2012-01-29 18:29:57Z oheger $
37 */
38 public class WindowEvent extends BuilderEvent
39 {
40 /**
41 * The serial version UID.
42 */
43 private static final long serialVersionUID = 6168945067550400189L;
44
45 /** Stores a reference to the window that caused this event. */
46 private final Window sourceWindow;
47
48 /** The type of this event. */
49 private final Type type;
50
51 /**
52 * Creates an instance of <code>WindowEvent</code> and sets the properties.
53 *
54 * @param source the event's source
55 * @param sourceWindow a reference to the affected window
56 * @param type the event type
57 */
58 public WindowEvent(Object source, Window sourceWindow, Type type)
59 {
60 super(source);
61 this.sourceWindow = sourceWindow;
62 this.type = type;
63 }
64
65 /**
66 * Returns the source window. This is the window that caused this event.
67 *
68 * @return the source window
69 */
70 public Object getSourceWindow()
71 {
72 return sourceWindow;
73 }
74
75 /**
76 * Returns the type of this event. The type can be used to find out which
77 * action was performed on the window when this event was triggered.
78 *
79 * @return the type of this event
80 */
81 public Type getType()
82 {
83 return type;
84 }
85
86 /**
87 * An enumeration for the different types of window events. The type
88 * determines the action that was performed on the window when an event was
89 * fired.
90 */
91 public static enum Type
92 {
93 /** The window was activated. */
94 WINDOW_ACTIVATED,
95
96 /** The window is about to be closed. */
97 WINDOW_CLOSING,
98
99 /** The window was closed. */
100 WINDOW_CLOSED,
101
102 /** The window was deactivated. */
103 WINDOW_DEACTIVATED,
104
105 /** A window that was minimized to an icon was restored. */
106 WINDOW_DEICONIFIED,
107
108 /** A window was minimized to an icon. */
109 WINDOW_ICONIFIED,
110
111 /**
112 * The window was opened. This is the first event that can be fired by a
113 * window.
114 */
115 WINDOW_OPENED
116 }
117 }