jdk/src/java.desktop/macosx/classes/com/apple/eawt/AppEvent.java
changeset 36959 d839463825a2
parent 36853 9001df2d68e9
parent 36958 8a320111d9fe
child 36960 d7731fdfe7c3
equal deleted inserted replaced
36853:9001df2d68e9 36959:d839463825a2
     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 }