List of usage examples for java.awt Desktop isDesktopSupported
public static boolean isDesktopSupported()
From source file:org.yccheok.jstock.gui.CompanyNews.java
static void openWebpage(URI uri) { Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try {/* w w w . j a v a 2 s. c o m*/ desktop.browse(uri); } catch (Exception e) { log.error(null, e); } } }
From source file:context.ui.misc.FileHandler.java
/** * * @param url/* w ww . j a v a 2 s.c om*/ */ public static void openWebpage(String url) { try { URI uri = new URI(url); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(uri); } } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
From source file:org.pdfsam.App.java
private void doOpen(OpenFileRequest event) { if (Desktop.isDesktopSupported()) { try {/*w w w. ja v a2s . c o m*/ Desktop.getDesktop().open(event.getFile()); } catch (IOException e) { LOG.error("Unable to open '{}'", event.getFile().getAbsoluteFile()); } } }
From source file:org.brickred.tools.GenerateToken.java
private void getAccessToken() throws Exception { SocialAuthConfig config = SocialAuthConfig.getDefault(); config.load();/*from w w w. java2 s. c o m*/ 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"); } startServer(); String url = manager.getAuthenticationUrl(providerId, successURL); 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 (code == null && error == null) { gotAuthorizationResponse.awaitUninterruptibly(); } if (error != null) { throw new IOException("User authorization failed (" + error + ")"); } } finally { lock.unlock(); } stop(); manager.getAuthenticationUrl(providerId, successURL); AccessGrant accessGrant = manager.createAccessGrant(providerId, code, successURL); Exporter.exportAccessGrant(accessGrant, tokenFilePath); LOG.info("Access Grant Object saved in a file :: " + tokenFilePath + File.separatorChar + accessGrant.getProviderId() + "_accessGrant_file.txt"); }
From source file:appmain.AppMain.java
private void openFile(File file) { try {/*from www . jav a2s. c om*/ if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(file); } } catch (IOException ioe) { } }
From source file:net.mybox.mybox.ClientGUI.java
private void launchFileBrowser() { Desktop desktop = null;//from www . ja v a 2s.co m if (Desktop.isDesktopSupported()) { File dir = new File(client.GetClientDir()); desktop = Desktop.getDesktop(); try { desktop.open(dir); } catch (Exception ex) { System.err.println(ex.getMessage()); } } }
From source file:com.devbury.mkremote.server.QuickLaunchServiceImpl.java
public boolean isSupported() { boolean supported = false; supported = Desktop.isDesktopSupported(); logger.debug("isDesktopSupported {}", supported); if (supported) { supported = Desktop.getDesktop().isSupported(Action.OPEN); logger.debug("isOpenSupported {}", supported); }//from w w w. ja v a 2s . c o m return supported; }
From source file:org.pmedv.blackboard.dialogs.DatasheetDialog.java
@Override protected void initializeComponents() { sheetProvider = AppContext.getContext().getBean(DataSheetProvider.class); sheetPanel = new DatasheetPanel(); busyPanel = new JBusyComponent<DatasheetPanel>(sheetPanel); setSize(new Dimension(900, 650)); getContentPanel().add(busyPanel);/*ww w.j a va 2 s . co m*/ SwingWorker<ArrayList<DatasheetBean>, Void> w = new SwingWorker<ArrayList<DatasheetBean>, Void>() { @Override protected ArrayList<DatasheetBean> doInBackground() throws Exception { busyPanel.setBusy(true); sheetProvider.loadSheets(); return sheetProvider.getDatasheetList().getDatasheets(); } @Override protected void done() { log.info("Done loading sheets."); try { model = new DataSheetTableModel(get()); sheetPanel.getDatasheetTable().setModel(model); } catch (Exception e) { e.printStackTrace(); } busyPanel.setBusy(false); sheetPanel.transferFocus(); } }; getOkButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); getCancelButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result = OPTION_CANCEL; setVisible(false); } }); sheetPanel.getDatasheetTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int modelIndex = sheetPanel.getDatasheetTable() .convertRowIndexToModel(sheetPanel.getDatasheetTable().getSelectedRow()); DatasheetBean sheet = model.getDatasheetBeans().get(modelIndex); if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try { desktop.open(new File(sheet.getLocation())); } catch (Exception e1) { ErrorUtils.showErrorDialog(e1); } } } } }); sheetPanel.getAddSheetButton().setAction(AppContext.getContext().getBean(AddDatasheetCommand.class)); sheetPanel.getRemoveSheetButton().setAction(AppContext.getContext().getBean(RemoveDatasheetCommand.class)); sheetPanel.getImportFolderButton() .setAction(AppContext.getContext().getBean(ImportDatasheetFolderCommand.class)); // create filter for sheets DataSheetFilter filter = new DataSheetFilter(sheetPanel.getDatasheetTable()); BindingGroup filterGroup = new BindingGroup(); // bind filter JTextBox's text attribute to part tables filterString attribute filterGroup.addBinding(Bindings.createAutoBinding(READ, sheetPanel.getFilterPanel().getFilterTextField(), BeanProperty.create("text"), filter, BeanProperty.create("filterString"))); filterGroup.bind(); w.execute(); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopExportDisplay.java
private void openFileAction(String finalFileName, ExportDataProvider dataProvider) { File destFile = null;/*from w w w. ja v a 2 s .co m*/ try { destFile = File.createTempFile("get_" + FilenameUtils.getBaseName(finalFileName), "." + getFileExt(finalFileName)); } catch (IOException e) { String message = messages.getMessage(DesktopExportDisplay.class, "export.tempFileError"); getFrame().getWindowManager().showNotification(message, Frame.NotificationType.WARNING); } if (destFile != null) { if (Desktop.isDesktopSupported() && saveFile(dataProvider, destFile)) { try { Desktop.getDesktop().open(destFile); } catch (IOException ex) { String message = messages.getMessage(DesktopExportDisplay.class, "export.openError"); getFrame().getWindowManager().showNotification(message, Frame.NotificationType.WARNING); } } } }
From source file:io.bitsquare.common.util.Utilities.java
public static void openURI(URI uri) throws IOException { if (!isLinux() && Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { Desktop.getDesktop().browse(uri); } else {// www . j ava2 s . c o m // Maybe Application.HostServices works in those cases? // HostServices hostServices = getHostServices(); // hostServices.showDocument(uri.toString()); // On Linux Desktop is poorly implemented. // See https://stackoverflow.com/questions/18004150/desktop-api-is-not-supported-on-the-current-platform if (!DesktopUtil.browse(uri)) throw new IOException("Failed to open URI: " + uri.toString()); } }