Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/macosx/classes/com/apple/eawt/AppEvent.java
38831 views
/*1* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.apple.eawt;2627import java.io.File;28import java.net.URI;29import java.util.*;30import java.awt.Window;3132/**33* AppEvents are sent to listeners and handlers installed on the {@link Application}.34*35* @since Java for Mac OS X 10.6 Update 336* @since Java for Mac OS X 10.5 Update 837*/38public abstract class AppEvent extends EventObject {39AppEvent() {40super(Application.getApplication());41}4243/**44* Contains a list of files.45*/46public abstract static class FilesEvent extends AppEvent {47final List<File> files;4849FilesEvent(final List<File> files) {50this.files = files;51}5253/**54* @return the list of files55*/56public List<File> getFiles() {57return files;58}59}6061/**62* Event sent when the app is asked to open a list of files.63*64* @see OpenFilesHandler#openFiles(OpenFilesEvent)65*/66public static class OpenFilesEvent extends FilesEvent {67final String searchTerm;6869OpenFilesEvent(final List<File> files, final String searchTerm) {70super(files);71this.searchTerm = searchTerm;72}7374/**75* 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.76* This is useful for highlighting the search term in the documents when they are opened.77* @return the search term used to find the files78*/79public String getSearchTerm() {80return searchTerm;81}82}8384/**85* Event sent when the app is asked to print a list of files.86*87* @see PrintFilesHandler#printFiles(PrintFilesEvent)88*/89public static class PrintFilesEvent extends FilesEvent {90PrintFilesEvent(final List<File> files) {91super(files);92}93}9495/**96* Event sent when the app is asked to open a URI.97*98* @see OpenURIHandler#openURI(OpenURIEvent)99*/100public static class OpenURIEvent extends AppEvent {101final URI uri;102103OpenURIEvent(final URI uri) {104this.uri = uri;105}106107/**108* @return the URI the app was asked to open109*/110public URI getURI() {111return uri;112}113}114115/**116* Event sent when the application is asked to open it's about window.117*118* @see AboutHandler#handleAbout()119*/120public static class AboutEvent extends AppEvent { AboutEvent() { } }121122/**123* Event sent when the application is asked to open it's preferences window.124*125* @see PreferencesHandler#handlePreferences()126*/127public static class PreferencesEvent extends AppEvent { PreferencesEvent() { } }128129/**130* Event sent when the application is asked to quit.131*132* @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse)133*/134public static class QuitEvent extends AppEvent { QuitEvent() { } }135136/**137* Event sent when the application is asked to re-open itself.138*139* @see AppReOpenedListener#appReOpened(AppReOpenedEvent)140*/141public static class AppReOpenedEvent extends AppEvent { AppReOpenedEvent() { } }142143/**144* Event sent when the application has become the foreground app, and when it has resigned being the foreground app.145*146* @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent)147* @see AppForegroundListener#appMovedToBackground(AppForegroundEvent)148*/149public static class AppForegroundEvent extends AppEvent { AppForegroundEvent() { } }150151/**152* Event sent when the application has been hidden or shown.153*154* @see AppHiddenListener#appHidden(AppHiddenEvent)155* @see AppHiddenListener#appUnhidden(AppHiddenEvent)156*/157public static class AppHiddenEvent extends AppEvent { AppHiddenEvent() { } }158159/**160* Event sent when the user session has been changed via Fast User Switching.161*162* @see UserSessionListener#userSessionActivated(UserSessionEvent)163* @see UserSessionListener#userSessionDeactivated(UserSessionEvent)164*/165public static class UserSessionEvent extends AppEvent { UserSessionEvent() { } }166167/**168* Event sent when the displays attached to the system enter and exit power save sleep.169*170* @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent)171* @see ScreenSleepListener#screenAwoke(ScreenSleepEvent)172*/173public static class ScreenSleepEvent extends AppEvent { ScreenSleepEvent() { } }174175/**176* Event sent when the system enters and exits power save sleep.177*178* @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent)179* @see SystemSleepListener#systemAwoke(SystemSleepEvent)180*/181public static class SystemSleepEvent extends AppEvent { SystemSleepEvent() { } }182183/**184* Event sent when a window is entering/exiting or has entered/exited full screen state.185*186* @see FullScreenUtilities187*188* @since Java for Mac OS X 10.7 Update 1189*/190public static class FullScreenEvent extends AppEvent {191final Window window;192193FullScreenEvent(final Window window) {194this.window = window;195}196197/**198* @return window transitioning between full screen states199*/200public Window getWindow() {201return window;202}203}204}205206207