--- old/make/mapfiles/libawt_xawt/mapfile-vers 2016-01-22 10:07:05.527772400 +0300 +++ new/make/mapfiles/libawt_xawt/mapfile-vers 2016-01-22 10:07:05.452592600 +0300 @@ -150,6 +150,12 @@ Java_sun_awt_X11_XlibWrapper_XdbeEndIdiom; Java_sun_awt_X11_XDesktopPeer_init; Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show; + Java_sun_awt_X11_XTaskbarPeer_init; + Java_sun_awt_X11_XTaskbarPeer_runloop; + Java_sun_awt_X11_XTaskbarPeer_setBadge; + Java_sun_awt_X11_XTaskbarPeer_setUrgent; + Java_sun_awt_X11_XTaskbarPeer_updateProgress; + Java_sun_awt_X11_XTaskbarPeer_setNativeMenu; Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl; Java_sun_awt_X11_XRobotPeer_keyPressImpl; Java_sun_awt_X11_XRobotPeer_keyReleaseImpl; --- old/src/java.desktop/macosx/classes/com/apple/eawt/Application.java 2016-01-22 10:07:05.733072400 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/Application.java 2016-01-22 10:07:05.657990900 +0300 @@ -26,10 +26,10 @@ package com.apple.eawt; import java.awt.Image; -import java.awt.Point; import java.awt.PopupMenu; import java.awt.Toolkit; import java.awt.Window; +import java.awt.desktop.*; import java.beans.Beans; import javax.swing.JMenuBar; @@ -104,38 +104,38 @@ } /** - * Adds sub-types of {@link AppEventListener} to listen for notifications from the native Mac OS X system. + * Adds sub-types of {@link SystemEventListener} to listen for notifications from the native Mac OS X system. * * @see AppForegroundListener * @see AppHiddenListener * @see AppReOpenedListener - * @see ScreenSleepListener - * @see SystemSleepListener - * @see UserSessionListener + * @see AppScreenSleepListener + * @see AppSystemSleepListener + * @see AppUserSessionListener * * @param listener * @since Java for Mac OS X 10.6 Update 3 * @since Java for Mac OS X 10.5 Update 8 */ - public void addAppEventListener(final AppEventListener listener) { + public void addAppEventListener(final SystemEventListener listener) { eventHandler.addListener(listener); } /** - * Removes sub-types of {@link AppEventListener} from listening for notifications from the native Mac OS X system. + * Removes sub-types of {@link SystemEventListener} from listening for notifications from the native Mac OS X system. * * @see AppForegroundListener * @see AppHiddenListener * @see AppReOpenedListener - * @see ScreenSleepListener - * @see SystemSleepListener - * @see UserSessionListener + * @see AppScreenSleepListener + * @see AppSystemSleepListener + * @see AppUserSessionListener * * @param listener * @since Java for Mac OS X 10.6 Update 3 * @since Java for Mac OS X 10.5 Update 8 */ - public void removeAppEventListener(final AppEventListener listener) { + public void removeAppEventListener(final SystemEventListener listener) { eventHandler.removeListener(listener); } @@ -366,6 +366,17 @@ 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 + * @since 1.9 + */ + public void setDockIconProgress(final int value) { + iconHandler.setDockIconProgress(value); + } /** * Sets the default menu bar to use when there are no active frames. @@ -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 2016-01-22 10:07:05.939822500 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java 2016-01-22 10:07:05.869512700 +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 2016-01-22 10:07:06.141550600 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java 2016-01-22 10:07:06.069920100 +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 2016-01-22 10:07:06.345078900 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java 2016-01-22 10:07:06.274747900 +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 2016-01-22 10:07:06.551490900 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java 2016-01-22 10:07:06.479797000 +0300 @@ -25,7 +25,7 @@ package com.apple.eawt; -import com.apple.eawt.AppEvent.FullScreenEvent; +import com.apple.eawt.event.FullScreenEvent; /** * Abstract adapter class for receiving fullscreen events. This class is provided --- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java 2016-01-22 10:07:06.751927700 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenHandler.java 2016-01-22 10:07:06.682018900 +0300 @@ -25,13 +25,13 @@ package com.apple.eawt; +import com.apple.eawt.event.FullScreenEvent; import java.awt.*; import java.util.*; import java.util.List; import javax.swing.RootPaneContainer; -import com.apple.eawt.AppEvent.FullScreenEvent; import sun.awt.SunToolkit; import java.lang.annotation.Native; --- old/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java 2016-01-22 10:07:06.955190600 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java 2016-01-22 10:07:06.883792000 +0300 @@ -25,9 +25,9 @@ package com.apple.eawt; +import com.apple.eawt.event.FullScreenEvent; import java.util.EventListener; -import com.apple.eawt.AppEvent.FullScreenEvent; /** * --- old/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java 2016-01-22 10:07:07.164615600 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java 2016-01-22 10:07:07.085966900 +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 2016-01-22 10:07:07.367367800 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java 2016-01-22 10:07:07.296464000 +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); } } @@ -302,7 +301,9 @@ } class _UserSessionDispatcher extends _BooleanAppEventMultiplexor { - UserSessionEvent createEvent(final boolean isTrue) { return new UserSessionEvent(); } + UserSessionEvent createEvent(final boolean isTrue) { + return new UserSessionEvent(AppEvent.UserSessionEvent.REASON_UNSPECIFIED); + } void performFalseEventOn(final UserSessionListener listener, final UserSessionEvent e) { listener.userSessionDeactivated(e); @@ -391,7 +392,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 +525,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 +572,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 2016-01-22 10:07:07.577346400 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java 2016-01-22 10:07:07.506799300 +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 2016-01-22 10:07:07.785438800 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java 2016-01-22 10:07:07.709809100 +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 2016-01-22 10:07:08.000435700 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDesktopPeer.java 2016-01-22 10:07:07.921655200 +0300 @@ -25,9 +25,14 @@ package sun.lwawt.macosx; +import com.apple.eawt.Application; + +import javax.swing.*; import java.awt.Desktop.Action; +import java.awt.desktop.*; import java.awt.peer.DesktopPeer; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; @@ -37,34 +42,126 @@ * * @see DesktopPeer */ -public class CDesktopPeer implements DesktopPeer { +final public class CDesktopPeer implements DesktopPeer { + @Override public boolean isSupported(Action action) { - // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. - // Though we don't really differentiate between OPEN / EDIT return true; } + @Override public void open(File file) throws IOException { this.lsOpenFile(file, false); } + @Override public void edit(File file) throws IOException { this.lsOpenFile(file, false); } + @Override public void print(File file) throws IOException { this.lsOpenFile(file, true); } + @Override public void mail(URI uri) throws IOException { this.lsOpen(uri); } + @Override public void browse(URI uri) throws IOException { this.lsOpen(uri); } + @Override + public void addAppEventListener(SystemEventListener listener) { + Application.getApplication().addAppEventListener(listener); + } + + @Override + public void removeAppEventListener(SystemEventListener listener) { + Application.getApplication().removeAppEventListener(listener); + } + + @Override + public void setAboutHandler(AboutHandler aboutHandler) { + Application.getApplication().setAboutHandler(aboutHandler); + } + + @Override + public void setPreferencesHandler(PreferencesHandler preferencesHandler) { + Application.getApplication().setPreferencesHandler(preferencesHandler); + } + + @Override + public void setOpenFileHandler(OpenFilesHandler openFileHandler) { + Application.getApplication().setOpenFileHandler(openFileHandler); + } + + @Override + public void setPrintFileHandler(PrintFilesHandler printFileHandler) { + Application.getApplication().setPrintFileHandler(printFileHandler); + } + + @Override + public void setOpenURIHandler(OpenURIHandler openURIHandler) { + Application.getApplication().setOpenURIHandler(openURIHandler); + } + + @Override + public void setQuitHandler(QuitHandler quitHandler) { + Application.getApplication().setQuitHandler(quitHandler); + } + + @Override + public void setQuitStrategy(QuitStrategy strategy) { + Application.getApplication().setQuitStrategy(strategy); + } + + @Override + public void enableSuddenTermination() { + Application.getApplication().enableSuddenTermination(); + } + + @Override + public void disableSuddenTermination() { + Application.getApplication().disableSuddenTermination(); + } + + @Override + public void requestForeground(boolean allWindows) { + Application.getApplication().requestForeground(allWindows); + } + + @Override + public void openHelpViewer() { + Application.getApplication().openHelpViewer(); + } + + @Override + public void setDefaultMenuBar(JMenuBar menuBar) { + Application.getApplication().setDefaultMenuBar(menuBar); + } + + @Override + public boolean browseFileDirectory(File file) { + try { + return com.apple.eio.FileManager.revealInFinder(file); + } catch (FileNotFoundException ex) { + return false; //handled in java.awt.Desktop + } + } + + @Override + public boolean moveToTrash(File file) { + try { + return com.apple.eio.FileManager.moveToTrash(file); + } catch (FileNotFoundException ex) { + return false; //handled in java.awt.Desktop + } + } + private void lsOpen(URI uri) throws IOException { int status = _lsOpenURI(uri.toString()); --- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2016-01-22 10:07:08.203994400 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2016-01-22 10:07:08.133494200 +0300 @@ -25,6 +25,7 @@ package sun.lwawt.macosx; +import java.awt.peer.TaskbarPeer; import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.dnd.*; @@ -296,6 +297,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 2016-01-22 10:07:08.410400900 +0300 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.h 2016-01-22 10:07:08.340637200 +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 2016-01-22 10:07:08.617293600 +0300 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m 2016-01-22 10:07:08.546907200 +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 2016-01-22 10:07:08.823215300 +0300 +++ new/src/java.desktop/share/classes/java/awt/Desktop.java 2016-01-22 10:07:08.752355300 +0300 @@ -25,22 +25,23 @@ package java.awt; +import java.awt.desktop.*; import java.awt.peer.DesktopPeer; import java.io.File; import java.io.FilePermission; import java.io.IOException; +import java.lang.annotation.Native; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import sun.awt.SunToolkit; +import javax.swing.JMenuBar; import sun.security.util.SecurityConstants; /** - * The {@code Desktop} class allows a Java application to launch - * associated applications registered on the native desktop to handle - * a {@link java.net.URI} or a file. + * The {@code Desktop} class allows interact with various desktop capabilities. * *

Supported operations include: *

    @@ -58,6 +59,9 @@ * or file. If there is no associated application or the associated * application fails to be launched, an exception is thrown. * + * Please see {@link Desktop.Action} for the full list of supported operations + * and capabilities. + * *

    An application is registered to a URI or file type; for * example, the {@code "sxi"} file extension is typically registered * to StarOffice. The mechanism of registering, accessing, and @@ -70,6 +74,8 @@ * application is executed, it will be executed on the same system as * the one on which the Java application was launched. * + * @see Action + * * @since 1.6 * @author Armin Chen * @author George Zhang @@ -106,11 +112,145 @@ * @see Desktop#mail(java.net.URI) */ MAIL, + /** * Represents a "browse" action. * @see Desktop#browse(java.net.URI) */ - BROWSE + BROWSE, + + /** + * Represents an AppForegroundListener + * @see java.awt.desktop.AppForegroundListener + * @since 1.9 + */ + APP_EVENT_FOREGROUND, + + /** + * Represents an AppHiddenListener + * @see java.awt.desktop.AppHiddenListener + * @since 1.9 + */ + APP_EVENT_HIDDEN, + + /** + * Represents an AppReopenedListener + * @see java.awt.desktop.AppReopenedListener + * @since 1.9 + */ + APP_EVENT_REOPENED, + + /** + * Represents a ScreenSleepListener + * @see java.awt.desktop.ScreenSleepListener + * @since 1.9 + */ + APP_EVENT_SCREEN_SLEEP, + + /** + * Represents a SystemSleepListener + * @see java.awt.desktop.SystemSleepListener + * @since 1.9 + */ + APP_EVENT_SYSTEM_SLEEP, + + /** + * Represents a UserSessionListener + * @see java.awt.desktop.UserSessionListener + * @since 1.9 + */ + APP_EVENT_USER_SESSION, + + /** + * Represents an AboutHandler + * @see #setAboutHandler(java.awt.desktop.AboutHandler) + * @since 1.9 + */ + APP_ABOUT, + + /** + * Represents a PreferencesHandler + * @see #setPreferencesHandler(java.awt.desktop.PreferencesHandler) + * @since 1.9 + */ + APP_PREFERENCES, + + /** + * Represents an OpenFilesHandler + * @see #setOpenFileHandler(java.awt.desktop.OpenFilesHandler) + * @since 1.9 + */ + APP_OPEN_FILE, + + /** + * Represents a PrintFilesHandler + * @see #setPrintFileHandler(java.awt.desktop.PrintFilesHandler) + * @since 1.9 + */ + APP_PRINT_FILE, + + /** + * Represents an OpenURIHandler + * @see #setOpenURIHandler(java.awt.desktop.OpenURIHandler) + * @since 1.9 + */ + APP_OPEN_URI, + + /** + * Represents a QuitHandler + * @see #setQuitHandler(java.awt.desktop.QuitHandler) + * @since 1.9 + */ + APP_QUIT_HANDLER, + + /** + * Represents a QuitStrategy + * @see #setQuitStrategy(java.awt.desktop.QuitStrategy) + * @since 1.9 + */ + APP_QUIT_STRATEGY, + + /** + * Represents a SuddenTermination + * @see #enableSuddenTermination() + * @since 1.9 + */ + APP_SUDDEN_TERMINATION, + + /** + * Represents a requestForeground + * @see #requestForeground(boolean) + * @since 1.9 + */ + APP_REQUEST_FOREGROUND, + + /** + * Represents a HelpViewer + * @see #openHelpViewer() + * @since 1.9 + */ + APP_HELP_VIEWER, + + /** + * Represents a menu bar + * @see #setDefaultMenuBar(javax.swing.JMenuBar) + * @since 1.9 + */ + APP_MENU_BAR, + + /** + * Represents a browse file directory + * @see #browseFileDirectory(java.io.File) + * @since 1.9 + */ + BROWSE_FILE_DIR, + + /** + * Represents a move to trash + * @see #moveToTrash(java.io.File) + * @since 1.9 + */ + MOVE_TO_TRASH }; private DesktopPeer peer; @@ -128,10 +268,10 @@ /** * Returns the Desktop instance of the current - * browser context. On some platforms the Desktop API may not be + * desktop context. On some platforms the Desktop API may not be * supported; use the {@link #isDesktopSupported} method to * determine if the current desktop is supported. - * @return the Desktop instance of the current browser context + * @return the Desktop instance * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if this class is not @@ -208,7 +348,7 @@ if (!file.exists()) { throw new IllegalArgumentException("The file: " - + file.getPath() + " doesn't exist."); + + file.getPath() + " doesn't exist."); } file.canRead(); @@ -224,7 +364,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 +378,7 @@ SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AWTPermission( - "showWindowWithoutWarningBanner")); + "showWindowWithoutWarningBanner")); } } @@ -479,7 +619,334 @@ SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new FilePermission("<>", - SecurityConstants.FILE_EXECUTE_ACTION)); + SecurityConstants.FILE_EXECUTE_ACTION)); + } + } + + private void checkRead() throws SecurityException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new FilePermission("<>", + SecurityConstants.FILE_READ_ACTION)); + } + } + + private void checkWrite() throws SecurityException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new FilePermission("<>", + SecurityConstants.FILE_WRITE_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 the current + * platform. + * + * @param listener listener + * @see AppForegroundListener + * @see AppHiddenListener + * @see AppReopenedListener + * @see ScreenSleepListener + * @see SystemSleepListener + * @see UserSessionListener + * @since 1.9 + */ + 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 the current + * platform. + * + * @param listener listener + * @see AppForegroundListener + * @see AppHiddenListener + * @see AppReopenedListener + * @see ScreenSleepListener + * @see SystemSleepListener + * @see UserSessionListener + * @since 1.9 + */ + 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 + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_ABOUT} action + * {@link AboutHandler#handleAbout} )} message + * @since 1.9 + */ + public void setAboutHandler(final AboutHandler aboutHandler) { + checkActionSupport(Action.APP_ABOUT); + peer.setAboutHandler(aboutHandler); + } + + /** + * Installs a handler to show a custom Preferences window for your + * application. + *

    + * Setting the {@link PreferencesHandler} to null reverts it to + * the default behavior + * + * @param preferencesHandler the handler to respond to the + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_PREFERENCES} action + * {@link PreferencesHandler#handlePreferences(PreferencesEvent)} + * @since 1.9 + */ + public void setPreferencesHandler(final PreferencesHandler preferencesHandler) { + checkActionSupport(Action.APP_PREFERENCES); + peer.setPreferencesHandler(preferencesHandler); + } + + /** + * Installs the handler which is notified when the application is asked to + * open a list of files. + * + * @implNote Please note that for Mac OS, notifications + * are only sent if the Java app is a bundled application, + * with a {@code CFBundleDocumentTypes} array present in its + * Info.plist. See the + * + * Info.plist Key Reference for more information about adding a + * {@code CFBundleDocumentTypes} key to your app's Info.plist. + * + * @param openFileHandler handler + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_OPEN_FILE} action + * @since 1.9 + */ + public void setOpenFileHandler(final OpenFilesHandler openFileHandler) { + checkActionSupport(Action.APP_OPEN_FILE); + peer.setOpenFileHandler(openFileHandler); + } + + /** + * Installs the handler which is notified when the application is asked to + * print a list of files. + * + * @implNote Please note that for Mac OS, notifications + * are only sent if the Java app is a bundled application, + * with a {@code CFBundleDocumentTypes} array present in its + * Info.plist. See the + * + * Info.plist Key Reference for more information about adding a + * {@code CFBundleDocumentTypes} key to your app's Info.plist. + * + * @param printFileHandler handler + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_PRINT_FILE} action + * @since 1.9 + */ + public void setPrintFileHandler(final PrintFilesHandler printFileHandler) { + checkActionSupport(Action.APP_PRINT_FILE); + peer.setPrintFileHandler(printFileHandler); + } + + /** + * Installs the handler which is notified when the application is asked to + * open a URL. + * + * Setting the handler to null causes all + * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be + * enqueued until another handler is set. + * + * @implNote Please note that for Mac OS, notifications + * are only sent if the Java app is a bundled application, + * with a {@code CFBundleDocumentTypes} array present in its + * Info.plist. See the + * + * Info.plist Key Reference for more information about adding a + * {@code CFBundleDocumentTypes} key to your app's Info.plist. + * + * @param openURIHandler handler + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_OPEN_URI} action + * @since 1.9 + */ + public void setOpenURIHandler(final OpenURIHandler openURIHandler) { + checkActionSupport(Action.APP_OPEN_URI); + peer.setOpenURIHandler(openURIHandler); + } + + /** + * Installs the handler which determines if the application should quit. The + * handler is passed a one-shot {@link QuitResponse} which can cancel or + * proceed with the quit. Setting the handler to null causes + * all quit requests to directly perform the default {@link QuitStrategy}. + * + * @param quitHandler the handler that is called when the application is + * asked to quit + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_QUIT_HANDLER} action + * @since 1.9 + */ + public void setQuitHandler(final QuitHandler quitHandler) { + checkActionSupport(Action.APP_QUIT_HANDLER); + peer.setQuitHandler(quitHandler); + } + + /** + * Sets the default strategy used to quit this application. The default is + * calling SYSTEM_EXIT_0. + * + * @param strategy the way this application should be shutdown + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action + * @see QuitStrategy + * @since 1.9 + */ + public void setQuitStrategy(final QuitStrategy strategy) { + checkActionSupport(Action.APP_QUIT_STRATEGY); + peer.setQuitStrategy(strategy); + } + + /** + * Enables this application to be suddenly terminated. + * + * Call this method to indicate your application's state is saved, and + * requires no notification to be terminated. Letting your application + * remain terminatable improves the user experience by avoiding re-paging in + * your application when it's asked to quit. + * + * Note: enabling sudden termination will allow your application to be + * quit without notifying your QuitHandler, or running any shutdown + * hooks. + * E.g. user-initiated Cmd-Q, logout, restart, or shutdown requests will + * effectively "kill -KILL" your application. + * + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action + * @see #disableSuddenTermination() + * @since 1.9 + */ + public void enableSuddenTermination() { + checkActionSupport(Action.APP_SUDDEN_TERMINATION); + peer.enableSuddenTermination(); + } + + /** + * Prevents this application from being suddenly terminated. + * + * Call this method to indicate that your application has unsaved state, and + * may not be terminated without notification. + * + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action + * @see #enableSuddenTermination() + * @since 1.9 + */ + public void disableSuddenTermination() { + checkActionSupport(Action.APP_SUDDEN_TERMINATION); + peer.disableSuddenTermination(); + } + + /** + * Requests this application to move to the foreground. + * + * @param allWindows if all windows of this application should be moved to + * the foreground, or only the foremost one + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_REQUEST_FOREGROUND} action + * @since 1.9 + */ + public void requestForeground(final boolean allWindows) { + checkAWTPermission(); + checkActionSupport(Action.APP_REQUEST_FOREGROUND); + peer.requestForeground(allWindows); + } + + /** + * Opens the native help viewer application. + * + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_HELP_VIEWER} action + * @since 1.9 + */ + public void openHelpViewer() { + checkAWTPermission(); + checkActionSupport(Action.APP_HELP_VIEWER); + peer.openHelpViewer(); + } + + /** + * Sets the default menu bar to use when there are no active frames. + * + * @implNote Aqua Look and Feel should be active to support this on Mac OS. + * + * @param menuBar to use when no other frames are active + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#APP_MENU_BAR} action + * @since 1.9 + */ + public void setDefaultMenuBar(final JMenuBar menuBar) { + checkAWTPermission(); + checkActionSupport(Action.APP_MENU_BAR); + peer.setDefaultMenuBar(menuBar); + } + + /** + * Opens a folder containing the {@code file} and selects it + * in a default system file manager. + * @param file the file + * @throws SecurityException If a security manager exists and its + * {@link SecurityManager#checkRead(java.lang.String)} method + * denies read access to the file + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#BROWSE_FILE_DIR} action + * @throws NullPointerException if {@code file} is {@code null} + * @throws IllegalArgumentException if the specified file doesn't + * exist + * @since 1.9 + */ + public void browseFileDirectory(File file) { + checkRead(); + checkActionSupport(Action.BROWSE_FILE_DIR); + checkFileValidation(file); + peer.browseFileDirectory(file); + } + + /** + * Moves the specified file to the trash. + * + * @param file the file + * @return returns true if successfully moved the file to the trash. + * @throws SecurityException If a security manager exists and its + * {@link SecurityManager#checkWrite(java.lang.String)} method + * denies write access to the file + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#MOVE_TO_TRASH} action + * @throws NullPointerException if {@code file} is {@code null} + * @throws IllegalArgumentException if the specified file doesn't + * exist + * + * @since 1.9 + */ + public boolean moveToTrash(final File file) { + checkWrite(); + checkActionSupport(Action.MOVE_TO_TRASH); + checkFileValidation(file); + return peer.moveToTrash(file); + } } --- old/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java 2016-01-22 10:07:09.033974600 +0300 +++ new/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java 2016-01-22 10:07:08.963623700 +0300 @@ -22,14 +22,21 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package java.awt.peer; - import java.io.File; import java.io.IOException; import java.net.URI; import java.awt.Desktop.Action; +import java.awt.desktop.AboutHandler; +import java.awt.desktop.SystemEventListener; +import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.OpenURIHandler; +import java.awt.desktop.PreferencesHandler; +import java.awt.desktop.PrintFilesHandler; +import java.awt.desktop.QuitHandler; +import java.awt.desktop.QuitStrategy; +import javax.swing.JMenuBar; /** * The {@code DesktopPeer} interface provides methods for the operation @@ -104,4 +111,168 @@ * or it fails to be launched. */ void browse(URI uri) throws IOException; + + /** + * Adds sub-types of {@link SystemEventListener} to listen for notifications + * from the native system. + * + * @param listener listener + * @see java.awt.desktop.AppForegroundListener + * @see java.awt.desktop.AppHiddenListener + * @see java.awt.desktop.AppReopenedListener + * @see java.awt.desktop.ScreenSleepListener + * @see java.awt.desktop.SystemSleepListener + * @see java.awt.desktop.UserSessionListener + */ + default void addAppEventListener(final SystemEventListener listener) { + } + + /** + * Removes sub-types of {@link SystemEventListener} to listen for notifications + * from the native system. + * + * @param listener listener + * @see java.awt.desktop.AppForegroundListener + * @see java.awt.desktop.AppHiddenListener + * @see java.awt.desktop.AppReopenedListener + * @see java.awt.desktop.ScreenSleepListener + * @see java.awt.desktop.SystemSleepListener + * @see java.awt.desktop.UserSessionListener + */ + default void removeAppEventListener(final SystemEventListener listener) { + } + + /** + * Installs a handler to show a custom About window for your application. + *

    + * 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 java.awt.desktop.PreferencesHandler#handlePreferences(java.awt.AppEvent.PreferencesEvent) } + */ + default void setPreferencesHandler(final PreferencesHandler preferencesHandler) { + } + + /** + * Installs the handler which is notified when the application is asked to + * open a list of files. + * + * @param openFileHandler handler + * + */ + default void setOpenFileHandler(final OpenFilesHandler openFileHandler) { + } + + /** + * Installs the handler which is notified when the application is asked to + * print a list of files. + * + * @param printFileHandler handler + */ + default void setPrintFileHandler(final PrintFilesHandler printFileHandler) { + } + + /** + * Installs the handler which is notified when the application is asked to + * open a URL. + * + * Setting the handler to null causes all + * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be + * enqueued until another handler is set. + * + * @param openURIHandler handler + */ + default void setOpenURIHandler(final OpenURIHandler openURIHandler) { + } + + /** + * Installs the handler which determines if the application should quit. + * + * @param quitHandler the handler that is called when the application is + * asked to quit + * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler) + */ + default void setQuitHandler(final QuitHandler quitHandler) { + } + + /** + * Sets the default strategy used to quit this application. The default is + * calling SYSTEM_EXIT_0. + * + * @param strategy the way this application should be shutdown + */ + default void setQuitStrategy(final QuitStrategy strategy) { + } + + /** + * Enables this application to be suddenly terminated. + * + * @see java.awt.Desktop#disableSuddenTermination() + */ + default void enableSuddenTermination() { + } + + /** + * Prevents this application from being suddenly terminated. + * + * @see java.awt.Desktop#enableSuddenTermination() + */ + default void disableSuddenTermination() { + } + + /** + * Requests this application to move to the foreground. + * + * @param allWindows if all windows of this application should be moved to + * the foreground, or only the foremost one + */ + default void requestForeground(final boolean allWindows) { + } + + /** + * Opens the native help viewer application. + */ + default void openHelpViewer() { + } + + /** + * Sets the default menu bar to use when there are no active frames. + * + * @param menuBar to use when no other frames are active + */ + default void setDefaultMenuBar(final JMenuBar menuBar) { + } + + /** + * Opens a folder containing the {@code file} in a default system file manager. + * @param file the file + * @return returns true if successfully opened + */ + default boolean browseFileDirectory(File file) { + return false; + } + /** + * Moves the specified file to the trash. + * + * @param file the file + * @return returns true if successfully moved the file to the trash. + */ + default boolean moveToTrash(File file) { + return false; + } + } --- old/src/java.desktop/share/classes/sun/awt/ComponentFactory.java 2016-01-22 10:07:09.237739900 +0300 +++ new/src/java.desktop/share/classes/sun/awt/ComponentFactory.java 2016-01-22 10:07:09.167578500 +0300 @@ -25,6 +25,7 @@ package sun.awt; +import java.awt.peer.TaskbarPeer; import java.awt.*; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.InvalidDnDOperationException; @@ -73,6 +74,23 @@ default DesktopPeer createDesktopPeer(Desktop target) { throw new HeadlessException(); } + + /** + * Creates this toolkit's implementation of the {@code Taskbar} using the + * specified peer interface. + * + * @param target the taskbar to be implemented + * @return this toolkit's implementation of the {@code Taskbar} + * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns + * true + * @see java.awt.GraphicsEnvironment#isHeadless + * @see java.awt.Taskbar + * @see java.awt.peer.TaskbarPeer + * @since 1.9 + */ + default TaskbarPeer createTaskbarPeer(Taskbar target) { + throw new HeadlessException(); + } /** * Creates this toolkit's implementation of {@code Button} using the --- old/src/java.desktop/share/classes/sun/awt/HToolkit.java 2016-01-22 10:07:09.442973400 +0300 +++ new/src/java.desktop/share/classes/sun/awt/HToolkit.java 2016-01-22 10:07:09.371473600 +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 2016-01-22 10:07:09.647222200 +0300 +++ new/src/java.desktop/share/classes/sun/awt/SunToolkit.java 2016-01-22 10:07:09.576133200 +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 2016-01-22 10:07:09.866435900 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java 2016-01-22 10:07:09.792068600 +0300 @@ -24,6 +24,7 @@ */ package sun.awt.X11; +import java.awt.peer.TaskbarPeer; import java.awt.*; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; @@ -2552,6 +2553,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 2016-01-22 10:07:10.090036800 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c 2016-01-22 10:07:10.017326800 +0300 @@ -829,6 +829,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 2016-01-22 10:07:10.308466900 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h 2016-01-22 10:07:10.238191900 +0300 @@ -282,6 +282,15 @@ GSList *next; }; +typedef struct _GList GList; + +struct _GList +{ + gpointer data; + GList *next; + GList *prev; +}; + typedef void GdkColormap; typedef void GdkDrawable; typedef void GdkGC; @@ -832,6 +841,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 2016-01-22 10:07:10.515406200 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java 2016-01-22 10:07:10.445213100 +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,34 @@ private static String ACTION_OPEN_VERB = "open"; private static String ACTION_EDIT_VERB = "edit"; private static String ACTION_PRINT_VERB = "print"; - + + private static boolean isEventUserSessionSupported = false; + + private static native void init(); + + WDesktopPeer() { + init(); + isEventUserSessionSupported = OSInfo.getWindowsVersion() + .compareTo(OSInfo.WINDOWS_VISTA) >= 0; + } + @Override public boolean isSupported(Action action) { - // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows. - return true; + switch(action) { + case OPEN: + case EDIT: + case PRINT: + case MAIL: + case BROWSE: + case MOVE_TO_TRASH: + case APP_SUDDEN_TERMINATION: + case APP_EVENT_SYSTEM_SLEEP: + return true; + case APP_EVENT_USER_SESSION: + return isEventUserSessionSupported; + default: + return false; + } } @Override @@ -93,5 +123,71 @@ } private static native String ShellExecute(String fileOrUri, String verb); + + private static final EventListenerList listenerList = new EventListenerList(); + @Override + public void disableSuddenTermination() { + setSuddenTerminationEnabled(false); + } + + @Override + public void enableSuddenTermination() { + setSuddenTerminationEnabled(true); + } + + private static native void setSuddenTerminationEnabled(boolean enable); + + @Override + public void addAppEventListener(final SystemEventListener listener) { + if (listener instanceof UserSessionListener) { + listenerList.add(UserSessionListener.class, (UserSessionListener) listener); + } + if (listener instanceof SystemSleepListener) { + listenerList.add(SystemSleepListener.class, (SystemSleepListener) listener); + } + } + + @Override + public void removeAppEventListener(final SystemEventListener listener) { + if (listener instanceof UserSessionListener) { + listenerList.remove(UserSessionListener.class, (UserSessionListener) listener); + } + if (listener instanceof SystemSleepListener) { + listenerList.remove(SystemSleepListener.class, (SystemSleepListener) listener); + } + } + + private static void userSessionCallback(boolean activated, int reason) { + UserSessionListener[] listeners = listenerList.getListeners(UserSessionListener.class); + for (UserSessionListener use : listeners) { + EventQueue.invokeLater(() -> { + if (activated) { + use.userSessionActivated(new AppEvent.UserSessionEvent(reason)); + } else { + use.userSessionDeactivated(new AppEvent.UserSessionEvent(reason)); + } + }); + } + } + + private static void systemSleepCallback(boolean resumed) { + SystemSleepListener[] listeners = listenerList.getListeners(SystemSleepListener.class); + for (SystemSleepListener ssl : listeners) { + EventQueue.invokeLater(() -> { + if (resumed) { + ssl.systemAwoke(new AppEvent.SystemSleepEvent()); + } else { + ssl.systemAboutToSleep(new AppEvent.SystemSleepEvent()); + } + }); + } + } + + @Override + public boolean moveToTrash(File file) { + return moveToTrash(file.getAbsolutePath()); + } + private static native boolean moveToTrash(String file); + } --- old/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java 2016-01-22 10:07:10.720671500 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java 2016-01-22 10:07:10.649641700 +0300 @@ -25,6 +25,7 @@ package sun.awt.windows; +import java.awt.peer.TaskbarPeer; import java.awt.*; import java.awt.im.InputMethodHighlight; import java.awt.im.spi.InputMethodDescriptor; @@ -1110,16 +1111,27 @@ @Override public native boolean syncNativeQueue(final long timeout); + @Override public boolean isDesktopSupported() { return true; } - + @Override public DesktopPeer createDesktopPeer(Desktop target) { return new WDesktopPeer(); } + @Override + public boolean isTaskbarSupported() { + return WTaskbarPeer.isTaskbarSupported(); + } + + @Override + public TaskbarPeer createTaskbarPeer(Taskbar target) { + return new WTaskbarPeer(); + } + private static native void setExtraMouseButtonsEnabledNative(boolean enable); @Override --- old/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2016-01-22 10:07:10.942623600 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2016-01-22 10:07:10.861497900 +0300 @@ -28,6 +28,18 @@ #include #include #include +#include +#include "awt_Toolkit.h" + +#define BUFFER_LIMIT MAX_PATH+1 + +#define NOTIFY_FOR_ALL_SESSIONS 1 +#define NOTIFY_FOR_THIS_SESSION 0 + +typedef BOOL (WINAPI *WTSRegisterSessionNotification)(HWND,DWORD); +static WTSRegisterSessionNotification fn_WTSRegisterSessionNotification; + +BOOL isSuddenTerminationEnabled = TRUE; #ifdef __cplusplus extern "C" { @@ -35,6 +47,29 @@ /* * 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); + } + } + } + ::CoInitialize(NULL); +} + +/* + * Class: sun_awt_windows_WDesktopPeer * Method: ShellExecute * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; */ @@ -82,6 +117,53 @@ return NULL; } +/* + * Class: sun_awt_windows_WDesktopPeer + * Method: moveToTrash + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WDesktopPeer_moveToTrash + (JNIEnv *env, jclass, jstring jpath) +{ + LPCTSTR pathStr = JNU_GetStringPlatformChars(env, jpath, (jboolean *)NULL); + if (pathStr) { + try { + LPTSTR fileBuffer = new TCHAR[BUFFER_LIMIT]; + memset(fileBuffer, 0, BUFFER_LIMIT * sizeof(TCHAR)); + // the fileBuffer is double null terminated string + _tcsncpy(fileBuffer, pathStr, BUFFER_LIMIT - 2); + + SHFILEOPSTRUCT fop; + memset(&fop, 0, sizeof(SHFILEOPSTRUCT)); + fop.hwnd = NULL; + fop.wFunc = FO_DELETE; + fop.pFrom = fileBuffer; + fop.fFlags = FOF_ALLOWUNDO; + + int res = SHFileOperation(&fop); + + delete[] fileBuffer; + JNU_ReleaseStringPlatformChars(env, jpath, pathStr); + + return !res ? JNI_TRUE : JNI_FALSE; + } catch (std::bad_alloc&) { + JNU_ReleaseStringPlatformChars(env, jpath, pathStr); + } + } + return JNI_FALSE; +} + +/* + * Class: sun_awt_windows_WDesktopPeer + * Method: setSuddenTerminationEnabled + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_setSuddenTerminationEnabled + (JNIEnv *, jclass, jboolean enabled) +{ + isSuddenTerminationEnabled = enabled; +} + #ifdef __cplusplus } #endif --- old/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp 2016-01-22 10:07:11.144539100 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp 2016-01-22 10:07:11.073265300 +0300 @@ -62,6 +62,7 @@ #include #include +#include extern void initScreens(JNIEnv *env); extern "C" void awt_dnd_initialize(); @@ -80,6 +81,8 @@ extern jfieldID jawtSDataID; extern jfieldID jawtSMgrID; +extern BOOL isSuddenTerminationEnabled; + extern void DWMResetCompositionEnabled(); /************************************************************************ @@ -269,6 +272,9 @@ /* ids for WToolkit fields accessed from native code */ jmethodID AwtToolkit::windowsSettingChangeMID; jmethodID AwtToolkit::displayChangeMID; + +jmethodID AwtToolkit::userSessionMID; +jmethodID AwtToolkit::systemSleepMID; /* ids for Toolkit methods */ jmethodID AwtToolkit::getDefaultToolkitMID; jmethodID AwtToolkit::getFontMetricsMID; @@ -1046,6 +1052,9 @@ /* Session management */ case WM_QUERYENDSESSION: { /* Shut down cleanly */ + if (!isSuddenTerminationEnabled) { + return FALSE; + } if (JVM_RaiseSignal(SIGTERM)) { AwtToolkit::GetInstance().m_vmSignalled = TRUE; } @@ -1075,6 +1084,68 @@ DASSERT(FALSE); break; } +#ifndef WM_WTSSESSION_CHANGE +#define WM_WTSSESSION_CHANGE 0x02B1 +#define WTS_CONSOLE_CONNECT 0x1 +#define WTS_CONSOLE_DISCONNECT 0x2 +#define WTS_REMOTE_CONNECT 0x3 +#define WTS_REMOTE_DISCONNECT 0x4 +#define WTS_SESSION_LOGON 0x5 +#define WTS_SESSION_LOGOFF 0x6 +#define WTS_SESSION_LOCK 0x7 +#define WTS_SESSION_UNLOCK 0x8 +#define WTS_SESSION_REMOTE_CONTROL 0x9 +#endif // WM_WTSSESSION_CHANGE + case WM_WTSSESSION_CHANGE: { + jclass clzz = env->FindClass("sun/awt/windows/WDesktopPeer"); + DASSERT(clzz != NULL); + if (!clzz) throw std::bad_alloc(); + + if (wParam == WTS_CONSOLE_CONNECT + || wParam == WTS_CONSOLE_DISCONNECT + || wParam == WTS_REMOTE_CONNECT + || wParam == WTS_REMOTE_DISCONNECT + || wParam == WTS_SESSION_UNLOCK + || wParam == WTS_SESSION_LOCK) { + + BOOL activate = wParam == WTS_CONSOLE_CONNECT + || wParam == WTS_REMOTE_CONNECT + || wParam == WTS_SESSION_UNLOCK; + int reason = java_awt_AppEvent_UserSessionEvent_REASON_UNSPECIFIED; + switch (wParam) { + case WTS_CONSOLE_CONNECT: + case WTS_CONSOLE_DISCONNECT: + reason = java_awt_AppEvent_UserSessionEvent_REASON_CONSOLE; + break; + case WTS_REMOTE_CONNECT: + case WTS_REMOTE_DISCONNECT: + reason = java_awt_AppEvent_UserSessionEvent_REASON_REMOTE; + break; + case WTS_SESSION_UNLOCK: + case WTS_SESSION_LOCK: + reason = java_awt_AppEvent_UserSessionEvent_REASON_LOCK; + } + + env->CallStaticVoidMethod(clzz, AwtToolkit::userSessionMID, + activate + ? JNI_TRUE + : JNI_FALSE, reason); + } + break; + } + case WM_POWERBROADCAST: { + jclass clzz = env->FindClass("sun/awt/windows/WDesktopPeer"); + DASSERT(clzz != NULL); + if (!clzz) throw std::bad_alloc(); + + if (wParam == PBT_APMSUSPEND || wParam == PBT_APMRESUMEAUTOMATIC) { + env->CallStaticVoidMethod(clzz, AwtToolkit::systemSleepMID, + wParam == PBT_APMRESUMEAUTOMATIC + ? JNI_TRUE + : JNI_FALSE); + } + break; + } case WM_SYNC_WAIT: SetEvent(AwtToolkit::GetInstance().m_waitEvent); break; @@ -2133,6 +2204,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", "(ZI)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 2016-01-22 10:07:11.390878900 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h 2016-01-22 10:07:11.309659000 +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 2016-01-22 10:07:11.600389000 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Window.h 2016-01-22 10:07:11.526928600 +0300 @@ -397,4 +397,6 @@ inline bool IsAlwaysOnTop() { return m_alwaysOnTop; } }; +HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h); + #endif /* AWT_WINDOW_H */ --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java 2016-01-22 10:07:11.734970300 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/macosx/classes/com/apple/eawt/event/FullScreenEvent.java 2016-01-22 10:07:11.963403000 +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 com.apple.eawt.event; + +import com.apple.eawt.Application; +import java.awt.Window; +import java.util.EventObject; + +@SuppressWarnings("serial") // JDK implementation class +public class FullScreenEvent extends EventObject { + + final Window window; + + /** + * @param window window + */ + public FullScreenEvent(final Window window) { + super(Application.getApplication()); + this.window = window; + } + + /** + * @return window transitioning between full screen states + */ + public Window getWindow() { + return window; + } +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTaskbarPeer.java 2016-01-22 10:07:12.187852200 +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.peer.TaskbarPeer; + +final public class CTaskbarPeer implements TaskbarPeer { + + CTaskbarPeer() {} + + @Override + public boolean isSupported(Feature feature) { + switch(feature) { + case ICON_BADGE_TEXT: + case ICON_BADGE_NUMBER: + case ICON_IMAGE: + case MENU: + case PROGRESS_VALUE: + case USER_ATTENTION: + return true; + default: + return false; + } + } + + @Override + public void setProgressValue(int value) { + Application.getApplication().setDockIconProgress(value); + } + + @Override + public void setIconBadge(String badge) { + Application.getApplication().setDockIconBadge(badge); + } + + @Override + public Image getIconImage() { + return Application.getApplication().getDockIconImage(); + } + + @Override + public void setIconImage(Image image) { + Application.getApplication().setDockIconImage(image); + } + + @Override + public PopupMenu getMenu() { + return Application.getApplication().getDockMenu(); + } + + @Override + public void setMenu(PopupMenu menu) { + Application.getApplication().setDockMenu(menu); + } + + @Override + public void requestUserAttention(boolean enabled, boolean critical) { + if (enabled) { + Application.getApplication().requestUserAttention(critical); + } + } +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/AppEvent.java 2016-01-22 10:07:12.405445200 +0300 @@ -0,0 +1,328 @@ +/* + * 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.lang.annotation.Native; +import java.net.URI; +import java.util.EventObject; +import java.util.List; + +/** + * AppEvents are sent to listeners and handlers installed on the {@link Desktop}. + * + * @since 1.9 + */ + +public class AppEvent extends EventObject { + private static final long serialVersionUID = -5958503993556009432L; + + AppEvent() { + super(Desktop.getDesktop()); + } + + /** + * Contains a list of files. + */ + public static class FilesEvent extends AppEvent { + private static final long serialVersionUID = 5271763715462312871L; + + final List files; + + /** + * Constructs a FilesEvent + * @param files files + * @param searchTerm searchTerm + */ + FilesEvent(final List files) { + this.files = files; + } + + /** + * Gets the list of 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 + */ + public static class OpenFilesEvent extends FilesEvent { + private static final long serialVersionUID = -3982871005867718956L; + + final String searchTerm; + + /** + * Constructs an OpenFilesEvent + * @param files files + * @param searchTerm searchTerm + */ + public OpenFilesEvent(final List files, final String searchTerm) { + super(files); + this.searchTerm = searchTerm; + } + + /** + * Gets the search term. The platform may additionally provide the search + * term that was used to find the files. This is for example the case + * on Mac OS X, when the files were opened using the Spotlight search + * menu or a Finder search window. + * + * This is useful for highlighting the search term in the documents when + * they are opened. + * @return the search term used to find the files + */ + public String getSearchTerm() { + return searchTerm; + } + } + + /** + * Event sent when the app is asked to print a list of files. + * + * @see PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent) + */ + public static class PrintFilesEvent extends FilesEvent { + private static final long serialVersionUID = -5752560876153618618L; + + /** + * Constructs a PrintFilesEvent + * @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) + */ + public static class OpenURIEvent extends AppEvent { + private static final long serialVersionUID = 221209100935933476L; + + final URI uri; + + /** + * Constructs an OpenURIEvent + * @param uri URI + */ + public OpenURIEvent(final URI uri) { + this.uri = uri; + } + + /** + * Get the URI the app was asked to open + * @return the URI + */ + public URI getURI() { + return uri; + } + } + + /** + * Event sent when the application is asked to open its about window. + * + * @see AboutHandler#handleAbout + */ + public static class AboutEvent extends AppEvent { + private static final long serialVersionUID = -5987180734802756477L; + + /** + * Constructs an AboutEvent + */ + public AboutEvent() {} + } + + /** + * Event sent when the application is asked to open its preferences window. + * + * @see PreferencesHandler#handlePreferences + */ + public static class PreferencesEvent extends AppEvent { + private static final long serialVersionUID = -6398607097086476160L; + /** + * Constructs a PreferencesEvent + */ + public PreferencesEvent() {} + } + + /** + * Event sent when the application is asked to quit. + * + * @see QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, QuitResponse) + */ + public static class QuitEvent extends AppEvent { + private static final long serialVersionUID = -256100795532403146L; + + /** + * Constructs a QuitEvent + */ + public QuitEvent() {} + } + + /** + * Event sent when the application is asked to re-open itself. + * + * @see AppReopenedListener#appReopened(AppEvent.AppReopenedEvent) + */ + public static class AppReopenedEvent extends AppEvent { + private static final long serialVersionUID = 1503238361530407990L; + + /** + * Constructs an AppReopenedEvent + */ + 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) + */ + public static class AppForegroundEvent extends AppEvent { + private static final long serialVersionUID = -5513582555740533911L; + + /** + * Constructs an AppForegroundEvent + */ + public AppForegroundEvent() { } + } + + /** + * Event sent when the application has been hidden or shown. + * + * @see AppHiddenListener#appHidden(AppEvent.AppHiddenEvent) + * @see AppHiddenListener#appUnhidden(AppEvent.AppHiddenEvent) + */ + public static class AppHiddenEvent extends AppEvent { + private static final long serialVersionUID = 2637465279476429224L; + + /** + * Constructs an AppHiddenEvent + */ + public AppHiddenEvent() { } + } + + /** + * Event sent when the user session has been changed. + * + * Some systems may provide a reason of a user session change. + * + * @see UserSessionListener#userSessionActivated(AppEvent.UserSessionEvent) + * @see UserSessionListener#userSessionDeactivated(AppEvent.UserSessionEvent) + */ + public static class UserSessionEvent extends AppEvent { + private static final long serialVersionUID = 6747138462796569055L; + + private final int reason; + + /** + * The system does not provide a reason for a session change. + */ + @Native + public static final int REASON_UNSPECIFIED = 0x0; + + /** + * The session was connected/disconnected to the console terminal. + */ + @Native + public static final int REASON_CONSOLE = 0x1; + + /** + * The session was connected/disconnected to the remote terminal. + */ + @Native + public static final int REASON_REMOTE = 0x2; + + /** + * The session has been locked/unlocked. + */ + @Native + public static final int REASON_LOCK = 0x3; + + /** + * Constructs a UserSessionEvent + * + * @param reason of session change + */ + public UserSessionEvent(int reason) { + this.reason = reason; + } + + /** + * Gets a reason of the user session change. + * + * @return reason a reason + * @see #REASON_UNSPECIFIED + * @see #REASON_CONSOLE + * @see #REASON_REMOTE + * @see #REASON_LOCK + */ + public int getReason() { + return reason; + } + } + + /** + * 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) + */ + public static class ScreenSleepEvent extends AppEvent { + private static final long serialVersionUID = 7521606180376544150L; + + /** + * Constructs a ScreenSleepEvent + */ + public ScreenSleepEvent() { } + } + + /** + * Event sent when the system enters and exits power save sleep. + * + * @see SystemSleepListener#systemAboutToSleep(AppEvent.SystemSleepEvent) + * @see SystemSleepListener#systemAwoke(AppEvent.SystemSleepEvent) + */ + public static class SystemSleepEvent extends AppEvent { + private static final long serialVersionUID = 11372269824930549L; + + /** + * Constructs a SystemSleepEvent + */ + public SystemSleepEvent() { } + } + +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/Taskbar.java 2016-01-22 10:07:12.625797100 +0300 @@ -0,0 +1,442 @@ +/* + * 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.peer.TaskbarPeer; +import sun.awt.SunToolkit; +import java.lang.annotation.Native; + +/** + * The {@code Taskbar} class allows a Java application to interact with + * the system task area (taskbar, Dock, etc.). + * + *

    + * There are a variety of interactions depending on the current platform such as + * displaying progress of some task, appending user-specified menu to the application + * icon context menu, etc. + * + * @implNote Linux support is currently limited to Unity. However to make these + * features work on Unity, the app should be run from a .desktop file with + * specified {@code java.desktop.appName} system property set to this .desktop + * file name: + * {@code Exec=java -Djava.desktop.appName=MyApp.desktop -jar /path/to/myapp.jar} + * see + * https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles + * + * @since 1.9 + */ + +public class Taskbar { + + /** + * List of provided features. + */ + public static enum Feature { + + /** + * @see #setIconBadge(java.lang.String) + */ + ICON_BADGE_TEXT, + + /** + * @see #setIconBadge(java.lang.String) + */ + ICON_BADGE_NUMBER, + + /** + * @see #setWindowIconBadge(java.awt.Window, java.awt.Image) + */ + ICON_BADGE_IMAGE_WINDOW, + + /** + * @see #setIconImage(java.awt.Image) + */ + ICON_IMAGE, + + /** + * @see #setMenu(java.awt.PopupMenu) + * @see #getMenu() + */ + MENU, + + /** + * @see #setWindowProgressState(java.awt.Window, int) + */ + PROGRESS_STATE_WINDOW, + + /** + * @see #setProgressValue(int) + */ + PROGRESS_VALUE, + + /** + * @see #setWindowProgressValue(java.awt.Window, int) + */ + PROGRESS_VALUE_WINDOW, + + /** + * @see #requestUserAttention(boolean, boolean) + */ + USER_ATTENTION, + + /** + * @see #requestWindowUserAttention(java.awt.Window) + */ + USER_ATTENTION_WINDOW + } + + /** + * Stops displaying the progress. + */ + @Native + public static final int STATE_OFF = 0x0; + + /** + * The progress indicator displays with normal color and determinate mode. + */ + @Native + public static final int STATE_NORMAL = 0x1; + + /** + * Shows progress as paused, progress can be resumed by the user. + * Switches to the determinate display. + */ + @Native + public static final int STATE_PAUSED = 0x2; + + /** + * The progress indicator displays activity without specifying what + * proportion of the progress is complete. + */ + @Native + public static final int STATE_INDETERMINATE = 0x3; + + /** + * Shows that an error has occurred. + * Switches to the determinate display. + */ + @Native + public static final int STATE_ERROR = 0x4; + + private TaskbarPeer peer; + + /** + * Tests whether a {@code Feature} is supported on the current platform. + * @param feature the specified {@link Feature} + * @return true if the specified feature is supported on the current platform + */ + public boolean isSupported(Feature feature) { + return peer.isSupported(feature); + } + + /** + * Checks if the feature type is supported. + * + * @param featureType the action type in question + * @throws UnsupportedOperationException if the specified action type is not + * supported on the current platform + */ + private void checkFeatureSupport(Feature featureType){ + if (!isSupported(featureType)) { + throw new UnsupportedOperationException("The " + featureType.name() + + " feature is not supported on the current platform!"); + } + } + + /** + * Calls to the security manager's checkPermission method with + * an AWTPermission("showWindowWithoutWarningBanner") + * permission. + */ + private void checkAWTPermission(){ + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new AWTPermission( + "showWindowWithoutWarningBanner")); + } + } + + private Taskbar() { + Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); + if (defaultToolkit instanceof SunToolkit) { + peer = ((SunToolkit) defaultToolkit).createTaskbarPeer(this); + } + } + + /** + * Returns the Taskbar instance of the current + * taskbar context. On some platforms the Taskbar API may not be + * supported; use the {@link #isTaskbarSupported} method to + * determine if the current taskbar is supported. + * @return the Taskbar instance + * @throws HeadlessException if {@link + * GraphicsEnvironment#isHeadless()} returns {@code true} + * @throws UnsupportedOperationException if this class is not + * supported on the current platform + * @see #isTaskbarSupported() + * @see java.awt.GraphicsEnvironment#isHeadless + */ + public static synchronized Taskbar getTaskbar(){ + if (GraphicsEnvironment.isHeadless()) throw new HeadlessException(); + + if (!Taskbar.isTaskbarSupported()) { + throw new UnsupportedOperationException("Taskbar API is not " + + "supported on the current platform"); + } + + sun.awt.AppContext context = sun.awt.AppContext.getAppContext(); + Taskbar taskbar = (Taskbar)context.get(Taskbar.class); + + if (taskbar == null) { + taskbar = new Taskbar(); + context.put(Taskbar.class, taskbar); + } + + return taskbar; + } + + /** + * Tests whether this class is supported on the current platform. + * If it's supported, use {@link #getTaskbar()} to retrieve an + * instance. + * + * @return true if this class is supported on the + * current platform; false otherwise + * @see #getTaskbar() + */ + public static boolean isTaskbarSupported(){ + Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); + if (defaultToolkit instanceof SunToolkit) { + return ((SunToolkit)defaultToolkit).isTaskbarSupported(); + } + return false; + } + + /** + * Requests user attention to this application. + * + * Depending on the platform, this may be visually indicated by a bouncing + * or flashing icon in the task area. It may have no effect on an already active + * application. + * + * On some platforms (e.g. Mac OS) this effect may disappear upon app activation + * and cannot be dismissed by setting {@code enabled} to false. + * Other platforms may require an additional call + * {@link #requestUserAttention} to dismiss this request + * with {@code enabled} parameter set to false. + * + * @param enabled disables this request if false + * @param critical if this is an important request + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#USER_ATTENTION} feature + */ + public void requestUserAttention(final boolean enabled, final boolean critical) { + checkAWTPermission(); + checkFeatureSupport(Feature.USER_ATTENTION); + peer.requestUserAttention(enabled, critical); + } + + /** + * Requests user attention to the specified window until it is activated. + * + * On an already active window requesting attention does nothing. + * + * @param w window + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#USER_ATTENTION_WINDOW} feature + */ + public void requestWindowUserAttention(Window w) { + checkAWTPermission(); + checkFeatureSupport(Feature.USER_ATTENTION_WINDOW); + peer.requestWindowUserAttention(w); + } + + /** + * Attaches the contents of the provided PopupMenu to the application icon + * in the task area. + * + * @param menu the PopupMenu to attach to this application + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#MENU} feature + */ + public void setMenu(final PopupMenu menu) { + checkAWTPermission(); + checkFeatureSupport(Feature.MENU); + peer.setMenu(menu); + } + + /** + * Gets PopupMenu used to add items to this application's icon in system task area. + * + * @return the PopupMenu + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#MENU} feature + */ + public PopupMenu getMenu() { + checkAWTPermission(); + checkFeatureSupport(Feature.MENU); + return peer.getMenu(); + } + + /** + * Changes this application's icon to the provided image. + * + * @param image to change + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature + */ + public void setIconImage(final Image image) { + checkAWTPermission(); + checkFeatureSupport(Feature.ICON_IMAGE); + peer.setIconImage(image); + } + + /** + * Obtains an image of this application's icon. + * + * @return an image of this application's icon + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature + */ + public Image getIconImage() { + checkAWTPermission(); + checkFeatureSupport(Feature.ICON_IMAGE); + return peer.getIconImage(); + } + + /** + * Affixes a small system-provided badge to this application's icon. + * Usually a number. + * + * Some platforms do not support string values and accept only integer + * values. In this case, pass an integer represented as a string as parameter. + * This can be tested by {@code Feature.ICON_BADGE_STRING} and + * {@code Feature.ICON_BADGE_NUMBER}. + * + * Passing {@code null} as parameter hides the badge. + * @param badge label to affix to the icon + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER} feature + */ + public void setIconBadge(final String badge) { + checkAWTPermission(); + checkFeatureSupport(Feature.ICON_BADGE_NUMBER); + peer.setIconBadge(badge); + } + + /** + * Affixes a small badge to this application's icon in the task area + * for the specified window. + * It may be disabled by system settings. + * + * @param w window to update + * @param badge image to affix to the icon + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#ICON_BADGE_IMAGE_WINDOW} feature + */ + public void setWindowIconBadge(Window w, final Image badge) { + checkAWTPermission(); + checkFeatureSupport(Feature.ICON_BADGE_IMAGE_WINDOW); + if (w != null) { + peer.setWindowIconBadge(w, badge); + } + } + + + /** + * Affixes a small system-provided progress bar to this application's icon. + * + * @param value from 0 to 100, other to disable progress indication + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#PROGRESS_VALUE} feature + */ + public void setProgressValue(int value) { + checkAWTPermission(); + checkFeatureSupport(Feature.PROGRESS_VALUE); + peer.setProgressValue(value); + } + + /** + * Displays progress for specified window. + * + * @param w window to update + * @param value from 0 to 100, other to disable progress indication + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#PROGRESS_VALUE_WINDOW} feature + */ + public void setWindowProgressValue(Window w, int value) { + checkAWTPermission(); + checkFeatureSupport(Feature.PROGRESS_VALUE_WINDOW); + if (w != null) { + peer.setWindowProgressValue(w, value); + } + } + + /** + * Sets a progress state for a specified window. + * + * @param w window + * @param state to change to + * @see #STATE_OFF + * @see #STATE_NORMAL + * @see #STATE_PAUSED + * @see #STATE_INDETERMINATE + * @see #STATE_ERROR + * @throws SecurityException if a security manager exists and it denies the + * AWTPermission("showWindowWithoutWarningBanner") permission. + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Taskbar.Feature#PROGRESS_STATE_WINDOW} feature + * @throws IllegalArgumentException if {@code state} is invalid + */ + public void setWindowProgressState(Window w, int state) { + checkAWTPermission(); + checkFeatureSupport(Feature.PROGRESS_STATE_WINDOW); + if (state < STATE_OFF && state > STATE_ERROR) { + throw new IllegalArgumentException("Invalid state value"); + } + if (w != null) { + peer.setWindowProgressState(w, state); + } + } +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AboutHandler.java 2016-01-22 10:07:12.843843400 +0300 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +import java.awt.AppEvent.AboutEvent; + +/** + * An implementer receives notification when the app is asked to show its about dialog. + * + * @see java.awt.Desktop#setAboutHandler(java.awt.desktop.AboutHandler) + */ +public interface AboutHandler { + /** + * Called when the application is asked to show its about dialog. + * @param e the request to show the about dialog. + */ + public void handleAbout(final AboutEvent e); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AppForegroundListener.java 2016-01-22 10:07:13.068830700 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AppHiddenListener.java 2016-01-22 10:07:13.288452900 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/AppReopenedListener.java 2016-01-22 10:07:13.507246400 +0300 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +import java.awt.AppEvent.AppReopenedEvent; + +/** + * Implementors receive notification when the app has been asked to open again. + * + * This notification is useful for showing a new document when your app has no open windows. + */ +public interface AppReopenedListener extends SystemEventListener { + /** + * Called when the app has been reopened + * @param e the request to reopen the app + */ + public void appReopened(final AppReopenedEvent e); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/OpenFilesHandler.java 2016-01-22 10:07:13.732940400 +0300 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +import java.awt.AppEvent.OpenFilesEvent; + +/** + * An implementor is notified when the application is asked to open a list of files. + * + * @see java.awt.Desktop#setOpenFileHandler(java.awt.desktop.OpenFilesHandler) + */ +public interface OpenFilesHandler { + /** + * Called when the application is asked to open a list of files. + * @param e the request to open a list of files, and the search term used to find them, if any. + */ + public void openFiles(final OpenFilesEvent e); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/OpenURIHandler.java 2016-01-22 10:07:13.951738400 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/PreferencesHandler.java 2016-01-22 10:07:14.179138400 +0300 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +import java.awt.AppEvent.PreferencesEvent; + +/** + * An implementor is notified when the app is asked to show its preferences UI. + * + * @see java.awt.Desktop#setPreferencesHandler(java.awt.desktop.PreferencesHandler) + */ +public interface PreferencesHandler { + /** + * Called when the app is asked to show its preferences UI. + * @param e the request to show preferences. + */ + public void handlePreferences(final PreferencesEvent e); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/PrintFilesHandler.java 2016-01-22 10:07:14.396776000 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/QuitHandler.java 2016-01-22 10:07:14.623799600 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/QuitResponse.java 2016-01-22 10:07:14.848570700 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/QuitStrategy.java 2016-01-22 10:07:15.090342100 +0300 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +/** + * The strategy used to shut down the application, if Sudden Termination is not enabled. + * + * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler) + * @see java.awt.Desktop#setQuitStrategy(java.awt.desktop.QuitStrategy) + * @see java.awt.Desktop#enableSuddenTermination() + * @see java.awt.Desktop#disableSuddenTermination() + * + */ +public enum QuitStrategy { + /** + * Shuts down the application by calling System.exit(0). This is the default strategy. + */ + SYSTEM_EXIT_0, + + /** + * Shuts down the application by closing each window from back-to-front. + */ + CLOSE_ALL_WINDOWS +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepListener.java 2016-01-22 10:07:15.308190000 +0300 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +import java.awt.AppEvent.ScreenSleepEvent; + +/** + * Implementors receive notification when the displays attached to the system have entered power save sleep. + * + * This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service. + * + */ +public interface ScreenSleepListener extends SystemEventListener { + + /** + * Called when the system displays have entered power save sleep. + * @param e the screen sleep event + */ + public void screenAboutToSleep(final ScreenSleepEvent e); + + /** + * Called when the system displays have awoken from power save sleep. + * @param e the screen sleep event + */ + public void screenAwoke(final ScreenSleepEvent e); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/SystemEventListener.java 2016-01-22 10:07:15.529959400 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/SystemSleepListener.java 2016-01-22 10:07:15.747720600 +0300 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.desktop; + +import java.awt.AppEvent.SystemSleepEvent; + +/** + * Implementors receive notification as the system is entering sleep, and after the system wakes. + * + * This notification is useful for disconnecting from network services prior to sleep, or re-establishing a connection if the network configuration has changed during sleep. + */ +public interface SystemSleepListener extends SystemEventListener { + /** + * Called when the system is about to sleep. + * Note: This message may not be delivered prior to the actual system sleep, and may be processed after the corresponding wake has occurred. + * @param e the system sleep event + */ + public void systemAboutToSleep(final SystemSleepEvent e); + + /** + * Called after the system has awoken from sleeping. + * @param e the system sleep event + */ + public void systemAwoke(final SystemSleepEvent e); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/desktop/UserSessionListener.java 2016-01-22 10:07:15.973590400 +0300 @@ -0,0 +1,56 @@ +/* + * 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 the user session changes. + * + * This notification is useful for discontinuing a costly animation, + * or indicating that the user is no longer present on a network service. + * + * Some systems may provide a reason of the user session change. + * + * @see java.awt.AppEvent.UserSessionEvent#SESSION_UNSPECIFIED + * @see java.awt.AppEvent.UserSessionEvent#SESSION_CONSOLE + * @see java.awt.AppEvent.UserSessionEvent#SESSION_REMOTE + * @see java.awt.AppEvent.UserSessionEvent#SESSION_LOCK + * + */ +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java 2016-01-22 10:07:16.192157800 +0300 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.awt.peer; + +import java.awt.Image; +import java.awt.PopupMenu; +import java.awt.Taskbar; +import java.awt.Taskbar.Feature; +import java.awt.Window; + + +/** + * The {@code TaskbarPeer} interface provides methods for interacting with + * system task area. + */ +public interface TaskbarPeer { + + /** + * Requests user attention to this application. + * + * @param enabled disables this request if false + * @param critical if this is an important request + * @see Taskbar#requestUserAttention + */ + default void requestUserAttention(boolean enabled, final boolean critical) {} + + /** + * Requests user attention to the specified window until it is activated. + * + * On an already active window requesting attention does nothing. + * + * @param w window + */ + default void requestWindowUserAttention(Window w) {} + + /** + * Attaches the contents of the provided PopupMenu to the application icon + * in system task area. + * + * @param menu the PopupMenu to attach to this application + */ + default void setMenu(final PopupMenu menu) {} + + /** + * Gets PopupMenu used to add items to this application's icon in system task area. + * + * @return the PopupMenu + */ + default PopupMenu getMenu() { return null; } + + /** + * Changes this application's icon to the provided image. + * + * @param image to change + */ + default void setIconImage(final Image image) {} + + /** + * Obtains an image of this application's icon. + * + * @return an image of this application's icon + */ + default Image getIconImage() { return null; } + + /** + * Affixes a small system-provided badge to this application's icon. + * Usually a number. + * + * @param badge label to affix to the icon + */ + default void setIconBadge(final String badge) {} + + /** + * Affixes a small badge to this application's icon in task area + * for the specified window. + * + * @param w window to update + * @param badge image to affix to the icon + */ + default void setWindowIconBadge(Window w, final Image badge) {} + + /** + * Displays progress for specified window. + * + * @param w window to update + * @param value from 0 to 100, other to disable progress indication + */ + default void setWindowProgressValue(Window w, int value) {} + + /** + * Sets a progress state for a specified window. + * + * @param w window + * @param state to change to + * @see Taskbar#setWindowProgressState + */ + default void setWindowProgressState(Window w, int state) {} + + /** + * Affixes a small system-provided progress bar to this application's icon. + * + * @param value from 0 to 100, other to disable progress indication + */ + default void setProgressValue(int value) {} + + /** + * Tests support of {@code Feature} on current platform. + * @param f feature to test + * @return true if feature supported supported + */ + default public boolean isSupported(Feature f) { return false; } +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java 2016-01-22 10:07:16.422669500 +0300 @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.awt.X11; + +import java.awt.MenuItem; +import java.awt.PopupMenu; +import java.awt.Taskbar.Feature; +import java.awt.peer.TaskbarPeer; +import java.awt.event.ActionEvent; +import sun.misc.ManagedLocalsThread; +import java.security.AccessController; +import sun.security.action.GetPropertyAction; + +final class XTaskbarPeer implements TaskbarPeer { + + private static boolean nativeLibraryLoaded = false; + private static boolean initExecuted = false; + + private PopupMenu menu = null; + + private static void initWithLock() { + XToolkit.awtLock(); + try { + if (!initExecuted) { + String dname = AccessController.doPrivileged( + new GetPropertyAction("java.desktop.appName", "")); + nativeLibraryLoaded = init(dname); + if (nativeLibraryLoaded) { + ManagedLocalsThread t + = new ManagedLocalsThread(() -> { + runloop(); + }); + t.setDaemon(true); + t.start(); + } + } + } finally { + initExecuted = true; + XToolkit.awtUnlock(); + } + } + + XTaskbarPeer() { + initWithLock(); + } + + static boolean isTaskbarSupported() { + initWithLock(); + return nativeLibraryLoaded; + } + + @Override + public boolean isSupported(Feature feature) { + switch (feature) { + case ICON_BADGE_NUMBER: + case MENU: + case PROGRESS_VALUE: + case USER_ATTENTION: + return true; + default: + return false; + } + } + + @Override + public void setProgressValue(int value) { + boolean visible + = value >= 0 + && value <= 100; + + double v = visible + ? (double) value / 100 + : 0d; + + updateProgress(v, visible); + } + + @Override + public void setIconBadge(String badge) { + boolean visible = false; + long val = 0; + if (badge != null) { + try { + val = Long.parseLong(badge); + visible = true; + } catch (NumberFormatException e) { + } + } + setBadge(val, visible); + } + + @Override + public PopupMenu getMenu() { + return menu; + } + + @Override + public synchronized void setMenu(PopupMenu m) { + this.menu = m; + + if (menu != null && menu.getItemCount() > 0) { + int msize = menu.getItemCount(); + MenuItem[] items = new MenuItem[msize]; + for (int i = 0; i < msize; i++) { + items[i] = menu.getItem(i); + } + setNativeMenu(items); + } else { + setNativeMenu(null); + } + } + + @Override + public void requestUserAttention(boolean enabled, boolean critical) { + setUrgent(enabled); + } + + private static void menuItemCallback(MenuItem mi) { + if (mi != null) { + ActionEvent ae = new ActionEvent(mi, ActionEvent.ACTION_PERFORMED, + mi.getActionCommand()); + try { + XToolkit.awtLock(); + XToolkit.postEvent(XToolkit.targetToAppContext(ae.getSource()), ae); + } finally { + XToolkit.awtUnlock(); + } + } + } + + private static native boolean init(String name); + + private static native void runloop(); + + private native void setBadge(long value, boolean visible); + + private native void updateProgress(double value, boolean visible); + + private native void setUrgent(boolean urgent); + + private native void setNativeMenu(MenuItem[] items); +} --- /dev/null 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c 2016-01-22 10:07:16.644507600 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h 2016-01-22 10:07:16.863074700 +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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WTaskbarPeer.java 2016-01-22 10:07:17.090492900 +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.peer.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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp 2016-01-22 10:07:17.308680100 +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 = TBPF_NOPROGRESS; + 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 2016-01-22 09:56:14.568005295 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.h 2016-01-22 10:07:17.525499500 +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 2016-01-22 10:07:17.874970200 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.019923600 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.156684100 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.292477200 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.427712500 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.562623700 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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/OpenFilesHandler.java 2016-01-22 10:07:18.701078600 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.837655300 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:18.972962600 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.109266900 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.268088700 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.423342500 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.569165600 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.709132900 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.854302500 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:19.991644800 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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 2016-01-22 10:07:20.126606400 +0300 +++ /dev/null 2016-01-22 09:56:14.568005295 +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()); - } - } - } -}