1 /*
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.apple.eawt;
27
28 import java.io.File;
29 import java.net.URI;
30 import java.util.*;
31 import java.awt.Window;
32
33 /**
34 * AppEvents are sent to listeners and handlers installed on the {@link Application}.
35 *
36 * @since Java for Mac OS X 10.6 Update 3
37 * @since Java for Mac OS X 10.5 Update 8
38 */
39 public abstract class AppEvent extends EventObject {
40 AppEvent() {
41 super(Application.getApplication());
42 }
43
44 /**
45 * Contains a list of files.
46 */
47 public abstract static class FilesEvent extends AppEvent {
48 final List<File> files;
49
50 FilesEvent(final List<File> files) {
51 this.files = files;
52 }
53
54 /**
55 * @return the list of files
56 */
57 public List<File> getFiles() {
58 return files;
59 }
60 }
61
62 /**
63 * Event sent when the app is asked to open a list of files.
64 *
65 * @see OpenFilesHandler#openFiles(OpenFilesEvent)
66 */
67 public static class OpenFilesEvent extends FilesEvent {
68 final String searchTerm;
69
70 OpenFilesEvent(final List<File> files, final String searchTerm) {
71 super(files);
72 this.searchTerm = searchTerm;
73 }
74
75 /**
76 * If the files were opened using the Spotlight search menu or a Finder search window, this method obtains the search term used to find the files.
77 * This is useful for highlighting the search term in the documents when they are opened.
78 * @return the search term used to find the files
79 */
80 public String getSearchTerm() {
81 return searchTerm;
82 }
83 }
84
85 /**
86 * Event sent when the app is asked to print a list of files.
87 *
88 * @see PrintFilesHandler#printFiles(PrintFilesEvent)
89 */
90 public static class PrintFilesEvent extends FilesEvent {
91 PrintFilesEvent(final List<File> files) {
92 super(files);
93 }
94 }
95
96 /**
97 * Event sent when the app is asked to open a URI.
98 *
99 * @see OpenURIHandler#openURI(OpenURIEvent)
100 */
101 public static class OpenURIEvent extends AppEvent {
102 final URI uri;
103
104 OpenURIEvent(final URI uri) {
105 this.uri = uri;
106 }
107
108 /**
109 * @return the URI the app was asked to open
110 */
111 public URI getURI() {
112 return uri;
113 }
114 }
115
116 /**
117 * Event sent when the application is asked to open it's about window.
118 *
119 * @see AboutHandler#handleAbout()
120 */
121 public static class AboutEvent extends AppEvent { AboutEvent() { } }
122
123 /**
124 * Event sent when the application is asked to open it's preferences window.
125 *
126 * @see PreferencesHandler#handlePreferences()
127 */
128 public static class PreferencesEvent extends AppEvent { PreferencesEvent() { } }
129
130 /**
131 * Event sent when the application is asked to quit.
132 *
133 * @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse)
134 */
135 public static class QuitEvent extends AppEvent { QuitEvent() { } }
136
137 /**
138 * Event sent when the application is asked to re-open itself.
139 *
140 * @see AppReOpenedListener#appReOpened(AppReOpenedEvent)
141 */
142 public static class AppReOpenedEvent extends AppEvent { AppReOpenedEvent() { } }
143
144 /**
145 * Event sent when the application has become the foreground app, and when it has resigned being the foreground app.
146 *
147 * @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent)
148 * @see AppForegroundListener#appMovedToBackground(AppForegroundEvent)
149 */
150 public static class AppForegroundEvent extends AppEvent { AppForegroundEvent() { } }
151
152 /**
153 * Event sent when the application has been hidden or shown.
154 *
155 * @see AppHiddenListener#appHidden(AppHiddenEvent)
156 * @see AppHiddenListener#appUnhidden(AppHiddenEvent)
157 */
158 public static class AppHiddenEvent extends AppEvent { AppHiddenEvent() { } }
159
160 /**
161 * Event sent when the user session has been changed via Fast User Switching.
162 *
163 * @see UserSessionListener#userSessionActivated(UserSessionEvent)
164 * @see UserSessionListener#userSessionDeactivated(UserSessionEvent)
165 */
166 public static class UserSessionEvent extends AppEvent { UserSessionEvent() { } }
167
168 /**
169 * Event sent when the displays attached to the system enter and exit power save sleep.
170 *
171 * @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent)
172 * @see ScreenSleepListener#screenAwoke(ScreenSleepEvent)
173 */
174 public static class ScreenSleepEvent extends AppEvent { ScreenSleepEvent() { } }
175
176 /**
177 * Event sent when the system enters and exits power save sleep.
178 *
179 * @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent)
180 * @see SystemSleepListener#systemAwoke(SystemSleepEvent)
181 */
182 public static class SystemSleepEvent extends AppEvent { SystemSleepEvent() { } }
183
184 /**
185 * Event sent when a window is entering/exiting or has entered/exited full screen state.
186 *
187 * @see FullScreenUtilities
188 *
189 * @since Java for Mac OS X 10.7 Update 1
190 */
191 public static class FullScreenEvent extends AppEvent {
192 final Window window;
193
194 FullScreenEvent(final Window window) {
195 this.window = window;
196 }
197
198 /**
199 * @return window transitioning between full screen states
200 */
201 public Window getWindow() {
202 return window;
203 }
204 }
205 }
|
1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.apple.eawt;
27
28 import java.io.File;
29 import java.net.URI;
30 import java.util.*;
31 import java.awt.Window;
32
33 /**
34 * AppEvents are sent to listeners and handlers installed on the {@link Application}.
35 *
36 * @since Java for Mac OS X 10.6 Update 3
37 * @since Java for Mac OS X 10.5 Update 8
38 */
39 @SuppressWarnings("serial") // JDK implementation class
40 public abstract class AppEvent extends EventObject {
41 AppEvent() {
42 super(Application.getApplication());
43 }
44
45 /**
46 * Contains a list of files.
47 */
48 @SuppressWarnings("serial") // JDK implementation class
49 public abstract static class FilesEvent extends AppEvent {
50 final List<File> files;
51
52 FilesEvent(final List<File> files) {
53 this.files = files;
54 }
55
56 /**
57 * @return the list of files
58 */
59 public List<File> getFiles() {
60 return files;
61 }
62 }
63
64 /**
65 * Event sent when the app is asked to open a list of files.
66 *
67 * @see OpenFilesHandler#openFiles(OpenFilesEvent)
68 */
69 @SuppressWarnings("serial") // JDK implementation class
70 public static class OpenFilesEvent extends FilesEvent {
71 final String searchTerm;
72
73 OpenFilesEvent(final List<File> files, final String searchTerm) {
74 super(files);
75 this.searchTerm = searchTerm;
76 }
77
78 /**
79 * If the files were opened using the Spotlight search menu or a Finder search window, this method obtains the search term used to find the files.
80 * This is useful for highlighting the search term in the documents when they are opened.
81 * @return the search term used to find the files
82 */
83 public String getSearchTerm() {
84 return searchTerm;
85 }
86 }
87
88 /**
89 * Event sent when the app is asked to print a list of files.
90 *
91 * @see PrintFilesHandler#printFiles(PrintFilesEvent)
92 */
93 @SuppressWarnings("serial") // JDK implementation class
94 public static class PrintFilesEvent extends FilesEvent {
95 PrintFilesEvent(final List<File> files) {
96 super(files);
97 }
98 }
99
100 /**
101 * Event sent when the app is asked to open a URI.
102 *
103 * @see OpenURIHandler#openURI(OpenURIEvent)
104 */
105 @SuppressWarnings("serial") // JDK implementation class
106 public static class OpenURIEvent extends AppEvent {
107 final URI uri;
108
109 OpenURIEvent(final URI uri) {
110 this.uri = uri;
111 }
112
113 /**
114 * @return the URI the app was asked to open
115 */
116 public URI getURI() {
117 return uri;
118 }
119 }
120
121 /**
122 * Event sent when the application is asked to open it's about window.
123 *
124 * @see AboutHandler#handleAbout()
125 */
126 @SuppressWarnings("serial") // JDK implementation class
127 public static class AboutEvent extends AppEvent { AboutEvent() { } }
128
129 /**
130 * Event sent when the application is asked to open it's preferences window.
131 *
132 * @see PreferencesHandler#handlePreferences()
133 */
134 @SuppressWarnings("serial") // JDK implementation class
135 public static class PreferencesEvent extends AppEvent { PreferencesEvent() { } }
136
137 /**
138 * Event sent when the application is asked to quit.
139 *
140 * @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse)
141 */
142 @SuppressWarnings("serial") // JDK implementation class
143 public static class QuitEvent extends AppEvent { QuitEvent() { } }
144
145 /**
146 * Event sent when the application is asked to re-open itself.
147 *
148 * @see AppReOpenedListener#appReOpened(AppReOpenedEvent)
149 */
150 @SuppressWarnings("serial") // JDK implementation class
151 public static class AppReOpenedEvent extends AppEvent { AppReOpenedEvent() { } }
152
153 /**
154 * Event sent when the application has become the foreground app, and when it has resigned being the foreground app.
155 *
156 * @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent)
157 * @see AppForegroundListener#appMovedToBackground(AppForegroundEvent)
158 */
159 @SuppressWarnings("serial") // JDK implementation class
160 public static class AppForegroundEvent extends AppEvent { AppForegroundEvent() { } }
161
162 /**
163 * Event sent when the application has been hidden or shown.
164 *
165 * @see AppHiddenListener#appHidden(AppHiddenEvent)
166 * @see AppHiddenListener#appUnhidden(AppHiddenEvent)
167 */
168 @SuppressWarnings("serial") // JDK implementation class
169 public static class AppHiddenEvent extends AppEvent { AppHiddenEvent() { } }
170
171 /**
172 * Event sent when the user session has been changed via Fast User Switching.
173 *
174 * @see UserSessionListener#userSessionActivated(UserSessionEvent)
175 * @see UserSessionListener#userSessionDeactivated(UserSessionEvent)
176 */
177 @SuppressWarnings("serial") // JDK implementation class
178 public static class UserSessionEvent extends AppEvent { UserSessionEvent() { } }
179
180 /**
181 * Event sent when the displays attached to the system enter and exit power save sleep.
182 *
183 * @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent)
184 * @see ScreenSleepListener#screenAwoke(ScreenSleepEvent)
185 */
186 @SuppressWarnings("serial") // JDK implementation class
187 public static class ScreenSleepEvent extends AppEvent { ScreenSleepEvent() { } }
188
189 /**
190 * Event sent when the system enters and exits power save sleep.
191 *
192 * @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent)
193 * @see SystemSleepListener#systemAwoke(SystemSleepEvent)
194 */
195 @SuppressWarnings("serial") // JDK implementation class
196 public static class SystemSleepEvent extends AppEvent { SystemSleepEvent() { } }
197
198 /**
199 * Event sent when a window is entering/exiting or has entered/exited full screen state.
200 *
201 * @see FullScreenUtilities
202 *
203 * @since Java for Mac OS X 10.7 Update 1
204 */
205 @SuppressWarnings("serial") // JDK implementation class
206 public static class FullScreenEvent extends AppEvent {
207 final Window window;
208
209 FullScreenEvent(final Window window) {
210 this.window = window;
211 }
212
213 /**
214 * @return window transitioning between full screen states
215 */
216 public Window getWindow() {
217 return window;
218 }
219 }
220 }
|