1 /* 2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package java.awt.peer; 26 27 import java.io.File; 28 import java.io.IOException; 29 import java.net.URI; 30 import java.awt.Desktop.Action; 31 import java.awt.desktop.AboutHandler; 32 import java.awt.desktop.SystemEventListener; 33 import java.awt.desktop.OpenFilesHandler; 34 import java.awt.desktop.OpenURIHandler; 35 import java.awt.desktop.PreferencesHandler; 36 import java.awt.desktop.PrintFilesHandler; 37 import java.awt.desktop.QuitHandler; 38 import java.awt.desktop.QuitStrategy; 39 import javax.swing.JMenuBar; 40 41 /** 42 * The {@code DesktopPeer} interface provides methods for the operation 43 * of open, edit, print, browse and mail with the given URL or file, by 44 * launching the associated application. 45 * <p> 46 * Each platform has an implementation class for this interface. 47 * 48 */ 49 public interface DesktopPeer { 50 51 /** 52 * Returns whether the given action is supported on the current platform. 53 * @param action the action type to be tested if it's supported on the 54 * current platform. 55 * @return {@code true} if the given action is supported on 56 * the current platform; {@code false} otherwise. 57 */ 58 boolean isSupported(Action action); 145 /** 146 * Installs a handler to show a custom About window for your application. 147 * <p> 148 * Setting the {@link AboutHandler} to {@code null} reverts it to the 149 * default behavior. 150 * 151 * @param aboutHandler the handler to respond to the 152 * {@link AboutHandler#handleAbout} )} message 153 */ 154 default void setAboutHandler(final AboutHandler aboutHandler) { 155 } 156 157 /** 158 * Installs a handler to show a custom Preferences window for your 159 * application. 160 * <p> 161 * Setting the {@link PreferencesHandler} to {@code null} reverts it to 162 * the default behavior 163 * 164 * @param preferencesHandler the handler to respond to the 165 * {@link java.awt.desktop.PreferencesHandler#handlePreferences(java.awt.PreferencesEvent) } 166 */ 167 default void setPreferencesHandler(final PreferencesHandler preferencesHandler) { 168 } 169 170 /** 171 * Installs the handler which is notified when the application is asked to 172 * open a list of files. 173 * 174 * @param openFileHandler handler 175 * 176 */ 177 default void setOpenFileHandler(final OpenFilesHandler openFileHandler) { 178 } 179 180 /** 181 * Installs the handler which is notified when the application is asked to 182 * print a list of files. 183 * 184 * @param printFileHandler handler 185 */ 186 default void setPrintFileHandler(final PrintFilesHandler printFileHandler) { 187 } 188 189 /** 190 * Installs the handler which is notified when the application is asked to 191 * open a URL. 192 * 193 * Setting the handler to {@code null} causes all 194 * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be 195 * enqueued until another handler is set. 196 * 197 * @param openURIHandler handler 198 */ 199 default void setOpenURIHandler(final OpenURIHandler openURIHandler) { 200 } 201 202 /** 203 * Installs the handler which determines if the application should quit. 204 * 205 * @param quitHandler the handler that is called when the application is 206 * asked to quit 207 * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler) 208 */ 209 default void setQuitHandler(final QuitHandler quitHandler) { 210 } 211 212 /** 213 * Sets the default strategy used to quit this application. The default is 214 * calling SYSTEM_EXIT_0. | 1 /* 2 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package java.awt.peer; 26 27 import java.awt.Desktop.Action; 28 import java.awt.desktop.AboutHandler; 29 import java.awt.desktop.OpenFilesHandler; 30 import java.awt.desktop.OpenURIEvent; 31 import java.awt.desktop.OpenURIHandler; 32 import java.awt.desktop.PreferencesEvent; 33 import java.awt.desktop.PreferencesHandler; 34 import java.awt.desktop.PrintFilesHandler; 35 import java.awt.desktop.QuitHandler; 36 import java.awt.desktop.QuitStrategy; 37 import java.awt.desktop.SystemEventListener; 38 import java.io.File; 39 import java.io.IOException; 40 import java.net.URI; 41 42 import javax.swing.JMenuBar; 43 44 /** 45 * The {@code DesktopPeer} interface provides methods for the operation 46 * of open, edit, print, browse and mail with the given URL or file, by 47 * launching the associated application. 48 * <p> 49 * Each platform has an implementation class for this interface. 50 * 51 */ 52 public interface DesktopPeer { 53 54 /** 55 * Returns whether the given action is supported on the current platform. 56 * @param action the action type to be tested if it's supported on the 57 * current platform. 58 * @return {@code true} if the given action is supported on 59 * the current platform; {@code false} otherwise. 60 */ 61 boolean isSupported(Action action); 148 /** 149 * Installs a handler to show a custom About window for your application. 150 * <p> 151 * Setting the {@link AboutHandler} to {@code null} reverts it to the 152 * default behavior. 153 * 154 * @param aboutHandler the handler to respond to the 155 * {@link AboutHandler#handleAbout} )} message 156 */ 157 default void setAboutHandler(final AboutHandler aboutHandler) { 158 } 159 160 /** 161 * Installs a handler to show a custom Preferences window for your 162 * application. 163 * <p> 164 * Setting the {@link PreferencesHandler} to {@code null} reverts it to 165 * the default behavior 166 * 167 * @param preferencesHandler the handler to respond to the 168 * {@link java.awt.desktop.PreferencesHandler#handlePreferences(PreferencesEvent) } 169 */ 170 default void setPreferencesHandler(final PreferencesHandler preferencesHandler) { 171 } 172 173 /** 174 * Installs the handler which is notified when the application is asked to 175 * open a list of files. 176 * 177 * @param openFileHandler handler 178 * 179 */ 180 default void setOpenFileHandler(final OpenFilesHandler openFileHandler) { 181 } 182 183 /** 184 * Installs the handler which is notified when the application is asked to 185 * print a list of files. 186 * 187 * @param printFileHandler handler 188 */ 189 default void setPrintFileHandler(final PrintFilesHandler printFileHandler) { 190 } 191 192 /** 193 * Installs the handler which is notified when the application is asked to 194 * open a URL. 195 * 196 * Setting the handler to {@code null} causes all 197 * {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be 198 * enqueued until another handler is set. 199 * 200 * @param openURIHandler handler 201 */ 202 default void setOpenURIHandler(final OpenURIHandler openURIHandler) { 203 } 204 205 /** 206 * Installs the handler which determines if the application should quit. 207 * 208 * @param quitHandler the handler that is called when the application is 209 * asked to quit 210 * @see java.awt.Desktop#setQuitHandler(java.awt.desktop.QuitHandler) 211 */ 212 default void setQuitHandler(final QuitHandler quitHandler) { 213 } 214 215 /** 216 * Sets the default strategy used to quit this application. The default is 217 * calling SYSTEM_EXIT_0. |