@Override public final void updaterUpdateAvailable(final String localVersion, final String remoteVersion) { final String link = "https://github.com/" + GithubUpdater.UPDATER_GITHUB_USERNAME + "/" + GithubUpdater.UPDATER_GITHUB_REPO + "/releases/latest"; if(JOptionPane.showConfirmDialog(this, "<html>An update is available : v" + remoteVersion + " !<br/>" + "Would you like to visit " + link + " to download it ?</html>", Constants.APP_NAME, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { try { if(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { Desktop.getDesktop().browse(new URI(link)); } } catch(final Exception ex) { ex.printStackTrace(guiPrintStream); ex.printStackTrace(); JOptionPane.showMessageDialog(ProjectsFrame.this, String.format(Constants.GUI_DIALOG_ERROR_MESSAGE, ex.getMessage()), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } }
@Override protected void actionPerformed(GuiButton clickedButton) throws IOException { if (clickedButton.id == 0) { try { String link = "https://github.com/Moudoux/EMC-Installer/releases"; if (clientInfo.get("updateLinkOverride").getAsBoolean()) { link = clientInfo.get("website").getAsString(); } Desktop.getDesktop().browse(new URL(link).toURI()); } catch (Exception e) { ; } Minecraft.getMinecraft().shutdown(); } Minecraft.getMinecraft().displayGuiScreen(null); super.actionPerformed(clickedButton); }
private static boolean editDESKTOP(File file) { logOut("Trying to use Desktop.getDesktop().edit() with " + file); try { if (!Desktop.isDesktopSupported()) { logErr("Platform is not supported."); return false; } if (!Desktop.getDesktop().isSupported(Desktop.Action.EDIT)) { logErr("EDIT is not supported."); return false; } Desktop.getDesktop().edit(file); return true; } catch (Throwable t) { logErr("Error using desktop edit.", t); return false; } }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Simple Web Server"); BorderPane root = new BorderPane(); TextArea area = new TextArea(); root.setCenter(area); ToolBar bar = new ToolBar(); Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true); openInBrowser.setOnAction((event) -> { try { Desktop.getDesktop().browse(URI.create(webRoot)); } catch (IOException e) { e.printStackTrace(); } }); Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true); changeRoot.setOnAction((event) -> { DirectoryChooser chooser = new DirectoryChooser(); File showDialog = chooser.showDialog(primaryStage); if (showDialog != null) server.setRoot(showDialog); }); bar.getItems().add(openInBrowser); bar.getItems().add(changeRoot); root.setTop(bar); System.setOut(new PrintStream(new Console(area))); System.setErr(new PrintStream(new Console(area))); area.setEditable(false); primaryStage.setScene(new Scene(root)); primaryStage.setOnShown((e) -> startServer(getParameters().getRaw())); primaryStage.show(); }
public void onActionClickAliasHyperlink() { LoggerFacade.getDefault().debug(this.getClass(), "On action click [Alias] Hyperlink"); // NOI18N if ( Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE) ) { try { final URL url = new URL(link.getUrl()); Desktop.getDesktop().browse(url.toURI()); } catch (IOException | URISyntaxException ex) { LoggerFacade.getDefault().error(this.getClass(), "Can't open url: " + link.getUrl(), ex); // NOI18N } } else { LoggerFacade.getDefault().warn(this.getClass(), "Desktop.isDesktopSupported() isn't supported"); } }
@Override public void onClick(ActionEvent arg0) { try { URI v_URI = URI.create(AppMain.$SourceCode); Desktop v_Desktop = Desktop.getDesktop(); // 判断系统桌面是否支持要执行的功能 if ( v_Desktop.isSupported(Desktop.Action.BROWSE) ) { // 获取系统默认浏览器打开链接 v_Desktop.browse(v_URI); } } catch (Exception e) { e.printStackTrace(); } }
/** * Browse the given URL * * @param url url * @param name title */ public static void browse(final URL url, final String name) { if (Desktop.isDesktopSupported()) { try { // need this strange code, because the URL.toURI() method have // some trouble dealing with UTF-8 encoding sometimes final URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(), url.getRef()); Desktop.getDesktop().browse(uri); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); JOptionPane.showMessageDialog(null, Resources.getLabel("error.open.url", name)); } } else { JOptionPane.showMessageDialog(null, Resources.getLabel("error.open.url", name)); } }
private void jButtonIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIniciarActionPerformed try { // Consumiendo web service String json = iniciarServidor(); user = new Gson().fromJson(json, Pc.class); System.out.println("Recibido: " + user); jLabel1.setForeground(Color.green); Desktop.getDesktop().browse(new URI("http://" + ip + ":" + user.getPuertoPHP() + "/phpmyadmin")); url.setText("http://" + ip + ":" + user.getPuertoPHP() + "/phpmyadmin"); jlabelSQL.setText("PuertoSQL: " + user.getPuertoSQL()); this.setTitle("App [ID:" + user.getId() + "]"); } catch (IOException | URISyntaxException ex) { Logger.getLogger(VentanaPrincipal.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Open an Explorer with the given Path * * @param directoryPath - Path to open * @return Open-Explorer ActionListener */ static ActionListener openExplorer(String directoryPath) { return e -> { Desktop desktop = Desktop.getDesktop(); try { desktop.open(new java.io.File(File.ensureDSonEndOfPath(directoryPath)).getAbsoluteFile()); } catch(Exception ex) { ex.printStackTrace(); ErrorWindow errorWindow = new ErrorWindow( "Unable to open the File-Explorer with the Directory: " + directoryPath, ErrorWindow.ERROR_LEVEL_ERROR, false ); errorWindow.show(); } }; }
/** * If possible this method opens the default browser to the specified web * page. If not it notifies the user of webpage's url so that they may * access it manually. * * @param message Error message to display * @param uri */ public static void openInBrowser(String message, URI uri) { try { java.util.logging.Logger.getLogger(Help.class.getName()).log(Level.INFO, "Opening url {0}", uri); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(uri); } else { throw new UnsupportedOperationException("Desktop Api Not supported in this System"); } } catch (Exception e) { java.util.logging.Logger.getLogger(Help.class.getName()).log(Level.WARNING, null, e); // Copy URL to the clipboard so the user can paste it into their browser Utils.copyTextToClipboard(uri.toString()); // Notify the user of the failure JOptionPane.showMessageDialog(null, message + "\n" + "The URL has been copied to your clipboard, simply paste into your browser to access.\n" + "Webpage: " + uri); } }
@Override public void mouseClicked(MouseEvent e) { JTable table = (JTable) e.getSource(); Point pt = e.getPoint(); int ccol = table.columnAtPoint(pt); int crow = table.rowAtPoint(pt); Object value = table.getValueAt(crow, ccol); if (value instanceof URL) { URL url = (URL) value; try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(url.toURI()); } } catch (Exception ex) { throw new IllegalStateException(ex); } } }
@Override public void mouseClicked(MouseEvent e) { try { Desktop desktop = java.awt.Desktop.getDesktop(); URI uri = new java.net.URI(href); desktop.browse(uri); } catch( Exception ex ) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Unable to open link in the system browser", "Could not follow link", JOptionPane.ERROR_MESSAGE); } }
@Override public void mouseClicked(MouseEvent e) { if( e.getSource() == preamble ) { try { Desktop desktop = java.awt.Desktop.getDesktop(); URI uri = new java.net.URI(CANVAS_SIGNUP_URL); desktop.browse(uri); } catch( Exception ex ) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Unable to open link in the system browser", "Could not follow link", JOptionPane.ERROR_MESSAGE); } } }
public void standardOpen() { AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { try { debug("using Desktop.open"); Desktop.getDesktop().open(tempFile); } catch( Exception io ) { logException("Error opening file", io); } return null; } }, openPermissionContext); }
private static boolean openDESKTOP(File file) { logOut("Trying to use Desktop.getDesktop().open() with " + file.toString()); try { if (!Desktop.isDesktopSupported()) { logErr("Platform is not supported."); return false; } if (!Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { logErr("OPEN is not supported."); return false; } Desktop.getDesktop().open(file); return true; } catch (Throwable t) { logErr("Error using desktop open.", t); return false; } }
/** * Opens a website using the default browser. It will automatically apply http:// infront of the * url if not existant already. * * @param urlAsString * website to visit */ public static void browse(final String urlAsString) { if (Desktop.isDesktopSupported()) { /** * HACK * Workaround for Unix, since the Desktop Class seems to freeze the application unless * the call is threaded. */ new Thread(() -> { final Desktop desktop = Desktop.getDesktop(); try { final String fixedUrl = StringUtility.fixUrlIfNecessary(urlAsString); final URL url = new URL(fixedUrl); desktop.browse(new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef())); } catch (final IOException | URISyntaxException exception) { Logging.warn("Couldn't visit website '" + urlAsString + "'", exception); } }).start(); } }
/** View project source code on GitHub. */ public static void onViewGitHub() { try { URI githubURI = new URI("https://github.com/Stevoisiak/Virtual-Game-Shelf"); Desktop.getDesktop().browse(githubURI); } catch (URISyntaxException | IOException ex) { ex.printStackTrace(); } }
@Override public void openFile(File file) { try { Desktop.getDesktop().open(file); } catch (IOException e) { throw new IllegalStateException("Error opening file: " + file, e); } }
public void openHarComapareInBrowser() { String add = server().url() + "/dashboard/harCompare/home.html"; if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { try { Desktop.getDesktop().browse(new URL(add).toURI()); } catch (URISyntaxException | IOException ex) { Logger.getLogger(DashBoardManager.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); } } }
protected void generarListado() { try { JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(this); File file = chooser.getSelectedFile(); if(file!=null){ generarPDF(file); Desktop.getDesktop().open(file); } }catch(IOException ex) { JOptionPane.showMessageDialog(null, "No se encuentra el fichero creado"); } }
protected void generarListado(String sql) { try { this.sql=sql; JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(this); File file = chooser.getSelectedFile(); if(file!=null){ generarPDF(file); Desktop.getDesktop().open(file); } }catch(IOException ex) { JOptionPane.showMessageDialog(null, "No se encuentra el fichero creado"); } }
/** * Notifies observers and updates state if all files have been ripped. */ void checkIfComplete() { if (observer == null) { logger.debug("observer is null"); return; } if (!completed) { completed = true; logger.info(" Rip completed!"); RipStatusComplete rsc = new RipStatusComplete(workingDir, getCount()); RipStatusMessage msg = new RipStatusMessage(STATUS.RIP_COMPLETE, rsc); observer.update(this, msg); Logger rootLogger = Logger.getRootLogger(); FileAppender fa = (FileAppender) rootLogger.getAppender("FILE"); if (fa != null) { logger.debug("Changing log file back to 'ripme.log'"); fa.setFile("ripme.log"); fa.activateOptions(); } if (Utils.getConfigBoolean("urls_only.save", false)) { String urlFile = this.workingDir + File.separator + "urls.txt"; try { Desktop.getDesktop().open(new File(urlFile)); } catch (IOException e) { logger.warn("Error while opening " + urlFile, e); } } } }
/** * Builds the tool information * * @return JComponent */ private JComponent buildInfo() { JPanel info = new JPanel(); info.setLayout(new BoxLayout(info, BoxLayout.Y_AXIS)); JLabel title = new JLabel("VISNode"); title.setFont(new Font("Segoe UI", Font.PLAIN, 32)); JLabel version = new JLabel(VERSION); version.setBackground(Color.red); // github = new JButton(); // github.setIcon(IconFactory.get().create("fa:github")); // github.setText(GITHUB_URL); // github.setBorder(BorderFactory.createEmptyBorder()); // github.setBorderPainted(false); // github.setContentAreaFilled(false); // github.setFocusPainted(false); // github.setOpaque(false); info.add(title); info.add(version); info.add(Labels.create(GITHUB_URL).icon(IconFactory.get().create("fa:github")).onClick((ev) -> { try { Desktop.getDesktop().browse(new URL(GITHUB_URL).toURI()); } catch (IOException | URISyntaxException e) { ExceptionHandler.get().handle(e); } })); return info; }
/** * Creates new form ProblemComponent */ public ProblemComponent(Problem problem, RefactoringUI ui, boolean single) { initComponents(); this.ui = ui; icon.setIcon(problem.isFatal()?ErrorPanel.getFatalErrorIcon():ErrorPanel.getNonfatalErrorIcon()); problemDescription.setText(problem.getMessage()); this.problem = problem; this.details = problem.getDetails(); //setLightBackground(); if (!single && details != null) { org.openide.awt.Mnemonics.setLocalizedText(showDetails, details.getDetailsHint()); showDetails.setPreferredSize(new Dimension((int) buttonWidth, (int) showDetails.getMinimumSize().getHeight())); } else { showDetails.setVisible(false); } problemDescription.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException ex) { LOGGER.log(Level.INFO, "Desktop.browse failed: ", ex); // NOI18N } } } }); }
@Override public void open(FileObject file, int line) { File realFile = FileUtil.toFile(file); if (realFile != null) { try { Desktop.getDesktop().edit(realFile); } catch (IOException ex) { LOGGER.log(Level.INFO, null, ex); } } }
private HtmlBrowserComponent createExternalBrowser() { Factory browser = IDESettings.getExternalWWWBrowser(); if (browser == null) { Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { browser = new DesktopBrowser(desktop); } else { //external browser is not available, fallback to swingbrowser browser = new SwingBrowser(); } } return new HtmlBrowserComponent(browser, true, true); }
static void install() { try { Desktop app = Desktop.getDesktop(); NbApplicationAdapterJDK9 al = new NbApplicationAdapterJDK9(); app.setAboutHandler(al); app.setOpenFileHandler(al); app.setPreferencesHandler(al); app.setQuitHandler(al); } catch (Throwable ex) { ErrorManager.getDefault().notify(ErrorManager.WARNING, ex); } finally { } NbApplicationAdapter.install(); }
/** * Triggers first build events. * * @param command The current build command. * * @throws Exception If any exception occurs. */ private final void firstBuild(final BuildCommand command) throws Exception { registerFileListener(command); buildDirectory = command.getCurrentBuildDirectory(); outputLine("You can point your browser to http://localhost:" + port + "."); blankLine(); server.start(NanoHTTPD.SOCKET_READ_TIMEOUT, false); if(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { Desktop.getDesktop().browse(new URL("http://localhost:" + port).toURI()); } }
@FXML public void deleteSelectedFiles(ActionEvent event) { final ObservableList<FileInfo> selectedFiles = matchingFilesListView.getSelectionModel().getSelectedItems(); if (selectedFiles.size() > 0) { showConfirmationDialog("Are you sure you want to delete the selected files", () -> selectedFiles.forEach(f -> { if (Desktop.getDesktop().moveToTrash(new File(f.getPath()))) { matchingFilesListView.getItems().remove(f); dupes.get(dupeFileGroupListView.getSelectionModel().getSelectedItem()) .remove(f); } })); } }
/** * On systems where Desktop.getDesktop().browse() does not work for http://, creates an HTML * page which redirects to the given URI and calls Desktop.browse() with this file through the * file:// url which seems to work better, at least for KDE. */ public static void browse(URI uri) throws IOException { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(uri); } catch (IOException e) { File tempFile = File.createTempFile("rmredirect", ".html"); tempFile.deleteOnExit(); FileWriter out = new FileWriter(tempFile); try { out.write(String.format( "<!DOCTYPE html>\n" + "<html><meta http-equiv=\"refresh\" content=\"0; URL=%s\"><body>You are redirected to %s</body></html>", uri.toString(), uri.toString())); } finally { out.close(); } Desktop.getDesktop().browse(tempFile.toURI()); } catch (UnsupportedOperationException e1) { throw new IOException(e1); } } else { LOGGER.log(Level.SEVERE, "Failed to open web page in browser, browsing is not supported on this platform."); SwingTools.showVerySimpleErrorMessage("url_handler.unsupported", uri.toString()); } }
/** * Apre la pagina web indicata dal parametro uri nel browser predefinito * @param uri pagina web da aprire. * @throws Exception se l'uri non è valido. */ private static void openWebPage(URI uri) throws Exception { Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(uri); } }
protected void desktopOpen(File file) { try { Desktop.getDesktop().open(file); } catch (Throwable e) { logger.info(e.getMessage()); } }
@Override public void openWithSystem(IResourceActionSource source, Resource resource) { Path filePath = resource.getFilePath(); if (filePath != null) { try { Desktop.getDesktop().open(filePath.toFile()); } catch (IOException e) { FXUIUtils._showMessageDialog(DisplayWindow.this, e.getMessage(), "Can't open file with system editor", AlertType.ERROR); } } }
private void labelPagerMouseClicked( java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelPagerMouseClicked if (pagerUrl != null) { try { Desktop.getDesktop().browse(new URI(pagerUrl)); } catch (URISyntaxException | IOException ex) { QLog.l().logger().error(ex); } } }
@Override public void handleEvent(Event event) { HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget(); String href = anchorElement.getHref(); if (Desktop.isDesktopSupported()) { openLinkInSystemBrowser(href); } else { LOGGER.warning("OS does not support desktop operations like browsing. Cannot open link '{" + href + "}'."); } event.preventDefault(); }
private void openLinkInSystemBrowser(String url) { LOGGER.info("Opening link '{" + url + "}' in default system browser."); try { URI uri = new URI(url); Desktop.getDesktop().browse(uri); } catch (Throwable e) { LOGGER.warning("Error on opening link '{" + url + "}' in system browser."); } }
private static void openBrowserForJavadoc(String relativeUrl) { try { final URI uri = new URI(JAVADOC_BASE + relativeUrl); Desktop.getDesktop().browse(uri); } catch (Exception ignored) { } }
private void abrirlink(HyperlinkEvent e){ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception error) { System.err.println("Não foi possível lançar o navegador!" + "\n" + error.getMessage()); } } }
public static boolean speak(String text) { if(Desktop.isDesktopSupported()) { try { final String format = "dim fname\n" + "set objVoice=createobject(\"sapi.spvoice\")\n" + "objvoice.speak (\"%s\")"; String temp = String.format(format, text); File file_temp = File.createTempFile("" + ((int) (Math.random() * 10000)), ".vbs"); FileWriter fw = new FileWriter(file_temp); BufferedWriter bw = new BufferedWriter(fw); bw.write(temp); bw.newLine(); bw.close(); fw.close(); bw = null; fw = null; Desktop.getDesktop().open(file_temp); Thread.sleep(1000); file_temp.delete(); return true; } catch (Exception ex) { StaticStandard.logErr("Error while speaking: " + ex, ex); return false; } } else { return false; } }
private void linkSUBDBLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_linkSUBDBLabelMouseClicked try { Desktop.getDesktop().browse(new URI("http://www.thesubdb.com")); } catch (URISyntaxException | IOException ex) { Logger.getLogger(About.class.getName()).log(Level.SEVERE, null, ex); } }