java.awt.Desktop.Action Java Examples
The following examples show how to use
java.awt.Desktop.Action.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DesktopBrowserLauncher.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
/** * View a URI in a browser. * * @param uri URI to display in browser. * @throws IOException if browser can not be launched */ private static void viewInBrowser(URI uri) throws IOException { if (Desktop.isDesktopSupported() && DESKTOP.isSupported(Action.BROWSE)) { DESKTOP.browse(uri); } else { Dialog<ButtonType> alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.WARNING)); Logging.debugPrint("unable to browse to " + uri); alert.setTitle(LanguageBundle.getString("in_err_browser_err")); alert.setContentText(LanguageBundle.getFormattedString("in_err_browser_uri", uri)); GuiUtility.runOnJavaFXThreadNow(alert::showAndWait); } }
Example #2
Source File: Desktop.java From Repeat with Apache License 2.0 | 6 votes |
public static boolean openFile(File file) { if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop().isSupported(Action.OPEN)) { try { java.awt.Desktop.getDesktop().open(file); } catch (IOException e) { LOGGER.log(Level.WARNING, "IOException when opening file.", e); return false; } return true; } if (OSIdentifier.IS_WINDOWS) { return openFileWindows(file); } if (OSIdentifier.IS_LINUX) { return openFileLinux(file); } if (OSIdentifier.IS_OSX) { return openFileOSX(file); } return false; }
Example #3
Source File: ShowLibraryFolderCommand.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent event) { try { File dir = mLibrary.getPath().toFile(); Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Action.BROWSE_FILE_DIR)) { File[] contents = dir.listFiles(); if (contents != null && contents.length > 0) { Arrays.sort(contents); dir = contents[0]; } desktop.browseFileDirectory(dir.getCanonicalFile()); } else { desktop.open(dir); } } catch (Exception exception) { WindowUtils.showError(null, exception.getMessage()); } }
Example #4
Source File: WDesktopPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public boolean isSupported(Action action) { 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; } }
Example #5
Source File: DesktopBrowserLauncher.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
/** * View a URI in a browser. * * @param uri URI to display in browser. * @throws IOException if browser can not be launched */ private static void viewInBrowser(URI uri) throws IOException { if (Desktop.isDesktopSupported() && DESKTOP.isSupported(Action.BROWSE)) { DESKTOP.browse(uri); } else { Dialog<ButtonType> alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.WARNING)); Logging.debugPrint("unable to browse to " + uri); alert.setTitle(LanguageBundle.getString("in_err_browser_err")); alert.setContentText(LanguageBundle.getFormattedString("in_err_browser_uri", uri)); GuiUtility.runOnJavaFXThreadNow(alert::showAndWait); } }
Example #6
Source File: DesktopHandler.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * Initialize the Mac-specific properties. * Create an ApplicationAdapter to listen for Help, Prefs, and Quit. */ public static void initialize() { if (initialized) { return; } initialized = true; if (!Desktop.isDesktopSupported()) { return; } Desktop theDesktop = Desktop.getDesktop(); if (theDesktop.isSupported(Action.APP_ABOUT)) { theDesktop.setAboutHandler(new AboutHandler()); } if (theDesktop.isSupported(Action.APP_PREFERENCES)) { theDesktop.setPreferencesHandler(new PreferencesHandler()); } if (theDesktop.isSupported(Action.APP_QUIT_HANDLER)) { theDesktop.setQuitHandler(new QuitHandler()); } }
Example #7
Source File: Desktop.java From olca-app with Mozilla Public License 2.0 | 5 votes |
public static void browse(String uri) { try { if (java.awt.Desktop.isDesktopSupported()) { java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if (desktop.isSupported(Action.BROWSE)) { desktop.browse(new URI(uri)); } } } catch (Exception e) { log.error("Browse URI failed", e); } }
Example #8
Source File: DesktopHandler.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * Initialize the Mac-specific properties. * Create an ApplicationAdapter to listen for Help, Prefs, and Quit. */ public static void initialize() { if (initialized) { return; } initialized = true; if (!Desktop.isDesktopSupported()) { return; } Desktop theDesktop = Desktop.getDesktop(); if (theDesktop.isSupported(Action.APP_ABOUT)) { theDesktop.setAboutHandler(new AboutHandler()); } if (theDesktop.isSupported(Action.APP_PREFERENCES)) { theDesktop.setPreferencesHandler(new PreferencesHandler()); } if (theDesktop.isSupported(Action.APP_QUIT_HANDLER)) { theDesktop.setQuitHandler(new QuitHandler()); } }
Example #9
Source File: LinkEntry.java From minicraft-plus-revived with GNU General Public License v3.0 | 5 votes |
public LinkEntry(int color, String text, String url, String failMsg, boolean localize) { super(text, () -> { if(!checkedDesktop) { checkedDesktop = true; if(Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); canBrowse = desktop.isSupported(Action.BROWSE); } } if(canBrowse) { // try to open the download link directly from the browser. try { URI uri = URI.create(url); Game.setMenu(new TempDisplay(3000, false, true, new Menu.Builder(true, 0, RelPos.CENTER, new StringEntry(Localization.getLocalized(openMsg))).createMenu())); desktop.browse(uri); } catch(IOException e) { System.err.println("Could not parse LinkEntry url \""+url+"\" into valid URI:"); e.printStackTrace(); canBrowse = false; } } if(!canBrowse) { Game.setMenu(new BookDisplay(failMsg, false)); } }, localize); this.color = color; }
Example #10
Source File: ErrorHandler.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
private static JButton actionButton(String text, Desktop.Action action, Runnable listener) { final JButton button = new JButton(text); if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(action)) { button.addActionListener(e -> listener.run()); return button; } button.setEnabled(false); return button; }
Example #11
Source File: CheckUpdate.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Show download page. */ public void showDownloadPage() { if (client != null) { URL url = client.getDownloadURL(); if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) { Desktop desktop = Desktop.getDesktop(); try { desktop.browse(url.toURI()); } catch (IOException | URISyntaxException e) { ConsoleManager.getInstance().exception(this, e); } } } }
Example #12
Source File: WDesktopPeer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows. return true; }
Example #13
Source File: CDesktopPeer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #14
Source File: XDesktopPeer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action type) { return supportedActions.contains(type); }
Example #15
Source File: CDesktopPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #16
Source File: WDesktopPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows. return true; }
Example #17
Source File: XDesktopPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action type) { return supportedActions.contains(type); }
Example #18
Source File: CDesktopPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #19
Source File: StandaloneShutdownDialog.java From webanno with Apache License 2.0 | 4 votes |
@EventListener public void onApplicationEvent(ApplicationReadyEvent aEvt) { log.info("Console: " + ((System.console() != null) ? "available" : "not available")); log.info("Headless: " + (GraphicsEnvironment.isHeadless() ? "yes" : "no")); // Show this only when run from the standalone JAR via a double-click if (port != -1 && System.console() == null && !GraphicsEnvironment.isHeadless() && runningFromCommandline) { log.info("If you are running " + applicationName + " in a server environment, please use '-Djava.awt.headless=true'"); eventPublisher.publishEvent( new ShutdownDialogAvailableEvent(StandaloneShutdownDialog.this)); final int style; final String[] options; if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) { style = JOptionPane.OK_CANCEL_OPTION; options = new String[] { ACTION_SHUTDOWN, ACTION_OPEN_BROWSER }; } else { style = JOptionPane.OK_OPTION; options = new String[] { ACTION_SHUTDOWN }; } EventQueue.invokeLater(() -> { final JOptionPane optionPane = new JOptionPane( new JLabel("<HTML>" + applicationName + " is running now and can be " + "accessed via <b>http://localhost:8080</b>.<br>" + applicationName + " works best with the browsers Google Chrome or Safari.<br>" + "Use this dialog to shut " + applicationName + " down.</HTML>"), JOptionPane.INFORMATION_MESSAGE, style, null, options); final JDialog dialog = new JDialog((JFrame) null, applicationName, false); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { // Avoid closing window by other means than button } }); optionPane.addPropertyChangeListener(this::handleCloseEvent); dialog.pack(); dialog.setVisible(true); }); } else { log.info("Running in server environment or from command line: disabling interactive shutdown dialog."); } }
Example #20
Source File: XDesktopPeer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action type) { return supportedActions.contains(type); }
Example #21
Source File: WDesktopPeer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows. return true; }
Example #22
Source File: CDesktopPeer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #23
Source File: CDesktopPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #24
Source File: XDesktopPeer.java From hottub with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action type) { return supportedActions.contains(type); }
Example #25
Source File: WDesktopPeer.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows. return true; }
Example #26
Source File: CDesktopPeer.java From hottub with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #27
Source File: WDesktopPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows. return true; }
Example #28
Source File: XDesktopPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action type) { return supportedActions.contains(type); }
Example #29
Source File: CDesktopPeer.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public boolean isSupported(Action action) { // OPEN, EDIT, PRINT, MAIL, BROWSE all supported. // Though we don't really differentiate between OPEN / EDIT return true; }
Example #30
Source File: GenerateToken.java From socialauth with MIT License | 4 votes |
private void getAccessToken() throws Exception { SocialAuthConfig config = SocialAuthConfig.getDefault(); config.load(); SocialAuthManager manager = new SocialAuthManager(); manager.setSocialAuthConfig(config); URL aURL = new URL(successURL); host = aURL.getHost(); port = aURL.getPort(); port = port == -1 ? 80 : port; callbackPath = aURL.getPath(); if (tokenFilePath == null) { tokenFilePath = System.getProperty("user.home"); } String url = manager.getAuthenticationUrl(providerId, successURL); startServer(); if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Action.BROWSE)) { try { desktop.browse(URI.create(url)); // return; } catch (IOException e) { // handled below } } } lock.lock(); try { while (paramsMap == null && error == null) { gotAuthorizationResponse.awaitUninterruptibly(); } if (error != null) { throw new IOException("User authorization failed (" + error + ")"); } } finally { lock.unlock(); } stop(); AccessGrant accessGrant = manager.createAccessGrant(providerId, paramsMap, successURL); Exporter.exportAccessGrant(accessGrant, tokenFilePath); LOG.info("Access Grant Object saved in a file :: " + tokenFilePath + File.separatorChar + accessGrant.getProviderId() + "_accessGrant_file.txt"); }