--- old/make/mapfiles/libawt_xawt/mapfile-vers 2015-11-19 18:20:22.561553866 +0300 +++ new/make/mapfiles/libawt_xawt/mapfile-vers 2015-11-19 18:20:22.433553863 +0300 @@ -150,6 +150,13 @@ Java_sun_awt_X11_XlibWrapper_XdbeEndIdiom; Java_sun_awt_X11_XDesktopPeer_init; Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show; + Java_sun_awt_X11_XTaskbarPeer_initIDs; + Java_sun_awt_X11_XTaskbarPeer_init; + Java_sun_awt_X11_XTaskbarPeer_runloop; + Java_sun_awt_X11_XTaskbarPeer_setBadge; + Java_sun_awt_X11_XTaskbarPeer_setUrgent; + Java_sun_awt_X11_XTaskbarPeer_updateProgress; + Java_sun_awt_X11_XTaskbarPeer_setNativeMenu; Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl; Java_sun_awt_X11_XRobotPeer_keyPressImpl; Java_sun_awt_X11_XRobotPeer_keyReleaseImpl; --- old/src/java.desktop/macosx/classes/com/apple/eawt/Application.java 2015-11-19 18:20:22.989553877 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/Application.java 2015-11-19 18:20:22.857553874 +0300 @@ -30,6 +30,7 @@ import java.awt.PopupMenu; import java.awt.Toolkit; import java.awt.Window; +import java.awt.desktop.*; import java.beans.Beans; import javax.swing.JMenuBar; @@ -104,38 +105,38 @@ } /** - * Adds sub-types of {@link AppEventListener} to listen for notifications from the native Mac OS X system. + * Adds sub-types of {@link SystemEventListener} to listen for notifications from the native Mac OS X system. * * @see AppForegroundListener * @see AppHiddenListener * @see AppReOpenedListener - * @see ScreenSleepListener - * @see SystemSleepListener - * @see UserSessionListener + * @see AppScreenSleepListener + * @see AppSystemSleepListener + * @see AppUserSessionListener * * @param listener * @since Java for Mac OS X 10.6 Update 3 * @since Java for Mac OS X 10.5 Update 8 */ - public void addAppEventListener(final AppEventListener listener) { + public void addAppEventListener(final SystemEventListener listener) { eventHandler.addListener(listener); } /** - * Removes sub-types of {@link AppEventListener} from listening for notifications from the native Mac OS X system. + * Removes sub-types of {@link SystemEventListener} from listening for notifications from the native Mac OS X system. * * @see AppForegroundListener * @see AppHiddenListener * @see AppReOpenedListener - * @see ScreenSleepListener - * @see SystemSleepListener - * @see UserSessionListener + * @see AppScreenSleepListener + * @see AppSystemSleepListener + * @see AppUserSessionListener * * @param listener * @since Java for Mac OS X 10.6 Update 3 * @since Java for Mac OS X 10.5 Update 8 */ - public void removeAppEventListener(final AppEventListener listener) { + public void removeAppEventListener(final SystemEventListener listener) { eventHandler.removeListener(listener); } @@ -366,6 +367,16 @@ public void setDockIconBadge(final String badge) { iconHandler.setDockIconBadge(badge); } + + /** + * Displays a progress bar to this application's Dock icon. + * Acceptable values are from 0 to 100, any other disables progress indication. + * + * @param value progress value + */ + public void setDockIconProgress(final int value) { + iconHandler.setDockIconProgress(value); + } /** * Sets the default menu bar to use when there are no active frames. @@ -397,168 +408,4 @@ ((CPlatformWindow)platformWindow).toggleFullScreen(); } - - // -- DEPRECATED API -- - - /** - * Adds the specified ApplicationListener as a receiver of callbacks from this class. - * This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed. - * - * @param listener an implementation of ApplicationListener that handles ApplicationEvents - * - * @deprecated register individual handlers for each task (About, Preferences, Open, Print, Quit, etc) - * @since 1.4 - */ - @SuppressWarnings("deprecation") - @Deprecated - public void addApplicationListener(final ApplicationListener listener) { - eventHandler.legacyHandler.addLegacyAppListener(listener); - } - - /** - * Removes the specified ApplicationListener from being a receiver of callbacks from this class. - * This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed. - * - * @param listener an implementation of ApplicationListener that had previously been registered to handle ApplicationEvents - * - * @deprecated unregister individual handlers for each task (About, Preferences, Open, Print, Quit, etc) - * @since 1.4 - */ - @SuppressWarnings("deprecation") - @Deprecated - public void removeApplicationListener(final ApplicationListener listener) { - eventHandler.legacyHandler.removeLegacyAppListener(listener); - } - - /** - * Enables the Preferences item in the application menu. The ApplicationListener receives a callback for - * selection of the Preferences item in the application menu only if this is set to 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-19 18:20:23.413553888 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java 2015-11-19 18:20:23.281553884 +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-19 18:20:23.821553898 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java 2015-11-19 18:20:23.689553895 +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-19 18:20:24.237553909 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java 2015-11-19 18:20:24.105553906 +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-19 18:20:24.641553919 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java 2015-11-19 18:20:24.521553916 +0300 @@ -25,7 +25,7 @@ package com.apple.eawt; -import com.apple.eawt.AppEvent.FullScreenEvent; +import java.awt.AppEvent.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-19 18:20:25.037553929 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java 2015-11-19 18:20:24.913553926 +0300 @@ -31,7 +31,8 @@ import javax.swing.RootPaneContainer; -import com.apple.eawt.AppEvent.FullScreenEvent; +import java.awt.AppEvent.FullScreenEvent; +import java.awt.desktop.FullScreenListener; import sun.awt.SunToolkit; import java.lang.annotation.Native; --- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenUtilities.java 2015-11-19 18:20:25.453553940 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenUtilities.java 2015-11-19 18:20:25.325553937 +0300 @@ -32,6 +32,7 @@ import sun.lwawt.macosx.*; import com.apple.eawt.event.GestureUtilities; +import java.awt.desktop.FullScreenListener; /** * Utility class perform animated full screen actions to top-level {@link Window}s. --- old/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java 2015-11-19 18:20:25.873553951 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java 2015-11-19 18:20:25.745553947 +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-19 18:20:26.293553962 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java 2015-11-19 18:20:26.157553958 +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 _AppEventMultiplexor { - void performOnListener(AppReOpenedListener listener, final _NativeEvent event) { - final AppReOpenedEvent e = new AppReOpenedEvent(); - listener.appReOpened(e); + class _AppReOpenedDispatcher extends _AppEventMultiplexor { + void performOnListener(AppReopenedListener listener, final _NativeEvent event) { + final AppReopenedEvent e = new AppReopenedEvent(); + listener.appReopened(e); } } @@ -391,7 +390,7 @@ } void performUsing(final QuitHandler handler, final _NativeEvent event) { - final QuitResponse response = obtainQuitResponse(); // obtains the "current" quit response + final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response handler.handleQuitRequestWith(new QuitEvent(), response); } } @@ -524,9 +523,6 @@ setHandlerContext(AppContext.getAppContext()); - // if a new handler is installed, block addition of legacy ApplicationListeners - if (handler == legacyHandler) return; - legacyHandler.blockLegacyAPI(); } void performDefaultAction(final _NativeEvent event) { } // by default, do nothing @@ -574,10 +570,6 @@ } } } - - // if a new handler is installed, block addition of legacy ApplicationListeners - if (handler == legacyHandler) return; - legacyHandler.blockLegacyAPI(); } } } --- old/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java 2015-11-19 18:20:26.721553972 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java 2015-11-19 18:20:26.593553969 +0300 @@ -26,7 +26,6 @@ package com.apple.eawt; import java.awt.Frame; -import java.awt.peer.MenuComponentPeer; import javax.swing.*; import javax.swing.plaf.MenuBarUI; --- old/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java 2015-11-19 18:20:27.129553983 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java 2015-11-19 18:20:27.005553980 +0300 @@ -371,6 +371,11 @@ } @Override + public final boolean isTaskbarSupported() { + return true; + } + + @Override public final KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() { return LWKeyboardFocusManagerPeer.getInstance(); } --- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java 2015-11-19 18:20:27.545553994 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java 2015-11-19 18:20:27.417553990 +0300 @@ -25,9 +25,19 @@ package sun.lwawt.macosx; +import com.apple.eawt.Application; +import com.apple.eawt.FullScreenUtilities; +import sun.awt.AWTAccessor; +import sun.lwawt.LWWindowPeer; + +import javax.swing.*; +import java.awt.*; import java.awt.Desktop.Action; +import java.awt.desktop.*; +import java.awt.peer.ComponentPeer; import java.awt.peer.DesktopPeer; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; @@ -37,34 +47,230 @@ * * @see DesktopPeer */ -public class CDesktopPeer implements DesktopPeer { +final public class CDesktopPeer implements DesktopPeer { + + private static final CFileManager fileManager = new CFileManager(); + @Override public boolean isSupported(Action action) { - // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. - // Though we don't really differentiate between OPEN / EDIT return true; } + @Override public void open(File file) throws IOException { this.lsOpenFile(file, false); } + @Override public void edit(File file) throws IOException { this.lsOpenFile(file, false); } + @Override public void print(File file) throws IOException { this.lsOpenFile(file, true); } + @Override public void mail(URI uri) throws IOException { this.lsOpen(uri); } + @Override public void browse(URI uri) throws IOException { this.lsOpen(uri); } + @Override + public void addAppEventListener(SystemEventListener listener) { + Application.getApplication().addAppEventListener(listener); + } + + @Override + public void removeAppEventListener(SystemEventListener listener) { + Application.getApplication().removeAppEventListener(listener); + } + + @Override + public void setAboutHandler(AboutHandler aboutHandler) { + Application.getApplication().setAboutHandler(aboutHandler); + } + + @Override + public void setPreferencesHandler(PreferencesHandler preferencesHandler) { + Application.getApplication().setPreferencesHandler(preferencesHandler); + } + + @Override + public void setOpenFileHandler(OpenFilesHandler openFileHandler) { + Application.getApplication().setOpenFileHandler(openFileHandler); + } + + @Override + public void setPrintFileHandler(PrintFilesHandler printFileHandler) { + Application.getApplication().setPrintFileHandler(printFileHandler); + } + + @Override + public void setOpenURIHandler(OpenURIHandler openURIHandler) { + Application.getApplication().setOpenURIHandler(openURIHandler); + } + + @Override + public void setQuitHandler(QuitHandler quitHandler) { + Application.getApplication().setQuitHandler(quitHandler); + } + + @Override + public void setQuitStrategy(QuitStrategy strategy) { + Application.getApplication().setQuitStrategy(strategy); + } + + @Override + public void enableSuddenTermination() { + Application.getApplication().enableSuddenTermination(); + } + + @Override + public void disableSuddenTermination() { + Application.getApplication().disableSuddenTermination(); + } + + @Override + public void requestForeground(boolean allWindows) { + Application.getApplication().requestForeground(allWindows); + } + + @Override + public void openHelpViewer() { + Application.getApplication().openHelpViewer(); + } + + @Override + public void setDefaultMenuBar(JMenuBar menuBar) { + Application.getApplication().setDefaultMenuBar(menuBar); + } + + @Override + public void addWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + FullScreenUtilities.addFullScreenListenerTo(window, listener); + } + + @Override + public void removeWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + FullScreenUtilities.removeFullScreenListenerFrom(window, listener); + } + + @Override + public void setWindowCanFullScreen(Window window, boolean canFullScreen) { + FullScreenUtilities.setWindowCanFullScreen(window, canFullScreen); + } + + @Override + public void requestToggleFullScreen(Window window) { + final ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(window); + + if (!(peer instanceof LWWindowPeer)) { + return; + } + Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow(); + if (!(platformWindow instanceof CPlatformWindow)) { + return; + } + ((CPlatformWindow) platformWindow).toggleFullScreen(); + } + + @Override + public FileManager getFileManager() { + return fileManager; + } + + private static class CFileManager extends FileManager { + + @Override + public int OSTypeToInt(String type) { + return com.apple.eio.FileManager.OSTypeToInt(type); + } + + @Override + public void setFileTypeAndCreator(String filename, int type, int creator) + throws IOException { + com.apple.eio.FileManager.setFileTypeAndCreator(filename, type, creator); + } + + @Override + public void setFileType(String filename, int type) throws IOException { + com.apple.eio.FileManager.setFileType(filename, type); + } + + @Override + public void setFileCreator(String filename, int creator) throws IOException { + com.apple.eio.FileManager.setFileCreator(filename, creator); + } + + @Override + public int getFileType(String filename) throws IOException { + return com.apple.eio.FileManager.getFileType(filename); + } + + @Override + public int getFileCreator(String filename) throws IOException { + return com.apple.eio.FileManager.getFileCreator(filename); + } + + @Override + public String findFolder(int folderType) throws FileNotFoundException { + return com.apple.eio.FileManager.findFolder(folderType); + } + + @Override + public String findFolder(short domain, int folderType) + throws FileNotFoundException { + return com.apple.eio.FileManager.findFolder(domain, folderType); + } + + @Override + public String findFolder(short domain, int folderType, boolean createIfNeeded) + throws FileNotFoundException { + return com.apple.eio.FileManager.findFolder(domain, folderType, createIfNeeded); + } + + @Override + public String getResource(String resourceName) throws FileNotFoundException { + return com.apple.eio.FileManager.getResource(resourceName); + } + + @Override + public String getResource(String resourceName, String subDirName) + throws FileNotFoundException { + return com.apple.eio.FileManager.getResource(resourceName, subDirName); + } + + @Override + public String getResource(String resourceName, String subDirName, String type) + throws FileNotFoundException { + return com.apple.eio.FileManager.getResource(resourceName, subDirName, type); + } + + @Override + public String getPathToApplicationBundle() { + return com.apple.eio.FileManager.getPathToApplicationBundle(); + } + + @Override + public boolean moveToTrash(File file) throws FileNotFoundException { + return com.apple.eio.FileManager.moveToTrash(file); + } + + @Override + public boolean revealInFinder(File file) throws FileNotFoundException { + return com.apple.eio.FileManager.revealInFinder(file); + } + + } + private void lsOpen(URI uri) throws IOException { int status = _lsOpenURI(uri.toString()); --- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2015-11-19 18:20:27.969554004 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2015-11-19 18:20:27.837554001 +0300 @@ -296,6 +296,11 @@ public DesktopPeer createDesktopPeer(Desktop target) { return new CDesktopPeer(); } + + @Override + public TaskbarPeer createTaskbarPeer(Taskbar target) { + return new CTaskbarPeer(); + } @Override public LWCursorManager getCursorManager() { --- old/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.h 2015-11-19 18:20:28.409554016 +0300 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.h 2015-11-19 18:20:28.277554012 +0300 @@ -39,6 +39,8 @@ NSMenu *fDockMenu; CMenuBar *fDefaultMenuBar; + + NSProgressIndicator *fProgressIndicator; BOOL fHandlesDocumentTypes; BOOL fHandlesURLTypes; @@ -47,6 +49,8 @@ @property (nonatomic, retain) NSMenuItem *fPreferencesMenu; @property (nonatomic, retain) NSMenuItem *fAboutMenu; +@property (nonatomic, retain) NSProgressIndicator *fProgressIndicator; + @property (nonatomic, retain) NSMenu *fDockMenu; @property (nonatomic, retain) CMenuBar *fDefaultMenuBar; --- old/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m 2015-11-19 18:20:28.817554026 +0300 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m 2015-11-19 18:20:28.689554023 +0300 @@ -100,6 +100,7 @@ @synthesize fPreferencesMenu; @synthesize fAboutMenu; +@synthesize fProgressIndicator; @synthesize fDockMenu; @synthesize fDefaultMenuBar; @@ -200,6 +201,18 @@ self.fPreferencesMenu = (NSMenuItem*)[appMenu itemWithTag:PREFERENCES_TAG]; self.fAboutMenu = (NSMenuItem*)[appMenu itemAtIndex:0]; + + NSDockTile *dockTile = [NSApp dockTile]; + self.fProgressIndicator = [[NSProgressIndicator alloc] + initWithFrame:NSMakeRect(3.f, 0.f, dockTile.size.width - 6.f, 20.f)]; + + [fProgressIndicator setStyle:NSProgressIndicatorBarStyle]; + [fProgressIndicator setIndeterminate:NO]; + [[dockTile contentView] addSubview:fProgressIndicator]; + [fProgressIndicator setMinValue:0]; + [fProgressIndicator setMaxValue:100]; + [fProgressIndicator setHidden:YES]; + [fProgressIndicator release]; // If the java application has a bundle with an Info.plist file with // a CFBundleDocumentTypes entry, then it is set up to handle Open Doc @@ -252,6 +265,7 @@ self.fAboutMenu = nil; self.fDockMenu = nil; self.fDefaultMenuBar = nil; + self.fProgressIndicator = nil; [super dealloc]; } @@ -468,6 +482,9 @@ [dockImageView setImageScaling:NSImageScaleProportionallyUpOrDown]; [dockImageView setImage:image]; + [[ApplicationDelegate sharedDelegate].fProgressIndicator removeFromSuperview]; + [dockImageView addSubview:[ApplicationDelegate sharedDelegate].fProgressIndicator]; + // add it to the NSDockTile [dockTile setContentView: dockImageView]; [dockTile display]; @@ -475,6 +492,20 @@ [dockImageView release]; } ++ (void)_setDockIconProgress:(NSNumber *)value { +AWT_ASSERT_APPKIT_THREAD; + + ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate]; + if ([value doubleValue] >= 0 && [value doubleValue] <=100) { + [delegate.fProgressIndicator setDoubleValue:[value doubleValue]]; + [delegate.fProgressIndicator setHidden:NO]; + } else { + [delegate.fProgressIndicator setHidden:YES]; + } + + [[NSApp dockTile] display]; +} + // Obtains the image of the Dock icon, either manually set, a drawn copy, or the default NSApplicationIcon + (NSImage *)_dockIconImage { AWT_ASSERT_APPKIT_THREAD; @@ -609,6 +640,24 @@ } /* + * Class: com_apple_eawt__AppDockIconHandler + * Method: nativeSetDockIconProgress + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconProgress + (JNIEnv *env, jclass clz, jint value) +{ + JNF_COCOA_ENTER(env); + + [ThreadUtilities performOnMainThread:@selector(_setDockIconProgress:) + on:[ApplicationDelegate class] + withObject:[NSNumber numberWithInt:value] + waitUntilDone:NO]; + + JNF_COCOA_EXIT(env); +} + +/* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeGetDockIconImage * Signature: ()J --- old/src/java.desktop/share/classes/java/awt/Desktop.java 2015-11-19 18:20:29.273554038 +0300 +++ new/src/java.desktop/share/classes/java/awt/Desktop.java 2015-11-19 18:20:29.149554035 +0300 @@ -22,9 +22,9 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package java.awt; +import java.awt.desktop.*; import java.awt.peer.DesktopPeer; import java.io.File; import java.io.FilePermission; @@ -35,6 +35,7 @@ import java.net.URL; import sun.awt.SunToolkit; +import javax.swing.JMenuBar; import sun.security.util.SecurityConstants; /** @@ -69,6 +70,18 @@ *

Note: when some action is invoked and the associated * application is executed, it will be executed on the same system as * the one on which the Java application was launched. + * + *

+ * Please note that for Mac OS notifications for + * {@link OpenFilesHandler#openFiles(AppEvent.OpenFilesEvent)}, + * {@link PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)} )} and + * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} + * are only sent if the Java app is a bundled application, + * with a CFBundleDocumentTypes array present in it's + * Info.plist. See the + * Info.plist + * Key Reference for more information about adding a + * CFBundleDocumentTypes key to your app's Info.plist. * * @since 1.6 * @author Armin Chen @@ -110,7 +123,124 @@ * Represents a "browse" action. * @see Desktop#browse(java.net.URI) */ - BROWSE + BROWSE, + + /** + * Represents a AppForegroundListener + * @see java.awt.desktop.AppForegroundListener + */ + APP_EVENT_FOREGROUND, + + /** + * Represents a AppHiddenListener + * @see java.awt.desktop.AppHiddenListener + */ + APP_EVENT_HIDDEN, + + /** + * Represents a AppReopenedListener + * @see java.awt.desktop.AppReopenedListener + */ + APP_EVENT_REOPENED, + + /** + * Represents a ScreenSleepListener + * @see java.awt.desktop.ScreenSleepListener + */ + APP_EVENT_SCREEN_SLEEP, + + /** + * Represents a SystemSleepListener + * @see java.awt.desktop.SystemSleepListener + */ + APP_EVENT_SYSTEM_SLEEP, + + /** + * Represents a UserSessionListener + * @see java.awt.desktop.UserSessionListener + */ + APP_EVENT_USER_SESSION, + + /** + * Represents a AboutHandler + * @see #setAboutHandler(java.awt.desktop.AboutHandler) + */ + APP_ABOUT, + + /** + * Represents a PreferencesHandler + * @see #setPreferencesHandler(java.awt.desktop.PreferencesHandler) + */ + APP_PREFERENCES, + + /** + * Represents a OpenFilesHandler + * @see #setOpenFileHandler(java.awt.desktop.OpenFilesHandler) + */ + APP_OPEN_FILE, + + /** + * Represents a PrintFilesHandler + * @see #setPrintFileHandler(java.awt.desktop.PrintFilesHandler) + */ + APP_PRINT_FILE, + + /** + * Represents a OpenURIHandler + * @see #setOpenURIHandler(java.awt.desktop.OpenURIHandler) + */ + APP_OPEN_URI, + + /** + * Represents a QuitHandler + * @see #setQuitHandler(java.awt.desktop.QuitHandler) + */ + APP_QUIT_HANDLER, + + /** + * Represents a QuitStrategy + * @see #setQuitStrategy(java.awt.desktop.QuitStrategy) + */ + APP_QUIT_STRATEGY, + + /** + * Represents a SuddenTermination + * @see #enableSuddenTermination() + */ + APP_SUDDEN_TERMINATION, + + /** + * Represents a requestForeground + * @see #requestForeground(boolean) + */ + APP_REQUEST_FOREGROUND, + + /** + * Represents a HelpViewer + * @see #openHelpViewer() + */ + APP_HELP_VIEWER, + + /** + * Represents a menu bar + * @see #setDefaultMenuBar(javax.swing.JMenuBar) + */ + APP_MENU_BAR, + + /** + * Represents a platform specific full screen + * @see #addWindowFullScreenListener(java.awt.Window, java.awt.desktop.FullScreenListener) + * @see #removeWindowFullScreenListener(java.awt.Window, java.awt.desktop.FullScreenListener) + * @see #setWindowCanFullScreen(java.awt.Window, boolean) + * @see #requestToggleFullScreen(java.awt.Window) + */ + FULLSCREEN, + + /** + * Represents a FileManager + * @see #getFileManager() + */ + FILEMANAGER }; private DesktopPeer peer; @@ -208,7 +338,7 @@ if (!file.exists()) { throw new IllegalArgumentException("The file: " - + file.getPath() + " doesn't exist."); + + file.getPath() + " doesn't exist."); } file.canRead(); @@ -224,7 +354,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 +368,7 @@ SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AWTPermission( - "showWindowWithoutWarningBanner")); + "showWindowWithoutWarningBanner")); } } @@ -479,7 +609,273 @@ SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new FilePermission("<>", - SecurityConstants.FILE_EXECUTE_ACTION)); + SecurityConstants.FILE_EXECUTE_ACTION)); } } + + /** + * Adds sub-types of {@link SystemEventListener} to listen for notifications + * from the native system. + * + * Has no effect if SystemEventListener's sub-type is unsupported on current + * platform. + * + * @param listener listener + * @see AppForegroundListener + * @see AppHiddenListener + * @see AppReopenedListener + * @see ScreenSleepListener + * @see SystemSleepListener + * @see UserSessionListener + */ + public void addAppEventListener(final SystemEventListener listener) { + peer.addAppEventListener(listener); + } + + /** + * Removes sub-types of {@link SystemEventListener} to listen for notifications + * from the native system. + * + * Has no effect if SystemEventListener's sub-type is unsupported on current + * platform. + * + * @param listener listener + * @see AppForegroundListener + * @see AppHiddenListener + * @see AppReOpenedListener + * @see AppScreenSleepListener + * @see AppSystemSleepListener + * @see AppUserSessionListener + */ + public void removeAppEventListener(final SystemEventListener listener) { + peer.removeAppEventListener(listener); + } + + /** + * Installs a handler to show a custom About window for your application. + *

+ * Setting the {@link AboutHandler} to null reverts it to the + * default behavior. + * + * @param aboutHandler the handler to respond to the + * {@link AboutHandler#handleAbout} )} message + */ + 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. + *

+ * Setting the {@link PreferencesHandler} to null reverts it to + * the default behavior + * + * @param preferencesHandler the handler to respond to the + * {@link PreferencesHandler#handlePreferences(PreferencesEvent)} + */ + 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. + * + * @param openFileHandler handler + */ + 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. + * + * @param printFileHandler handler + */ + 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. + * + * @param openURIHandler handler + */ + 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 + */ + 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 + */ + 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. + * + * @see #disableSuddenTermination() + */ + 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. + * + * @see #enableSuddenTermination() + */ + 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 + */ + public void requestForeground(final boolean allWindows) { + checkActionSupport(Action.APP_REQUEST_FOREGROUND); + peer.requestForeground(allWindows); + } + + /** + * Opens the native help viewer application. + */ + public void openHelpViewer() { + checkActionSupport(Action.APP_HELP_VIEWER); + peer.openHelpViewer(); + } + + /** + * Sets the default menu bar to use when there are no active frames. + * + * Note, Aqua Look and Feel should be active to support this on Mac OS. + * + * @param menuBar to use when no other frames are active + */ + public void setDefaultMenuBar(final JMenuBar menuBar) { + checkActionSupport(Action.APP_MENU_BAR); + peer.setDefaultMenuBar(menuBar); + } + + /** + * Attaches a {@link FullScreenListener} to the specified top-level + * {@link Window}. + * + * @param window to attach the {@link FullScreenListener} to + * @param listener to be notified when a full screen event occurs + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + public void addWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + checkActionSupport(Action.FULLSCREEN); + peer.addWindowFullScreenListener(window, listener); + } + + /** + * Removes a {@link FullScreenListener} from the specified top-level + * {@link Window}. + * + * @param window to remove the {@link FullScreenListener} from + * @param listener to be removed + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + public void removeWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + checkActionSupport(Action.FULLSCREEN); + peer.removeWindowFullScreenListener(window, listener); + } + + /** + * Marks a {@link Window} as able to animate into or out of full screen + * mode. + * + * Only top-level {@link Window}s which are {@link RootPaneContainer}s are + * able to be animated into and out of full screen mode. The {@link Window} + * must be marked as full screen-able before the native peer is created with + * {@link Component#addNotify()}. + * + * @param window window + * @param canFullScreen flag + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + public void setWindowCanFullScreen(final Window window, final boolean canFullScreen) { + checkActionSupport(Action.FULLSCREEN); + peer.setWindowCanFullScreen(window, canFullScreen); + } + + /** + * Requests that a {@link Window} should get into or out of full screen + * mode. Only {@link Window}s marked as full screenable by + * {@link #setWindowCanFullScreen(Window, boolean)} can be toggled. + * + * @param window to animate into or out of full screen mode + */ + public void requestToggleFullScreen(final Window window) { + checkActionSupport(Action.FULLSCREEN); + peer.requestToggleFullScreen(window); + } + + /** + * Returns the mac specific FileManager. + * @return FileManager + * @see FileManager + */ + public FileManager getFileManager() { + checkActionSupport(Action.FILEMANAGER); + return peer.getFileManager(); + } + } --- old/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java 2015-11-19 18:20:29.717554049 +0300 +++ new/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java 2015-11-19 18:20:29.593554046 +0300 @@ -22,14 +22,25 @@ * 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.Window; +import java.awt.desktop.AboutHandler; +import java.awt.desktop.FileManager; +import java.awt.desktop.FullScreenListener; +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; +import javax.swing.RootPaneContainer; /** * The {@code DesktopPeer} interface provides methods for the operation @@ -104,4 +115,228 @@ * 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. + *

+ * Setting the {@link AboutHandler} to 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. + *

+ * Setting the {@link PreferencesHandler} to null reverts it to + * the default behavior + * + * @param preferencesHandler the handler to respond to the + * {@link PreferencesHandler#handlePreferences(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. 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 + */ + 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. + * + * 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. + * + * @see #disableSuddenTermination() + */ + default void 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. + * + * @see #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) { + } + + /** + * Attaches a {@link FullScreenListener} to the specified top-level + * {@link Window}. + * + * @param window to attach the {@link FullScreenListener} to + * @param listener to be notified when a full screen event occurs + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + default void addWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + } + + /** + * Removes a {@link FullScreenListener} from the specified top-level + * {@link Window}. + * + * @param window to remove the {@link FullScreenListener} from + * @param listener to be removed + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + default void removeWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + } + + /** + * Marks a {@link Window} as able to animate into or out of full screen + * mode. + * + * Only top-level {@link Window}s which are {@link RootPaneContainer}s are + * able to be animated into and out of full screen mode. The {@link Window} + * must be marked as full screen-able before the native peer is created with + * {@link Component#addNotify()}. + * + * @param window window + * @param canFullScreen flag + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + default void setWindowCanFullScreen(final Window window, + final boolean canFullScreen) { + } + + /** + * Requests that a {@link Window} should get into or out of full screen + * mode. Only {@link Window}s marked as full screenable by + * {@link #setWindowCanFullScreen(Window, boolean)} can be toggled. + * + * @param window to animate into or out of full screen mode + */ + default void requestToggleFullScreen(final Window window) { + } + + /** + * Returns the Mac specific FileManager. + * @return FileManager + * @see FileManager + */ + default FileManager getFileManager() { + return null; + } + } --- old/src/java.desktop/share/classes/sun/awt/ComponentFactory.java 2015-11-19 18:20:30.141554060 +0300 +++ new/src/java.desktop/share/classes/sun/awt/ComponentFactory.java 2015-11-19 18:20:30.013554057 +0300 @@ -73,6 +73,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-19 18:20:30.569554071 +0300 +++ new/src/java.desktop/share/classes/sun/awt/HToolkit.java 2015-11-19 18:20:30.445554068 +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-19 18:20:30.989554082 +0300 +++ new/src/java.desktop/share/classes/sun/awt/SunToolkit.java 2015-11-19 18:20:30.865554079 +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-19 18:20:31.445554093 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2015-11-19 18:20:31.309554090 +0300 @@ -2567,6 +2567,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-19 18:20:31.897554105 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c 2015-11-19 18:20:31.765554102 +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-19 18:20:32.357554117 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h 2015-11-19 18:20:32.237554114 +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-19 18:20:32.785554128 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java 2015-11-19 18:20:32.657554124 +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,32 @@ 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 APP_EVENT_SYSTEM_SLEEP: + return true; + case APP_EVENT_USER_SESSION: + return isEventUserSessionSupported; + default: + return false; + } } @Override @@ -93,5 +121,52 @@ } 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()); + } + }); + } + } } --- old/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java 2015-11-19 18:20:33.233554139 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java 2015-11-19 18:20:33.073554135 +0300 @@ -1110,16 +1110,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-19 18:20:33.689554151 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2015-11-19 18:20:33.561554148 +0300 @@ -28,6 +28,13 @@ #include #include #include +#include "awt_Toolkit.h" + +#define NOTIFY_FOR_ALL_SESSIONS 1 +#define NOTIFY_FOR_THIS_SESSION 0 + +typedef BOOL (WINAPI *WTSRegisterSessionNotification)(HWND,DWORD); +static WTSRegisterSessionNotification fn_WTSRegisterSessionNotification; #ifdef __cplusplus extern "C" { @@ -35,6 +42,28 @@ /* * Class: sun_awt_windows_WDesktopPeer + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_init + (JNIEnv *, jclass) { + static HMODULE libWtsapi32 = NULL; + if (libWtsapi32 == NULL) { + libWtsapi32 = JDK_LoadSystemLibrary("Wtsapi32.dll"); + if (libWtsapi32) { + fn_WTSRegisterSessionNotification = (WTSRegisterSessionNotification) + GetProcAddress(libWtsapi32, "WTSRegisterSessionNotification"); + if (fn_WTSRegisterSessionNotification) { + HWND hwnd = AwtToolkit::GetInstance().GetHWnd(); + //used for UserSessionListener + fn_WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION); + } + } + } +} + +/* + * Class: sun_awt_windows_WDesktopPeer * Method: ShellExecute * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; */ --- old/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp 2015-11-19 18:20:34.197554164 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp 2015-11-19 18:20:34.061554160 +0300 @@ -269,6 +269,9 @@ /* ids for WToolkit fields accessed from native code */ jmethodID AwtToolkit::windowsSettingChangeMID; jmethodID AwtToolkit::displayChangeMID; + +jmethodID AwtToolkit::userSessionMID; +jmethodID AwtToolkit::systemSleepMID; /* ids for Toolkit methods */ jmethodID AwtToolkit::getDefaultToolkitMID; jmethodID AwtToolkit::getFontMetricsMID; @@ -1075,6 +1078,44 @@ DASSERT(FALSE); break; } +#ifndef WM_WTSSESSION_CHANGE +#define WM_WTSSESSION_CHANGE 0x02B1 +#define WTS_CONSOLE_CONNECT 0x1 +#define WTS_CONSOLE_DISCONNECT 0x2 +#define WTS_REMOTE_CONNECT 0x3 +#define WTS_REMOTE_DISCONNECT 0x4 +#define WTS_SESSION_LOGON 0x5 +#define WTS_SESSION_LOGOFF 0x6 +#define WTS_SESSION_LOCK 0x7 +#define WTS_SESSION_UNLOCK 0x8 +#define WTS_SESSION_REMOTE_CONTROL 0x9 +#endif // WM_WTSSESSION_CHANGE + case WM_WTSSESSION_CHANGE: { + jclass clzz = env->FindClass("sun/awt/windows/WDesktopPeer"); + DASSERT(clzz != NULL); + if (!clzz) throw std::bad_alloc(); + + if (wParam == WTS_SESSION_LOCK || wParam == WTS_SESSION_UNLOCK) { + env->CallStaticVoidMethod(clzz, AwtToolkit::userSessionMID, + wParam == WTS_SESSION_UNLOCK + ? JNI_TRUE + : JNI_FALSE); + } + break; + } + case WM_POWERBROADCAST: { + jclass clzz = env->FindClass("sun/awt/windows/WDesktopPeer"); + DASSERT(clzz != NULL); + if (!clzz) throw std::bad_alloc(); + + if (wParam == PBT_APMSUSPEND || wParam == PBT_APMRESUMEAUTOMATIC) { + env->CallStaticVoidMethod(clzz, AwtToolkit::systemSleepMID, + wParam == PBT_APMRESUMEAUTOMATIC + ? JNI_TRUE + : JNI_FALSE); + } + break; + } case WM_SYNC_WAIT: SetEvent(AwtToolkit::GetInstance().m_waitEvent); break; @@ -2133,6 +2174,20 @@ CHECK_NULL(jawtVImgClass); jawtComponentClass = (jclass)env->NewGlobalRef(componentClassLocal); + jclass dPeerClassLocal = env->FindClass("sun/awt/windows/WDesktopPeer"); + DASSERT(dPeerClassLocal != 0); + CHECK_NULL(dPeerClassLocal); + + AwtToolkit::userSessionMID = + env->GetStaticMethodID(dPeerClassLocal, "userSessionCallback", "(Z)V"); + DASSERT(AwtToolkit::userSessionMID != 0); + CHECK_NULL(AwtToolkit::userSessionMID); + + AwtToolkit::systemSleepMID = + env->GetStaticMethodID(dPeerClassLocal, "systemSleepCallback", "(Z)V"); + DASSERT(AwtToolkit::systemSleepMID != 0); + CHECK_NULL(AwtToolkit::systemSleepMID); + CATCH_BAD_ALLOC; } --- old/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h 2015-11-19 18:20:34.677554176 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h 2015-11-19 18:20:34.537554173 +0300 @@ -171,12 +171,15 @@ /* java.awt.Toolkit method ids */ static jmethodID getDefaultToolkitMID; static jmethodID getFontMetricsMID; - static jmethodID insetsMID; + static jmethodID insetsMID; /* sun.awt.windows.WToolkit ids */ static jmethodID windowsSettingChangeMID; static jmethodID displayChangeMID; + static jmethodID userSessionMID; + static jmethodID systemSleepMID; + BOOL m_isDynamicLayoutSet; AwtToolkit(); --- old/src/java.desktop/windows/native/libawt/windows/awt_Window.h 2015-11-19 18:20:35.109554187 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Window.h 2015-11-19 18:20:34.977554184 +0300 @@ -398,4 +398,6 @@ inline bool IsAlwaysOnTop() { return m_alwaysOnTop; } }; +HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h); + #endif /* AWT_WINDOW_H */ --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java 2015-11-19 18:20:35.397554195 +0300 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011, 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 com.apple.eawt; + +import java.awt.desktop.QuitResponse; + +/** + * Used to respond to a request to quit the application. + * The QuitResponse may be used after the {@link QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, MacQuitResponse)} method has returned, and may be used from any thread. + * + * @see Application#setQuitHandler(QuitHandler) + * @see QuitHandler + * @see Application#setQuitStrategy(QuitStrategy) + * + * @since Java for Mac OS X 10.6 Update 3 + * @since Java for Mac OS X 10.5 Update 8 + */ +public class MacQuitResponse implements QuitResponse { + final _AppEventHandler appEventHandler; + + MacQuitResponse(final _AppEventHandler appEventHandler) { + this.appEventHandler = appEventHandler; + } + + /** + * Notifies the external quit requester that the quit will proceed, and performs the default {@link QuitStrategy}. + */ + @Override + public void performQuit() { + if (appEventHandler.currentQuitResponse != this) return; + appEventHandler.performQuit(); + } + + /** + * Notifies the external quit requester that the user has explicitly canceled the pending quit, and leaves the application running. + * Note: this will cancel a pending log-out, restart, or shutdown. + */ + @Override + public void cancelQuit() { + if (appEventHandler.currentQuitResponse != this) return; + appEventHandler.cancelQuit(); + } +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTaskbarPeer.java 2015-11-19 18:20:35.817554205 +0300 @@ -0,0 +1,89 @@ +/* + * 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.lwawt.macosx; + +import com.apple.eawt.Application; +import java.awt.Image; +import java.awt.PopupMenu; +import java.awt.Taskbar.Feature; +import java.awt.TaskbarPeer; + +final public class CTaskbarPeer implements TaskbarPeer { + + CTaskbarPeer() {} + + @Override + public boolean isSupported(Feature feature) { + switch(feature) { + case ICON_BADGE_TEXT: + case ICON_BADGE_NUMBER: + case ICON_IMAGE: + case MENU: + case PROGRESS_VALUE: + case USER_ATTENTION: + return true; + default: + return false; + } + } + + @Override + public void setProgressValue(int value) { + Application.getApplication().setDockIconProgress(value); + } + + @Override + public void setIconBadge(String badge) { + Application.getApplication().setDockIconBadge(badge); + } + + @Override + public Image getIconImage() { + return Application.getApplication().getDockIconImage(); + } + + @Override + public void setIconImage(Image image) { + Application.getApplication().setDockIconImage(image); + } + + @Override + public PopupMenu getMenu() { + return Application.getApplication().getDockMenu(); + } + + @Override + public void setMenu(PopupMenu menu) { + Application.getApplication().setDockMenu(menu); + } + + @Override + public void requestUserAttention(boolean enabled, boolean critical) { + if (enabled) { + Application.getApplication().requestUserAttention(critical); + } + } +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/AppEvent.java 2015-11-19 18:20:36.289554217 +0300 @@ -0,0 +1,286 @@ +/* + * 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; + +import java.awt.desktop.*; +import java.io.File; +import java.net.URI; +import java.util.EventObject; +import java.util.List; + +/** + * AppEvents are sent to listeners and handlers installed on the {@link Application}. + * + */ +@SuppressWarnings("serial") // JDK implementation class +public class AppEvent extends EventObject { + + AppEvent() { + super(Desktop.getDesktop()); + } + + /** + * Contains a list of files. + */ + @SuppressWarnings("serial") // JDK implementation class + public static class FilesEvent extends AppEvent { + final List files; + + FilesEvent(final List files) { + this.files = files; + } + + /** + * @return the list of files + */ + public List getFiles() { + return files; + } + } + + /** + * Event sent when the app is asked to open a list of files. + * + * @see OpenFilesHandler#openFiles + */ + @SuppressWarnings("serial") // JDK implementation class + public static class OpenFilesEvent extends FilesEvent { + final String searchTerm; + + /** + * @param files files + * @param searchTerm searchTerm + */ + public OpenFilesEvent(final List files, final String searchTerm) { + super(files); + this.searchTerm = searchTerm; + } + + /** + * If the files were opened using the Spotlight search menu or a Finder search window, this method obtains the search term used to find the files. + * This is useful for highlighting the search term in the documents when they are opened. + * @return the search term used to find the files + */ + public String getSearchTerm() { + return searchTerm; + } + } + + /** + * Event sent when the app is asked to print a list of files. + * + * @see PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class PrintFilesEvent extends FilesEvent { + + /** + * @param files files + */ + public PrintFilesEvent(final List files) { + super(files); + } + } + + /** + * Event sent when the app is asked to open a URI. + * + * @see OpenURIHandler#openURI(AppEvent.OpenURIEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class OpenURIEvent extends AppEvent { + final URI uri; + + /** + * @param uri uri + */ + public OpenURIEvent(final URI uri) { + this.uri = uri; + } + + /** + * @return the URI the app was asked to open + */ + public URI getURI() { + return uri; + } + } + + /** + * Event sent when the application is asked to open it's about window. + * + * @see AboutHandler#handleAbout + */ + @SuppressWarnings("serial") // JDK implementation class + public static class AboutEvent extends AppEvent { + + /** + * + */ + public AboutEvent() {} + } + + /** + * Event sent when the application is asked to open it's preferences window. + * + * @see PreferencesHandler#handlePreferences + */ + @SuppressWarnings("serial") // JDK implementation class + public static class PreferencesEvent extends AppEvent { + + /** + * + */ + public PreferencesEvent() {} + } + + /** + * Event sent when the application is asked to quit. + * + * @see QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, QuitResponse) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class QuitEvent extends AppEvent { + + /** + * + */ + public QuitEvent() {} + } + + /** + * Event sent when the application is asked to re-open itself. + * + * @see AppReOpenedListener#appReOpened(AppEvent.AppReOpenedEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class AppReopenedEvent extends AppEvent { + + /** + * + */ + public AppReopenedEvent() { } + } + + /** + * Event sent when the application has become the foreground app, and when it has resigned being the foreground app. + * + * @see AppForegroundListener#appRaisedToForeground(AppEvent.AppForegroundEvent) + * @see AppForegroundListener#appMovedToBackground(AppEvent.AppForegroundEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class AppForegroundEvent extends AppEvent { + + /** + * + */ + public AppForegroundEvent() { } + } + + /** + * Event sent when the application has been hidden or shown. + * + * @see AppHiddenListener#appHidden(AppEvent.AppHiddenEvent) + * @see AppHiddenListener#appUnhidden(AppEvent.AppHiddenEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class AppHiddenEvent extends AppEvent { + + /** + * + */ + public AppHiddenEvent() { } + } + + /** + * Event sent when the user session has been changed via Fast User Switching. + * + * @see UserSessionListener#userSessionActivated(AppEvent.UserSessionEvent) + * @see UserSessionListener#userSessionDeactivated(AppEvent.UserSessionEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class UserSessionEvent extends AppEvent { + + /** + * + */ + public UserSessionEvent() { } + } + + /** + * Event sent when the displays attached to the system enter and exit power save sleep. + * + * @see ScreenSleepListener#screenAboutToSleep(AppEvent.ScreenSleepEvent) + * @see ScreenSleepListener#screenAwoke(AppEvent.ScreenSleepEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class ScreenSleepEvent extends AppEvent { + + /** + * + */ + public ScreenSleepEvent() { } + } + + /** + * Event sent when the system enters and exits power save sleep. + * + * @see SystemSleepListener#systemAboutToSleep(AppEvent.SystemSleepEvent) + * @see SystemSleepListener#systemAwoke(AppEvent.SystemSleepEvent) + */ + @SuppressWarnings("serial") // JDK implementation class + public static class SystemSleepEvent extends AppEvent { + + /** + * + */ + public SystemSleepEvent() { } + } + + /** + * Event sent when a window is entering/exiting or has entered/exited full screen state. + * + * @see FullScreenUtilities + */ + @SuppressWarnings("serial") // JDK implementation class + public static class FullScreenEvent extends AppEvent { + final Window window; + + /** + * @param window window + */ + public FullScreenEvent(final Window window) { + this.window = window; + } + + /** + * @return window transitioning between full screen states + */ + public Window getWindow() { + return window; + } + } +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/Taskbar.java 2015-11-19 18:20:36.721554229 +0300 @@ -0,0 +1,365 @@ +/* + * 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; + +import sun.awt.SunToolkit; + +/** + * The {@code Taskbar} class allows a Java application to interact with + * system task area(Taskbar, Dock, etc.). + * + * There are a variety of interactions depending on running platform such as + * displaying progress of some task, appending user specified menu to application + * icon context menu, etc. + * + * Linux support is limited to Unity, however to make this features work on Unity + * the app should be run from a .desktop file with specified java.desktop.appName + * system property set to this .desktop file name: + * Exec=java -Djava.desktop.appName=MyApp.desktop -jar /path/to/myapp.jar + * see https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles + */ + +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. + */ + public static final int STATE_OFF = 0x0; + + /** + * The progress indicator displays with normal color and determinate mode. + */ + public static final int STATE_NORMAL = 0x1; + + /** + * Shows progress as paused, progress can be resumed by user. + * Switches to the determinate display. + */ + public static final int STATE_PAUSED = 0x2; + + /** + * The progress indicator displays activity without specifying what + * proportion of the progress is complete. + */ + public static final int STATE_INDETERMINATE = 0x3; + + /** + * Shows that an error has occurred. + * Switches to the determinate display. + */ + 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!"); + } + } + private Taskbar() { + Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); + if (defaultToolkit instanceof SunToolkit) { + peer = ((SunToolkit) defaultToolkit).createTaskbarPeer(this); + } + } + + /** + * Returns the Taskbar instance of the current + * browser 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 of the current browser context + * @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 platform, this may be visually indicated by bouncing + * or flashing icon in task area. It may has 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. + * On other platforms may require additional call to + * {@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 + */ + public void requestUserAttention(final boolean enabled, final boolean critical) { + 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 + */ + public void requestWindowUserAttention(Window w) { + checkFeatureSupport(Feature.USER_ATTENTION_WINDOW); + peer.requestWindowUserAttention(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 + */ + public void setMenu(final PopupMenu menu) { + checkFeatureSupport(Feature.MENU); + peer.setMenu(menu); + } + + /** + * Gets PopupMenu used to add items to this application's icon in system task area. + * + * @return the PopupMenu + */ + public PopupMenu getMenu() { + checkFeatureSupport(Feature.MENU); + return peer.getMenu(); + } + + /** + * Changes this application's icon to the provided image. + * + * @param image to change + */ + public void setIconImage(final Image image) { + checkFeatureSupport(Feature.ICON_IMAGE); + peer.setIconImage(image); + } + + /** + * Obtains an image of this application's icon. + * + * @return an image of this application's icon + */ + public Image getIconImage() { + checkFeatureSupport(Feature.ICON_IMAGE); + return peer.getIconImage(); + } + + /** + * Affixes a small system provided badge to this application's icon. + * Usually a number. + * + * Some platforms does not support string values and accepts only integer + * values. In this case pass an integer represented as string as a 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 + */ + public void setIconBadge(final String badge) { + checkFeatureSupport(Feature.ICON_BADGE_NUMBER); + peer.setIconBadge(badge); + } + + /** + * Affixes a small badge to this application's icon in 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 + */ + public void setWindowIconBadge(Window w, final Image badge) { + 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 + */ + public void setProgressValue(int value) { + 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 + */ + public void setWindowProgressValue(Window w, int value) { + 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 + */ + public void setWindowProgressState(Window w, int state) { + 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); + } + } + + private native void initIDs(); + +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/TaskbarPeer.java 2015-11-19 18:20:37.233554242 +0300 @@ -0,0 +1,131 @@ +/* + * 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; + +import java.awt.Taskbar.Feature; + + +/** + * 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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AboutHandler.java 2015-11-19 18:20:37.749554255 +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 it's about dialog. + * + * @see java.awt.Desktop#setAboutHandler(java.awt.desktop.AboutHandler) + */ +public interface AboutHandler { + /** + * Called when the application is asked to show it's about dialog. + * @param e the request to show the about dialog. + */ + public void handleAbout(final AboutEvent e); +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AppForegroundListener.java 2015-11-19 18:20:38.237554267 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AppHiddenListener.java 2015-11-19 18:20:38.717554280 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AppReopenedListener.java 2015-11-19 18:20:39.169554291 +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 re-opened + * @param e the request to re-open the app + */ + public void appReopened(final AppReopenedEvent e); +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/FileManager.java 2015-11-19 18:20:39.657554304 +0300 @@ -0,0 +1,281 @@ +/* + * 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.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +/** + * Provides functionality to query and modify Mac-specific file attributes. The methods in this class are based on Finder + * attributes. These attributes in turn are dependent on HFS and HFS+ file systems. As such, it is important to recognize + * their limitation when writing code that must function well across multiple platforms.

+ * + * In addition to file name suffixes, Mac OS X can use Finder attributes like file type and creator codes to + * identify and handle files. These codes are unique 4-byte identifiers. The file type is a string that describes the + * contents of a file. For example, the file type APPL identifies the file as an application and therefore + * executable. A file type of TEXT means that the file contains raw text. Any application that can read raw + * text can open a file of type TEXT. Applications that use proprietary file types might assign their files a proprietary + * file type code. + *

+ * To identify the application that can handle a document, the Finder can look at the creator. For example, if a user + * double-clicks on a document with the ttxt creator, it opens up in Text Edit, the application registered + * with the ttxt creator code. Note that the creator + * code can be set to any application, not necessarily the application that created it. For example, if you + * use an editor to create an HTML document, you might want to assign a browser's creator code for the file rather than + * the HTML editor's creator code. Double-clicking on the document then opens the appropriate browser rather than the + *HTML editor. + *

+ * If you plan to publicly distribute your application, you must register its creator and any proprietary file types with the Apple + * Developer Connection to avoid collisions with codes used by other developers. You can register a codes online at the + * Creator Code Registration site. + */ +public abstract class FileManager { + + /** + * The default. + */ + public static final short kOnAppropriateDisk = -32767; + + /** + * Read-only system hierarchy. + */ + public static final short kSystemDomain = -32766; + + /** + * All users of a single machine have access to these resources. + */ + public static final short kLocalDomain = -32765; + + /** + * All users configured to use a common network server has access to these + * resources. + */ + public static final short kNetworkDomain = -32764; + + /** + * Read/write. Resources that are private to the user. + */ + public static final short kUserDomain = -32763; + + /** + * Converts an OSType (e.g. "macs" from {@literal }) + * into an int. + * + * @param type the 4 character type to convert. + * @return an int representing the 4 character value + */ + public abstract int OSTypeToInt(String type); + + /** + * Sets the file type and creator codes for a file + * or folder. + * + * @param filename file name + * @param type of a file + * @param creator for a file + * @throws java.io.IOException if an I/O exception occurs + */ + public abstract void setFileTypeAndCreator(String filename, int type, int creator) throws IOException; + + /** + * Sets the file type code for a file or folder. + * + * @param filename file name + * @param type of a file + * @throws java.io.IOException if an I/O exception occurs + */ + public abstract void setFileType(String filename, int type) throws IOException; + + /** + * Sets the file creator code for a file or folder. + * + * @param filename file name + * @param creator for a file + * @throws java.io.IOException if an I/O exception occurs + */ + public abstract void setFileCreator(String filename, int creator) throws IOException; + + /** + * Obtains the file type code for a file or folder. + * + * @param filename file name + * @return file or folder type + * @throws java.io.IOException if an I/O exception occurs + */ + public abstract int getFileType(String filename) throws IOException; + + /** + * Obtains the file creator code for a file or folder. + * + * @param filename file name + * @return creator for a file or folder + * @throws java.io.IOException if an I/O exception occurs + */ + public abstract int getFileCreator(String filename) throws IOException; + + /** + * Locates a folder of a particular type. Mac OS X recognizes certain + * specific folders that have distinct purposes. For example, the user's + * desktop or temporary folder. These folders have corresponding codes. + * Given one of these codes, this method returns the path to that particular + * folder. Certain folders of a given type may appear in more than one + * domain. For example, although there is only one root folder, + * there are multiple pref folders. If this method is called to + * find the pref folder, it will return the first one it finds, + * the user's preferences folder in ~/Library/Preferences. To + * explicitly locate a folder in a certain domain use + * findFolder(short domain, int folderType) or findFolder(short domain, int folderType, + * boolean createIfNeeded). + * + * @param folderType folder type + * @return the path to the folder searched for + * @throws java.io.FileNotFoundException if the folder does not exist + */ + public abstract String findFolder(int folderType) throws FileNotFoundException; + + /** + * Locates a folder of a particular type, within a given domain. Similar to + * findFolder(int folderType) except that the domain to look in + * can be specified. Valid values for domaininclude: + *

+ *
user
+ *
The User domain contains resources specific to the user who is + * currently logged in
+ *
local
+ *
The Local domain contains resources shared by all users of the system + * but are not needed for the system itself to run.
+ *
network
+ *
The Network domain contains resources shared by users of a local area + * network.
+ *
system
+ *
The System domain contains the operating system resources installed + * by Apple.
+ *
+ * + * @param domain domain + * @param folderType folder type + * @return the path to the folder searched for + * @throws java.io.FileNotFoundException if the folder does not exist + */ + public abstract String findFolder(short domain, int folderType) throws FileNotFoundException; + + /** + * Locates a folder of a particular type within a given domain and + * optionally creating the folder if it does not exist. The behavior is + * similar to findFolder(int folderType) and + * findFolder(short domain, int folderType) except that it can + * create the folder if it does not already exist. + * + * @param domain domain + * @param folderType folder type + * @param createIfNeeded set to true, by setting to + * false the behavior will be the same as + * findFolder(short domain, int folderType, boolean createIfNeeded) + * @return the path to the folder searched for + * @throws java.io.FileNotFoundException if the folder does not exist + */ + public abstract String findFolder(short domain, int folderType, + boolean createIfNeeded) throws FileNotFoundException; + + + /** + * Returns full pathname for the resource identified by a given name. + * + * @param resourceName resource name + * @return full pathname + * @throws java.io.FileNotFoundException if the resource does not exist + */ + public abstract String getResource(String resourceName) throws FileNotFoundException; + + /** + * Returns full pathname for the resource identified by a given name and + * located in the specified bundle subdirectory. + * + * @param resourceName resource name + * @param subDirName subdirectory name + * @return full pathname + * @throws java.io.FileNotFoundException if the resource does not exist + */ + public abstract String getResource(String resourceName, String subDirName) + throws FileNotFoundException; + + /** + * Returns the full pathname for the resource identified by the given name + * and file extension and located in the specified bundle subdirectory. + * + * If extension is an empty string or null, the returned pathname is the + * first one encountered where the file name exactly matches name. + * + * If subpath is null, this method searches the top-level nonlocalized + * resource directory (typically Resources) and the top-level of any + * language-specific directories. For example, suppose you have a modern + * bundle and specify "Documentation" for the subpath parameter. This method + * would first look in the Contents/Resources/Documentation directory of the + * bundle, followed by the Documentation subdirectories of each + * language-specific .lproj directory. (The search order for the + * language-specific directories corresponds to the user's preferences.) + * This method does not recurse through any other subdirectories at any of + * these locations. For more details see the AppKit NSBundle documentation. + * + * @param resourceName the name of the resource file + * @param subDirName subdirectory + * @param type type + * @return full pathname for the resource identified by the given name and + * file extension and located in the specified bundle subdirectory. + * @throws java.io.FileNotFoundException if the resource does not exist + */ + public abstract String getResource(String resourceName, String subDirName, + String type) throws FileNotFoundException; + + /** + * Obtains the path to the current application's NSBundle, may not return a + * valid path if Java was launched from the command line. + * + * @return full pathname of the NSBundle of the current application + * executable. + */ + public abstract String getPathToApplicationBundle(); + + /** + * Moves the specified file to the Trash + * + * @param file the file + * @return returns true if the NSFileManager successfully moved the file to + * the Trash. + * @throws FileNotFoundException if the file does not exist + */ + public abstract boolean moveToTrash(final File file) throws FileNotFoundException; + + /** + * Reveals the specified file in the Finder + * + * @param file the file to reveal + * @return returns true if the NSFileManager successfully revealed the file + * in the Finder. + * @throws FileNotFoundException if the file does not exist + */ + public abstract boolean revealInFinder(final File file) throws FileNotFoundException; +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/FullScreenListener.java 2015-11-19 18:20:40.165554317 +0300 @@ -0,0 +1,64 @@ +/* + * 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; + +import java.awt.AppEvent.FullScreenEvent; + +/** + * An implementor is notified when a window is entering/exiting or + * has entered/exited full screen state. + */ +public interface FullScreenListener extends EventListener { + + /** + * Invoked when a window has started to enter full screen. + * + * @param e containing the specific window entering full screen. + */ + default public void windowEnteringFullScreen(final FullScreenEvent e) {} + + /** + * Invoked when a window has fully entered full screen. + * + * @param e containing the specific window which has entered full screen. + */ + default public void windowEnteredFullScreen(final FullScreenEvent e) {} + + /** + * Invoked when a window has started to exit full screen. + * + * @param e containing the specific window exiting full screen. + */ + default public void windowExitingFullScreen(final FullScreenEvent e) {} + + /** + * Invoked when a window has fully exited full screen. + * + * @param e containing the specific window which has exited full screen. + */ + default public void windowExitedFullScreen(final FullScreenEvent e) {} +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/OpenFilesHandler.java 2015-11-19 18:20:40.717554331 +0300 @@ -0,0 +1,42 @@ +/* + * 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. + * This message is only sent if the application has registered that it handles CFBundleDocumentTypes in it's Info.plist. + * + * @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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/OpenURIHandler.java 2015-11-19 18:20:41.209554343 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/PreferencesHandler.java 2015-11-19 18:20:41.693554356 +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 it's preferences UI. + * + * @see java.awt.Desktop#setPreferencesHandler(java.awt.desktop.PreferencesHandler) + */ +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); +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/PrintFilesHandler.java 2015-11-19 18:20:42.169554368 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/QuitHandler.java 2015-11-19 18:20:42.661554381 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/QuitResponse.java 2015-11-19 18:20:43.177554394 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/QuitStrategy.java 2015-11-19 18:20:43.665554406 +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 use 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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepListener.java 2015-11-19 18:20:44.221554421 +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 awoke from power save sleep. + * @param e the screen sleep event + */ + public void screenAwoke(final ScreenSleepEvent e); +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/SystemEventListener.java 2015-11-19 18:20:44.797554435 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/SystemSleepListener.java 2015-11-19 18:20:45.281554448 +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 awoke from sleeping. + * @param e the system sleep event + */ + public void systemAwoke(final SystemSleepEvent e); +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/UserSessionListener.java 2015-11-19 18:20:45.765554460 +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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java 2015-11-19 18:20:46.329554475 +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.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-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c 2015-11-19 18:20:46.857554488 +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 +#include "jvm_md.h" +#include +#include + +#include "jni_util.h" +#include "awt_Taskbar.h" + + +extern JavaVM *jvm; + +#define NO_SYMBOL_EXCEPTION 1 + +#define UNITY_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("unity", "9") +#define UNITY_LIB JNI_LIB_NAME("unity") + +static jmp_buf j; + +static void *unity_libhandle = NULL; + +static DbusmenuMenuitem* menu = NULL; +UnityLauncherEntry* entry = NULL; + +static jclass jTaskbarCls = NULL; +static jmethodID jTaskbarCallback = NULL; +static jmethodID jMenuItemGetLabel = NULL; + +GList* globalRefs = NULL; + +static void* dl_symbol(const char* name) { + void* result = dlsym(unity_libhandle, name); + if (!result) + longjmp(j, NO_SYMBOL_EXCEPTION); + + return result; +} + +static gboolean unity_load() { + unity_libhandle = dlopen(UNITY_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL); + if (unity_libhandle == NULL) { + unity_libhandle = dlopen(UNITY_LIB, RTLD_LAZY | RTLD_LOCAL); + if (unity_libhandle == NULL) { + return FALSE; + } + } + if (setjmp(j) == 0) { + fp_unity_launcher_entry_get_for_desktop_file = dl_symbol("unity_launcher_entry_get_for_desktop_file"); + fp_unity_launcher_entry_set_count = dl_symbol("unity_launcher_entry_set_count"); + fp_unity_launcher_entry_set_count_visible = dl_symbol("unity_launcher_entry_set_count_visible"); + fp_unity_launcher_entry_set_urgent = dl_symbol("unity_launcher_entry_set_urgent"); + fp_unity_launcher_entry_set_progress = dl_symbol("unity_launcher_entry_set_progress"); + fp_unity_launcher_entry_set_progress_visible = dl_symbol("unity_launcher_entry_set_progress_visible"); + + fp_dbusmenu_menuitem_new = dl_symbol("dbusmenu_menuitem_new"); + fp_dbusmenu_menuitem_property_set = dl_symbol("dbusmenu_menuitem_property_set"); + fp_dbusmenu_menuitem_property_set_int = dl_symbol("dbusmenu_menuitem_property_set_int"); + fp_dbusmenu_menuitem_property_get_int = dl_symbol("dbusmenu_menuitem_property_get_int"); + fp_dbusmenu_menuitem_property_set = dl_symbol("dbusmenu_menuitem_property_set"); + fp_dbusmenu_menuitem_child_append = dl_symbol("dbusmenu_menuitem_child_append"); + fp_dbusmenu_menuitem_child_delete = dl_symbol("dbusmenu_menuitem_child_delete"); + fp_dbusmenu_menuitem_take_children = dl_symbol("dbusmenu_menuitem_take_children"); + fp_dbusmenu_menuitem_foreach = dl_symbol("dbusmenu_menuitem_foreach"); + fp_unity_launcher_entry_set_quicklist = dl_symbol("unity_launcher_entry_set_quicklist"); + } else { + dlclose(unity_libhandle); + unity_libhandle = NULL; + return FALSE; + } + return TRUE; +} + +void callback(DbusmenuMenuitem* mi, guint ts, jobject data) { + JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2); + (*env)->CallStaticVoidMethod(env, jTaskbarCls, jTaskbarCallback, data, + fp_dbusmenu_menuitem_property_get_int(mi, "toggle-state") + ? JNI_FALSE + : JNI_TRUE); +} + +/* + * Class: sun_awt_X11_XTaskbarPeer + * Method: init + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XTaskbarPeer_init +(JNIEnv *env, jclass cls, jstring jname) { + jclass clazz; + + jTaskbarCls = (*env)->NewGlobalRef(env, cls); + + CHECK_NULL_RETURN(jTaskbarCallback = + (*env)->GetStaticMethodID(env, cls, "menuItemCallback", "(Ljava/awt/MenuItem;)V"), JNI_FALSE); + CHECK_NULL_RETURN( + clazz = (*env)->FindClass(env, "java/awt/MenuItem"), JNI_FALSE); + CHECK_NULL_RETURN( + jMenuItemGetLabel = (*env)->GetMethodID(env, clazz, "getLabel", "()Ljava/lang/String;"), JNI_FALSE); + + if (gtk2_load(env) && unity_load()) { + const gchar* name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name) { + entry = fp_unity_launcher_entry_get_for_desktop_file(name); + (*env)->ReleaseStringUTFChars(env, jname, name); + return JNI_TRUE; + } + } + return JNI_FALSE; +} + +/* + * Class: sun_awt_X11_XTaskbarPeer + * Method: runloop + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_runloop +(JNIEnv *env, jclass cls) { + fp_gdk_threads_enter(); + fp_gtk_main(); + fp_gdk_threads_leave(); +} + +/* + * Class: sun_awt_X11_XTaskbarPeer + * Method: setBadge + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setBadge +(JNIEnv *env, jobject obj, jlong value, jboolean visible) { + fp_gdk_threads_enter(); + fp_unity_launcher_entry_set_count(entry, value); + fp_unity_launcher_entry_set_count_visible(entry, visible); + fp_gdk_threads_leave(); +} + +/* + * Class: sun_awt_X11_XTaskbarPeer + * Method: setUrgent + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setUrgent +(JNIEnv *env, jobject obj, jboolean urgent) { + fp_gdk_threads_enter(); + fp_unity_launcher_entry_set_urgent(entry, urgent); + fp_gdk_threads_leave(); +} + +/* + * Class: sun_awt_X11_XTaskbarPeer + * Method: updateProgress + * Signature: (DZ)V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_updateProgress +(JNIEnv *env, jobject obj, jdouble value, jboolean visible) { + fp_gdk_threads_enter(); + fp_unity_launcher_entry_set_progress(entry, value); + fp_unity_launcher_entry_set_progress_visible(entry, visible); + fp_gdk_threads_leave(); +} + +void deleteGlobalRef(gpointer data) { + JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2); + (*env)->DeleteGlobalRef(env, data); +} + +void fill_menu(JNIEnv *env, jobjectArray items) { + int index; + jsize length = (*env)->GetArrayLength(env, items); + for (index = 0; index < length; index++) { + jobject elem = (*env)->GetObjectArrayElement(env, items, index); + if ((*env)->ExceptionCheck(env)) { + break; + } + elem = (*env)->NewGlobalRef(env, elem); + + globalRefs = fp_g_list_append(globalRefs, elem); + + jstring jlabel = (jstring) (*env)->CallObjectMethod(env, elem, jMenuItemGetLabel); + if (!(*env)->ExceptionCheck(env) && jlabel) { + const gchar* label = (*env)->GetStringUTFChars(env, jlabel, NULL); + if (label) { + DbusmenuMenuitem* mi = fp_dbusmenu_menuitem_new(); + if (!strcmp(label, "-")) { + fp_dbusmenu_menuitem_property_set(mi, "type", "separator"); + } else { + fp_dbusmenu_menuitem_property_set(mi, "label", label); + } + + (*env)->ReleaseStringUTFChars(env, jlabel, label); + fp_dbusmenu_menuitem_child_append(menu, mi); + fp_g_signal_connect(mi, "item_activated", G_CALLBACK(callback), elem); + } + } + } +} + +/* + * Class: sun_awt_X11_XTaskbarPeer + * Method: setNativeMenu + * Signature: ([Ljava/awt/MenuItem;)V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setNativeMenu +(JNIEnv *env, jobject obj, jobjectArray items) { + + fp_gdk_threads_enter(); + + if (!menu) { + menu = fp_dbusmenu_menuitem_new(); + fp_unity_launcher_entry_set_quicklist(entry, menu); + } + + GList* list = fp_dbusmenu_menuitem_take_children(menu); + fp_g_list_free_full(list, fp_g_object_unref); + + fp_g_list_free_full(globalRefs, deleteGlobalRef); + globalRefs = NULL; + + if (items) { + fill_menu(env, items); + } + + fp_gdk_threads_leave(); +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h 2015-11-19 18:20:47.353554501 +0300 @@ -0,0 +1,57 @@ +/* + * 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 thats + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef AWT_TASKBAR_H +#define AWT_TASKBAR_H + +#include "gtk2_interface.h" + +typedef void UnityLauncherEntry; +typedef void DbusmenuMenuitem; + +static UnityLauncherEntry* (*fp_unity_launcher_entry_get_for_desktop_file) (const gchar* desktop_file); + +static void (*fp_unity_launcher_entry_set_count) (UnityLauncherEntry* self, gint64 value); +static void (*fp_unity_launcher_entry_set_count_visible) (UnityLauncherEntry* self, gboolean value); + +static void (*fp_unity_launcher_entry_set_urgent) (UnityLauncherEntry* self, gboolean value); + +static void (*fp_unity_launcher_entry_set_progress) (UnityLauncherEntry* self, gdouble value); +static void (*fp_unity_launcher_entry_set_progress_visible) (UnityLauncherEntry* self, gboolean value); + + +static DbusmenuMenuitem* (*fp_dbusmenu_menuitem_new) (void); +static gboolean (*fp_dbusmenu_menuitem_property_set) (DbusmenuMenuitem* mi, const gchar* property, const gchar* value); +static gboolean (*fp_dbusmenu_menuitem_property_set_int) (DbusmenuMenuitem * mi, const gchar * property, const gint value); +static gint (*fp_dbusmenu_menuitem_property_get_int) (const DbusmenuMenuitem * mi, const gchar * property); +static gboolean (*fp_dbusmenu_menuitem_child_append) (DbusmenuMenuitem* mi, DbusmenuMenuitem* child); +static gboolean (*fp_dbusmenu_menuitem_child_delete) (DbusmenuMenuitem * mi, DbusmenuMenuitem * child); +static GList * (*fp_dbusmenu_menuitem_take_children) (DbusmenuMenuitem * mi); +static void (*fp_dbusmenu_menuitem_foreach) (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); +static void (*fp_unity_launcher_entry_set_quicklist) (UnityLauncherEntry* self, DbusmenuMenuitem* value); + + +#endif /* AWT_TASKBAR_H */ + --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WTaskbarPeer.java 2015-11-19 18:20:47.829554513 +0300 @@ -0,0 +1,145 @@ +/* + * 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.windows; + +import java.awt.AlphaComposite; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Taskbar.Feature; +import java.awt.TaskbarPeer; +import java.awt.Window; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import sun.awt.AWTAccessor; +import sun.awt.OSInfo; + +final public class WTaskbarPeer implements TaskbarPeer { + + private static boolean supported = false; + private static boolean initExecuted = false; + + private static synchronized void init() { + if (!initExecuted) { + supported = OSInfo.getWindowsVersion() + .compareTo(OSInfo.WINDOWS_7) >= 0 + && nativeInit(); + } + initExecuted = true; + } + + static boolean isTaskbarSupported() { + init(); + return supported; + } + + WTaskbarPeer() { + init(); + } + + @Override + public boolean isSupported(Feature feature) { + switch(feature) { + case ICON_BADGE_IMAGE_WINDOW: + case PROGRESS_STATE_WINDOW: + case PROGRESS_VALUE_WINDOW: + return supported; + case USER_ATTENTION_WINDOW: + return true; + default: + return false; + } + } + + private static int[] imageToArray(Image image) { + if (image == null) { + return null; + } + + int w = image.getWidth(null); + int h = image.getHeight(null); + + if (w < 0 || h < 0) { + return null; + } + + BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); + Graphics2D g2 = bimg.createGraphics(); + g2.setComposite(AlphaComposite.Src); + g2.drawImage(image, 0, 0, null); + g2.dispose(); + + return ((DataBufferInt) bimg.getRaster().getDataBuffer()).getData(); + } + + @Override + public void setWindowIconBadge(Window window, final Image image) { + WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window); + if (wp != null) { + int w = 0; + int h = 0; + int[] buffer = imageToArray(image); + if (buffer != null) { + w = image.getWidth(null); + h = image.getHeight(null); + } + setOverlayIcon(wp.getHWnd(), buffer, w, h); + } + } + + @Override + public void requestWindowUserAttention(Window window) { + WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window); + if (wp != null) { + flashWindow(wp.getHWnd()); + } + } + + @Override + public void setWindowProgressValue(Window window, int value) { + WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window); + if (wp != null) { + setProgressValue(wp.getHWnd(), value); + } + } + + @Override + public void setWindowProgressState(Window window, int state) { + WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window); + if (wp != null) { + setProgressState(wp.getHWnd(), state); + } + } + + private static native boolean nativeInit(); + + private native void setProgressValue(long hwnd, int value); + + private native void setProgressState(long hwnd, int state); + + private native void setOverlayIcon(long hwnd, int[] badge, int width, int height); + + private native void flashWindow(long hWnd); + +} --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp 2015-11-19 18:20:48.281554525 +0300 @@ -0,0 +1,111 @@ +/* + * 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 "jni_util.h" +#include "awt.h" +#include +#include "awt_Taskbar.h" +#include "java_awt_Taskbar.h" +#include "awt_Window.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: nativeInit + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WTaskbarPeer_nativeInit + (JNIEnv *env, jclass) +{ + if (SUCCEEDED(::CoInitialize(NULL)) + && SUCCEEDED(::CoCreateInstance(CLSID_TaskbarList, NULL, + CLSCTX_INPROC_SERVER, IID_ITaskbarList, (LPVOID *)&m_Taskbar))) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: setProgressValue + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressValue + (JNIEnv *, jobject, jlong window, jint value) +{ + m_Taskbar->SetProgressValue((HWND)window, value, 100); +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: setProgressState + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressState + (JNIEnv *, jobject, jlong window, jint state) +{ + TBPFLAG flag; + switch (state) { + case java_awt_Taskbar_STATE_OFF: flag = TBPF_NOPROGRESS; break; + case java_awt_Taskbar_STATE_NORMAL: flag = TBPF_NORMAL; break; + case java_awt_Taskbar_STATE_PAUSED: flag = TBPF_PAUSED; break; + case java_awt_Taskbar_STATE_INDETERMINATE: flag = TBPF_INDETERMINATE; break; + case java_awt_Taskbar_STATE_ERROR: flag = TBPF_ERROR; break; + } + m_Taskbar->SetProgressState((HWND)window, flag); + +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: flashWindow + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_flashWindow + (JNIEnv *, jobject, jlong window) +{ + AwtWindow::FlashWindowEx((HWND) window, 3, 0, FLASHW_TIMERNOFG); +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: setOverlayIcon + * Signature: (J[III)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setOverlayIcon + (JNIEnv *env, jobject, jlong window, jintArray buf, jint w, jint h) +{ + HICON icon = CreateIconFromRaster(env, buf, w, h); + m_Taskbar->SetOverlayIcon((HWND)window, icon, NULL); + ::DestroyIcon(icon); +} +#ifdef __cplusplus +} +#endif --- /dev/null 2015-11-09 12:41:48.570911013 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.h 2015-11-19 18:20:48.701554535 +0300 @@ -0,0 +1,108 @@ +/* + * 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. + */ + +#ifndef AWT_TASKBAR_H +#define AWT_TASKBAR_H + +#include +#include + + +#ifndef __ITaskbarList_INTERFACE_DEFINED__ +#define __ITaskbarList_INTERFACE_DEFINED__ +extern "C" { + const GUID CLSID_TaskbarList = {0x56FDF344, 0xFD6D, 0x11D0, + {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}}; + const GUID IID_ITaskbarList = {0x56FDF342, 0xFD6D, 0x11D0, + {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}}; +} + +class ITaskbarList : public IUnknown { +public: + virtual HRESULT STDMETHODCALLTYPE HrInit(void) = 0; + virtual HRESULT STDMETHODCALLTYPE AddTab(HWND hwnd) = 0; + virtual HRESULT STDMETHODCALLTYPE DeleteTab(HWND hwnd) = 0; + virtual HRESULT STDMETHODCALLTYPE ActivateTab(HWND hwnd) = 0; + virtual HRESULT STDMETHODCALLTYPE SetActiveAlt(HWND hwnd) = 0; +}; +#endif /* ITaskbarList */ + +#ifndef __ITaskbarList2_INTERFACE_DEFINED__ +#define __ITaskbarList2_INTERFACE_DEFINED__ + +class ITaskbarList2 : public ITaskbarList { +public: + virtual HRESULT STDMETHODCALLTYPE MarkFullscreenWindow(HWND hwnd, BOOL fFullscreen) = 0; +}; +#endif /* ITaskbarList2 */ + +#ifndef __ITaskbarList3_INTERFACE_DEFINED__ +#define __ITaskbarList3_INTERFACE_DEFINED__ + +typedef enum THUMBBUTTONFLAGS { + THBF_ENABLED = 0, THBF_DISABLED = 0x1, THBF_DISMISSONCLICK = 0x2, THBF_NOBACKGROUND = 0x4, THBF_HIDDEN = 0x8, THBF_NONINTERACTIVE = 0x10 +} THUMBBUTTONFLAGS; + +typedef enum THUMBBUTTONMASK { + THB_BITMAP = 0x1, THB_ICON = 0x2, THB_TOOLTIP = 0x4, THB_FLAGS = 0x8 +} THUMBBUTTONMASK; + +typedef struct THUMBBUTTON { + THUMBBUTTONMASK dwMask; + UINT iId; + UINT iBitmap; + HICON hIcon; + WCHAR szTip[260]; + THUMBBUTTONFLAGS dwFlags; +} THUMBBUTTON; + +typedef enum TBPFLAG { + TBPF_NOPROGRESS = 0, TBPF_INDETERMINATE = 0x1, TBPF_NORMAL = 0x2, TBPF_ERROR = 0x4, TBPF_PAUSED = 0x8 +} TBPFLAG; +#define THBN_CLICKED 0x1800 + +class ITaskbarList3 : public ITaskbarList2 { +public: + virtual HRESULT STDMETHODCALLTYPE SetProgressValue(HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) = 0; + virtual HRESULT STDMETHODCALLTYPE SetProgressState(HWND hwnd, TBPFLAG tbpFlags) = 0; + virtual HRESULT STDMETHODCALLTYPE RegisterTab(HWND hwndTab, HWND hwndMDI) = 0; + virtual HRESULT STDMETHODCALLTYPE UnregisterTab(HWND hwndTab) = 0; + virtual HRESULT STDMETHODCALLTYPE SetTabOrder(HWND hwndTab, HWND hwndInsertBefore) = 0; + virtual HRESULT STDMETHODCALLTYPE SetTabActive(HWND hwndTab, HWND hwndMDI, DWORD dwReserved) = 0; + virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons(HWND hwnd, UINT cButtons, THUMBBUTTON * pButton) = 0; + virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons(HWND hwnd, UINT cButtons, THUMBBUTTON * pButton) = 0; + virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList(HWND hwnd, HIMAGELIST himl) = 0; + virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon(HWND hwnd, HICON hIcon, LPCWSTR pszDescription) = 0; + virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip(HWND hwnd, LPCWSTR pszTip) = 0; + virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip(HWND hwnd, RECT *prcClip) = 0; +}; +#endif /* ITaskbarList3 */ + + +ITaskbarList3 * m_Taskbar; + + +#endif /* AWT_TASKBAR_H */ + --- old/src/java.desktop/macosx/classes/com/apple/eawt/AboutHandler.java 2015-11-19 18:20:49.245554549 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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.AboutEvent; - -/** - * An implementor receives notification when the app is asked to show it's about dialog. - * - * @see Application#setAboutHandler(AboutHandler) - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -public interface AboutHandler { - /** - * Called when the application is asked to show it's about dialog. - * @param e the request to show the about dialog. - */ - public void handleAbout(final AboutEvent e); -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/AppEvent.java 2015-11-19 18:20:49.505554556 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -import java.io.File; -import java.net.URI; -import java.util.*; -import java.awt.Window; - -/** - * AppEvents are sent to listeners and handlers installed on the {@link Application}. - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -@SuppressWarnings("serial") // JDK implementation class -public abstract class AppEvent extends EventObject { - AppEvent() { - super(Application.getApplication()); - } - - /** - * Contains a list of files. - */ - @SuppressWarnings("serial") // JDK implementation class - public abstract static class FilesEvent extends AppEvent { - final List files; - - FilesEvent(final List files) { - this.files = files; - } - - /** - * @return the list of files - */ - public List getFiles() { - return files; - } - } - - /** - * Event sent when the app is asked to open a list of files. - * - * @see OpenFilesHandler#openFiles(OpenFilesEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class OpenFilesEvent extends FilesEvent { - final String searchTerm; - - OpenFilesEvent(final List files, final String searchTerm) { - super(files); - this.searchTerm = searchTerm; - } - - /** - * If the files were opened using the Spotlight search menu or a Finder search window, this method obtains the search term used to find the files. - * This is useful for highlighting the search term in the documents when they are opened. - * @return the search term used to find the files - */ - public String getSearchTerm() { - return searchTerm; - } - } - - /** - * Event sent when the app is asked to print a list of files. - * - * @see PrintFilesHandler#printFiles(PrintFilesEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class PrintFilesEvent extends FilesEvent { - PrintFilesEvent(final List files) { - super(files); - } - } - - /** - * Event sent when the app is asked to open a URI. - * - * @see OpenURIHandler#openURI(OpenURIEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class OpenURIEvent extends AppEvent { - final URI uri; - - OpenURIEvent(final URI uri) { - this.uri = uri; - } - - /** - * @return the URI the app was asked to open - */ - public URI getURI() { - return uri; - } - } - - /** - * Event sent when the application is asked to open it's about window. - * - * @see AboutHandler#handleAbout() - */ - @SuppressWarnings("serial") // JDK implementation class - public static class AboutEvent extends AppEvent { AboutEvent() { } } - - /** - * Event sent when the application is asked to open it's preferences window. - * - * @see PreferencesHandler#handlePreferences() - */ - @SuppressWarnings("serial") // JDK implementation class - public static class PreferencesEvent extends AppEvent { PreferencesEvent() { } } - - /** - * Event sent when the application is asked to quit. - * - * @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class QuitEvent extends AppEvent { QuitEvent() { } } - - /** - * Event sent when the application is asked to re-open itself. - * - * @see AppReOpenedListener#appReOpened(AppReOpenedEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class AppReOpenedEvent extends AppEvent { AppReOpenedEvent() { } } - - /** - * Event sent when the application has become the foreground app, and when it has resigned being the foreground app. - * - * @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent) - * @see AppForegroundListener#appMovedToBackground(AppForegroundEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class AppForegroundEvent extends AppEvent { AppForegroundEvent() { } } - - /** - * Event sent when the application has been hidden or shown. - * - * @see AppHiddenListener#appHidden(AppHiddenEvent) - * @see AppHiddenListener#appUnhidden(AppHiddenEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class AppHiddenEvent extends AppEvent { AppHiddenEvent() { } } - - /** - * Event sent when the user session has been changed via Fast User Switching. - * - * @see UserSessionListener#userSessionActivated(UserSessionEvent) - * @see UserSessionListener#userSessionDeactivated(UserSessionEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class UserSessionEvent extends AppEvent { UserSessionEvent() { } } - - /** - * Event sent when the displays attached to the system enter and exit power save sleep. - * - * @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent) - * @see ScreenSleepListener#screenAwoke(ScreenSleepEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class ScreenSleepEvent extends AppEvent { ScreenSleepEvent() { } } - - /** - * Event sent when the system enters and exits power save sleep. - * - * @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent) - * @see SystemSleepListener#systemAwoke(SystemSleepEvent) - */ - @SuppressWarnings("serial") // JDK implementation class - public static class SystemSleepEvent extends AppEvent { SystemSleepEvent() { } } - - /** - * Event sent when a window is entering/exiting or has entered/exited full screen state. - * - * @see FullScreenUtilities - * - * @since Java for Mac OS X 10.7 Update 1 - */ - @SuppressWarnings("serial") // JDK implementation class - public static class FullScreenEvent extends AppEvent { - final Window window; - - FullScreenEvent(final Window window) { - this.window = window; - } - - /** - * @return window transitioning between full screen states - */ - public Window getWindow() { - return window; - } - } -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/AppEventListener.java 2015-11-19 18:20:49.805554564 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -/** - * Common interface for all event listener sub-types. - * Implementors may implement multiple sub-types, but only need to call {@link Application#addAppEventListener(AppEventListener)} once to receive all notifications. - * - * @see AppReOpenedListener - * @see AppForegroundListener - * @see AppHiddenListener - * @see ScreenSleepListener - * @see SystemSleepListener - * @see UserSessionListener - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -public interface AppEventListener { } --- old/src/java.desktop/macosx/classes/com/apple/eawt/AppForegroundListener.java 2015-11-19 18:20:50.121554572 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -import com.apple.eawt.AppEvent.AppForegroundEvent; - -/** - * Implementors are notified when the app becomes the foreground app and when it resigns being the foreground app. - * This notification is useful for hiding and showing transient UI like palette windows which should be hidden when the app is in the background. - * - * @see Application#addAppEventListener(AppEventListener) - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -public interface AppForegroundListener extends AppEventListener { - /** - * Called when the app becomes the foreground app. - * @param e the app became foreground notification. - */ - public void appRaisedToForeground(final AppForegroundEvent e); - - /** - * Called when the app resigns to the background and another app becomes the foreground app. - * @param e the app resigned foreground notification. - */ - public void appMovedToBackground(final AppForegroundEvent e); -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/AppHiddenListener.java 2015-11-19 18:20:50.401554579 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -import com.apple.eawt.AppEvent.AppHiddenEvent; - -/** - * Implementors are notified when the app is hidden or shown by the user. - * This notification is helpful for discontinuing a costly animation if it's not visible to the user. - * - * @see Application#addAppEventListener(AppEventListener) - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -public interface AppHiddenListener extends AppEventListener { - /** - * Called the app is hidden. - * @param e - */ - public void appHidden(final AppHiddenEvent e); - - /** - * Called when the hidden app is shown again (but not necessarily brought to the foreground). - * @param e - */ - public void appUnhidden(final AppHiddenEvent e); -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/AppReOpenedListener.java 2015-11-19 18:20:50.689554586 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -import com.apple.eawt.AppEvent.AppReOpenedEvent; - -/** - * Implementors receive notification when the app has been asked to open again. - * Re-open events occur when the user clicks on the running app's Dock icon. - * Re-open events also occur when the app is double-clicked in the Finder and the app is already running. - * - * This notification is useful for showing a new document when your app has no open windows. - * - * @see Application#addAppEventListener(AppEventListener) - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -public interface AppReOpenedListener extends AppEventListener { - /** - * Called when the app has been re-opened (it's Dock icon was clicked on, or was double-clicked in the Finder) - * @param e the request to re-open the app - */ - public void appReOpened(final AppReOpenedEvent e); -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java 2015-11-19 18:20:50.949554593 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,61 +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 java.util.EventListener; - -import com.apple.eawt.AppEvent.FullScreenEvent; - -/** - * - * - * @since Java for Mac OS X 10.7 Update 1 - */ -public interface FullScreenListener extends EventListener { - /** - * Invoked when a window has started to enter full screen. - * @param event containing the specific window entering full screen. - */ - public void windowEnteringFullScreen(final FullScreenEvent e); - - /** - * Invoked when a window has fully entered full screen. - * @param event containing the specific window which has entered full screen. - */ - public void windowEnteredFullScreen(final FullScreenEvent e); - - /** - * Invoked when a window has started to exit full screen. - * @param event containing the specific window exiting full screen. - */ - public void windowExitingFullScreen(final FullScreenEvent e); - - /** - * Invoked when a window has fully exited full screen. - * @param event containing the specific window which has exited full screen. - */ - public void windowExitedFullScreen(final FullScreenEvent e); -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/OpenFilesHandler.java 2015-11-19 18:20:51.225554600 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -import com.apple.eawt.AppEvent.OpenFilesEvent; - -/** - * An implementor is notified when the application is asked to open a list of files. - * This message is only sent if the application has registered that it handles CFBundleDocumentTypes in it's Info.plist. - * - * @see Application#setOpenFileHandler(OpenFilesHandler) - * - * @since Java for Mac OS X 10.6 Update 3 - * @since Java for Mac OS X 10.5 Update 8 - */ -public interface OpenFilesHandler { - /** - * Called when the application is asked to open a list of files. - * @param e the request to open a list of files, and the search term used to find them, if any. - */ - public void openFiles(final OpenFilesEvent e); -} --- old/src/java.desktop/macosx/classes/com/apple/eawt/OpenURIHandler.java 2015-11-19 18:20:51.509554607 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +0300 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.apple.eawt; - -import com.apple.eawt.AppEvent.OpenURIEvent; - -/** - * An implementor is notified when the application is asked to open a URI. - * The application only sends {@link com.apple.eawt.EAWTEvent.OpenURIEvent}s when it has been launched as a bundled Mac application, and it's Info.plist claims URL schemes in it's 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-19 18:20:51.781554614 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:52.077554622 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:52.365554629 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:52.641554636 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:52.929554644 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:53.197554650 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:53.469554657 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:53.729554664 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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-19 18:20:53.985554671 +0300 +++ /dev/null 2015-11-09 12:41:48.570911013 +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 legacyAppListeners = new Vector(); - boolean blockLegacyAPI; - boolean initializedParentDispatchers; - - _AppEventLegacyHandler(final _AppEventHandler parent) { - this.parent = parent; - } - - void blockLegacyAPI() { - blockLegacyAPI = true; - } - - void checkIfLegacyAPIBlocked() { - if (!blockLegacyAPI) return; - throw new IllegalStateException("Cannot add com.apple.eawt.ApplicationListener after installing an app event handler"); - } - - void addLegacyAppListener(final ApplicationListener listener) { - checkIfLegacyAPIBlocked(); - - if (!initializedParentDispatchers) { - final _AppMenuBarHandler menuBarHandler = Application.getApplication().menuBarHandler; - final boolean prefsMenuAlreadyExplicitlySet = menuBarHandler.prefsMenuItemExplicitlySet; - - parent.aboutDispatcher.setHandler(this); - parent.preferencesDispatcher.setHandler(this); - if (!prefsMenuAlreadyExplicitlySet) { - menuBarHandler.setPreferencesMenuItemVisible(false); // default behavior is not to have a preferences item - } - parent.openAppDispatcher.setHandler(this); - parent.reOpenAppDispatcher.addListener(this); - parent.openFilesDispatcher.setHandler(this); - parent.printFilesDispatcher.setHandler(this); - parent.quitDispatcher.setHandler(this); - - initializedParentDispatchers = true; - } - - synchronized (legacyAppListeners) { - legacyAppListeners.addElement(listener); - } - } - - public void removeLegacyAppListener(final ApplicationListener listener) { - checkIfLegacyAPIBlocked(); - - synchronized (legacyAppListeners) { - legacyAppListeners.removeElement(listener); - } - } - - @Override - public void handleAbout(final AboutEvent e) { - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handleAbout(ae); - } - }); - - if (ae.isHandled()) return; - parent.openCocoaAboutWindow(); - } - - @Override - public void handlePreferences(final PreferencesEvent e) { - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handlePreferences(ae); - } - }); - } - - @Override - public void handleOpenApp() { - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handleOpenApplication(ae); - } - }); - } - - @Override - public void appReOpened(final AppReOpenedEvent e) { - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handleReOpenApplication(ae); - } - }); - } - - @Override - public void openFiles(final OpenFilesEvent e) { - final List files = e.getFiles(); - for (final File file : files) { // legacy ApplicationListeners only understood one file at a time - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handleOpenFile(ae); - } - }); - } - } - - @Override - public void printFiles(PrintFilesEvent e) { - final List files = e.getFiles(); - for (final File file : files) { // legacy ApplicationListeners only understood one file at a time - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handlePrintFile(ae); - } - }); - } - } - - @Override - public void handleQuitRequestWith(final QuitEvent e, final QuitResponse response) { - final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit()); - sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { - public void dispatchEvent(final ApplicationListener listener) { - listener.handleQuit(ae); - } - }); - - if (ae.isHandled()) { - parent.performQuit(); - } else { - parent.cancelQuit(); - } - } - - interface EventDispatcher { - void dispatchEvent(final ApplicationListener listener); - } - - // helper that cycles through the loop and aborts if the event is handled, or there are no listeners - void sendEventToEachListenerUntilHandled(final ApplicationEvent event, final EventDispatcher dispatcher) { - synchronized (legacyAppListeners) { - if (legacyAppListeners.size() == 0) return; - - final Enumeration e = legacyAppListeners.elements(); - while (e.hasMoreElements() && !event.isHandled()) { - dispatcher.dispatchEvent(e.nextElement()); - } - } - } -}