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 (true
) or not (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 true
. Because AWT supplies
- * a standard About window when an application may not, by default this is set to 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 (true
) or not (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 java.awt.MouseInfo.getPointerInfo().getLocation()
.
- *
- * @since 1.4
- */
- @Deprecated
- public static Point getMouseLocationOnScreen() {
- return java.awt.MouseInfo.getPointerInfo().getLocation();
- }
}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java 2015-11-24 19:06:33.060601309 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java 2015-11-24 19:06:32.928601305 +0300
@@ -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")
--- old/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java 2015-11-24 19:06:33.520601320 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java 2015-11-24 19:06:33.372601317 +0300
@@ -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
--- old/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java 2015-11-24 19:06:33.936601331 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java 2015-11-24 19:06:33.796601327 +0300
@@ -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 @@
* event
. To reject the quit, set 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);
--- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java 2015-11-24 19:06:34.372601342 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java 2015-11-24 19:06:34.232601339 +0300
@@ -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
--- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java 2015-11-24 19:06:34.800601353 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java 2015-11-24 19:06:34.672601350 +0300
@@ -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;
--- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java 2015-11-24 19:06:35.232601364 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java 2015-11-24 19:06:35.092601361 +0300
@@ -25,9 +25,9 @@
package com.apple.eawt;
+import com.apple.eawt.event.FullScreenEvent;
import java.util.EventListener;
-import com.apple.eawt.AppEvent.FullScreenEvent;
/**
*
--- old/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java 2015-11-24 19:06:35.676601376 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java 2015-11-24 19:06:35.540601372 +0300
@@ -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);
@@ -92,6 +93,10 @@
void setDockIconBadge(final String badge) {
nativeSetDockIconBadge(badge);
}
+
+ void setDockIconProgress(int value) {
+ nativeSetDockIconProgress(value);
+ }
static Creator getCImageCreator() {
try {
--- old/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java 2015-11-24 19:06:36.132601387 +0300
+++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java 2015-11-24 19:06:35.984601383 +0300
@@ -26,6 +26,7 @@
package com.apple.eawt;
import java.awt.*;
+import java.awt.desktop.*;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.*;
@@ -34,7 +35,7 @@
import sun.awt.AppContext;
import sun.awt.SunToolkit;
-import com.apple.eawt.AppEvent.*;
+import java.awt.AppEvent.*;
class _AppEventHandler {
private static final int NOTIFY_ABOUT = 1;
@@ -84,8 +85,6 @@
final _ScreenSleepDispatcher screenSleepDispatcher = new _ScreenSleepDispatcher();
final _SystemSleepDispatcher systemSleepDispatcher = new _SystemSleepDispatcher();
- final _AppEventLegacyHandler legacyHandler = new _AppEventLegacyHandler(this);
-
QuitStrategy defaultQuitAction = QuitStrategy.SYSTEM_EXIT_0;
_AppEventHandler() {
@@ -101,8 +100,8 @@
}
}
- 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 +109,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 +126,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() {
@@ -270,10 +269,10 @@
}
}
- class _AppReOpenedDispatcher extends _AppEventMultiplexorSupported operations include: *
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
@@ -70,6 +73,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 +111,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 1.9
+ */
+ APP_EVENT_FOREGROUND,
+
+ /**
+ * Represents an AppHiddenListener
+ * @see java.awt.desktop.AppHiddenListener
+ * @since 1.9
+ */
+ APP_EVENT_HIDDEN,
+
+ /**
+ * Represents an AppReopenedListener
+ * @see java.awt.desktop.AppReopenedListener
+ * @since 1.9
+ */
+ APP_EVENT_REOPENED,
+
+ /**
+ * Represents a ScreenSleepListener
+ * @see java.awt.desktop.ScreenSleepListener
+ * @since 1.9
+ */
+ APP_EVENT_SCREEN_SLEEP,
+
+ /**
+ * Represents a SystemSleepListener
+ * @see java.awt.desktop.SystemSleepListener
+ * @since 1.9
+ */
+ APP_EVENT_SYSTEM_SLEEP,
+
+ /**
+ * Represents a UserSessionListener
+ * @see java.awt.desktop.UserSessionListener
+ * @since 1.9
+ */
+ APP_EVENT_USER_SESSION,
+
+ /**
+ * Represents an AboutHandler
+ * @see #setAboutHandler(java.awt.desktop.AboutHandler)
+ * @since 1.9
+ */
+ APP_ABOUT,
+
+ /**
+ * Represents a PreferencesHandler
+ * @see #setPreferencesHandler(java.awt.desktop.PreferencesHandler)
+ * @since 1.9
+ */
+ APP_PREFERENCES,
+
+ /**
+ * Represents an OpenFilesHandler
+ * @see #setOpenFileHandler(java.awt.desktop.OpenFilesHandler)
+ * @since 1.9
+ */
+ APP_OPEN_FILE,
+
+ /**
+ * Represents a PrintFilesHandler
+ * @see #setPrintFileHandler(java.awt.desktop.PrintFilesHandler)
+ * @since 1.9
+ */
+ APP_PRINT_FILE,
+
+ /**
+ * Represents an OpenURIHandler
+ * @see #setOpenURIHandler(java.awt.desktop.OpenURIHandler)
+ * @since 1.9
+ */
+ APP_OPEN_URI,
+
+ /**
+ * Represents a QuitHandler
+ * @see #setQuitHandler(java.awt.desktop.QuitHandler)
+ * @since 1.9
+ */
+ APP_QUIT_HANDLER,
+
+ /**
+ * Represents a QuitStrategy
+ * @see #setQuitStrategy(java.awt.desktop.QuitStrategy)
+ * @since 1.9
+ */
+ APP_QUIT_STRATEGY,
+
+ /**
+ * Represents a SuddenTermination
+ * @see #enableSuddenTermination()
+ * @since 1.9
+ */
+ APP_SUDDEN_TERMINATION,
+
+ /**
+ * Represents a requestForeground
+ * @see #requestForeground(boolean)
+ * @since 1.9
+ */
+ APP_REQUEST_FOREGROUND,
+
+ /**
+ * Represents a HelpViewer
+ * @see #openHelpViewer()
+ * @since 1.9
+ */
+ APP_HELP_VIEWER,
+
+ /**
+ * Represents a menu bar
+ * @see #setDefaultMenuBar(javax.swing.JMenuBar)
+ * @since 1.9
+ */
+ APP_MENU_BAR,
+
+ /**
+ * Represents a browse file directory
+ * @see #browseFileDirectory(java.io.File)
+ * @since 1.9
+ */
+ BROWSE_FILE_DIR,
+
+ /**
+ * Represents a move to trash
+ * @see #moveToTrash(java.io.File)
+ * @since 1.9
+ */
+ MOVE_TO_TRASH
};
private DesktopPeer peer;
@@ -128,10 +267,10 @@
/**
* Returns the
+ * Setting the {@link AboutHandler} to
+ * Setting the {@link PreferencesHandler} to
+ * Setting the {@link AboutHandler} to
+ * Setting the {@link PreferencesHandler} to
+ * 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
+ * https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles
+ *
+ * @since 1.9
+ */
+
+public class Taskbar {
+
+ /**
+ * List of provided features.
+ */
+ public static enum Feature {
+
+ /**
+ * @see #setIconBadge(java.lang.String)
+ */
+ ICON_BADGE_TEXT,
+
+ /**
+ * @see #setIconBadge(java.lang.String)
+ */
+ ICON_BADGE_NUMBER,
+
+ /**
+ * @see #setWindowIconBadge(java.awt.Window, java.awt.Image)
+ */
+ ICON_BADGE_IMAGE_WINDOW,
+
+ /**
+ * @see #setIconImage(java.awt.Image)
+ */
+ ICON_IMAGE,
+
+ /**
+ * @see #setMenu(java.awt.PopupMenu)
+ * @see #getMenu()
+ */
+ MENU,
+
+ /**
+ * @see #setWindowProgressState(java.awt.Window, int)
+ */
+ PROGRESS_STATE_WINDOW,
+
+ /**
+ * @see #setProgressValue(int)
+ */
+ PROGRESS_VALUE,
+
+ /**
+ * @see #setWindowProgressValue(java.awt.Window, int)
+ */
+ PROGRESS_VALUE_WINDOW,
+
+ /**
+ * @see #requestUserAttention(boolean, boolean)
+ */
+ USER_ATTENTION,
+
+ /**
+ * @see #requestWindowUserAttention(java.awt.Window)
+ */
+ USER_ATTENTION_WINDOW
+ }
+
+ /**
+ * Stops displaying the progress.
+ */
+ @Native
+ public static final int STATE_OFF = 0x0;
+
+ /**
+ * The progress indicator displays with normal color and determinate mode.
+ */
+ @Native
+ public static final int STATE_NORMAL = 0x1;
+
+ /**
+ * Shows progress as paused, progress can be resumed by the user.
+ * Switches to the determinate display.
+ */
+ @Native
+ public static final int STATE_PAUSED = 0x2;
+
+ /**
+ * The progress indicator displays activity without specifying what
+ * proportion of the progress is complete.
+ */
+ @Native
+ public static final int STATE_INDETERMINATE = 0x3;
+
+ /**
+ * Shows that an error has occurred.
+ * Switches to the determinate display.
+ */
+ @Native
+ public static final int STATE_ERROR = 0x4;
+
+ 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 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 +347,7 @@
if (!file.exists()) {
throw new IllegalArgumentException("The file: "
- + file.getPath() + " doesn't exist.");
+ + file.getPath() + " doesn't exist.");
}
file.canRead();
@@ -224,7 +363,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 +377,7 @@
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new AWTPermission(
- "showWindowWithoutWarningBanner"));
+ "showWindowWithoutWarningBanner"));
}
}
@@ -479,7 +618,334 @@
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new FilePermission("<null
reverts it to the
+ * default behavior.
+ *
+ * @param aboutHandler the handler to respond to the
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_ABOUT} action
+ * {@link AboutHandler#handleAbout} )} message
+ * @since 1.9
+ */
+ public void setAboutHandler(final AboutHandler aboutHandler) {
+ checkActionSupport(Action.APP_ABOUT);
+ peer.setAboutHandler(aboutHandler);
+ }
+
+ /**
+ * Installs a handler to show a custom Preferences window for your
+ * application.
+ * null
reverts it to
+ * the default behavior
+ *
+ * @param preferencesHandler the handler to respond to the
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_PREFERENCES} action
+ * {@link PreferencesHandler#handlePreferences(PreferencesEvent)}
+ * @since 1.9
+ */
+ public void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
+ 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
+ *
+ * Info.plist Key Reference for more information about adding a
+ * {@code CFBundleDocumentTypes} key to your app's Info.plist.
+ *
+ * @param openFileHandler handler
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_OPEN_FILE} action
+ * @since 1.9
+ */
+ public void setOpenFileHandler(final OpenFilesHandler openFileHandler) {
+ 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
+ *
+ * Info.plist Key Reference for more information about adding a
+ * {@code CFBundleDocumentTypes} key to your app's Info.plist.
+ *
+ * @param printFileHandler handler
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_PRINT_FILE} action
+ * @since 1.9
+ */
+ public void setPrintFileHandler(final PrintFilesHandler printFileHandler) {
+ 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 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
+ *
+ * Info.plist Key Reference for more information about adding a
+ * {@code CFBundleDocumentTypes} key to your app's Info.plist.
+ *
+ * @param openURIHandler handler
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_OPEN_URI} action
+ * @since 1.9
+ */
+ public void setOpenURIHandler(final OpenURIHandler openURIHandler) {
+ 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 QuitResponse} which can cancel or
+ * proceed with the quit. Setting the handler to 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 UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_QUIT_HANDLER} action
+ * @since 1.9
+ */
+ public void setQuitHandler(final QuitHandler quitHandler) {
+ 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 UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action
+ * @see QuitStrategy
+ * @since 1.9
+ */
+ public void setQuitStrategy(final QuitStrategy strategy) {
+ 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.
+ *
+ * Note: enabling sudden termination will allow your application to be
+ * quit without notifying your QuitHandler, or running any shutdown
+ * hooks.
+ * E.g. user-initiated Cmd-Q, logout, restart, or shutdown requests will
+ * effectively "kill -KILL" your application.
+ *
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action
+ * @see #disableSuddenTermination()
+ * @since 1.9
+ */
+ public void enableSuddenTermination() {
+ 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 UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action
+ * @see #enableSuddenTermination()
+ * @since 1.9
+ */
+ public void disableSuddenTermination() {
+ 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
+ * AWTPermission("showWindowWithoutWarningBanner")
permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_REQUEST_FOREGROUND} action
+ * @since 1.9
+ */
+ public void requestForeground(final boolean allWindows) {
+ checkAWTPermission();
+ checkActionSupport(Action.APP_REQUEST_FOREGROUND);
+ peer.requestForeground(allWindows);
+ }
+
+ /**
+ * Opens the native help viewer application.
+ *
+ * @throws SecurityException if a security manager exists and it denies the
+ * AWTPermission("showWindowWithoutWarningBanner")
permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_HELP_VIEWER} action
+ * @since 1.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
+ * AWTPermission("showWindowWithoutWarningBanner")
permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#APP_MENU_BAR} action
+ * @since 1.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 1.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 1.9
+ */
+ public boolean moveToTrash(final File file) {
+ checkWrite();
+ checkActionSupport(Action.MOVE_TO_TRASH);
+ checkFileValidation(file);
+ return peer.moveToTrash(file);
+ }
}
--- old/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java 2015-11-24 19:06:39.700601479 +0300
+++ new/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java 2015-11-24 19:06:39.548601475 +0300
@@ -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.
+ * 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.
+ * null
reverts it to
+ * the default behavior
+ *
+ * @param preferencesHandler the handler to respond to the
+ * {@link java.awt.desktop.PreferencesHandler#handlePreferences(java.awt.AppEvent.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 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;
+ }
+
}
--- old/src/java.desktop/share/classes/sun/awt/ComponentFactory.java 2015-11-24 19:06:40.176601491 +0300
+++ new/src/java.desktop/share/classes/sun/awt/ComponentFactory.java 2015-11-24 19:06:40.024601487 +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;
@@ -73,6 +74,23 @@
default DesktopPeer createDesktopPeer(Desktop target) {
throw new HeadlessException();
}
+
+ /**
+ * 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 1.9
+ */
+ default TaskbarPeer createTaskbarPeer(Taskbar target) {
+ throw new HeadlessException();
+ }
/**
* Creates this toolkit's implementation of {@code Button} using the
--- old/src/java.desktop/share/classes/sun/awt/HToolkit.java 2015-11-24 19:06:40.604601502 +0300
+++ new/src/java.desktop/share/classes/sun/awt/HToolkit.java 2015-11-24 19:06:40.468601498 +0300
@@ -281,10 +281,16 @@
return false;
}
+
@Override
public boolean isDesktopSupported() {
return false;
}
+
+ @Override
+ public boolean isTaskbarSupported() {
+ return false;
+ }
public boolean isWindowOpacityControlSupported() {
return false;
--- old/src/java.desktop/share/classes/sun/awt/SunToolkit.java 2015-11-24 19:06:41.072601514 +0300
+++ new/src/java.desktop/share/classes/sun/awt/SunToolkit.java 2015-11-24 19:06:40.912601510 +0300
@@ -1792,6 +1792,7 @@
public abstract boolean isDesktopSupported();
+ public abstract boolean isTaskbarSupported();
/*
* consumeNextKeyTyped() method is not currently used,
--- old/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-11-24 19:06:41.552601526 +0300
+++ new/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-11-24 19:06:41.384601522 +0300
@@ -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;
@@ -2567,6 +2568,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;
}
--- old/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c 2015-11-24 19:06:42.040601538 +0300
+++ new/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c 2015-11-24 19:06:41.904601535 +0300
@@ -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.
--- old/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h 2015-11-24 19:06:42.540601551 +0300
+++ new/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h 2015-11-24 19:06:42.384601547 +0300
@@ -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.
--- old/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java 2015-11-24 19:06:42.996601563 +0300
+++ new/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java 2015-11-24 19:06:42.856601559 +0300
@@ -26,11 +26,18 @@
package sun.awt.windows;
+import java.awt.AppEvent;
import java.awt.Desktop.Action;
+import java.awt.EventQueue;
+import java.awt.desktop.SystemEventListener;
+import java.awt.desktop.SystemSleepListener;
+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;
/**
@@ -44,11 +51,33 @@
private static String ACTION_OPEN_VERB = "open";
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_EVENT_SYSTEM_SLEEP:
+ return true;
+ case APP_EVENT_USER_SESSION:
+ return isEventUserSessionSupported;
+ default:
+ return false;
+ }
}
@Override
@@ -93,5 +122,59 @@
}
private static native String ShellExecute(String fileOrUri, String verb);
-
+
+ private static final EventListenerList listenerList = new EventListenerList();
+
+ @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) {
+ UserSessionListener[] listeners = listenerList.getListeners(UserSessionListener.class);
+ for (UserSessionListener use : listeners) {
+ EventQueue.invokeLater(() -> {
+ if (activated) {
+ use.userSessionActivated(new AppEvent.UserSessionEvent());
+ } else {
+ use.userSessionDeactivated(new AppEvent.UserSessionEvent());
+ }
+ });
+ }
+ }
+
+ private static void systemSleepCallback(boolean resumed) {
+ SystemSleepListener[] listeners = listenerList.getListeners(SystemSleepListener.class);
+ for (SystemSleepListener ssl : listeners) {
+ EventQueue.invokeLater(() -> {
+ if (resumed) {
+ ssl.systemAwoke(new AppEvent.SystemSleepEvent());
+ } else {
+ ssl.systemAboutToSleep(new AppEvent.SystemSleepEvent());
+ }
+ });
+ }
+ }
+
+ @Override
+ public boolean moveToTrash(File file) {
+ return moveToTrash(file.getAbsolutePath());
+ }
+ private static native boolean moveToTrash(String file);
+
}
--- old/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java 2015-11-24 19:06:43.436601574 +0300
+++ new/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java 2015-11-24 19:06:43.308601571 +0300
@@ -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;
@@ -1110,16 +1111,27 @@
@Override
public native boolean syncNativeQueue(final long timeout);
+
@Override
public boolean isDesktopSupported() {
return true;
}
-
+
@Override
public DesktopPeer createDesktopPeer(Desktop target) {
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
--- old/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2015-11-24 19:06:43.888601586 +0300
+++ new/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2015-11-24 19:06:43.736601582 +0300
@@ -28,6 +28,16 @@
#include checkPermission
method with
+ * an 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 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 true
if this class is supported on the
+ * current platform; 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * AWTPermission("showWindowWithoutWarningBanner")
permission.
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Taskbar.Feature#PROGRESS_STATE_WINDOW} feature
+ * @throws IllegalArgumentException if {@code state} is invalid
+ */
+ public void setWindowProgressState(Window w, int state) {
+ checkAWTPermission();
+ checkFeatureSupport(Feature.PROGRESS_STATE_WINDOW);
+ if (state < STATE_OFF && state > STATE_ERROR) {
+ throw new IllegalArgumentException("Invalid state value");
+ }
+ if (w != null) {
+ peer.setWindowProgressState(w, state);
+ }
+ }
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/AboutHandler.java 2015-11-24 19:06:48.036601692 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.AboutEvent;
+
+/**
+ * An implementer receives notification when the app is asked to show its about dialog.
+ *
+ * @see java.awt.Desktop#setAboutHandler(java.awt.desktop.AboutHandler)
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/AppForegroundListener.java 2015-11-24 19:06:48.524601704 +0300
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, 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.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.
+ */
+public interface AppForegroundListener extends SystemEventListener {
+ /**
+ * 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);
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/AppHiddenListener.java 2015-11-24 19:06:49.000601717 +0300
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, 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.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.
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/AppReopenedListener.java 2015-11-24 19:06:49.536601730 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.AppReopenedEvent;
+
+/**
+ * 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.
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/OpenFilesHandler.java 2015-11-24 19:06:50.020601743 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.OpenFilesEvent;
+
+/**
+ * An implementor is notified when the application is asked to open a list of files.
+ *
+ * @see java.awt.Desktop#setOpenFileHandler(java.awt.desktop.OpenFilesHandler)
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/OpenURIHandler.java 2015-11-24 19:06:50.512601755 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.OpenURIEvent;
+
+/**
+ * An implementor is notified when the application is asked to open a URI.
+ *
+ * @see java.awt.Desktop#setOpenURIHandler(java.awt.desktop.OpenURIHandler)
+ */
+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);
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/PreferencesHandler.java 2015-11-24 19:06:50.980601767 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.PreferencesEvent;
+
+/**
+ * An implementor is notified when the app is asked to show its preferences UI.
+ *
+ * @see java.awt.Desktop#setPreferencesHandler(java.awt.desktop.PreferencesHandler)
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/PrintFilesHandler.java 2015-11-24 19:06:51.448601779 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.PrintFilesEvent;
+
+/**
+ * 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)
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/QuitHandler.java 2015-11-24 19:06:51.912601791 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, 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.AppEvent.QuitEvent;
+
+/**
+ * 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)
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/QuitResponse.java 2015-11-24 19:06:52.424601804 +0300
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, 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)
+ */
+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.
+ * Note: this will cancel a pending log-out, restart, or shutdown.
+ */
+ public void cancelQuit();
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/QuitStrategy.java 2015-11-24 19:06:52.988601819 +0300
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, 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()
+ *
+ */
+public enum QuitStrategy {
+ /**
+ * Shuts down the application by calling 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
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepListener.java 2015-11-24 19:06:53.476601831 +0300
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015, 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.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.
+ *
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/SystemEventListener.java 2015-11-24 19:06:53.960601844 +0300
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ */
+public interface SystemEventListener extends EventListener{}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/SystemSleepListener.java 2015-11-24 19:06:54.444601856 +0300
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, 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.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.
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/desktop/UserSessionListener.java 2015-11-24 19:06:54.924601868 +0300
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, 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.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.
+ *
+ */
+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 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java 2015-11-24 19:06:55.432601881 +0300
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2015, 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.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, int 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; }
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java 2015-11-24 19:06:55.944601894 +0300
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2015, 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);
+}
--- /dev/null 2015-11-19 20:55:17.685707015 +0300
+++ new/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c 2015-11-24 19:06:56.444601907 +0300
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2015, 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 CFBundleURLTypes
entry.
- * See the Info.plist Key Reference for more information about adding a 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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/PreferencesHandler.java 2015-11-24 19:07:01.556602038 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/PrintFilesHandler.java 2015-11-24 19:07:01.872602046 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/QuitHandler.java 2015-11-24 19:07:02.152602053 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/QuitResponse.java 2015-11-24 19:07:02.468602062 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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.
- * Note: this will cancel a pending log-out, restart, or shutdown.
- */
- public void cancelQuit() {
- if (appEventHandler.currentQuitResponse != this) return;
- appEventHandler.cancelQuit();
- }
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/QuitStrategy.java 2015-11-24 19:07:02.756602069 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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 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
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/ScreenSleepListener.java 2015-11-24 19:07:03.028602076 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/SystemSleepListener.java 2015-11-24 19:07:03.352602084 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/UserSessionListener.java 2015-11-24 19:07:03.644602092 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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);
-}
--- old/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventLegacyHandler.java 2015-11-24 19:07:03.944602099 +0300
+++ /dev/null 2015-11-19 20:55:17.685707015 +0300
@@ -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