--- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -150,6 +150,12 @@
Java_sun_awt_X11_XlibWrapper_XdbeEndIdiom;
Java_sun_awt_X11_XDesktopPeer_init;
Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show;
+ Java_sun_awt_X11_XTaskbarPeer_init;
+ Java_sun_awt_X11_XTaskbarPeer_runloop;
+ Java_sun_awt_X11_XTaskbarPeer_setBadge;
+ Java_sun_awt_X11_XTaskbarPeer_setUrgent;
+ Java_sun_awt_X11_XTaskbarPeer_updateProgress;
+ Java_sun_awt_X11_XTaskbarPeer_setNativeMenu;
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl;
Java_sun_awt_X11_XRobotPeer_keyPressImpl;
Java_sun_awt_X11_XRobotPeer_keyReleaseImpl;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/AboutHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.AboutEvent;
-
-/**
- * An implementor receives notification when the app is asked to show it's about dialog.
- *
- * @see Application#setAboutHandler(AboutHandler)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface AboutHandler {
- /**
- * Called when the application is asked to show it's about dialog.
- * @param e the request to show the about dialog.
- */
- public void handleAbout(final AboutEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/AppEvent.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import java.io.File;
-import java.net.URI;
-import java.util.*;
-import java.awt.Window;
-
-/**
- * AppEvents are sent to listeners and handlers installed on the {@link Application}.
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-@SuppressWarnings("serial") // JDK implementation class
-public abstract class AppEvent extends EventObject {
- AppEvent() {
- super(Application.getApplication());
- }
-
- /**
- * Contains a list of files.
- */
- @SuppressWarnings("serial") // JDK implementation class
- public abstract static class FilesEvent extends AppEvent {
- final List<File> files;
-
- FilesEvent(final List<File> files) {
- this.files = files;
- }
-
- /**
- * @return the list of files
- */
- public List<File> getFiles() {
- return files;
- }
- }
-
- /**
- * Event sent when the app is asked to open a list of files.
- *
- * @see OpenFilesHandler#openFiles(OpenFilesEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class OpenFilesEvent extends FilesEvent {
- final String searchTerm;
-
- OpenFilesEvent(final List<File> files, final String searchTerm) {
- super(files);
- this.searchTerm = searchTerm;
- }
-
- /**
- * 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.
- * This is useful for highlighting the search term in the documents when they are opened.
- * @return the search term used to find the files
- */
- public String getSearchTerm() {
- return searchTerm;
- }
- }
-
- /**
- * Event sent when the app is asked to print a list of files.
- *
- * @see PrintFilesHandler#printFiles(PrintFilesEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class PrintFilesEvent extends FilesEvent {
- PrintFilesEvent(final List<File> files) {
- super(files);
- }
- }
-
- /**
- * Event sent when the app is asked to open a URI.
- *
- * @see OpenURIHandler#openURI(OpenURIEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class OpenURIEvent extends AppEvent {
- final URI uri;
-
- OpenURIEvent(final URI uri) {
- this.uri = uri;
- }
-
- /**
- * @return the URI the app was asked to open
- */
- public URI getURI() {
- return uri;
- }
- }
-
- /**
- * Event sent when the application is asked to open it's about window.
- *
- * @see AboutHandler#handleAbout()
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class AboutEvent extends AppEvent { AboutEvent() { } }
-
- /**
- * Event sent when the application is asked to open it's preferences window.
- *
- * @see PreferencesHandler#handlePreferences()
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class PreferencesEvent extends AppEvent { PreferencesEvent() { } }
-
- /**
- * Event sent when the application is asked to quit.
- *
- * @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class QuitEvent extends AppEvent { QuitEvent() { } }
-
- /**
- * Event sent when the application is asked to re-open itself.
- *
- * @see AppReOpenedListener#appReOpened(AppReOpenedEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class AppReOpenedEvent extends AppEvent { AppReOpenedEvent() { } }
-
- /**
- * Event sent when the application has become the foreground app, and when it has resigned being the foreground app.
- *
- * @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent)
- * @see AppForegroundListener#appMovedToBackground(AppForegroundEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class AppForegroundEvent extends AppEvent { AppForegroundEvent() { } }
-
- /**
- * Event sent when the application has been hidden or shown.
- *
- * @see AppHiddenListener#appHidden(AppHiddenEvent)
- * @see AppHiddenListener#appUnhidden(AppHiddenEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class AppHiddenEvent extends AppEvent { AppHiddenEvent() { } }
-
- /**
- * Event sent when the user session has been changed via Fast User Switching.
- *
- * @see UserSessionListener#userSessionActivated(UserSessionEvent)
- * @see UserSessionListener#userSessionDeactivated(UserSessionEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class UserSessionEvent extends AppEvent { UserSessionEvent() { } }
-
- /**
- * Event sent when the displays attached to the system enter and exit power save sleep.
- *
- * @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent)
- * @see ScreenSleepListener#screenAwoke(ScreenSleepEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class ScreenSleepEvent extends AppEvent { ScreenSleepEvent() { } }
-
- /**
- * Event sent when the system enters and exits power save sleep.
- *
- * @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent)
- * @see SystemSleepListener#systemAwoke(SystemSleepEvent)
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class SystemSleepEvent extends AppEvent { SystemSleepEvent() { } }
-
- /**
- * Event sent when a window is entering/exiting or has entered/exited full screen state.
- *
- * @see FullScreenUtilities
- *
- * @since Java for Mac OS X 10.7 Update 1
- */
- @SuppressWarnings("serial") // JDK implementation class
- public static class FullScreenEvent extends AppEvent {
- final Window window;
-
- FullScreenEvent(final Window window) {
- this.window = window;
- }
-
- /**
- * @return window transitioning between full screen states
- */
- public Window getWindow() {
- return window;
- }
- }
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/AppEventListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-/**
- * Common interface for all event listener sub-types.
- * Implementors may implement multiple sub-types, but only need to call {@link Application#addAppEventListener(AppEventListener)} once to receive all notifications.
- *
- * @see AppReOpenedListener
- * @see AppForegroundListener
- * @see AppHiddenListener
- * @see ScreenSleepListener
- * @see SystemSleepListener
- * @see UserSessionListener
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface AppEventListener { }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/AppForegroundListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.AppForegroundEvent;
-
-/**
- * Implementors are notified when the app becomes the foreground app and when it resigns being the foreground app.
- * This notification is useful for hiding and showing transient UI like palette windows which should be hidden when the app is in the background.
- *
- * @see Application#addAppEventListener(AppEventListener)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface AppForegroundListener extends AppEventListener {
- /**
- * Called when the app becomes the foreground app.
- * @param e the app became foreground notification.
- */
- public void appRaisedToForeground(final AppForegroundEvent e);
-
- /**
- * Called when the app resigns to the background and another app becomes the foreground app.
- * @param e the app resigned foreground notification.
- */
- public void appMovedToBackground(final AppForegroundEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/AppHiddenListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.AppHiddenEvent;
-
-/**
- * Implementors are notified when the app is hidden or shown by the user.
- * This notification is helpful for discontinuing a costly animation if it's not visible to the user.
- *
- * @see Application#addAppEventListener(AppEventListener)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface AppHiddenListener extends AppEventListener {
- /**
- * Called the app is hidden.
- * @param e
- */
- public void appHidden(final AppHiddenEvent e);
-
- /**
- * Called when the hidden app is shown again (but not necessarily brought to the foreground).
- * @param e
- */
- public void appUnhidden(final AppHiddenEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/AppReOpenedListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.AppReOpenedEvent;
-
-/**
- * Implementors receive notification when the app has been asked to open again.
- * Re-open events occur when the user clicks on the running app's Dock icon.
- * Re-open events also occur when the app is double-clicked in the Finder and the app is already running.
- *
- * This notification is useful for showing a new document when your app has no open windows.
- *
- * @see Application#addAppEventListener(AppEventListener)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface AppReOpenedListener extends AppEventListener {
- /**
- * Called when the app has been re-opened (it's Dock icon was clicked on, or was double-clicked in the Finder)
- * @param e the request to re-open the app
- */
- public void appReOpened(final AppReOpenedEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/Application.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/Application.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,10 +26,10 @@
package com.apple.eawt;
import java.awt.Image;
-import java.awt.Point;
import java.awt.PopupMenu;
import java.awt.Toolkit;
import java.awt.Window;
+import java.awt.desktop.*;
import java.beans.Beans;
import javax.swing.JMenuBar;
@@ -104,38 +104,38 @@
}
/**
- * Adds sub-types of {@link AppEventListener} to listen for notifications from the native Mac OS X system.
+ * Adds sub-types of {@link SystemEventListener} to listen for notifications from the native Mac OS X system.
*
* @see AppForegroundListener
* @see AppHiddenListener
* @see AppReOpenedListener
- * @see ScreenSleepListener
- * @see SystemSleepListener
- * @see UserSessionListener
+ * @see AppScreenSleepListener
+ * @see AppSystemSleepListener
+ * @see AppUserSessionListener
*
* @param listener
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
- public void addAppEventListener(final AppEventListener listener) {
+ public void addAppEventListener(final SystemEventListener listener) {
eventHandler.addListener(listener);
}
/**
- * Removes sub-types of {@link AppEventListener} from listening for notifications from the native Mac OS X system.
+ * Removes sub-types of {@link SystemEventListener} from listening for notifications from the native Mac OS X system.
*
* @see AppForegroundListener
* @see AppHiddenListener
* @see AppReOpenedListener
- * @see ScreenSleepListener
- * @see SystemSleepListener
- * @see UserSessionListener
+ * @see AppScreenSleepListener
+ * @see AppSystemSleepListener
+ * @see AppUserSessionListener
*
* @param listener
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
- public void removeAppEventListener(final AppEventListener listener) {
+ public void removeAppEventListener(final SystemEventListener listener) {
eventHandler.removeListener(listener);
}
@@ -368,6 +368,17 @@
}
/**
+ * Displays a progress bar to this application's Dock icon.
+ * Acceptable values are from 0 to 100, any other disables progress indication.
+ *
+ * @param value progress value
+ * @since 1.9
+ */
+ public void setDockIconProgress(final int value) {
+ iconHandler.setDockIconProgress(value);
+ }
+
+ /**
* Sets the default menu bar to use when there are no active frames.
* Only used when the system property "apple.laf.useScreenMenuBar" is "true", and
* the Aqua Look and Feel is active.
@@ -397,168 +408,4 @@
((CPlatformWindow)platformWindow).toggleFullScreen();
}
-
- // -- DEPRECATED API --
-
- /**
- * Adds the specified ApplicationListener as a receiver of callbacks from this class.
- * This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
- *
- * @param listener an implementation of ApplicationListener that handles ApplicationEvents
- *
- * @deprecated register individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
- * @since 1.4
- */
- @SuppressWarnings("deprecation")
- @Deprecated
- public void addApplicationListener(final ApplicationListener listener) {
- eventHandler.legacyHandler.addLegacyAppListener(listener);
- }
-
- /**
- * Removes the specified ApplicationListener from being a receiver of callbacks from this class.
- * This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
- *
- * @param listener an implementation of ApplicationListener that had previously been registered to handle ApplicationEvents
- *
- * @deprecated unregister individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
- * @since 1.4
- */
- @SuppressWarnings("deprecation")
- @Deprecated
- public void removeApplicationListener(final ApplicationListener listener) {
- eventHandler.legacyHandler.removeLegacyAppListener(listener);
- }
-
- /**
- * Enables the Preferences item in the application menu. The ApplicationListener receives a callback for
- * selection of the Preferences item in the application menu only if this is set to {@code true}.
- *
- * If a Preferences item isn't present, this method adds and enables it.
- *
- * @param enable specifies whether the Preferences item in the application menu should be enabled ({@code true}) or not ({@code false})
- *
- * @deprecated no replacement
- * @since 1.4
- */
- @Deprecated
- public void setEnabledPreferencesMenu(final boolean enable) {
- menuBarHandler.setPreferencesMenuItemVisible(true);
- menuBarHandler.setPreferencesMenuItemEnabled(enable);
- }
-
- /**
- * Enables the About item in the application menu. The ApplicationListener receives a callback for
- * selection of the About item in the application menu only if this is set to {@code true}. Because AWT supplies
- * a standard About window when an application may not, by default this is set to {@code true}.
- *
- * If the About item isn't present, this method adds and enables it.
- *
- * @param enable specifies whether the About item in the application menu should be enabled ({@code true}) or not ({@code false})
- *
- * @deprecated no replacement
- * @since 1.4
- */
- @Deprecated
- public void setEnabledAboutMenu(final boolean enable) {
- menuBarHandler.setAboutMenuItemEnabled(enable);
- }
-
- /**
- * Determines if the Preferences item of the application menu is enabled.
- *
- * @deprecated no replacement
- * @since 1.4
- */
- @Deprecated
- public boolean getEnabledPreferencesMenu() {
- return menuBarHandler.isPreferencesMenuItemEnabled();
- }
-
- /**
- * Determines if the About item of the application menu is enabled.
- *
- * @deprecated no replacement
- * @since 1.4
- */
- @Deprecated
- public boolean getEnabledAboutMenu() {
- return menuBarHandler.isAboutMenuItemEnabled();
- }
-
- /**
- * Determines if the About item of the application menu is present.
- *
- * @deprecated no replacement
- * @since 1.4
- */
- @Deprecated
- public boolean isAboutMenuItemPresent() {
- return menuBarHandler.isAboutMenuItemVisible();
- }
-
- /**
- * Adds the About item to the application menu if the item is not already present.
- *
- * @deprecated use {@link #setAboutHandler(AboutHandler)} with a non-null {@link AboutHandler} parameter
- * @since 1.4
- */
- @Deprecated
- public void addAboutMenuItem() {
- menuBarHandler.setAboutMenuItemVisible(true);
- }
-
- /**
- * Removes the About item from the application menu if the item is present.
- *
- * @deprecated use {@link #setAboutHandler(AboutHandler)} with a null parameter
- * @since 1.4
- */
- @Deprecated
- public void removeAboutMenuItem() {
- menuBarHandler.setAboutMenuItemVisible(false);
- }
-
- /**
- * Determines if the About Preferences of the application menu is present. By default there is no Preferences menu item.
- *
- * @deprecated no replacement
- * @since 1.4
- */
- @Deprecated
- public boolean isPreferencesMenuItemPresent() {
- return menuBarHandler.isPreferencesMenuItemVisible();
- }
-
- /**
- * Adds the Preferences item to the application menu if the item is not already present.
- *
- * @deprecated use {@link #setPreferencesHandler(PreferencesHandler)} with a non-null {@link PreferencesHandler} parameter
- * @since 1.4
- */
- @Deprecated
- public void addPreferencesMenuItem() {
- menuBarHandler.setPreferencesMenuItemVisible(true);
- }
-
- /**
- * Removes the Preferences item from the application menu if that item is present.
- *
- * @deprecated use {@link #setPreferencesHandler(PreferencesHandler)} with a null parameter
- * @since 1.4
- */
- @Deprecated
- public void removePreferencesMenuItem() {
- menuBarHandler.setPreferencesMenuItemVisible(false);
- }
-
- /**
- * @deprecated Use {@code java.awt.MouseInfo.getPointerInfo().getLocation()}.
- *
- * @since 1.4
- */
- @Deprecated
- public static Point getMouseLocationOnScreen() {
- return java.awt.MouseInfo.getPointerInfo().getLocation();
- }
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
* @see ScreenSleepListener
* @see SystemSleepListener
*
- * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}.
+ * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse}.
* @since 1.4
*/
@SuppressWarnings("deprecation")
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
/**
* The class of events sent to the deprecated ApplicationListener callbacks.
*
- * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}
+ * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse}
* @since 1.4
*/
@Deprecated
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
* @see SystemSleepListener
*
* @since 1.4
- * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}
+ * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse}
*/
@SuppressWarnings("deprecation")
@Deprecated
@@ -134,7 +134,7 @@
* {@code event}. To reject the quit, set {@code isHandled(false)}.
*
* @param event a Quit Application event
- * @deprecated use {@link QuitHandler} and {@link QuitResponse}
+ * @deprecated use {@link QuitHandler} and {@link MacQuitResponse}
*/
@Deprecated
public void handleQuit(ApplicationEvent event);
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
package com.apple.eawt;
-import com.apple.eawt.AppEvent.FullScreenEvent;
+import com.apple.eawt.event.FullScreenEvent;
/**
* Abstract adapter class for receiving fullscreen events. This class is provided
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,13 @@
package com.apple.eawt;
+import com.apple.eawt.event.FullScreenEvent;
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.RootPaneContainer;
-import com.apple.eawt.AppEvent.FullScreenEvent;
import sun.awt.SunToolkit;
import java.lang.annotation.Native;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,9 @@
package com.apple.eawt;
+import com.apple.eawt.event.FullScreenEvent;
import java.util.EventListener;
-import com.apple.eawt.AppEvent.FullScreenEvent;
/**
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.apple.eawt;
+
+import java.awt.desktop.QuitResponse;
+
+/**
+ * Used to respond to a request to quit the application.
+ * The QuitResponse may be used after the {@link QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, MacQuitResponse)} method has returned, and may be used from any thread.
+ *
+ * @see Application#setQuitHandler(QuitHandler)
+ * @see QuitHandler
+ * @see Application#setQuitStrategy(QuitStrategy)
+ *
+ * @since Java for Mac OS X 10.6 Update 3
+ * @since Java for Mac OS X 10.5 Update 8
+ */
+public class MacQuitResponse implements QuitResponse {
+ final _AppEventHandler appEventHandler;
+
+ MacQuitResponse(final _AppEventHandler appEventHandler) {
+ this.appEventHandler = appEventHandler;
+ }
+
+ /**
+ * Notifies the external quit requester that the quit will proceed, and performs the default {@link QuitStrategy}.
+ */
+ @Override
+ public void performQuit() {
+ if (appEventHandler.currentQuitResponse != this) return;
+ appEventHandler.performQuit();
+ }
+
+ /**
+ * Notifies the external quit requester that the user has explicitly canceled the pending quit, and leaves the application running.
+ * <b>Note: this will cancel a pending log-out, restart, or shutdown.</b>
+ */
+ @Override
+ public void cancelQuit() {
+ if (appEventHandler.currentQuitResponse != this) return;
+ appEventHandler.cancelQuit();
+ }
+}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/OpenFilesHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.OpenFilesEvent;
-
-/**
- * An implementor is notified when the application is asked to open a list of files.
- * This message is only sent if the application has registered that it handles CFBundleDocumentTypes in it's Info.plist.
- *
- * @see Application#setOpenFileHandler(OpenFilesHandler)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface OpenFilesHandler {
- /**
- * Called when the application is asked to open a list of files.
- * @param e the request to open a list of files, and the search term used to find them, if any.
- */
- public void openFiles(final OpenFilesEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/OpenURIHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.OpenURIEvent;
-
-/**
- * An implementor is notified when the application is asked to open a URI.
- * The application only sends {@link com.apple.eawt.EAWTEvent.OpenURIEvent}s when it has been launched as a bundled Mac application, and it's Info.plist claims URL schemes in it's {@code CFBundleURLTypes} entry.
- * See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleURLTypes} key to your app's Info.plist.
- *
- * @see Application#setOpenURIHandler(OpenURIHandler)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface OpenURIHandler {
- /**
- * Called when the application is asked to open a URI
- * @param e the request to open a URI
- */
- public void openURI(final OpenURIEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/PreferencesHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.PreferencesEvent;
-
-/**
- * An implementor is notified when the app is asked to show it's preferences UI.
- *
- * @see Application#setPreferencesHandler(PreferencesHandler)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface PreferencesHandler {
- /**
- * Called when the app is asked to show it's preferences UI.
- * @param e the request to show preferences.
- */
- public void handlePreferences(final PreferencesEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/PrintFilesHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.PrintFilesEvent;
-
-/**
- * An implementor can respond to requests to print documents that the app has been registered to handle.
- *
- * @see Application#setPrintFileHandler(PrintFilesHandler)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface PrintFilesHandler {
- /**
- * Called when the application is asked to print a list of files.
- * @param e the request to print a list of files.
- */
- public void printFiles(final PrintFilesEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/QuitHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.QuitEvent;
-
-/**
- * An implementor determines if requests to quit this application should proceed or cancel.
- *
- * @see Application#setQuitHandler(QuitHandler)
- * @see Application#setQuitStrategy(QuitStrategy)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface QuitHandler {
- /**
- * Invoked when the application is asked to quit.
- *
- * Implementors must call either {@link QuitResponse#cancelQuit()}, {@link QuitResponse#performQuit()}, or ensure the application terminates.
- * The process (or log-out) requesting this app to quit will be blocked until the {@link QuitResponse} is handled.
- * Apps that require complex UI to shutdown may call the {@link QuitResponse} from any thread.
- * Your app may be asked to quit multiple times before you have responded to the initial request.
- * This handler is called each time a quit is requested, and the same {@link QuitResponse} object is passed until it is handled.
- * Once used, the {@link QuitResponse} cannot be used again to change the decision.
- *
- * @param e the request to quit this application.
- * @param response the one-shot response object used to cancel or proceed with the quit action.
- */
- public void handleQuitRequestWith(final QuitEvent e, final QuitResponse response);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/QuitResponse.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-/**
- * Used to respond to a request to quit the application.
- * The QuitResponse may be used after the {@link QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, QuitResponse)} method has returned, and may be used from any thread.
- *
- * @see Application#setQuitHandler(QuitHandler)
- * @see QuitHandler
- * @see Application#setQuitStrategy(QuitStrategy)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public class QuitResponse {
- final _AppEventHandler appEventHandler;
-
- QuitResponse(final _AppEventHandler appEventHandler) {
- this.appEventHandler = appEventHandler;
- }
-
- /**
- * Notifies the external quit requester that the quit will proceed, and performs the default {@link QuitStrategy}.
- */
- public void performQuit() {
- if (appEventHandler.currentQuitResponse != this) return;
- appEventHandler.performQuit();
- }
-
- /**
- * Notifies the external quit requester that the user has explicitly canceled the pending quit, and leaves the application running.
- * <b>Note: this will cancel a pending log-out, restart, or shutdown.</b>
- */
- public void cancelQuit() {
- if (appEventHandler.currentQuitResponse != this) return;
- appEventHandler.cancelQuit();
- }
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/QuitStrategy.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-/**
- * The strategy use to shut down the application, if Sudden Termination is not enabled.
- *
- * @see Application#setQuitHandler(QuitHandler)
- * @see Application#setQuitStrategy(QuitStrategy)
- * @see Application#enableSuddenTermination()
- * @see Application#disableSuddenTermination()
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public enum QuitStrategy {
- /**
- * Shuts down the application by calling {@code System.exit(0)}. This is the default strategy.
- */
- SYSTEM_EXIT_0,
-
- /**
- * Shuts down the application by closing each window from back-to-front.
- */
- CLOSE_ALL_WINDOWS
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ScreenSleepListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.ScreenSleepEvent;
-
-/**
- * Implementors receive notification when the displays attached to the system have entered power save sleep.
- *
- * This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
- *
- * This message is not sent on Mac OS X versions prior to 10.6.
- *
- * @see Application#addAppEventListener(AppEventListener)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface ScreenSleepListener extends AppEventListener {
- /**
- * Called when the system displays have entered power save sleep.
- * @param e the screen sleep event
- */
- public void screenAboutToSleep(final ScreenSleepEvent e);
-
- /**
- * Called when the system displays have awoke from power save sleep.
- * @param e the screen sleep event
- */
- public void screenAwoke(final ScreenSleepEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/SystemSleepListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.SystemSleepEvent;
-
-/**
- * Implementors receive notification as the system is entering sleep, and after the system wakes.
- *
- * This notification is useful for disconnecting from network services prior to sleep, or re-establishing a connection if the network configuration has changed during sleep.
- *
- * @see Application#addAppEventListener(AppEventListener)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface SystemSleepListener extends AppEventListener {
- /**
- * Called when the system is about to sleep.
- * Note: This message may not be delivered prior to the actual system sleep, and may be processed after the corresponding wake has occurred.
- * @param e the system sleep event
- */
- public void systemAboutToSleep(final SystemSleepEvent e);
-
- /**
- * Called after the system has awoke from sleeping.
- * @param e the system sleep event
- */
- public void systemAwoke(final SystemSleepEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/UserSessionListener.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import com.apple.eawt.AppEvent.UserSessionEvent;
-
-/**
- * Implementors receive notification when Fast User Switching changes the user session.
- *
- * This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
- *
- * @see Application#addAppEventListener(AppEventListener)
- *
- * @since Java for Mac OS X 10.6 Update 3
- * @since Java for Mac OS X 10.5 Update 8
- */
-public interface UserSessionListener extends AppEventListener {
- /**
- * Called when the user session has been switched away.
- * @param e the user session switch event
- */
- public void userSessionDeactivated(final UserSessionEvent e);
-
- /**
- * Called when the user session has been switched to.
- * @param e the user session switch event
- */
- public void userSessionActivated(final UserSessionEvent e);
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
class _AppDockIconHandler {
private static native void nativeSetDockMenu(final long cmenu);
private static native void nativeSetDockIconImage(final long image);
+ private static native void nativeSetDockIconProgress(final int value);
private static native long nativeGetDockIconImage();
private static native void nativeSetDockIconBadge(final String badge);
@@ -93,6 +94,10 @@
nativeSetDockIconBadge(badge);
}
+ void setDockIconProgress(int value) {
+ nativeSetDockIconProgress(value);
+ }
+
static Creator getCImageCreator() {
try {
final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class<?>[] {});
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,47 @@
package com.apple.eawt;
-import java.awt.*;
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.desktop.AboutEvent;
+import java.awt.desktop.AboutHandler;
+import java.awt.desktop.AppForegroundEvent;
+import java.awt.desktop.AppForegroundListener;
+import java.awt.desktop.AppHiddenEvent;
+import java.awt.desktop.AppHiddenListener;
+import java.awt.desktop.AppReopenedEvent;
+import java.awt.desktop.AppReopenedListener;
+import java.awt.desktop.OpenFilesEvent;
+import java.awt.desktop.OpenFilesHandler;
+import java.awt.desktop.OpenURIEvent;
+import java.awt.desktop.OpenURIHandler;
+import java.awt.desktop.PreferencesEvent;
+import java.awt.desktop.PreferencesHandler;
+import java.awt.desktop.PrintFilesEvent;
+import java.awt.desktop.PrintFilesHandler;
+import java.awt.desktop.QuitEvent;
+import java.awt.desktop.QuitHandler;
+import java.awt.desktop.QuitStrategy;
+import java.awt.desktop.ScreenSleepEvent;
+import java.awt.desktop.ScreenSleepListener;
+import java.awt.desktop.SystemEventListener;
+import java.awt.desktop.SystemSleepEvent;
+import java.awt.desktop.SystemSleepListener;
+import java.awt.desktop.UserSessionEvent;
+import java.awt.desktop.UserSessionEvent.Reason;
+import java.awt.desktop.UserSessionListener;
import java.awt.event.WindowEvent;
import java.io.File;
-import java.net.*;
-import java.util.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.IdentityHashMap;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
-import com.apple.eawt.AppEvent.*;
-
class _AppEventHandler {
private static final int NOTIFY_ABOUT = 1;
private static final int NOTIFY_PREFS = 2;
@@ -84,9 +114,7 @@
final _ScreenSleepDispatcher screenSleepDispatcher = new _ScreenSleepDispatcher();
final _SystemSleepDispatcher systemSleepDispatcher = new _SystemSleepDispatcher();
- final _AppEventLegacyHandler legacyHandler = new _AppEventLegacyHandler(this);
-
- QuitStrategy defaultQuitAction = QuitStrategy.SYSTEM_EXIT_0;
+ QuitStrategy defaultQuitAction = QuitStrategy.NORMAL_EXIT;
_AppEventHandler() {
final String strategyProp = System.getProperty("apple.eawt.quitStrategy");
@@ -94,15 +122,16 @@
if ("CLOSE_ALL_WINDOWS".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
- } else if ("SYSTEM_EXIT_O".equals(strategyProp)) {
- setDefaultQuitStrategy(QuitStrategy.SYSTEM_EXIT_0);
+ } else if ("SYSTEM_EXIT_O".equals(strategyProp)
+ || "NORMAL_EXIT".equals(strategyProp)) {
+ setDefaultQuitStrategy(QuitStrategy.NORMAL_EXIT);
} else {
System.err.println("unrecognized apple.eawt.quitStrategy: " + strategyProp);
}
}
- void addListener(final AppEventListener listener) {
- if (listener instanceof AppReOpenedListener) reOpenAppDispatcher.addListener((AppReOpenedListener)listener);
+ void addListener(final SystemEventListener listener) {
+ if (listener instanceof AppReopenedListener) reOpenAppDispatcher.addListener((AppReopenedListener)listener);
if (listener instanceof AppForegroundListener) foregroundAppDispatcher.addListener((AppForegroundListener)listener);
if (listener instanceof AppHiddenListener) hiddenAppDispatcher.addListener((AppHiddenListener)listener);
if (listener instanceof UserSessionListener) userSessionDispatcher.addListener((UserSessionListener)listener);
@@ -110,8 +139,8 @@
if (listener instanceof SystemSleepListener) systemSleepDispatcher.addListener((SystemSleepListener)listener);
}
- void removeListener(final AppEventListener listener) {
- if (listener instanceof AppReOpenedListener) reOpenAppDispatcher.removeListener((AppReOpenedListener)listener);
+ void removeListener(final SystemEventListener listener) {
+ if (listener instanceof AppReopenedListener) reOpenAppDispatcher.removeListener((AppReopenedListener)listener);
if (listener instanceof AppForegroundListener) foregroundAppDispatcher.removeListener((AppForegroundListener)listener);
if (listener instanceof AppHiddenListener) hiddenAppDispatcher.removeListener((AppHiddenListener)listener);
if (listener instanceof UserSessionListener) userSessionDispatcher.removeListener((UserSessionListener)listener);
@@ -127,10 +156,10 @@
this.defaultQuitAction = defaultQuitAction;
}
- QuitResponse currentQuitResponse;
- synchronized QuitResponse obtainQuitResponse() {
+ MacQuitResponse currentQuitResponse;
+ synchronized MacQuitResponse obtainQuitResponse() {
if (currentQuitResponse != null) return currentQuitResponse;
- return currentQuitResponse = new QuitResponse(this);
+ return currentQuitResponse = new MacQuitResponse(this);
}
synchronized void cancelQuit() {
@@ -142,7 +171,7 @@
currentQuitResponse = null;
try {
- if (defaultQuitAction == QuitStrategy.SYSTEM_EXIT_0) System.exit(0);
+ if (defaultQuitAction == QuitStrategy.NORMAL_EXIT) System.exit(0);
if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
throw new RuntimeException("Unknown quit action");
@@ -270,10 +299,10 @@
}
}
- class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReOpenedListener> {
- void performOnListener(AppReOpenedListener listener, final _NativeEvent event) {
- final AppReOpenedEvent e = new AppReOpenedEvent();
- listener.appReOpened(e);
+ class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReopenedListener> {
+ void performOnListener(AppReopenedListener listener, final _NativeEvent event) {
+ final AppReopenedEvent e = new AppReopenedEvent();
+ listener.appReopened(e);
}
}
@@ -302,7 +331,9 @@
}
class _UserSessionDispatcher extends _BooleanAppEventMultiplexor<UserSessionListener, UserSessionEvent> {
- UserSessionEvent createEvent(final boolean isTrue) { return new UserSessionEvent(); }
+ UserSessionEvent createEvent(final boolean isTrue) {
+ return new UserSessionEvent(Reason.UNSPECIFIED);
+ }
void performFalseEventOn(final UserSessionListener listener, final UserSessionEvent e) {
listener.userSessionDeactivated(e);
@@ -391,7 +422,7 @@
}
void performUsing(final QuitHandler handler, final _NativeEvent event) {
- final QuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
+ final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
handler.handleQuitRequestWith(new QuitEvent(), response);
}
}
@@ -524,9 +555,6 @@
setHandlerContext(AppContext.getAppContext());
- // if a new handler is installed, block addition of legacy ApplicationListeners
- if (handler == legacyHandler) return;
- legacyHandler.blockLegacyAPI();
}
void performDefaultAction(final _NativeEvent event) { } // by default, do nothing
@@ -574,10 +602,6 @@
}
}
}
-
- // if a new handler is installed, block addition of legacy ApplicationListeners
- if (handler == legacyHandler) return;
- legacyHandler.blockLegacyAPI();
}
}
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventLegacyHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.apple.eawt;
-
-import java.awt.Toolkit;
-import java.io.File;
-import java.util.*;
-
-import com.apple.eawt.AppEvent.*;
-
-@SuppressWarnings("deprecation")
-class _AppEventLegacyHandler implements AboutHandler, PreferencesHandler, _OpenAppHandler, AppReOpenedListener, OpenFilesHandler, PrintFilesHandler, QuitHandler {
- final _AppEventHandler parent;
- final Vector<ApplicationListener> legacyAppListeners = new Vector<ApplicationListener>();
- boolean blockLegacyAPI;
- boolean initializedParentDispatchers;
-
- _AppEventLegacyHandler(final _AppEventHandler parent) {
- this.parent = parent;
- }
-
- void blockLegacyAPI() {
- blockLegacyAPI = true;
- }
-
- void checkIfLegacyAPIBlocked() {
- if (!blockLegacyAPI) return;
- throw new IllegalStateException("Cannot add com.apple.eawt.ApplicationListener after installing an app event handler");
- }
-
- void addLegacyAppListener(final ApplicationListener listener) {
- checkIfLegacyAPIBlocked();
-
- if (!initializedParentDispatchers) {
- final _AppMenuBarHandler menuBarHandler = Application.getApplication().menuBarHandler;
- final boolean prefsMenuAlreadyExplicitlySet = menuBarHandler.prefsMenuItemExplicitlySet;
-
- parent.aboutDispatcher.setHandler(this);
- parent.preferencesDispatcher.setHandler(this);
- if (!prefsMenuAlreadyExplicitlySet) {
- menuBarHandler.setPreferencesMenuItemVisible(false); // default behavior is not to have a preferences item
- }
- parent.openAppDispatcher.setHandler(this);
- parent.reOpenAppDispatcher.addListener(this);
- parent.openFilesDispatcher.setHandler(this);
- parent.printFilesDispatcher.setHandler(this);
- parent.quitDispatcher.setHandler(this);
-
- initializedParentDispatchers = true;
- }
-
- synchronized (legacyAppListeners) {
- legacyAppListeners.addElement(listener);
- }
- }
-
- public void removeLegacyAppListener(final ApplicationListener listener) {
- checkIfLegacyAPIBlocked();
-
- synchronized (legacyAppListeners) {
- legacyAppListeners.removeElement(listener);
- }
- }
-
- @Override
- public void handleAbout(final AboutEvent e) {
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handleAbout(ae);
- }
- });
-
- if (ae.isHandled()) return;
- parent.openCocoaAboutWindow();
- }
-
- @Override
- public void handlePreferences(final PreferencesEvent e) {
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handlePreferences(ae);
- }
- });
- }
-
- @Override
- public void handleOpenApp() {
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handleOpenApplication(ae);
- }
- });
- }
-
- @Override
- public void appReOpened(final AppReOpenedEvent e) {
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handleReOpenApplication(ae);
- }
- });
- }
-
- @Override
- public void openFiles(final OpenFilesEvent e) {
- final List<File> files = e.getFiles();
- for (final File file : files) { // legacy ApplicationListeners only understood one file at a time
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handleOpenFile(ae);
- }
- });
- }
- }
-
- @Override
- public void printFiles(PrintFilesEvent e) {
- final List<File> files = e.getFiles();
- for (final File file : files) { // legacy ApplicationListeners only understood one file at a time
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handlePrintFile(ae);
- }
- });
- }
- }
-
- @Override
- public void handleQuitRequestWith(final QuitEvent e, final QuitResponse response) {
- final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
- sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
- public void dispatchEvent(final ApplicationListener listener) {
- listener.handleQuit(ae);
- }
- });
-
- if (ae.isHandled()) {
- parent.performQuit();
- } else {
- parent.cancelQuit();
- }
- }
-
- interface EventDispatcher {
- void dispatchEvent(final ApplicationListener listener);
- }
-
- // helper that cycles through the loop and aborts if the event is handled, or there are no listeners
- void sendEventToEachListenerUntilHandled(final ApplicationEvent event, final EventDispatcher dispatcher) {
- synchronized (legacyAppListeners) {
- if (legacyAppListeners.size() == 0) return;
-
- final Enumeration<ApplicationListener> e = legacyAppListeners.elements();
- while (e.hasMoreElements() && !event.isHandled()) {
- dispatcher.dispatchEvent(e.nextElement());
- }
- }
- }
-}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
package com.apple.eawt;
import java.awt.Frame;
-import java.awt.peer.MenuComponentPeer;
import javax.swing.*;
import javax.swing.plaf.MenuBarUI;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/FullScreenEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.apple.eawt.event;
+
+import com.apple.eawt.Application;
+import java.awt.Window;
+import java.util.EventObject;
+
+@SuppressWarnings("serial") // JDK implementation class
+public class FullScreenEvent extends EventObject {
+
+ final Window window;
+
+ /**
+ * @param window window
+ */
+ public FullScreenEvent(final Window window) {
+ super(Application.getApplication());
+ this.window = window;
+ }
+
+ /**
+ * @return window transitioning between full screen states
+ */
+ public Window getWindow() {
+ return window;
+ }
+}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -371,6 +371,11 @@
}
@Override
+ public final boolean isTaskbarSupported() {
+ return true;
+ }
+
+ @Override
public final KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
return LWKeyboardFocusManagerPeer.getInstance();
}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,14 @@
package sun.lwawt.macosx;
+import com.apple.eawt.Application;
+
+import javax.swing.*;
import java.awt.Desktop.Action;
+import java.awt.desktop.*;
import java.awt.peer.DesktopPeer;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
@@ -37,34 +42,126 @@
*
* @see DesktopPeer
*/
-public class CDesktopPeer implements DesktopPeer {
+final public class CDesktopPeer implements DesktopPeer {
+ @Override
public boolean isSupported(Action action) {
- // OPEN, EDIT, PRINT, MAIL, BROWSE all supported.
- // Though we don't really differentiate between OPEN / EDIT
return true;
}
+ @Override
public void open(File file) throws IOException {
this.lsOpenFile(file, false);
}
+ @Override
public void edit(File file) throws IOException {
this.lsOpenFile(file, false);
}
+ @Override
public void print(File file) throws IOException {
this.lsOpenFile(file, true);
}
+ @Override
public void mail(URI uri) throws IOException {
this.lsOpen(uri);
}
+ @Override
public void browse(URI uri) throws IOException {
this.lsOpen(uri);
}
+ @Override
+ public void addAppEventListener(SystemEventListener listener) {
+ Application.getApplication().addAppEventListener(listener);
+ }
+
+ @Override
+ public void removeAppEventListener(SystemEventListener listener) {
+ Application.getApplication().removeAppEventListener(listener);
+ }
+
+ @Override
+ public void setAboutHandler(AboutHandler aboutHandler) {
+ Application.getApplication().setAboutHandler(aboutHandler);
+ }
+
+ @Override
+ public void setPreferencesHandler(PreferencesHandler preferencesHandler) {
+ Application.getApplication().setPreferencesHandler(preferencesHandler);
+ }
+
+ @Override
+ public void setOpenFileHandler(OpenFilesHandler openFileHandler) {
+ Application.getApplication().setOpenFileHandler(openFileHandler);
+ }
+
+ @Override
+ public void setPrintFileHandler(PrintFilesHandler printFileHandler) {
+ Application.getApplication().setPrintFileHandler(printFileHandler);
+ }
+
+ @Override
+ public void setOpenURIHandler(OpenURIHandler openURIHandler) {
+ Application.getApplication().setOpenURIHandler(openURIHandler);
+ }
+
+ @Override
+ public void setQuitHandler(QuitHandler quitHandler) {
+ Application.getApplication().setQuitHandler(quitHandler);
+ }
+
+ @Override
+ public void setQuitStrategy(QuitStrategy strategy) {
+ Application.getApplication().setQuitStrategy(strategy);
+ }
+
+ @Override
+ public void enableSuddenTermination() {
+ Application.getApplication().enableSuddenTermination();
+ }
+
+ @Override
+ public void disableSuddenTermination() {
+ Application.getApplication().disableSuddenTermination();
+ }
+
+ @Override
+ public void requestForeground(boolean allWindows) {
+ Application.getApplication().requestForeground(allWindows);
+ }
+
+ @Override
+ public void openHelpViewer() {
+ Application.getApplication().openHelpViewer();
+ }
+
+ @Override
+ public void setDefaultMenuBar(JMenuBar menuBar) {
+ Application.getApplication().setDefaultMenuBar(menuBar);
+ }
+
+ @Override
+ public boolean browseFileDirectory(File file) {
+ try {
+ return com.apple.eio.FileManager.revealInFinder(file);
+ } catch (FileNotFoundException ex) {
+ return false; //handled in java.awt.Desktop
+ }
+ }
+
+ @Override
+ public boolean moveToTrash(File file) {
+ try {
+ return com.apple.eio.FileManager.moveToTrash(file);
+ } catch (FileNotFoundException ex) {
+ return false; //handled in java.awt.Desktop
+ }
+ }
+
private void lsOpen(URI uri) throws IOException {
int status = _lsOpenURI(uri.toString());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTaskbarPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.lwawt.macosx;
+
+import com.apple.eawt.Application;
+import java.awt.Image;
+import java.awt.PopupMenu;
+import java.awt.Taskbar.Feature;
+import java.awt.peer.TaskbarPeer;
+
+final public class CTaskbarPeer implements TaskbarPeer {
+
+ CTaskbarPeer() {}
+
+ @Override
+ public boolean isSupported(Feature feature) {
+ switch(feature) {
+ case ICON_BADGE_TEXT:
+ case ICON_BADGE_NUMBER:
+ case ICON_IMAGE:
+ case MENU:
+ case PROGRESS_VALUE:
+ case USER_ATTENTION:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public void setProgressValue(int value) {
+ Application.getApplication().setDockIconProgress(value);
+ }
+
+ @Override
+ public void setIconBadge(String badge) {
+ Application.getApplication().setDockIconBadge(badge);
+ }
+
+ @Override
+ public Image getIconImage() {
+ return Application.getApplication().getDockIconImage();
+ }
+
+ @Override
+ public void setIconImage(Image image) {
+ Application.getApplication().setDockIconImage(image);
+ }
+
+ @Override
+ public PopupMenu getMenu() {
+ return Application.getApplication().getDockMenu();
+ }
+
+ @Override
+ public void setMenu(PopupMenu menu) {
+ Application.getApplication().setDockMenu(menu);
+ }
+
+ @Override
+ public void requestUserAttention(boolean enabled, boolean critical) {
+ if (enabled) {
+ Application.getApplication().requestUserAttention(critical);
+ }
+ }
+}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package sun.lwawt.macosx;
+import java.awt.peer.TaskbarPeer;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.*;
@@ -294,6 +295,11 @@
}
@Override
+ public TaskbarPeer createTaskbarPeer(Taskbar target) {
+ return new CTaskbarPeer();
+ }
+
+ @Override
public LWCursorManager getCursorManager() {
return CCursorManager.getInstance();
}
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.h Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.h Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,8 @@
NSMenu *fDockMenu;
CMenuBar *fDefaultMenuBar;
+ NSProgressIndicator *fProgressIndicator;
+
BOOL fHandlesDocumentTypes;
BOOL fHandlesURLTypes;
}
@@ -47,6 +49,8 @@
@property (nonatomic, retain) NSMenuItem *fPreferencesMenu;
@property (nonatomic, retain) NSMenuItem *fAboutMenu;
+@property (nonatomic, retain) NSProgressIndicator *fProgressIndicator;
+
@property (nonatomic, retain) NSMenu *fDockMenu;
@property (nonatomic, retain) CMenuBar *fDefaultMenuBar;
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -100,6 +100,7 @@
@synthesize fPreferencesMenu;
@synthesize fAboutMenu;
+@synthesize fProgressIndicator;
@synthesize fDockMenu;
@synthesize fDefaultMenuBar;
@@ -200,6 +201,18 @@
self.fPreferencesMenu = (NSMenuItem*)[appMenu itemWithTag:PREFERENCES_TAG];
self.fAboutMenu = (NSMenuItem*)[appMenu itemAtIndex:0];
+
+ NSDockTile *dockTile = [NSApp dockTile];
+ self.fProgressIndicator = [[NSProgressIndicator alloc]
+ initWithFrame:NSMakeRect(3.f, 0.f, dockTile.size.width - 6.f, 20.f)];
+
+ [fProgressIndicator setStyle:NSProgressIndicatorBarStyle];
+ [fProgressIndicator setIndeterminate:NO];
+ [[dockTile contentView] addSubview:fProgressIndicator];
+ [fProgressIndicator setMinValue:0];
+ [fProgressIndicator setMaxValue:100];
+ [fProgressIndicator setHidden:YES];
+ [fProgressIndicator release];
// If the java application has a bundle with an Info.plist file with
// a CFBundleDocumentTypes entry, then it is set up to handle Open Doc
@@ -252,6 +265,7 @@
self.fAboutMenu = nil;
self.fDockMenu = nil;
self.fDefaultMenuBar = nil;
+ self.fProgressIndicator = nil;
[super dealloc];
}
@@ -468,6 +482,9 @@
[dockImageView setImageScaling:NSImageScaleProportionallyUpOrDown];
[dockImageView setImage:image];
+ [[ApplicationDelegate sharedDelegate].fProgressIndicator removeFromSuperview];
+ [dockImageView addSubview:[ApplicationDelegate sharedDelegate].fProgressIndicator];
+
// add it to the NSDockTile
[dockTile setContentView: dockImageView];
[dockTile display];
@@ -475,6 +492,20 @@
[dockImageView release];
}
++ (void)_setDockIconProgress:(NSNumber *)value {
+AWT_ASSERT_APPKIT_THREAD;
+
+ ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate];
+ if ([value doubleValue] >= 0 && [value doubleValue] <=100) {
+ [delegate.fProgressIndicator setDoubleValue:[value doubleValue]];
+ [delegate.fProgressIndicator setHidden:NO];
+ } else {
+ [delegate.fProgressIndicator setHidden:YES];
+ }
+
+ [[NSApp dockTile] display];
+}
+
// Obtains the image of the Dock icon, either manually set, a drawn copy, or the default NSApplicationIcon
+ (NSImage *)_dockIconImage {
AWT_ASSERT_APPKIT_THREAD;
@@ -610,6 +641,24 @@
/*
* Class: com_apple_eawt__AppDockIconHandler
+ * Method: nativeSetDockIconProgress
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconProgress
+ (JNIEnv *env, jclass clz, jint value)
+{
+ JNF_COCOA_ENTER(env);
+
+ [ThreadUtilities performOnMainThread:@selector(_setDockIconProgress:)
+ on:[ApplicationDelegate class]
+ withObject:[NSNumber numberWithInt:value]
+ waitUntilDone:NO];
+
+ JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class: com_apple_eawt__AppDockIconHandler
* Method: nativeGetDockIconImage
* Signature: ()J
*/
--- a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,14 @@
package java.awt;
+import java.awt.desktop.AboutHandler;
+import java.awt.desktop.OpenFilesHandler;
+import java.awt.desktop.OpenURIHandler;
+import java.awt.desktop.PreferencesHandler;
+import java.awt.desktop.PrintFilesHandler;
+import java.awt.desktop.QuitHandler;
+import java.awt.desktop.QuitStrategy;
+import java.awt.desktop.SystemEventListener;
import java.awt.peer.DesktopPeer;
import java.io.File;
import java.io.FilePermission;
@@ -35,12 +43,11 @@
import java.net.URL;
import sun.awt.SunToolkit;
+import javax.swing.JMenuBar;
import sun.security.util.SecurityConstants;
/**
- * The {@code Desktop} class allows a Java application to launch
- * associated applications registered on the native desktop to handle
- * a {@link java.net.URI} or a file.
+ * The {@code Desktop} class allows interact with various desktop capabilities.
*
* <p> Supported operations include:
* <ul>
@@ -58,9 +65,11 @@
* or file. If there is no associated application or the associated
* application fails to be launched, an exception is thrown.
*
- * <p> An application is registered to a URI or file type; for
- * example, the {@code "sxi"} file extension is typically registered
- * to StarOffice. The mechanism of registering, accessing, and
+ * Please see {@link Desktop.Action} for the full list of supported operations
+ * and capabilities.
+ *
+ * <p> An application is registered to a URI or file type.
+ * The mechanism of registering, accessing, and
* launching the associated application is platform-dependent.
*
* <p> Each operation is an action type represented by the {@link
@@ -70,6 +79,8 @@
* application is executed, it will be executed on the same system as
* the one on which the Java application was launched.
*
+ * @see Action
+ *
* @since 1.6
* @author Armin Chen
* @author George Zhang
@@ -106,11 +117,145 @@
* @see Desktop#mail(java.net.URI)
*/
MAIL,
+
/**
* Represents a "browse" action.
* @see Desktop#browse(java.net.URI)
*/
- BROWSE
+ BROWSE,
+
+ /**
+ * Represents an AppForegroundListener
+ * @see java.awt.desktop.AppForegroundListener
+ * @since 9
+ */
+ APP_EVENT_FOREGROUND,
+
+ /**
+ * Represents an AppHiddenListener
+ * @see java.awt.desktop.AppHiddenListener
+ * @since 9
+ */
+ APP_EVENT_HIDDEN,
+
+ /**
+ * Represents an AppReopenedListener
+ * @see java.awt.desktop.AppReopenedListener
+ * @since 9
+ */
+ APP_EVENT_REOPENED,
+
+ /**
+ * Represents a ScreenSleepListener
+ * @see java.awt.desktop.ScreenSleepListener
+ * @since 9
+ */
+ APP_EVENT_SCREEN_SLEEP,
+
+ /**
+ * Represents a SystemSleepListener
+ * @see java.awt.desktop.SystemSleepListener
+ * @since 9
+ */
+ APP_EVENT_SYSTEM_SLEEP,
+
+ /**
+ * Represents a UserSessionListener
+ * @see java.awt.desktop.UserSessionListener
+ * @since 9
+ */
+ APP_EVENT_USER_SESSION,
+
+ /**
+ * Represents an AboutHandler
+ * @see #setAboutHandler(java.awt.desktop.AboutHandler)
+ * @since 9
+ */
+ APP_ABOUT,
+
+ /**
+ * Represents a PreferencesHandler
+ * @see #setPreferencesHandler(java.awt.desktop.PreferencesHandler)
+ * @since 9
+ */
+ APP_PREFERENCES,
+
+ /**
+ * Represents an OpenFilesHandler
+ * @see #setOpenFileHandler(java.awt.desktop.OpenFilesHandler)
+ * @since 9
+ */
+ APP_OPEN_FILE,
+
+ /**
+ * Represents a PrintFilesHandler
+ * @see #setPrintFileHandler(java.awt.desktop.PrintFilesHandler)
+ * @since 9
+ */
+ APP_PRINT_FILE,
+
+ /**
+ * Represents an OpenURIHandler
+ * @see #setOpenURIHandler(java.awt.desktop.OpenURIHandler)
+ * @since 9
+ */
+ APP_OPEN_URI,
+
+ /**
+ * Represents a QuitHandler
+ * @see #setQuitHandler(java.awt.desktop.QuitHandler)
+ * @since 9
+ */
+ APP_QUIT_HANDLER,
+
+ /**
+ * Represents a QuitStrategy
+ * @see #setQuitStrategy(java.awt.desktop.QuitStrategy)
+ * @since 9
+ */
+ APP_QUIT_STRATEGY,
+
+ /**
+ * Represents a SuddenTermination
+ * @see #enableSuddenTermination()
+ * @since 9
+ */
+ APP_SUDDEN_TERMINATION,
+
+ /**
+ * Represents a requestForeground
+ * @see #requestForeground(boolean)
+ * @since 9
+ */
+ APP_REQUEST_FOREGROUND,
+
+ /**
+ * Represents a HelpViewer
+ * @see #openHelpViewer()
+ * @since 9
+ */
+ APP_HELP_VIEWER,
+
+ /**
+ * Represents a menu bar
+ * @see #setDefaultMenuBar(javax.swing.JMenuBar)
+ * @since 9
+ */
+ APP_MENU_BAR,
+
+ /**
+ * Represents a browse file directory
+ * @see #browseFileDirectory(java.io.File)
+ * @since 9
+ */
+ BROWSE_FILE_DIR,
+
+ /**
+ * Represents a move to trash
+ * @see #moveToTrash(java.io.File)
+ * @since 9
+ */
+ MOVE_TO_TRASH
};
private DesktopPeer peer;
@@ -128,10 +273,10 @@
/**
* Returns the {@code Desktop} instance of the current
- * browser context. On some platforms the Desktop API may not be
+ * desktop context. On some platforms the Desktop API may not be
* supported; use the {@link #isDesktopSupported} method to
* determine if the current desktop is supported.
- * @return the Desktop instance of the current browser context
+ * @return the Desktop instance
* @throws HeadlessException if {@link
* GraphicsEnvironment#isHeadless()} returns {@code true}
* @throws UnsupportedOperationException if this class is not
@@ -208,7 +353,7 @@
if (!file.exists()) {
throw new IllegalArgumentException("The file: "
- + file.getPath() + " doesn't exist.");
+ + file.getPath() + " doesn't exist.");
}
file.canRead();
@@ -224,7 +369,7 @@
private void checkActionSupport(Action actionType){
if (!isSupported(actionType)) {
throw new UnsupportedOperationException("The " + actionType.name()
- + " action is not supported on the current platform!");
+ + " action is not supported on the current platform!");
}
}
@@ -238,7 +383,7 @@
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new AWTPermission(
- "showWindowWithoutWarningBanner"));
+ "showWindowWithoutWarningBanner"));
}
}
@@ -479,7 +624,409 @@
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new FilePermission("<<ALL FILES>>",
- SecurityConstants.FILE_EXECUTE_ACTION));
+ SecurityConstants.FILE_EXECUTE_ACTION));
+ }
+ }
+
+ private void checkRead() throws SecurityException {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new FilePermission("<<ALL FILES>>",
+ SecurityConstants.FILE_READ_ACTION));
+ }
+ }
+
+ private void checkDelete() throws SecurityException {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new FilePermission("<<ALL FILES>>",
+ SecurityConstants.FILE_DELETE_ACTION));
+ }
+ }
+
+ private void checkQuitPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkExit(0);
}
}
+
+ /**
+ * Adds sub-types of {@link SystemEventListener} to listen for notifications
+ * from the native system.
+ *
+ * Has no effect if SystemEventListener's sub-type is unsupported on the current
+ * platform.
+ *
+ * @param listener listener
+ *
+ * @throws SecurityException if a security manager exists and it
+ * denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission
+ *
+ * @see java.awt.desktop.AppForegroundListener
+ * @see java.awt.desktop.AppHiddenListener
+ * @see java.awt.desktop.AppReopenedListener
+ * @see java.awt.desktop.ScreenSleepListener
+ * @see java.awt.desktop.SystemSleepListener
+ * @see java.awt.desktop.UserSessionListener
+ * @since 9
+ */
+ public void addAppEventListener(final SystemEventListener listener) {
+ checkAWTPermission();
+ peer.addAppEventListener(listener);
+ }
+
+ /**
+ * Removes sub-types of {@link SystemEventListener} to listen for notifications
+ * from the native system.
+ *
+ * Has no effect if SystemEventListener's sub-type is unsupported on the current
+ * platform.
+ *
+ * @param listener listener
+ *
+ * @throws SecurityException if a security manager exists and it
+ * denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission
+ *
+ * @see java.awt.desktop.AppForegroundListener
+ * @see java.awt.desktop.AppHiddenListener
+ * @see java.awt.desktop.AppReopenedListener
+ * @see java.awt.desktop.ScreenSleepListener
+ * @see java.awt.desktop.SystemSleepListener
+ * @see java.awt.desktop.UserSessionListener
+ * @since 9
+ */
+ public void removeAppEventListener(final SystemEventListener listener) {
+ checkAWTPermission();
+ peer.removeAppEventListener(listener);
+ }
+
+ /**
+ * Installs a handler to show a custom About window for your application.
+ * <p>
+ * Setting the {@link java.awt.desktop.AboutHandler} to {@code null} reverts it to the
+ * default behavior.
+ *
+ * @param aboutHandler the handler to respond to the
+ * {@link java.awt.desktop.AboutHandler#handleAbout} )} message
+ *
+ * @throws SecurityException if a security manager exists and it
+ * denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_ABOUT} action
+ *
+ * @since 9
+ */
+ public void setAboutHandler(final AboutHandler aboutHandler) {
+ checkAWTPermission();
+ checkActionSupport(Action.APP_ABOUT);
+ peer.setAboutHandler(aboutHandler);
+ }
+
+ /**
+ * Installs a handler to show a custom Preferences window for your
+ * application.
+ * <p>
+ * Setting the {@link PreferencesHandler} to {@code null} reverts it to
+ * the default behavior
+ *
+ * @param preferencesHandler the handler to respond to the
+ * {@link PreferencesHandler#handlePreferences(PreferencesEvent)}
+ *
+ * @throws SecurityException if a security manager exists and it
+ * denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_PREFERENCES} action
+ * @since 9
+ */
+ public void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
+ checkAWTPermission();
+ checkActionSupport(Action.APP_PREFERENCES);
+ peer.setPreferencesHandler(preferencesHandler);
+ }
+
+ /**
+ * Installs the handler which is notified when the application is asked to
+ * open a list of files.
+ *
+ * @implNote Please note that for Mac OS, notifications
+ * are only sent if the Java app is a bundled application,
+ * with a {@code CFBundleDocumentTypes} array present in its
+ * Info.plist. See the
+ * <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">
+ * Info.plist Key Reference</a> for more information about adding a
+ * {@code CFBundleDocumentTypes} key to your app's Info.plist.
+ *
+ * @param openFileHandler handler
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@link java.lang.SecurityManager#checkRead(java.lang.String)}
+ * method denies read access to the files, or it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission, or the calling thread is not allowed to create a
+ * subprocess
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_OPEN_FILE} action
+ * @since 9
+ */
+ public void setOpenFileHandler(final OpenFilesHandler openFileHandler) {
+ checkAWTPermission();
+ checkExec();
+ checkRead();
+ checkActionSupport(Action.APP_OPEN_FILE);
+ peer.setOpenFileHandler(openFileHandler);
+ }
+
+ /**
+ * Installs the handler which is notified when the application is asked to
+ * print a list of files.
+ *
+ * @implNote Please note that for Mac OS, notifications
+ * are only sent if the Java app is a bundled application,
+ * with a {@code CFBundleDocumentTypes} array present in its
+ * Info.plist. See the
+ * <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">
+ * Info.plist Key Reference</a> for more information about adding a
+ * {@code CFBundleDocumentTypes} key to your app's Info.plist.
+ *
+ * @param printFileHandler handler
+ * @throws SecurityException if a security manager exists and its
+ * {@link java.lang.SecurityManager#checkPrintJobAccess()} method denies
+ * the permission to print.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_PRINT_FILE} action
+ * @since 9
+ */
+ public void setPrintFileHandler(final PrintFilesHandler printFileHandler) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPrintJobAccess();
+ }
+ checkActionSupport(Action.APP_PRINT_FILE);
+ peer.setPrintFileHandler(printFileHandler);
+ }
+
+ /**
+ * Installs the handler which is notified when the application is asked to
+ * open a URL.
+ *
+ * Setting the handler to {@code null} causes all
+ * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be
+ * enqueued until another handler is set.
+ *
+ * @implNote Please note that for Mac OS, notifications
+ * are only sent if the Java app is a bundled application,
+ * with a {@code CFBundleDocumentTypes} array present in its
+ * Info.plist. See the
+ * <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">
+ * Info.plist Key Reference</a> for more information about adding a
+ * {@code CFBundleDocumentTypes} key to your app's Info.plist.
+ *
+ * @param openURIHandler handler
+ *
+ * {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission, or the calling thread is not allowed to create a
+ * subprocess
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_OPEN_URI} action
+ * @since 9
+ */
+ public void setOpenURIHandler(final OpenURIHandler openURIHandler) {
+ checkAWTPermission();
+ checkExec();
+ checkActionSupport(Action.APP_OPEN_URI);
+ peer.setOpenURIHandler(openURIHandler);
+ }
+
+ /**
+ * Installs the handler which determines if the application should quit. The
+ * handler is passed a one-shot {@link java.awt.desktop.QuitResponse} which can cancel or
+ * proceed with the quit. Setting the handler to {@code null} causes
+ * all quit requests to directly perform the default {@link QuitStrategy}.
+ *
+ * @param quitHandler the handler that is called when the application is
+ * asked to quit
+ *
+ * @throws SecurityException if a security manager exists and it
+ * will not allow the caller to invoke {@code System.exit}
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_QUIT_HANDLER} action
+ * @since 9
+ */
+ public void setQuitHandler(final QuitHandler quitHandler) {
+ checkQuitPermission();
+ checkActionSupport(Action.APP_QUIT_HANDLER);
+ peer.setQuitHandler(quitHandler);
+ }
+
+ /**
+ * Sets the default strategy used to quit this application. The default is
+ * calling SYSTEM_EXIT_0.
+ *
+ * @param strategy the way this application should be shutdown
+ *
+ * @throws SecurityException if a security manager exists and it
+ * will not allow the caller to invoke {@code System.exit}
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action
+ * @see QuitStrategy
+ * @since 9
+ */
+ public void setQuitStrategy(final QuitStrategy strategy) {
+ checkQuitPermission();
+ checkActionSupport(Action.APP_QUIT_STRATEGY);
+ peer.setQuitStrategy(strategy);
+ }
+
+ /**
+ * Enables this application to be suddenly terminated.
+ *
+ * Call this method to indicate your application's state is saved, and
+ * requires no notification to be terminated. Letting your application
+ * remain terminatable improves the user experience by avoiding re-paging in
+ * your application when it's asked to quit.
+ *
+ * <b>Note: enabling sudden termination will allow your application to be
+ * quit without notifying your QuitHandler, or running any shutdown
+ * hooks.</b>
+ * E.g. user-initiated Cmd-Q, logout, restart, or shutdown requests will
+ * effectively "kill -KILL" your application.
+ *
+ * @throws SecurityException if a security manager exists and it
+ * will not allow the caller to invoke {@code System.exit}
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action
+ * @see #disableSuddenTermination()
+ * @since 9
+ */
+ public void enableSuddenTermination() {
+ checkQuitPermission();
+ checkActionSupport(Action.APP_SUDDEN_TERMINATION);
+ peer.enableSuddenTermination();
+ }
+
+ /**
+ * Prevents this application from being suddenly terminated.
+ *
+ * Call this method to indicate that your application has unsaved state, and
+ * may not be terminated without notification.
+ *
+ * @throws SecurityException if a security manager exists and it
+ * will not allow the caller to invoke {@code System.exit}
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action
+ * @see #enableSuddenTermination()
+ * @since 9
+ */
+ public void disableSuddenTermination() {
+ checkQuitPermission();
+ checkActionSupport(Action.APP_SUDDEN_TERMINATION);
+ peer.disableSuddenTermination();
+ }
+
+ /**
+ * Requests this application to move to the foreground.
+ *
+ * @param allWindows if all windows of this application should be moved to
+ * the foreground, or only the foremost one
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_REQUEST_FOREGROUND} action
+ * @since 9
+ */
+ public void requestForeground(final boolean allWindows) {
+ checkAWTPermission();
+ checkActionSupport(Action.APP_REQUEST_FOREGROUND);
+ peer.requestForeground(allWindows);
+ }
+
+ /**
+ * Opens the native help viewer application.
+ *
+ * @implNote Please note that for Mac OS, it opens the native help viewer
+ * application if a Help Book has been added to the application bundler
+ * and registered in the Info.plist with CFBundleHelpBookFolder
+ *
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_HELP_VIEWER} action
+ * @since 9
+ */
+ public void openHelpViewer() {
+ checkAWTPermission();
+ checkActionSupport(Action.APP_HELP_VIEWER);
+ peer.openHelpViewer();
+ }
+
+ /**
+ * Sets the default menu bar to use when there are no active frames.
+ *
+ * @implNote Aqua Look and Feel should be active to support this on Mac OS.
+ *
+ * @param menuBar to use when no other frames are active
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_MENU_BAR} action
+ * @since 9
+ */
+ public void setDefaultMenuBar(final JMenuBar menuBar) {
+ checkAWTPermission();
+ checkActionSupport(Action.APP_MENU_BAR);
+ peer.setDefaultMenuBar(menuBar);
+ }
+
+ /**
+ * Opens a folder containing the {@code file} and selects it
+ * in a default system file manager.
+ * @param file the file
+ * @throws SecurityException If a security manager exists and its
+ * {@link SecurityManager#checkRead(java.lang.String)} method
+ * denies read access to the file
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#BROWSE_FILE_DIR} action
+ * @throws NullPointerException if {@code file} is {@code null}
+ * @throws IllegalArgumentException if the specified file doesn't
+ * exist
+ * @since 9
+ */
+ public void browseFileDirectory(File file) {
+ checkRead();
+ checkActionSupport(Action.BROWSE_FILE_DIR);
+ checkFileValidation(file);
+ peer.browseFileDirectory(file);
+ }
+
+ /**
+ * Moves the specified file to the trash.
+ *
+ * @param file the file
+ * @return returns true if successfully moved the file to the trash.
+ * @throws SecurityException If a security manager exists and its
+ * {@link SecurityManager#checkWrite(java.lang.String)} method
+ * denies write access to the file
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#MOVE_TO_TRASH} action
+ * @throws NullPointerException if {@code file} is {@code null}
+ * @throws IllegalArgumentException if the specified file doesn't
+ * exist
+ *
+ * @since 9
+ */
+ public boolean moveToTrash(final File file) {
+ checkDelete();
+ checkActionSupport(Action.MOVE_TO_TRASH);
+ checkFileValidation(file);
+ return peer.moveToTrash(file);
+ }
}
--- a/jdk/src/java.desktop/share/classes/java/awt/Frame.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/java/awt/Frame.java Thu Mar 24 02:22:01 2016 +0300
@@ -38,6 +38,7 @@
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
+import javax.swing.WindowConstants;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt;
+
+import java.awt.peer.TaskbarPeer;
+import sun.awt.SunToolkit;
+
+/**
+ * The {@code Taskbar} class allows a Java application to interact with
+ * the system task area (taskbar, Dock, etc.).
+ *
+ * <p>
+ * There are a variety of interactions depending on the current platform such as
+ * displaying progress of some task, appending user-specified menu to the application
+ * icon context menu, etc.
+ *
+ * @implNote Linux support is currently limited to Unity. However to make these
+ * features work on Unity, the app should be run from a .desktop file with
+ * specified {@code java.desktop.appName} system property set to this .desktop
+ * file name:
+ * {@code Exec=java -Djava.desktop.appName=MyApp.desktop -jar /path/to/myapp.jar}
+ * see <a href="https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles">
+ * https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles</a>
+ *
+ * @since 9
+ */
+
+public class Taskbar {
+
+ /**
+ * List of provided features. Each platform supports a different
+ * set of features. You may use the {@link Taskbar#isSupported}
+ * method to determine if the given feature is supported by the
+ * current platform.
+ */
+ public static enum Feature {
+
+ /**
+ * Represents a textual icon badge feature.
+ * @see #setIconBadge(java.lang.String)
+ */
+ ICON_BADGE_TEXT,
+
+ /**
+ * Represents a numerical icon badge feature.
+ * @see #setIconBadge(java.lang.String)
+ */
+ ICON_BADGE_NUMBER,
+
+ /**
+ * Represents a graphical icon badge feature for a window.
+ * @see #setWindowIconBadge(java.awt.Window, java.awt.Image)
+ */
+ ICON_BADGE_IMAGE_WINDOW,
+
+ /**
+ * Represents an icon feature.
+ * @see #setIconImage(java.awt.Image)
+ */
+ ICON_IMAGE,
+
+ /**
+ * Represents a menu feature.
+ * @see #setMenu(java.awt.PopupMenu)
+ * @see #getMenu()
+ */
+ MENU,
+
+ /**
+ * Represents a progress state feature for a specified window.
+ * @see #setWindowProgressState(java.awt.Window, State)
+ */
+ PROGRESS_STATE_WINDOW,
+
+ /**
+ * Represents a progress value feature.
+ * @see #setProgressValue(int)
+ */
+ PROGRESS_VALUE,
+
+ /**
+ * Represents a progress value feature for a specified window.
+ * @see #setWindowProgressValue(java.awt.Window, int)
+ */
+ PROGRESS_VALUE_WINDOW,
+
+ /**
+ * Represents a user attention request feature.
+ * @see #requestUserAttention(boolean, boolean)
+ */
+ USER_ATTENTION,
+
+ /**
+ * Represents a user attention request feature for a specified window.
+ * @see #requestWindowUserAttention(java.awt.Window)
+ */
+ USER_ATTENTION_WINDOW
+ }
+
+ /**
+ * Kinds of available window progress states.
+ *
+ * @see #setWindowProgressState(java.awt.Window, java.awt.Taskbar.State)
+ */
+ public static enum State {
+ /**
+ * Stops displaying the progress.
+ */
+ OFF,
+ /**
+ * The progress indicator displays with normal color and determinate
+ * mode.
+ */
+ NORMAL,
+ /**
+ * Shows progress as paused, progress can be resumed by the user.
+ * Switches to the determinate display.
+ */
+ PAUSED,
+ /**
+ * The progress indicator displays activity without specifying what
+ * proportion of the progress is complete.
+ */
+ INDETERMINATE,
+ /**
+ * Shows that an error has occurred. Switches to the determinate
+ * display.
+ */
+ ERROR
+ }
+
+ private TaskbarPeer peer;
+
+ /**
+ * Tests whether a {@code Feature} is supported on the current platform.
+ * @param feature the specified {@link Feature}
+ * @return true if the specified feature is supported on the current platform
+ */
+ public boolean isSupported(Feature feature) {
+ return peer.isSupported(feature);
+ }
+
+ /**
+ * Checks if the feature type is supported.
+ *
+ * @param featureType the action type in question
+ * @throws UnsupportedOperationException if the specified action type is not
+ * supported on the current platform
+ */
+ private void checkFeatureSupport(Feature featureType){
+ if (!isSupported(featureType)) {
+ throw new UnsupportedOperationException("The " + featureType.name()
+ + " feature is not supported on the current platform!");
+ }
+ }
+
+ /**
+ * Calls to the security manager's {@code checkPermission} method with
+ * an {@code AWTPermission("showWindowWithoutWarningBanner")}
+ * permission.
+ */
+ private void checkAWTPermission(){
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new AWTPermission(
+ "showWindowWithoutWarningBanner"));
+ }
+ }
+
+ private Taskbar() {
+ Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
+ if (defaultToolkit instanceof SunToolkit) {
+ peer = ((SunToolkit) defaultToolkit).createTaskbarPeer(this);
+ }
+ }
+
+ /**
+ * Returns the {@code Taskbar} instance of the current
+ * taskbar context. On some platforms the Taskbar API may not be
+ * supported; use the {@link #isTaskbarSupported} method to
+ * determine if the current taskbar is supported.
+ * @return the Taskbar instance
+ * @throws HeadlessException if {@link
+ * GraphicsEnvironment#isHeadless()} returns {@code true}
+ * @throws UnsupportedOperationException if this class is not
+ * supported on the current platform
+ * @see #isTaskbarSupported()
+ * @see java.awt.GraphicsEnvironment#isHeadless
+ */
+ public static synchronized Taskbar getTaskbar(){
+ if (GraphicsEnvironment.isHeadless()) throw new HeadlessException();
+
+ if (!Taskbar.isTaskbarSupported()) {
+ throw new UnsupportedOperationException("Taskbar API is not " +
+ "supported on the current platform");
+ }
+
+ sun.awt.AppContext context = sun.awt.AppContext.getAppContext();
+ Taskbar taskbar = (Taskbar)context.get(Taskbar.class);
+
+ if (taskbar == null) {
+ taskbar = new Taskbar();
+ context.put(Taskbar.class, taskbar);
+ }
+
+ return taskbar;
+ }
+
+ /**
+ * Tests whether this class is supported on the current platform.
+ * If it's supported, use {@link #getTaskbar()} to retrieve an
+ * instance.
+ *
+ * @return {@code true} if this class is supported on the
+ * current platform; {@code false} otherwise
+ * @see #getTaskbar()
+ */
+ public static boolean isTaskbarSupported(){
+ Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
+ if (defaultToolkit instanceof SunToolkit) {
+ return ((SunToolkit)defaultToolkit).isTaskbarSupported();
+ }
+ return false;
+ }
+
+ /**
+ * Requests user attention to this application.
+ *
+ * Depending on the platform, this may be visually indicated by a bouncing
+ * or flashing icon in the task area. It may have no effect on an already active
+ * application.
+ *
+ * On some platforms (e.g. Mac OS) this effect may disappear upon app activation
+ * and cannot be dismissed by setting {@code enabled} to false.
+ * Other platforms may require an additional call
+ * {@link #requestUserAttention} to dismiss this request
+ * with {@code enabled} parameter set to false.
+ *
+ * @param enabled disables this request if false
+ * @param critical if this is an important request
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#USER_ATTENTION} feature
+ */
+ public void requestUserAttention(final boolean enabled, final boolean critical) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.USER_ATTENTION);
+ peer.requestUserAttention(enabled, critical);
+ }
+
+ /**
+ * Requests user attention to the specified window until it is activated.
+ *
+ * On an already active window requesting attention does nothing.
+ *
+ * @param w window
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#USER_ATTENTION_WINDOW} feature
+ */
+ public void requestWindowUserAttention(Window w) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.USER_ATTENTION_WINDOW);
+ peer.requestWindowUserAttention(w);
+ }
+
+ /**
+ * Attaches the contents of the provided PopupMenu to the application icon
+ * in the task area.
+ *
+ * @param menu the PopupMenu to attach to this application
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#MENU} feature
+ */
+ public void setMenu(final PopupMenu menu) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.MENU);
+ peer.setMenu(menu);
+ }
+
+ /**
+ * Gets PopupMenu used to add items to this application's icon in system task area.
+ *
+ * @return the PopupMenu
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#MENU} feature
+ */
+ public PopupMenu getMenu() {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.MENU);
+ return peer.getMenu();
+ }
+
+ /**
+ * Changes this application's icon to the provided image.
+ *
+ * @param image to change
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature
+ */
+ public void setIconImage(final Image image) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.ICON_IMAGE);
+ peer.setIconImage(image);
+ }
+
+ /**
+ * Obtains an image of this application's icon.
+ *
+ * @return an image of this application's icon
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature
+ */
+ public Image getIconImage() {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.ICON_IMAGE);
+ return peer.getIconImage();
+ }
+
+ /**
+ * Affixes a small system-provided badge to this application's icon.
+ * Usually a number.
+ *
+ * Some platforms do not support string values and accept only integer
+ * values. In this case, pass an integer represented as a string as parameter.
+ * This can be tested by {@code Feature.ICON_BADGE_STRING} and
+ * {@code Feature.ICON_BADGE_NUMBER}.
+ *
+ * Passing {@code null} as parameter hides the badge.
+ * @param badge label to affix to the icon
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER} feature
+ */
+ public void setIconBadge(final String badge) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.ICON_BADGE_NUMBER);
+ peer.setIconBadge(badge);
+ }
+
+ /**
+ * Affixes a small badge to this application's icon in the task area
+ * for the specified window.
+ * It may be disabled by system settings.
+ *
+ * @param w window to update
+ * @param badge image to affix to the icon
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#ICON_BADGE_IMAGE_WINDOW} feature
+ */
+ public void setWindowIconBadge(Window w, final Image badge) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.ICON_BADGE_IMAGE_WINDOW);
+ if (w != null) {
+ peer.setWindowIconBadge(w, badge);
+ }
+ }
+
+
+ /**
+ * Affixes a small system-provided progress bar to this application's icon.
+ *
+ * @param value from 0 to 100, other to disable progress indication
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#PROGRESS_VALUE} feature
+ */
+ public void setProgressValue(int value) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.PROGRESS_VALUE);
+ peer.setProgressValue(value);
+ }
+
+ /**
+ * Displays progress for specified window.
+ *
+ * @param w window to update
+ * @param value from 0 to 100, other to disable progress indication
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#PROGRESS_VALUE_WINDOW} feature
+ */
+ public void setWindowProgressValue(Window w, int value) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.PROGRESS_VALUE_WINDOW);
+ if (w != null) {
+ peer.setWindowProgressValue(w, value);
+ }
+ }
+
+ /**
+ * Sets a progress state for a specified window.
+ *
+ * @param w window
+ * @param state to change to
+ * @see State#OFF
+ * @see State#NORMAL
+ * @see State#PAUSED
+ * @see State#INDETERMINATE
+ * @see State#ERROR
+ * @throws SecurityException if a security manager exists and it denies the
+ * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#PROGRESS_STATE_WINDOW} feature
+ */
+ public void setWindowProgressState(Window w, State state) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.PROGRESS_STATE_WINDOW);
+ if (w != null) {
+ peer.setWindowProgressState(w, state);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AboutEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * Event sent when the application is asked to open its about window.
+ *
+ * @see AboutHandler#handleAbout
+ *
+ * @since 9
+ */
+public final class AboutEvent extends AppEvent {
+ private static final long serialVersionUID = -5987180734802756477L;
+
+ /**
+ * Constructs an {@code AboutEvent}
+ */
+ public AboutEvent() {
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AboutHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * An implementer receives notification when the app is asked to show its about
+ * dialog.
+ *
+ * @see java.awt.Desktop#setAboutHandler(java.awt.desktop.AboutHandler)
+ *
+ * @since 9
+ */
+public interface AboutHandler {
+
+ /**
+ * Called when the application is asked to show its about dialog.
+ *
+ * @param e the request to show the about dialog.
+ */
+ public void handleAbout(final AboutEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+import java.awt.Desktop;
+import java.util.EventObject;
+
+/**
+ * AppEvents are sent to listeners and handlers installed on the
+ * {@link java.awt.Desktop}.
+ *
+ * @since 9
+ */
+public class AppEvent extends EventObject {
+
+ private static final long serialVersionUID = -5958503993556009432L;
+
+ AppEvent() {
+ super(Desktop.getDesktop());
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppForegroundEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * Event sent when the application has become the foreground app, and when it is
+ * no longer the foreground app.
+ *
+ * @see AppForegroundListener#appRaisedToForeground(AppEvent.AppForegroundEvent)
+ * @see AppForegroundListener#appMovedToBackground(AppEvent.AppForegroundEvent)
+ *
+ * @since 9
+ */
+public final class AppForegroundEvent extends AppEvent {
+ private static final long serialVersionUID = -5513582555740533911L;
+
+ /**
+ * Constructs an {@code AppForegroundEvent}
+ */
+ public AppForegroundEvent() {
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppForegroundListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Implementors are notified when the app becomes the foreground app and when it
+ * is no longer the foreground app. This notification is useful for hiding and
+ * showing transient UI like palette windows which should be hidden when the app
+ * is in the background.
+ *
+ * @since 9
+ */
+public interface AppForegroundListener extends SystemEventListener {
+ /**
+ * Called when the app becomes the foreground app.
+ * @param e event
+ */
+ public void appRaisedToForeground(final AppForegroundEvent e);
+
+ /**
+ * Called when the app becomes the background app and another app becomes
+ * the foreground app.
+ *
+ * @param e event
+ */
+ public void appMovedToBackground(final AppForegroundEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppHiddenEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * Event sent when the application has been hidden or shown.
+ *
+ * @see AppHiddenListener#appHidden(AppEvent.AppHiddenEvent)
+ * @see AppHiddenListener#appUnhidden(AppEvent.AppHiddenEvent)
+ *
+ * @since 9
+ */
+public final class AppHiddenEvent extends AppEvent {
+ private static final long serialVersionUID = 2637465279476429224L;
+
+ /**
+ * Constructs an {@code AppHiddenEvent}
+ */
+ public AppHiddenEvent() {
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppHiddenListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Implementors are notified when the app is hidden or shown by the user. This
+ * notification is helpful for discontinuing a costly animation if it's not
+ * visible to the user.
+ *
+ * @since 9
+ */
+public interface AppHiddenListener extends SystemEventListener {
+
+ /**
+ * Called the app is hidden.
+ *
+ * @param e event
+ */
+ public void appHidden(final AppHiddenEvent e);
+
+ /**
+ * Called when the hidden app is shown again (but not necessarily brought to
+ * the foreground).
+ *
+ * @param e event
+ */
+ public void appUnhidden(final AppHiddenEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppReopenedEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * Event sent when the application is asked to re-open itself.
+ *
+ * @see AppReopenedListener#appReopened(AppEvent.AppReopenedEvent)
+ *
+ * @since 9
+ */
+public final class AppReopenedEvent extends AppEvent {
+ private static final long serialVersionUID = 1503238361530407990L;
+
+ /**
+ * Constructs an {@code AppReopenedEvent}
+ */
+ public AppReopenedEvent() {
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppReopenedListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Implementors receive notification when the app has been asked to open again.
+ *
+ * This notification is useful for showing a new document when your app has no open windows.
+ *
+ * @since 9
+ */
+public interface AppReopenedListener extends SystemEventListener {
+ /**
+ * Called when the app has been reopened
+ * @param e the request to reopen the app
+ */
+ public void appReopened(final AppReopenedEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/FilesEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Auxiliary event containing a list of files.
+ *
+ * @since 9
+ */
+public class FilesEvent extends AppEvent {
+ private static final long serialVersionUID = 5271763715462312871L;
+ final List<File> files;
+
+ /**
+ * Constructs a {@code FilesEvent}
+ * @param files files
+ * @param searchTerm searchTerm
+ */
+ FilesEvent(final List<File> files) {
+ this.files = files;
+ }
+
+ /**
+ * Gets the list of files
+ * @return the list of files
+ */
+ public List<File> getFiles() {
+ return files == null
+ ? null
+ : new ArrayList<>(files);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenFilesEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+import java.io.File;
+import java.util.List;
+
+
+/**
+ * Event sent when the app is asked to open a list of files.
+ *
+ * @see OpenFilesHandler#openFiles
+ *
+ * @since 9
+ */
+public final class OpenFilesEvent extends FilesEvent {
+ private static final long serialVersionUID = -3982871005867718956L;
+ final String searchTerm;
+
+ /**
+ * Constructs an {@code OpenFilesEvent}
+ * @param files files
+ * @param searchTerm searchTerm
+ */
+ public OpenFilesEvent(final List<File> files, final String searchTerm) {
+ super(files);
+ this.searchTerm = searchTerm == null
+ ? ""
+ : searchTerm;
+ }
+
+ /**
+ * Gets the search term. The platform may optionally provide the search
+ * term that was used to find the files. This is for example the case
+ * on Mac OS X, when the files were opened using the Spotlight search
+ * menu or a Finder search window.
+ *
+ * This is useful for highlighting the search term in the documents when
+ * they are opened.
+ *
+ * @return the search term used to find the files
+ */
+ public String getSearchTerm() {
+ return searchTerm;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenFilesHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * An implementor is notified when the application is asked to open a list of files.
+ *
+ * @see java.awt.Desktop#setOpenFileHandler(java.awt.desktop.OpenFilesHandler)
+ *
+ * @since 9
+ */
+public interface OpenFilesHandler {
+ /**
+ * Called when the application is asked to open a list of files.
+ * @param e the request to open a list of files, and the search term used to find them, if any.
+ */
+ public void openFiles(final OpenFilesEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenURIEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+import java.net.URI;
+
+
+/**
+ * Event sent when the app is asked to open a {@code URI}.
+ *
+ * @see OpenURIHandler#openURI(AppEvent.OpenURIEvent)
+ *
+ * @since 9
+ */
+public final class OpenURIEvent extends AppEvent {
+ private static final long serialVersionUID = 221209100935933476L;
+ final URI uri;
+
+ /**
+ * Constructs an {@code OpenURIEvent}
+ * @param uri {@code URI}
+ */
+ public OpenURIEvent(final URI uri) {
+ this.uri = uri;
+ }
+
+ /**
+ * Get the {@code URI} the app was asked to open
+ * @return the {@code URI}
+ */
+ public URI getURI() {
+ return uri;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenURIHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * An implementor is notified when the application is asked to open a URI.
+ *
+ * @see java.awt.Desktop#setOpenURIHandler(java.awt.desktop.OpenURIHandler)
+ *
+ * @since 9
+ */
+public interface OpenURIHandler {
+ /**
+ * Called when the application is asked to open a {@code URI}
+ * @param e the request to open a {@code URI}
+ */
+ public void openURI(final OpenURIEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/PreferencesEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * Event sent when the application is asked to open its preferences window.
+ *
+ * @see PreferencesHandler#handlePreferences
+ *
+ * @since 9
+ */
+public final class PreferencesEvent extends AppEvent {
+ private static final long serialVersionUID = -6398607097086476160L;
+
+ /**
+ * Constructs a {@code PreferencesEvent}
+ */
+ public PreferencesEvent() {
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/PreferencesHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * An implementor is notified when the app is asked to show its preferences UI.
+ *
+ * @see java.awt.Desktop#setPreferencesHandler(java.awt.desktop.PreferencesHandler)
+ *
+ * @since 9
+ */
+public interface PreferencesHandler {
+ /**
+ * Called when the app is asked to show its preferences UI.
+ * @param e the request to show preferences.
+ */
+ public void handlePreferences(final PreferencesEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/PrintFilesEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+package java.awt.desktop;
+
+import java.io.File;
+import java.util.List;
+
+
+/**
+ * Event sent when the app is asked to print a list of files.
+ *
+ * @see PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)
+ * @since 9
+ */
+public final class PrintFilesEvent extends FilesEvent {
+ private static final long serialVersionUID = -5752560876153618618L;
+
+ /**
+ * Constructs a {@code PrintFilesEvent}
+ * @param files files
+ */
+ public PrintFilesEvent(final List<File> files) {
+ super(files);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/PrintFilesHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * An implementor can respond to requests to print documents that the app has been registered to handle.
+ *
+ * @see java.awt.Desktop#setPrintFileHandler(java.awt.desktop.PrintFilesHandler)
+ *
+ * @since 9
+ */
+public interface PrintFilesHandler {
+ /**
+ * Called when the application is asked to print a list of files.
+ * @param e the request to print a list of files.
+ */
+ public void printFiles(final PrintFilesEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Event sent when the application is asked to quit.
+ *
+ * @see QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, QuitResponse)
+ *
+ * @since 9
+ */
+public final class QuitEvent extends AppEvent {
+
+ private static final long serialVersionUID = -256100795532403146L;
+
+ /**
+ * Constructs a {@code QuitEvent}
+ */
+ public QuitEvent() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitHandler.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * An implementor determines if requests to quit this application should proceed or cancel.
+ *
+ * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler)
+ * @see java.awt.Desktop#setQuitStrategy(java.awt.desktop.QuitStrategy)
+ *
+ * @since 9
+ */
+public interface QuitHandler {
+ /**
+ * Invoked when the application is asked to quit.
+ *
+ * Implementors must call either {@link QuitResponse#cancelQuit()}, {@link QuitResponse#performQuit()}, or ensure the application terminates.
+ * The process (or log-out) requesting this app to quit will be blocked until the {@link QuitResponse} is handled.
+ * Apps that require complex UI to shutdown may call the {@link QuitResponse} from any thread.
+ * Your app may be asked to quit multiple times before you have responded to the initial request.
+ * This handler is called each time a quit is requested, and the same {@link QuitResponse} object is passed until it is handled.
+ * Once used, the {@link QuitResponse} cannot be used again to change the decision.
+ *
+ * @param e the request to quit this application.
+ * @param response the one-shot response object used to cancel or proceed with the quit action.
+ */
+ public void handleQuitRequestWith(final QuitEvent e, final QuitResponse response);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitResponse.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Used to respond to a request to quit the application.
+ *
+ * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler)
+ * @see java.awt.desktop.QuitHandler
+ * @see java.awt.Desktop#setQuitStrategy(java.awt.desktop.QuitStrategy)
+ *
+ * @since 9
+ */
+public interface QuitResponse {
+
+ /**
+ * Notifies the external quit requester that the quit will proceed, and performs the default {@link java.awt.desktop.QuitStrategy}.
+ */
+ public void performQuit();
+
+ /**
+ * Notifies the external quit requester that the user has explicitly canceled the pending quit, and leaves the application running.
+ * <b>Note: this will cancel a pending log-out, restart, or shutdown.</b>
+ */
+ public void cancelQuit();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitStrategy.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * The strategy used to shut down the application, if Sudden Termination is not enabled.
+ *
+ * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler)
+ * @see java.awt.Desktop#setQuitStrategy(java.awt.desktop.QuitStrategy)
+ * @see java.awt.Desktop#enableSuddenTermination()
+ * @see java.awt.Desktop#disableSuddenTermination()
+ *
+ * @since 9
+ */
+public enum QuitStrategy {
+ /**
+ * Shuts down the application by calling {@code System.exit(0)}. This is the default strategy.
+ */
+ NORMAL_EXIT,
+
+ /**
+ * Shuts down the application by closing each window from back-to-front.
+ */
+ CLOSE_ALL_WINDOWS
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.awt.desktop;
+
+/**
+ * Event sent when the displays attached to the system enter and exit power save
+ * sleep.
+ *
+ * @see ScreenSleepListener#screenAboutToSleep(AppEvent.ScreenSleepEvent)
+ * @see ScreenSleepListener#screenAwoke(AppEvent.ScreenSleepEvent)
+ *
+ * @since 9
+ */
+public final class ScreenSleepEvent extends AppEvent {
+
+ private static final long serialVersionUID = 7521606180376544150L;
+
+ /**
+ * Constructs a ScreenSleepEvent
+ */
+ public ScreenSleepEvent() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Implementors receive notification when the displays attached to the system have entered power save sleep.
+ *
+ * This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
+ *
+ * @since 9
+ */
+public interface ScreenSleepListener extends SystemEventListener {
+
+ /**
+ * Called when the system displays have entered power save sleep.
+ * @param e the screen sleep event
+ */
+ public void screenAboutToSleep(final ScreenSleepEvent e);
+
+ /**
+ * Called when the system displays have awoken from power save sleep.
+ * @param e the screen sleep event
+ */
+ public void screenAwoke(final ScreenSleepEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemEventListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+import java.util.EventListener;
+
+/**
+ * Common interface for all event listener sub-types.
+ *
+ * Implementors may implement multiple sub-types, but only need to call
+ * {@link java.awt.Desktop#addAppEventListener(SystemEventListener)} once to
+ * receive all notifications.
+ *
+ * @since 9
+ */
+public interface SystemEventListener extends EventListener {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemSleepEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Event sent when the system enters and exits power save sleep.
+ *
+ * @see SystemSleepListener#systemAboutToSleep(AppEvent.SystemSleepEvent)
+ * @see SystemSleepListener#systemAwoke(AppEvent.SystemSleepEvent)
+ *
+ * @since 9
+ */
+public final class SystemSleepEvent extends AppEvent {
+
+ private static final long serialVersionUID = 11372269824930549L;
+
+ /**
+ * Constructs a SystemSleepEvent
+ */
+ public SystemSleepEvent() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemSleepListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+/**
+ * Implementors receive notification as the system is entering sleep, and after
+ * the system wakes.
+ *
+ * This notification is useful for disconnecting from network services prior to
+ * sleep, or re-establishing a connection if the network configuration has
+ * changed during sleep.
+ *
+ * @since 9
+ */
+public interface SystemSleepListener extends SystemEventListener {
+
+ /**
+ * Called when the system is about to sleep. Note: This message may not be
+ * delivered prior to the actual system sleep, and may be processed after
+ * the corresponding wake has occurred.
+ *
+ * @param e the system sleep event
+ */
+ public void systemAboutToSleep(final SystemSleepEvent e);
+
+ /**
+ * Called after the system has awoken from sleeping.
+ *
+ * @param e the system sleep event
+ */
+ public void systemAwoke(final SystemSleepEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/UserSessionEvent.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.awt.desktop;
+
+/**
+ * Event sent when the user session has been changed.
+ *
+ * Some systems may provide a reason of a user session change.
+ *
+ * @see UserSessionListener#userSessionActivated(AppEvent.UserSessionEvent)
+ * @see UserSessionListener#userSessionDeactivated(AppEvent.UserSessionEvent)
+ *
+ * @since 9
+ */
+public final class UserSessionEvent extends AppEvent {
+
+ private static final long serialVersionUID = 6747138462796569055L;
+
+ private final Reason reason;
+
+ /**
+ * Kinds of available reasons of user session change.
+ */
+ public static enum Reason {
+ /**
+ * The system does not provide a reason for a session change.
+ */
+ UNSPECIFIED,
+
+ /**
+ * The session was connected/disconnected to the console terminal.
+ */
+ CONSOLE,
+
+ /**
+ * The session was connected/disconnected to the remote terminal.
+ */
+ REMOTE,
+
+ /**
+ * The session has been locked/unlocked.
+ */
+ LOCK
+ }
+
+ /**
+ * Constructs a {@code UserSessionEvent}
+ *
+ * @param reason of session change
+ */
+ public UserSessionEvent(Reason reason) {
+ this.reason = reason;
+ }
+
+ /**
+ * Gets a reason of the user session change.
+ *
+ * @return reason a reason
+ * @see Reason#UNSPECIFIED
+ * @see Reason#CONSOLE
+ * @see Reason#REMOTE
+ * @see Reason#LOCK
+ */
+ public Reason getReason() {
+ return reason;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/UserSessionListener.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.desktop;
+
+
+/**
+ * Implementors receive notification when the user session changes.
+ *
+ * This notification is useful for discontinuing a costly animation,
+ * or indicating that the user is no longer present on a network service.
+ *
+ * Some systems may provide a reason of the user session change.
+ *
+ * @see UserSessionEvent.Reason#UNSPECIFIED
+ * @see UserSessionEvent.Reason#CONSOLE
+ * @see UserSessionEvent.Reason#REMOTE
+ * @see UserSessionEvent.Reason#LOCK
+ *
+ * @since 9
+ */
+public interface UserSessionListener extends SystemEventListener {
+ /**
+ * Called when the user session has been switched away.
+ * @param e the user session switch event
+ */
+ public void userSessionDeactivated(final UserSessionEvent e);
+
+ /**
+ * Called when the user session has been switched to.
+ * @param e the user session switch event
+ */
+ public void userSessionActivated(final UserSessionEvent e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/package.html Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,36 @@
+<!--
+ Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation. Oracle designates this
+ particular file as subject to the "Classpath" exception as provided
+ by Oracle in the LICENSE file that accompanied this code.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head><title></title></head>
+<body bgcolor="white">
+
+Provides interfaces and classes for interaction with various
+desktop capabilities.
+
+@since 9
+</body>
+</html>
--- a/jdk/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,14 +22,21 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
package java.awt.peer;
-
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.awt.Desktop.Action;
+import java.awt.desktop.AboutHandler;
+import java.awt.desktop.SystemEventListener;
+import java.awt.desktop.OpenFilesHandler;
+import java.awt.desktop.OpenURIHandler;
+import java.awt.desktop.PreferencesHandler;
+import java.awt.desktop.PrintFilesHandler;
+import java.awt.desktop.QuitHandler;
+import java.awt.desktop.QuitStrategy;
+import javax.swing.JMenuBar;
/**
* The {@code DesktopPeer} interface provides methods for the operation
@@ -104,4 +111,168 @@
* or it fails to be launched.
*/
void browse(URI uri) throws IOException;
+
+ /**
+ * Adds sub-types of {@link SystemEventListener} to listen for notifications
+ * from the native system.
+ *
+ * @param listener listener
+ * @see java.awt.desktop.AppForegroundListener
+ * @see java.awt.desktop.AppHiddenListener
+ * @see java.awt.desktop.AppReopenedListener
+ * @see java.awt.desktop.ScreenSleepListener
+ * @see java.awt.desktop.SystemSleepListener
+ * @see java.awt.desktop.UserSessionListener
+ */
+ default void addAppEventListener(final SystemEventListener listener) {
+ }
+
+ /**
+ * Removes sub-types of {@link SystemEventListener} to listen for notifications
+ * from the native system.
+ *
+ * @param listener listener
+ * @see java.awt.desktop.AppForegroundListener
+ * @see java.awt.desktop.AppHiddenListener
+ * @see java.awt.desktop.AppReopenedListener
+ * @see java.awt.desktop.ScreenSleepListener
+ * @see java.awt.desktop.SystemSleepListener
+ * @see java.awt.desktop.UserSessionListener
+ */
+ default void removeAppEventListener(final SystemEventListener listener) {
+ }
+
+ /**
+ * Installs a handler to show a custom About window for your application.
+ * <p>
+ * Setting the {@link AboutHandler} to {@code null} reverts it to the
+ * default behavior.
+ *
+ * @param aboutHandler the handler to respond to the
+ * {@link AboutHandler#handleAbout} )} message
+ */
+ default void setAboutHandler(final AboutHandler aboutHandler) {
+ }
+
+ /**
+ * Installs a handler to show a custom Preferences window for your
+ * application.
+ * <p>
+ * Setting the {@link PreferencesHandler} to {@code null} reverts it to
+ * the default behavior
+ *
+ * @param preferencesHandler the handler to respond to the
+ * {@link java.awt.desktop.PreferencesHandler#handlePreferences(java.awt.PreferencesEvent) }
+ */
+ default void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
+ }
+
+ /**
+ * Installs the handler which is notified when the application is asked to
+ * open a list of files.
+ *
+ * @param openFileHandler handler
+ *
+ */
+ default void setOpenFileHandler(final OpenFilesHandler openFileHandler) {
+ }
+
+ /**
+ * Installs the handler which is notified when the application is asked to
+ * print a list of files.
+ *
+ * @param printFileHandler handler
+ */
+ default void setPrintFileHandler(final PrintFilesHandler printFileHandler) {
+ }
+
+ /**
+ * Installs the handler which is notified when the application is asked to
+ * open a URL.
+ *
+ * Setting the handler to {@code null} causes all
+ * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be
+ * enqueued until another handler is set.
+ *
+ * @param openURIHandler handler
+ */
+ default void setOpenURIHandler(final OpenURIHandler openURIHandler) {
+ }
+
+ /**
+ * Installs the handler which determines if the application should quit.
+ *
+ * @param quitHandler the handler that is called when the application is
+ * asked to quit
+ * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler)
+ */
+ default void setQuitHandler(final QuitHandler quitHandler) {
+ }
+
+ /**
+ * Sets the default strategy used to quit this application. The default is
+ * calling SYSTEM_EXIT_0.
+ *
+ * @param strategy the way this application should be shutdown
+ */
+ default void setQuitStrategy(final QuitStrategy strategy) {
+ }
+
+ /**
+ * Enables this application to be suddenly terminated.
+ *
+ * @see java.awt.Desktop#disableSuddenTermination()
+ */
+ default void enableSuddenTermination() {
+ }
+
+ /**
+ * Prevents this application from being suddenly terminated.
+ *
+ * @see java.awt.Desktop#enableSuddenTermination()
+ */
+ default void disableSuddenTermination() {
+ }
+
+ /**
+ * Requests this application to move to the foreground.
+ *
+ * @param allWindows if all windows of this application should be moved to
+ * the foreground, or only the foremost one
+ */
+ default void requestForeground(final boolean allWindows) {
+ }
+
+ /**
+ * Opens the native help viewer application.
+ */
+ default void openHelpViewer() {
+ }
+
+ /**
+ * Sets the default menu bar to use when there are no active frames.
+ *
+ * @param menuBar to use when no other frames are active
+ */
+ default void setDefaultMenuBar(final JMenuBar menuBar) {
+ }
+
+ /**
+ * Opens a folder containing the {@code file} in a default system file manager.
+ * @param file the file
+ * @return returns true if successfully opened
+ */
+ default boolean browseFileDirectory(File file) {
+ return false;
+ }
+ /**
+ * Moves the specified file to the trash.
+ *
+ * @param file the file
+ * @return returns true if successfully moved the file to the trash.
+ */
+ default boolean moveToTrash(File file) {
+ return false;
+ }
+
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.awt.peer;
+
+import java.awt.Image;
+import java.awt.PopupMenu;
+import java.awt.Taskbar;
+import java.awt.Taskbar.Feature;
+import java.awt.Taskbar.State;
+import java.awt.Window;
+
+
+/**
+ * The {@code TaskbarPeer} interface provides methods for interacting with
+ * system task area.
+ */
+public interface TaskbarPeer {
+
+ /**
+ * Requests user attention to this application.
+ *
+ * @param enabled disables this request if false
+ * @param critical if this is an important request
+ * @see Taskbar#requestUserAttention
+ */
+ default void requestUserAttention(boolean enabled, final boolean critical) {}
+
+ /**
+ * Requests user attention to the specified window until it is activated.
+ *
+ * On an already active window requesting attention does nothing.
+ *
+ * @param w window
+ */
+ default void requestWindowUserAttention(Window w) {}
+
+ /**
+ * Attaches the contents of the provided PopupMenu to the application icon
+ * in system task area.
+ *
+ * @param menu the PopupMenu to attach to this application
+ */
+ default void setMenu(final PopupMenu menu) {}
+
+ /**
+ * Gets PopupMenu used to add items to this application's icon in system task area.
+ *
+ * @return the PopupMenu
+ */
+ default PopupMenu getMenu() { return null; }
+
+ /**
+ * Changes this application's icon to the provided image.
+ *
+ * @param image to change
+ */
+ default void setIconImage(final Image image) {}
+
+ /**
+ * Obtains an image of this application's icon.
+ *
+ * @return an image of this application's icon
+ */
+ default Image getIconImage() { return null; }
+
+ /**
+ * Affixes a small system-provided badge to this application's icon.
+ * Usually a number.
+ *
+ * @param badge label to affix to the icon
+ */
+ default void setIconBadge(final String badge) {}
+
+ /**
+ * Affixes a small badge to this application's icon in task area
+ * for the specified window.
+ *
+ * @param w window to update
+ * @param badge image to affix to the icon
+ */
+ default void setWindowIconBadge(Window w, final Image badge) {}
+
+ /**
+ * Displays progress for specified window.
+ *
+ * @param w window to update
+ * @param value from 0 to 100, other to disable progress indication
+ */
+ default void setWindowProgressValue(Window w, int value) {}
+
+ /**
+ * Sets a progress state for a specified window.
+ *
+ * @param w window
+ * @param state to change to
+ * @see Taskbar#setWindowProgressState
+ */
+ default void setWindowProgressState(Window w, State state) {}
+
+ /**
+ * Affixes a small system-provided progress bar to this application's icon.
+ *
+ * @param value from 0 to 100, other to disable progress indication
+ */
+ default void setProgressValue(int value) {}
+
+ /**
+ * Tests support of {@code Feature} on current platform.
+ * @param f feature to test
+ * @return true if feature supported supported
+ */
+ default public boolean isSupported(Feature f) { return false; }
+}
--- a/jdk/src/java.desktop/share/classes/module-info.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/module-info.java Thu Mar 24 02:22:01 2016 +0300
@@ -31,6 +31,7 @@
exports java.applet;
exports java.awt;
exports java.awt.color;
+ exports java.awt.desktop;
exports java.awt.dnd;
exports java.awt.event;
exports java.awt.font;
--- a/jdk/src/java.desktop/share/classes/sun/awt/ComponentFactory.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/sun/awt/ComponentFactory.java Thu Mar 24 02:22:01 2016 +0300
@@ -25,6 +25,7 @@
package sun.awt;
+import java.awt.peer.TaskbarPeer;
import java.awt.*;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.InvalidDnDOperationException;
@@ -75,6 +76,23 @@
}
/**
+ * Creates this toolkit's implementation of the {@code Taskbar} using the
+ * specified peer interface.
+ *
+ * @param target the taskbar to be implemented
+ * @return this toolkit's implementation of the {@code Taskbar}
+ * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+ * true
+ * @see java.awt.GraphicsEnvironment#isHeadless
+ * @see java.awt.Taskbar
+ * @see java.awt.peer.TaskbarPeer
+ * @since 9
+ */
+ default TaskbarPeer createTaskbarPeer(Taskbar target) {
+ throw new HeadlessException();
+ }
+
+ /**
* Creates this toolkit's implementation of {@code Button} using the
* specified peer interface.
*
--- a/jdk/src/java.desktop/share/classes/sun/awt/HToolkit.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/sun/awt/HToolkit.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -286,6 +286,11 @@
return false;
}
+ @Override
+ public boolean isTaskbarSupported() {
+ return false;
+ }
+
public boolean isWindowOpacityControlSupported() {
return false;
}
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1781,6 +1781,7 @@
public abstract boolean isDesktopSupported();
+ public abstract boolean isTaskbarSupported();
/*
* consumeNextKeyTyped() method is not currently used,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.awt.X11;
+
+import java.awt.MenuItem;
+import java.awt.PopupMenu;
+import java.awt.Taskbar.Feature;
+import java.awt.peer.TaskbarPeer;
+import java.awt.event.ActionEvent;
+import sun.misc.ManagedLocalsThread;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
+
+final class XTaskbarPeer implements TaskbarPeer {
+
+ private static boolean nativeLibraryLoaded = false;
+ private static boolean initExecuted = false;
+
+ private PopupMenu menu = null;
+
+ private static void initWithLock() {
+ XToolkit.awtLock();
+ try {
+ if (!initExecuted) {
+ String dname = AccessController.doPrivileged(
+ new GetPropertyAction("java.desktop.appName", ""));
+ nativeLibraryLoaded = init(dname);
+ if (nativeLibraryLoaded) {
+ ManagedLocalsThread t
+ = new ManagedLocalsThread(() -> {
+ runloop();
+ });
+ t.setDaemon(true);
+ t.start();
+ }
+ }
+ } finally {
+ initExecuted = true;
+ XToolkit.awtUnlock();
+ }
+ }
+
+ XTaskbarPeer() {
+ initWithLock();
+ }
+
+ static boolean isTaskbarSupported() {
+ initWithLock();
+ return nativeLibraryLoaded;
+ }
+
+ @Override
+ public boolean isSupported(Feature feature) {
+ switch (feature) {
+ case ICON_BADGE_NUMBER:
+ case MENU:
+ case PROGRESS_VALUE:
+ case USER_ATTENTION:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public void setProgressValue(int value) {
+ boolean visible
+ = value >= 0
+ && value <= 100;
+
+ double v = visible
+ ? (double) value / 100
+ : 0d;
+
+ updateProgress(v, visible);
+ }
+
+ @Override
+ public void setIconBadge(String badge) {
+ boolean visible = false;
+ long val = 0;
+ if (badge != null) {
+ try {
+ val = Long.parseLong(badge);
+ visible = true;
+ } catch (NumberFormatException e) {
+ }
+ }
+ setBadge(val, visible);
+ }
+
+ @Override
+ public PopupMenu getMenu() {
+ return menu;
+ }
+
+ @Override
+ public synchronized void setMenu(PopupMenu m) {
+ this.menu = m;
+
+ if (menu != null && menu.getItemCount() > 0) {
+ int msize = menu.getItemCount();
+ MenuItem[] items = new MenuItem[msize];
+ for (int i = 0; i < msize; i++) {
+ items[i] = menu.getItem(i);
+ }
+ setNativeMenu(items);
+ } else {
+ setNativeMenu(null);
+ }
+ }
+
+ @Override
+ public void requestUserAttention(boolean enabled, boolean critical) {
+ setUrgent(enabled);
+ }
+
+ private static void menuItemCallback(MenuItem mi) {
+ if (mi != null) {
+ ActionEvent ae = new ActionEvent(mi, ActionEvent.ACTION_PERFORMED,
+ mi.getActionCommand());
+ try {
+ XToolkit.awtLock();
+ XToolkit.postEvent(XToolkit.targetToAppContext(ae.getSource()), ae);
+ } finally {
+ XToolkit.awtUnlock();
+ }
+ }
+ }
+
+ private static native boolean init(String name);
+
+ private static native void runloop();
+
+ private native void setBadge(long value, boolean visible);
+
+ private native void updateProgress(double value, boolean visible);
+
+ private native void setUrgent(boolean urgent);
+
+ private native void setNativeMenu(MenuItem[] items);
+}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
*/
package sun.awt.X11;
+import java.awt.peer.TaskbarPeer;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
@@ -2568,6 +2569,16 @@
}
@Override
+ public boolean isTaskbarSupported(){
+ return XTaskbarPeer.isTaskbarSupported();
+ }
+
+ @Override
+ public TaskbarPeer createTaskbarPeer(Taskbar target){
+ return new XTaskbarPeer();
+ }
+
+ @Override
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -831,6 +831,10 @@
fp_gtk_separator_tool_item_new =
dl_symbol("gtk_vseparator_new");
}
+
+ fp_g_list_append = dl_symbol("g_list_append");
+ fp_g_list_free = dl_symbol("g_list_free");
+ fp_g_list_free_full = dl_symbol("g_list_free_full");
}
/* Now we have only one kind of exceptions: NO_SYMBOL_EXCEPTION
* Otherwise we can check the return value of setjmp method.
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -289,6 +289,15 @@
GSList *next;
};
+typedef struct _GList GList;
+
+struct _GList
+{
+ gpointer data;
+ GList *next;
+ GList *prev;
+};
+
typedef void GdkColormap;
typedef void GdkDrawable;
typedef void GdkGC;
@@ -841,6 +850,11 @@
gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
+
+GList* (*fp_g_list_append) (GList *list, gpointer data);
+void (*fp_g_list_free) (GList *list);
+void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
+
/**
* This function is available for GLIB > 2.20, so it MUST be
* called within GLIB_CHECK_VERSION(2, 20, 0) check.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <dlfcn.h>
+#include "jvm_md.h"
+#include <setjmp.h>
+#include <string.h>
+
+#include "jni_util.h"
+#include "awt_Taskbar.h"
+
+
+extern JavaVM *jvm;
+
+#define NO_SYMBOL_EXCEPTION 1
+
+#define UNITY_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("unity", "9")
+#define UNITY_LIB JNI_LIB_NAME("unity")
+
+static jmp_buf j;
+
+static void *unity_libhandle = NULL;
+
+static DbusmenuMenuitem* menu = NULL;
+UnityLauncherEntry* entry = NULL;
+
+static jclass jTaskbarCls = NULL;
+static jmethodID jTaskbarCallback = NULL;
+static jmethodID jMenuItemGetLabel = NULL;
+
+GList* globalRefs = NULL;
+
+static void* dl_symbol(const char* name) {
+ void* result = dlsym(unity_libhandle, name);
+ if (!result)
+ longjmp(j, NO_SYMBOL_EXCEPTION);
+
+ return result;
+}
+
+static gboolean unity_load() {
+ unity_libhandle = dlopen(UNITY_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+ if (unity_libhandle == NULL) {
+ unity_libhandle = dlopen(UNITY_LIB, RTLD_LAZY | RTLD_LOCAL);
+ if (unity_libhandle == NULL) {
+ return FALSE;
+ }
+ }
+ if (setjmp(j) == 0) {
+ fp_unity_launcher_entry_get_for_desktop_file = dl_symbol("unity_launcher_entry_get_for_desktop_file");
+ fp_unity_launcher_entry_set_count = dl_symbol("unity_launcher_entry_set_count");
+ fp_unity_launcher_entry_set_count_visible = dl_symbol("unity_launcher_entry_set_count_visible");
+ fp_unity_launcher_entry_set_urgent = dl_symbol("unity_launcher_entry_set_urgent");
+ fp_unity_launcher_entry_set_progress = dl_symbol("unity_launcher_entry_set_progress");
+ fp_unity_launcher_entry_set_progress_visible = dl_symbol("unity_launcher_entry_set_progress_visible");
+
+ fp_dbusmenu_menuitem_new = dl_symbol("dbusmenu_menuitem_new");
+ fp_dbusmenu_menuitem_property_set = dl_symbol("dbusmenu_menuitem_property_set");
+ fp_dbusmenu_menuitem_property_set_int = dl_symbol("dbusmenu_menuitem_property_set_int");
+ fp_dbusmenu_menuitem_property_get_int = dl_symbol("dbusmenu_menuitem_property_get_int");
+ fp_dbusmenu_menuitem_property_set = dl_symbol("dbusmenu_menuitem_property_set");
+ fp_dbusmenu_menuitem_child_append = dl_symbol("dbusmenu_menuitem_child_append");
+ fp_dbusmenu_menuitem_child_delete = dl_symbol("dbusmenu_menuitem_child_delete");
+ fp_dbusmenu_menuitem_take_children = dl_symbol("dbusmenu_menuitem_take_children");
+ fp_dbusmenu_menuitem_foreach = dl_symbol("dbusmenu_menuitem_foreach");
+ fp_unity_launcher_entry_set_quicklist = dl_symbol("unity_launcher_entry_set_quicklist");
+ fp_unity_launcher_entry_get_quicklist = dl_symbol("unity_launcher_entry_get_quicklist");
+ } else {
+ dlclose(unity_libhandle);
+ unity_libhandle = NULL;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void callback(DbusmenuMenuitem* mi, guint ts, jobject data) {
+ JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ (*env)->CallStaticVoidMethod(env, jTaskbarCls, jTaskbarCallback, data,
+ fp_dbusmenu_menuitem_property_get_int(mi, "toggle-state")
+ ? JNI_FALSE
+ : JNI_TRUE);
+}
+
+/*
+ * Class: sun_awt_X11_XTaskbarPeer
+ * Method: init
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XTaskbarPeer_init
+(JNIEnv *env, jclass cls, jstring jname) {
+ jclass clazz;
+
+ jTaskbarCls = (*env)->NewGlobalRef(env, cls);
+
+ CHECK_NULL_RETURN(jTaskbarCallback =
+ (*env)->GetStaticMethodID(env, cls, "menuItemCallback", "(Ljava/awt/MenuItem;)V"), JNI_FALSE);
+ CHECK_NULL_RETURN(
+ clazz = (*env)->FindClass(env, "java/awt/MenuItem"), JNI_FALSE);
+ CHECK_NULL_RETURN(
+ jMenuItemGetLabel = (*env)->GetMethodID(env, clazz, "getLabel", "()Ljava/lang/String;"), JNI_FALSE);
+
+ if (gtk2_load(env) && unity_load()) {
+ const gchar* name = (*env)->GetStringUTFChars(env, jname, NULL);
+ if (name) {
+ entry = fp_unity_launcher_entry_get_for_desktop_file(name);
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+ return JNI_TRUE;
+ }
+ }
+ return JNI_FALSE;
+}
+
+/*
+ * Class: sun_awt_X11_XTaskbarPeer
+ * Method: runloop
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_runloop
+(JNIEnv *env, jclass cls) {
+ fp_gdk_threads_enter();
+ fp_gtk_main();
+ fp_gdk_threads_leave();
+}
+
+/*
+ * Class: sun_awt_X11_XTaskbarPeer
+ * Method: setBadge
+ * Signature: (JZ)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setBadge
+(JNIEnv *env, jobject obj, jlong value, jboolean visible) {
+ fp_gdk_threads_enter();
+ fp_unity_launcher_entry_set_count(entry, value);
+ fp_unity_launcher_entry_set_count_visible(entry, visible);
+ DbusmenuMenuitem* m;
+ if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
+ fp_unity_launcher_entry_set_quicklist(entry, m);
+ }
+ fp_gdk_threads_leave();
+}
+
+/*
+ * Class: sun_awt_X11_XTaskbarPeer
+ * Method: setUrgent
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setUrgent
+(JNIEnv *env, jobject obj, jboolean urgent) {
+ fp_gdk_threads_enter();
+ fp_unity_launcher_entry_set_urgent(entry, urgent);
+ DbusmenuMenuitem* m;
+ if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
+ fp_unity_launcher_entry_set_quicklist(entry, m);
+ }
+ fp_gdk_threads_leave();
+}
+
+/*
+ * Class: sun_awt_X11_XTaskbarPeer
+ * Method: updateProgress
+ * Signature: (DZ)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_updateProgress
+(JNIEnv *env, jobject obj, jdouble value, jboolean visible) {
+ fp_gdk_threads_enter();
+ fp_unity_launcher_entry_set_progress(entry, value);
+ fp_unity_launcher_entry_set_progress_visible(entry, visible);
+ DbusmenuMenuitem* m;
+ if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
+ fp_unity_launcher_entry_set_quicklist(entry, m);
+ }
+ fp_gdk_threads_leave();
+}
+
+void deleteGlobalRef(gpointer data) {
+ JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ (*env)->DeleteGlobalRef(env, data);
+}
+
+void fill_menu(JNIEnv *env, jobjectArray items) {
+ int index;
+ jsize length = (*env)->GetArrayLength(env, items);
+ for (index = 0; index < length; index++) {
+ jobject elem = (*env)->GetObjectArrayElement(env, items, index);
+ if ((*env)->ExceptionCheck(env)) {
+ break;
+ }
+ elem = (*env)->NewGlobalRef(env, elem);
+
+ globalRefs = fp_g_list_append(globalRefs, elem);
+
+ jstring jlabel = (jstring) (*env)->CallObjectMethod(env, elem, jMenuItemGetLabel);
+ if (!(*env)->ExceptionCheck(env) && jlabel) {
+ const gchar* label = (*env)->GetStringUTFChars(env, jlabel, NULL);
+ if (label) {
+ DbusmenuMenuitem* mi = fp_dbusmenu_menuitem_new();
+ if (!strcmp(label, "-")) {
+ fp_dbusmenu_menuitem_property_set(mi, "type", "separator");
+ } else {
+ fp_dbusmenu_menuitem_property_set(mi, "label", label);
+ }
+
+ (*env)->ReleaseStringUTFChars(env, jlabel, label);
+ fp_dbusmenu_menuitem_child_append(menu, mi);
+ fp_g_signal_connect(mi, "item_activated", G_CALLBACK(callback), elem);
+ }
+ }
+ }
+}
+
+/*
+ * Class: sun_awt_X11_XTaskbarPeer
+ * Method: setNativeMenu
+ * Signature: ([Ljava/awt/MenuItem;)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setNativeMenu
+(JNIEnv *env, jobject obj, jobjectArray items) {
+
+ fp_gdk_threads_enter();
+
+ if (!menu) {
+ menu = fp_dbusmenu_menuitem_new();
+ }
+
+ fp_unity_launcher_entry_set_quicklist(entry, menu);
+
+ GList* list = fp_dbusmenu_menuitem_take_children(menu);
+ fp_g_list_free_full(list, fp_g_object_unref);
+
+ fp_g_list_free_full(globalRefs, deleteGlobalRef);
+ globalRefs = NULL;
+
+ if (items) {
+ fill_menu(env, items);
+ }
+
+ fp_gdk_threads_leave();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file thats
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef AWT_TASKBAR_H
+#define AWT_TASKBAR_H
+
+#include "gtk2_interface.h"
+
+typedef void UnityLauncherEntry;
+typedef void DbusmenuMenuitem;
+
+static UnityLauncherEntry* (*fp_unity_launcher_entry_get_for_desktop_file) (const gchar* desktop_file);
+
+static void (*fp_unity_launcher_entry_set_count) (UnityLauncherEntry* self, gint64 value);
+static void (*fp_unity_launcher_entry_set_count_visible) (UnityLauncherEntry* self, gboolean value);
+
+static void (*fp_unity_launcher_entry_set_urgent) (UnityLauncherEntry* self, gboolean value);
+
+static void (*fp_unity_launcher_entry_set_progress) (UnityLauncherEntry* self, gdouble value);
+static void (*fp_unity_launcher_entry_set_progress_visible) (UnityLauncherEntry* self, gboolean value);
+
+
+static DbusmenuMenuitem* (*fp_dbusmenu_menuitem_new) (void);
+static gboolean (*fp_dbusmenu_menuitem_property_set) (DbusmenuMenuitem* mi, const gchar* property, const gchar* value);
+static gboolean (*fp_dbusmenu_menuitem_property_set_int) (DbusmenuMenuitem * mi, const gchar * property, const gint value);
+static gint (*fp_dbusmenu_menuitem_property_get_int) (const DbusmenuMenuitem * mi, const gchar * property);
+static gboolean (*fp_dbusmenu_menuitem_child_append) (DbusmenuMenuitem* mi, DbusmenuMenuitem* child);
+static gboolean (*fp_dbusmenu_menuitem_child_delete) (DbusmenuMenuitem * mi, DbusmenuMenuitem * child);
+static GList * (*fp_dbusmenu_menuitem_take_children) (DbusmenuMenuitem * mi);
+static void (*fp_dbusmenu_menuitem_foreach) (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data);
+static void (*fp_unity_launcher_entry_set_quicklist) (UnityLauncherEntry* self, DbusmenuMenuitem* value);
+static DbusmenuMenuitem* (*fp_unity_launcher_entry_get_quicklist) (UnityLauncherEntry* self);
+
+
+#endif /* AWT_TASKBAR_H */
+
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,10 +27,19 @@
import java.awt.Desktop.Action;
+import java.awt.EventQueue;
+import java.awt.desktop.SystemEventListener;
+import java.awt.desktop.SystemSleepEvent;
+import java.awt.desktop.SystemSleepListener;
+import java.awt.desktop.UserSessionEvent;
+import java.awt.desktop.UserSessionEvent.Reason;
+import java.awt.desktop.UserSessionListener;
import java.awt.peer.DesktopPeer;
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import javax.swing.event.EventListenerList;
+import sun.awt.OSInfo;
/**
@@ -45,10 +54,33 @@
private static String ACTION_EDIT_VERB = "edit";
private static String ACTION_PRINT_VERB = "print";
+ private static boolean isEventUserSessionSupported = false;
+
+ private static native void init();
+
+ WDesktopPeer() {
+ init();
+ isEventUserSessionSupported = OSInfo.getWindowsVersion()
+ .compareTo(OSInfo.WINDOWS_VISTA) >= 0;
+ }
+
@Override
public boolean isSupported(Action action) {
- // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows.
- return true;
+ switch(action) {
+ case OPEN:
+ case EDIT:
+ case PRINT:
+ case MAIL:
+ case BROWSE:
+ case MOVE_TO_TRASH:
+ case APP_SUDDEN_TERMINATION:
+ case APP_EVENT_SYSTEM_SLEEP:
+ return true;
+ case APP_EVENT_USER_SESSION:
+ return isEventUserSessionSupported;
+ default:
+ return false;
+ }
}
@Override
@@ -94,4 +126,70 @@
private static native String ShellExecute(String fileOrUri, String verb);
+ private static final EventListenerList listenerList = new EventListenerList();
+
+ @Override
+ public void disableSuddenTermination() {
+ setSuddenTerminationEnabled(false);
+ }
+
+ @Override
+ public void enableSuddenTermination() {
+ setSuddenTerminationEnabled(true);
+ }
+
+ private static native void setSuddenTerminationEnabled(boolean enable);
+
+ @Override
+ public void addAppEventListener(final SystemEventListener listener) {
+ if (listener instanceof UserSessionListener) {
+ listenerList.add(UserSessionListener.class, (UserSessionListener) listener);
+ }
+ if (listener instanceof SystemSleepListener) {
+ listenerList.add(SystemSleepListener.class, (SystemSleepListener) listener);
+ }
+ }
+
+ @Override
+ public void removeAppEventListener(final SystemEventListener listener) {
+ if (listener instanceof UserSessionListener) {
+ listenerList.remove(UserSessionListener.class, (UserSessionListener) listener);
+ }
+ if (listener instanceof SystemSleepListener) {
+ listenerList.remove(SystemSleepListener.class, (SystemSleepListener) listener);
+ }
+ }
+
+ private static void userSessionCallback(boolean activated, Reason reason) {
+ UserSessionListener[] listeners = listenerList.getListeners(UserSessionListener.class);
+ for (UserSessionListener use : listeners) {
+ EventQueue.invokeLater(() -> {
+ if (activated) {
+ use.userSessionActivated(new UserSessionEvent(reason));
+ } else {
+ use.userSessionDeactivated(new UserSessionEvent(reason));
+ }
+ });
+ }
+ }
+
+ private static void systemSleepCallback(boolean resumed) {
+ SystemSleepListener[] listeners = listenerList.getListeners(SystemSleepListener.class);
+ for (SystemSleepListener ssl : listeners) {
+ EventQueue.invokeLater(() -> {
+ if (resumed) {
+ ssl.systemAwoke(new SystemSleepEvent());
+ } else {
+ ssl.systemAboutToSleep(new SystemSleepEvent());
+ }
+ });
+ }
+ }
+
+ @Override
+ public boolean moveToTrash(File file) {
+ return moveToTrash(file.getAbsolutePath());
+ }
+ private static native boolean moveToTrash(String file);
+
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WTaskbarPeer.java Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.awt.windows;
+
+import java.awt.AlphaComposite;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Taskbar.Feature;
+import java.awt.Taskbar.State;
+import java.awt.peer.TaskbarPeer;
+import java.awt.Window;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferInt;
+import sun.awt.AWTAccessor;
+import sun.awt.OSInfo;
+import sun.awt.shell.ShellFolder;
+
+final class WTaskbarPeer implements TaskbarPeer {
+
+ private static boolean supported = false;
+ private static boolean initExecuted = false;
+
+ private static synchronized void init() {
+ if (!initExecuted) {
+ supported = OSInfo.getWindowsVersion()
+ .compareTo(OSInfo.WINDOWS_7) >= 0
+ && ShellFolder.invoke(() -> nativeInit());
+ }
+ initExecuted = true;
+ }
+
+ static boolean isTaskbarSupported() {
+ init();
+ return supported;
+ }
+
+ WTaskbarPeer() {
+ init();
+ }
+
+ @Override
+ public boolean isSupported(Feature feature) {
+ switch(feature) {
+ case ICON_BADGE_IMAGE_WINDOW:
+ case PROGRESS_STATE_WINDOW:
+ case PROGRESS_VALUE_WINDOW:
+ return supported;
+ case USER_ATTENTION_WINDOW:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ private static int[] imageToArray(Image image) {
+ if (image == null) {
+ return null;
+ }
+
+ int w = image.getWidth(null);
+ int h = image.getHeight(null);
+
+ if (w < 0 || h < 0) {
+ return null;
+ }
+
+ BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
+ Graphics2D g2 = bimg.createGraphics();
+ g2.setComposite(AlphaComposite.Src);
+ g2.drawImage(image, 0, 0, null);
+ g2.dispose();
+
+ return ((DataBufferInt) bimg.getRaster().getDataBuffer()).getData();
+ }
+
+ @Override
+ public void setWindowIconBadge(Window window, final Image image) {
+ WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window);
+ if (wp != null) {
+ int[] buffer = imageToArray(image);
+ ShellFolder.invoke(() -> {
+ setOverlayIcon(wp.getHWnd(), buffer,
+ buffer != null ? image.getWidth(null) : 0,
+ buffer != null ? image.getHeight(null) : 0);
+ return null;
+ });
+ }
+ }
+
+ @Override
+ public void requestWindowUserAttention(Window window) {
+ WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window);
+ if (wp != null) {
+ flashWindow(wp.getHWnd());
+ }
+ }
+
+ @Override
+ public void setWindowProgressValue(Window window, int value) {
+ WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window);
+ if (wp != null) {
+ ShellFolder.invoke(() -> {
+ setProgressValue(wp.getHWnd(), value);
+ return null;
+ });
+ }
+ }
+
+ @Override
+ public void setWindowProgressState(Window window, State state) {
+ WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window);
+ if (wp != null) {
+ ShellFolder.invoke(() -> {
+ setProgressState(wp.getHWnd(), state);
+ return null;
+ });
+ }
+ }
+
+ private static native boolean nativeInit();
+
+ private native void setProgressValue(long hwnd, int value);
+
+ private native void setProgressState(long hwnd, State state);
+
+ private native void setOverlayIcon(long hwnd, int[] badge, int width, int height);
+
+ private native void flashWindow(long hWnd);
+
+}
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package sun.awt.windows;
+import java.awt.peer.TaskbarPeer;
import java.awt.*;
import java.awt.im.InputMethodHighlight;
import java.awt.im.spi.InputMethodDescriptor;
@@ -1131,6 +1132,7 @@
@Override
public native boolean syncNativeQueue(final long timeout);
+
@Override
public boolean isDesktopSupported() {
return true;
@@ -1141,6 +1143,16 @@
return new WDesktopPeer();
}
+ @Override
+ public boolean isTaskbarSupported() {
+ return WTaskbarPeer.isTaskbarSupported();
+ }
+
+ @Override
+ public TaskbarPeer createTaskbarPeer(Taskbar target) {
+ return new WTaskbarPeer();
+ }
+
private static native void setExtraMouseButtonsEnabledNative(boolean enable);
@Override
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,18 @@
#include <jni.h>
#include <shellapi.h>
#include <float.h>
+#include <shlobj.h>
+#include "awt_Toolkit.h"
+
+#define BUFFER_LIMIT MAX_PATH+1
+
+#define NOTIFY_FOR_ALL_SESSIONS 1
+#define NOTIFY_FOR_THIS_SESSION 0
+
+typedef BOOL (WINAPI *WTSRegisterSessionNotification)(HWND,DWORD);
+static WTSRegisterSessionNotification fn_WTSRegisterSessionNotification;
+
+BOOL isSuddenTerminationEnabled = TRUE;
#ifdef __cplusplus
extern "C" {
@@ -35,6 +47,28 @@
/*
* Class: sun_awt_windows_WDesktopPeer
+ * Method: init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_init
+ (JNIEnv *, jclass) {
+ static HMODULE libWtsapi32 = NULL;
+ if (libWtsapi32 == NULL) {
+ libWtsapi32 = JDK_LoadSystemLibrary("Wtsapi32.dll");
+ if (libWtsapi32) {
+ fn_WTSRegisterSessionNotification = (WTSRegisterSessionNotification)
+ GetProcAddress(libWtsapi32, "WTSRegisterSessionNotification");
+ if (fn_WTSRegisterSessionNotification) {
+ HWND hwnd = AwtToolkit::GetInstance().GetHWnd();
+ //used for UserSessionListener
+ fn_WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION);
+ }
+ }
+ }
+}
+
+/*
+ * Class: sun_awt_windows_WDesktopPeer
* Method: ShellExecute
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
*/
@@ -82,6 +116,53 @@
return NULL;
}
+/*
+ * Class: sun_awt_windows_WDesktopPeer
+ * Method: moveToTrash
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WDesktopPeer_moveToTrash
+ (JNIEnv *env, jclass, jstring jpath)
+{
+ LPCTSTR pathStr = JNU_GetStringPlatformChars(env, jpath, (jboolean *)NULL);
+ if (pathStr) {
+ try {
+ LPTSTR fileBuffer = new TCHAR[BUFFER_LIMIT];
+ memset(fileBuffer, 0, BUFFER_LIMIT * sizeof(TCHAR));
+ // the fileBuffer is double null terminated string
+ _tcsncpy(fileBuffer, pathStr, BUFFER_LIMIT - 2);
+
+ SHFILEOPSTRUCT fop;
+ memset(&fop, 0, sizeof(SHFILEOPSTRUCT));
+ fop.hwnd = NULL;
+ fop.wFunc = FO_DELETE;
+ fop.pFrom = fileBuffer;
+ fop.fFlags = FOF_ALLOWUNDO;
+
+ int res = SHFileOperation(&fop);
+
+ delete[] fileBuffer;
+ JNU_ReleaseStringPlatformChars(env, jpath, pathStr);
+
+ return !res ? JNI_TRUE : JNI_FALSE;
+ } catch (std::bad_alloc&) {
+ JNU_ReleaseStringPlatformChars(env, jpath, pathStr);
+ }
+ }
+ return JNI_FALSE;
+}
+
+/*
+ * Class: sun_awt_windows_WDesktopPeer
+ * Method: setSuddenTerminationEnabled
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_setSuddenTerminationEnabled
+ (JNIEnv *, jclass, jboolean enabled)
+{
+ isSuddenTerminationEnabled = enabled;
+}
+
#ifdef __cplusplus
}
#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "jni_util.h"
+#include "awt.h"
+#include <jni.h>
+#include "awt_Taskbar.h"
+#include "awt_Window.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Class: sun_awt_windows_WTaskbarPeer
+ * Method: nativeInit
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WTaskbarPeer_nativeInit
+ (JNIEnv *env, jclass)
+{
+ if (SUCCEEDED(::CoCreateInstance(CLSID_TaskbarList, NULL,
+ CLSCTX_INPROC_SERVER, IID_ITaskbarList, (LPVOID *)&m_Taskbar))) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
+}
+
+/*
+ * Class: sun_awt_windows_WTaskbarPeer
+ * Method: setProgressValue
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressValue
+ (JNIEnv *, jobject, jlong window, jint value)
+{
+ m_Taskbar->SetProgressValue((HWND)window, value, 100);
+}
+
+
+
+/*
+ * Class: sun_awt_windows_WTaskbarPeer
+ * Method: setProgressState
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressState
+ (JNIEnv *env, jobject, jlong window, jobject state)
+{
+ TBPFLAG flag = TBPF_NOPROGRESS;
+
+ static jmethodID nameMID = NULL;
+ if (!nameMID) {
+ jclass stateCls = env->FindClass("java/awt/Taskbar$State");
+ CHECK_NULL(stateCls);
+ nameMID = env->GetMethodID(stateCls, "name", "()Ljava/lang/String;");
+ CHECK_NULL(nameMID);
+ }
+ jstring value = (jstring) env->CallObjectMethod(state, nameMID);
+ CHECK_NULL(value);
+ const char* valueNative = env->GetStringUTFChars(value, 0);
+ if (valueNative) {
+ if (strcmp(valueNative, "OFF") == 0) {
+ flag = TBPF_NOPROGRESS;
+ } else if (strcmp(valueNative, "NORMAL") == 0) {
+ flag = TBPF_NORMAL;
+ } else if (strcmp(valueNative, "PAUSED") == 0) {
+ flag = TBPF_PAUSED;
+ } else if (strcmp(valueNative, "INDETERMINATE") == 0) {
+ flag = TBPF_INDETERMINATE;
+ } else if (strcmp(valueNative, "ERROR") == 0) {
+ flag = TBPF_ERROR;
+ }
+ env->ReleaseStringUTFChars(value, valueNative);
+ m_Taskbar->SetProgressState((HWND)window, flag);
+ }
+}
+
+/*
+ * Class: sun_awt_windows_WTaskbarPeer
+ * Method: flashWindow
+ * Signature: (JZ)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_flashWindow
+ (JNIEnv *, jobject, jlong window)
+{
+ AwtWindow::FlashWindowEx((HWND) window, 3, 0, FLASHW_TIMERNOFG);
+}
+
+/*
+ * Class: sun_awt_windows_WTaskbarPeer
+ * Method: setOverlayIcon
+ * Signature: (J[III)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setOverlayIcon
+ (JNIEnv *env, jobject, jlong window, jintArray buf, jint w, jint h)
+{
+ HICON icon = CreateIconFromRaster(env, buf, w, h);
+ m_Taskbar->SetOverlayIcon((HWND)window, icon, NULL);
+ ::DestroyIcon(icon);
+}
+#ifdef __cplusplus
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.h Thu Mar 24 02:22:01 2016 +0300
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef AWT_TASKBAR_H
+#define AWT_TASKBAR_H
+
+#include <windows.h>
+#include <shlobj.h>
+
+
+#ifndef __ITaskbarList_INTERFACE_DEFINED__
+#define __ITaskbarList_INTERFACE_DEFINED__
+extern "C" {
+ const GUID CLSID_TaskbarList = {0x56FDF344, 0xFD6D, 0x11D0,
+ {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}};
+ const GUID IID_ITaskbarList = {0x56FDF342, 0xFD6D, 0x11D0,
+ {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}};
+}
+
+class ITaskbarList : public IUnknown {
+public:
+ virtual HRESULT STDMETHODCALLTYPE HrInit(void) = 0;
+ virtual HRESULT STDMETHODCALLTYPE AddTab(HWND hwnd) = 0;
+ virtual HRESULT STDMETHODCALLTYPE DeleteTab(HWND hwnd) = 0;
+ virtual HRESULT STDMETHODCALLTYPE ActivateTab(HWND hwnd) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetActiveAlt(HWND hwnd) = 0;
+};
+#endif /* ITaskbarList */
+
+#ifndef __ITaskbarList2_INTERFACE_DEFINED__
+#define __ITaskbarList2_INTERFACE_DEFINED__
+
+class ITaskbarList2 : public ITaskbarList {
+public:
+ virtual HRESULT STDMETHODCALLTYPE MarkFullscreenWindow(HWND hwnd, BOOL fFullscreen) = 0;
+};
+#endif /* ITaskbarList2 */
+
+#ifndef __ITaskbarList3_INTERFACE_DEFINED__
+#define __ITaskbarList3_INTERFACE_DEFINED__
+
+typedef enum THUMBBUTTONFLAGS {
+ THBF_ENABLED = 0, THBF_DISABLED = 0x1, THBF_DISMISSONCLICK = 0x2, THBF_NOBACKGROUND = 0x4, THBF_HIDDEN = 0x8, THBF_NONINTERACTIVE = 0x10
+} THUMBBUTTONFLAGS;
+
+typedef enum THUMBBUTTONMASK {
+ THB_BITMAP = 0x1, THB_ICON = 0x2, THB_TOOLTIP = 0x4, THB_FLAGS = 0x8
+} THUMBBUTTONMASK;
+
+typedef struct THUMBBUTTON {
+ THUMBBUTTONMASK dwMask;
+ UINT iId;
+ UINT iBitmap;
+ HICON hIcon;
+ WCHAR szTip[260];
+ THUMBBUTTONFLAGS dwFlags;
+} THUMBBUTTON;
+
+typedef enum TBPFLAG {
+ TBPF_NOPROGRESS = 0, TBPF_INDETERMINATE = 0x1, TBPF_NORMAL = 0x2, TBPF_ERROR = 0x4, TBPF_PAUSED = 0x8
+} TBPFLAG;
+#define THBN_CLICKED 0x1800
+
+class ITaskbarList3 : public ITaskbarList2 {
+public:
+ virtual HRESULT STDMETHODCALLTYPE SetProgressValue(HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetProgressState(HWND hwnd, TBPFLAG tbpFlags) = 0;
+ virtual HRESULT STDMETHODCALLTYPE RegisterTab(HWND hwndTab, HWND hwndMDI) = 0;
+ virtual HRESULT STDMETHODCALLTYPE UnregisterTab(HWND hwndTab) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetTabOrder(HWND hwndTab, HWND hwndInsertBefore) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetTabActive(HWND hwndTab, HWND hwndMDI, DWORD dwReserved) = 0;
+ virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons(HWND hwnd, UINT cButtons, THUMBBUTTON * pButton) = 0;
+ virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons(HWND hwnd, UINT cButtons, THUMBBUTTON * pButton) = 0;
+ virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList(HWND hwnd, HIMAGELIST himl) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon(HWND hwnd, HICON hIcon, LPCWSTR pszDescription) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip(HWND hwnd, LPCWSTR pszTip) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip(HWND hwnd, RECT *prcClip) = 0;
+};
+#endif /* ITaskbarList3 */
+
+
+ITaskbarList3 * m_Taskbar;
+
+
+#endif /* AWT_TASKBAR_H */
+
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -80,6 +80,16 @@
extern jfieldID jawtSDataID;
extern jfieldID jawtSMgrID;
+jobject reasonUnspecified;
+jobject reasonConsole;
+jobject reasonRemote;
+jobject reasonLock;
+
+extern jobject GetStaticObject(JNIEnv *env, jclass wfClass, const char *fieldName,
+ const char *signature);
+
+extern BOOL isSuddenTerminationEnabled;
+
extern void DWMResetCompositionEnabled();
/************************************************************************
@@ -269,6 +279,9 @@
/* ids for WToolkit fields accessed from native code */
jmethodID AwtToolkit::windowsSettingChangeMID;
jmethodID AwtToolkit::displayChangeMID;
+
+jmethodID AwtToolkit::userSessionMID;
+jmethodID AwtToolkit::systemSleepMID;
/* ids for Toolkit methods */
jmethodID AwtToolkit::getDefaultToolkitMID;
jmethodID AwtToolkit::getFontMetricsMID;
@@ -1046,6 +1059,9 @@
/* Session management */
case WM_QUERYENDSESSION: {
/* Shut down cleanly */
+ if (!isSuddenTerminationEnabled) {
+ return FALSE;
+ }
if (JVM_RaiseSignal(SIGTERM)) {
AwtToolkit::GetInstance().m_vmSignalled = TRUE;
}
@@ -1075,6 +1091,69 @@
DASSERT(FALSE);
break;
}
+#ifndef WM_WTSSESSION_CHANGE
+#define WM_WTSSESSION_CHANGE 0x02B1
+#define WTS_CONSOLE_CONNECT 0x1
+#define WTS_CONSOLE_DISCONNECT 0x2
+#define WTS_REMOTE_CONNECT 0x3
+#define WTS_REMOTE_DISCONNECT 0x4
+#define WTS_SESSION_LOGON 0x5
+#define WTS_SESSION_LOGOFF 0x6
+#define WTS_SESSION_LOCK 0x7
+#define WTS_SESSION_UNLOCK 0x8
+#define WTS_SESSION_REMOTE_CONTROL 0x9
+#endif // WM_WTSSESSION_CHANGE
+ case WM_WTSSESSION_CHANGE: {
+ jclass clzz = env->FindClass("sun/awt/windows/WDesktopPeer");
+ DASSERT(clzz != NULL);
+ if (!clzz) throw std::bad_alloc();
+
+ if (wParam == WTS_CONSOLE_CONNECT
+ || wParam == WTS_CONSOLE_DISCONNECT
+ || wParam == WTS_REMOTE_CONNECT
+ || wParam == WTS_REMOTE_DISCONNECT
+ || wParam == WTS_SESSION_UNLOCK
+ || wParam == WTS_SESSION_LOCK) {
+
+ BOOL activate = wParam == WTS_CONSOLE_CONNECT
+ || wParam == WTS_REMOTE_CONNECT
+ || wParam == WTS_SESSION_UNLOCK;
+ jobject reason = reasonUnspecified;
+
+ switch (wParam) {
+ case WTS_CONSOLE_CONNECT:
+ case WTS_CONSOLE_DISCONNECT:
+ reason = reasonConsole;
+ break;
+ case WTS_REMOTE_CONNECT:
+ case WTS_REMOTE_DISCONNECT:
+ reason = reasonRemote;
+ break;
+ case WTS_SESSION_UNLOCK:
+ case WTS_SESSION_LOCK:
+ reason = reasonLock;
+ }
+
+ env->CallStaticVoidMethod(clzz, AwtToolkit::userSessionMID,
+ activate
+ ? JNI_TRUE
+ : JNI_FALSE, reason);
+ }
+ break;
+ }
+ case WM_POWERBROADCAST: {
+ jclass clzz = env->FindClass("sun/awt/windows/WDesktopPeer");
+ DASSERT(clzz != NULL);
+ if (!clzz) throw std::bad_alloc();
+
+ if (wParam == PBT_APMSUSPEND || wParam == PBT_APMRESUMEAUTOMATIC) {
+ env->CallStaticVoidMethod(clzz, AwtToolkit::systemSleepMID,
+ wParam == PBT_APMRESUMEAUTOMATIC
+ ? JNI_TRUE
+ : JNI_FALSE);
+ }
+ break;
+ }
case WM_SYNC_WAIT:
SetEvent(AwtToolkit::GetInstance().m_waitEvent);
break;
@@ -2133,6 +2212,45 @@
CHECK_NULL(jawtVImgClass);
jawtComponentClass = (jclass)env->NewGlobalRef(componentClassLocal);
+ jclass dPeerClassLocal = env->FindClass("sun/awt/windows/WDesktopPeer");
+ DASSERT(dPeerClassLocal != 0);
+ CHECK_NULL(dPeerClassLocal);
+
+ jclass reasonClassLocal = env->FindClass("java/awt/desktop/UserSessionEvent$Reason");
+ CHECK_NULL(reasonClassLocal);
+
+ reasonUnspecified = GetStaticObject(env, reasonClassLocal, "UNSPECIFIED",
+ "Ljava/awt/desktop/UserSessionEvent$Reason;");
+ CHECK_NULL (reasonUnspecified);
+ reasonUnspecified = env->NewGlobalRef(reasonUnspecified);
+
+ reasonConsole = GetStaticObject(env, reasonClassLocal, "CONSOLE",
+ "Ljava/awt/desktop/UserSessionEvent$Reason;");
+ CHECK_NULL (reasonConsole);
+ reasonConsole = env->NewGlobalRef(reasonConsole);
+
+ reasonRemote = GetStaticObject(env, reasonClassLocal, "REMOTE",
+ "Ljava/awt/desktop/UserSessionEvent$Reason;");
+ CHECK_NULL (reasonRemote);
+ reasonRemote = env->NewGlobalRef(reasonRemote);
+
+ reasonLock = GetStaticObject(env, reasonClassLocal, "LOCK",
+ "Ljava/awt/desktop/UserSessionEvent$Reason;");
+ CHECK_NULL (reasonLock);
+ reasonLock = env->NewGlobalRef(reasonLock);
+
+
+ AwtToolkit::userSessionMID =
+ env->GetStaticMethodID(dPeerClassLocal, "userSessionCallback",
+ "(ZLjava/awt/desktop/UserSessionEvent$Reason;)V");
+ DASSERT(AwtToolkit::userSessionMID != 0);
+ CHECK_NULL(AwtToolkit::userSessionMID);
+
+ AwtToolkit::systemSleepMID =
+ env->GetStaticMethodID(dPeerClassLocal, "systemSleepCallback", "(Z)V");
+ DASSERT(AwtToolkit::systemSleepMID != 0);
+ CHECK_NULL(AwtToolkit::systemSleepMID);
+
CATCH_BAD_ALLOC;
}
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -171,12 +171,15 @@
/* java.awt.Toolkit method ids */
static jmethodID getDefaultToolkitMID;
static jmethodID getFontMetricsMID;
- static jmethodID insetsMID;
+ static jmethodID insetsMID;
/* sun.awt.windows.WToolkit ids */
static jmethodID windowsSettingChangeMID;
static jmethodID displayChangeMID;
+ static jmethodID userSessionMID;
+ static jmethodID systemSleepMID;
+
BOOL m_isDynamicLayoutSet;
AwtToolkit();
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Window.h Wed Mar 23 21:20:25 2016 +0100
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Window.h Thu Mar 24 02:22:01 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -398,4 +398,6 @@
inline bool IsAlwaysOnTop() { return m_alwaysOnTop; }
};
+HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h);
+
#endif /* AWT_WINDOW_H */