List of usage examples for java.awt Desktop getDesktop
public static synchronized Desktop getDesktop()
From source file:dk.dma.epd.common.prototype.gui.notification.MsiNmNotificationPanel.java
/** * {@inheritDoc}// w ww . j av a2 s.c o m */ @Override public void hyperlinkUpdate(HyperlinkEvent hle) { if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) { try { URL url = hle.getURL(); if (url.getHost().equals("msinm") && url.getPath().length() > 1) { String msinmId = url.getPath().substring(1); for (MsiNmNotification notification : notificationPanel.getNotifications()) { if (notification.getSeriesId().equals(msinmId)) { EPD.getInstance().getNotificationCenter().openNotification(NotificationType.MSI_NM, notification.getId(), false); return; } Toolkit.getDefaultToolkit().beep(); } } else { Desktop desktop = Desktop.getDesktop(); desktop.browse(new URI(hle.getURL().toString())); } } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:org.mhisoft.common.util.FileUtils.java
public static void launchFile(String pathToFile) throws IOException { if (Desktop.isDesktopSupported()) { //try {// w w w .jav a 2s .c o m File myFile = new File(pathToFile); Desktop.getDesktop().open(myFile); //} catch (IOException ex) { // no application registered for PDFs //} } }
From source file:br.com.postalis.folhapgto.service.SvcFolhaPgtoImpl.java
private void gerarRelatorio(String nomeRel, String relJrxml, List<?> lista, Date dtRef) { JasperReport report = null;//w ww . ja v a 2 s . c o m String caminhoCompletoRel = ""; try { String pasta = "C:\\POSTALIS\\RELATORIOS\\"; report = JasperCompileManager .compileReport(getClass().getResourceAsStream("/relatorios/" + relJrxml + ".jrxml")); ImageIcon gto = new ImageIcon(getClass().getResource("/imagens/Logo branca.jpg")); Map parametros = new HashMap(); parametros.put("logo", gto.getImage()); parametros.put("referencia", DataUtil.getDataS(dtRef, "MM/yyyy")); caminhoCompletoRel = pasta + nomeRel + "_" + DataUtil.getDataS(dtRef, "ddMMyyyy") + "_" + DataUtil.getDiaProcessamentoComHoraMinutoSegundo() + ".pdf"; JasperPrint print = JasperFillManager.fillReport(report, parametros, new JRBeanCollectionDataSource(lista)); JasperExportManager.exportReportToPdfFile(print, caminhoCompletoRel); File pdf = new File(caminhoCompletoRel); Desktop.getDesktop().open(pdf); } catch (JRException ex) { LOGGER.error("Erro construir o relatorio Jasper: " + ex); } catch (IOException ex) { LOGGER.error("Erro ao abrir o relatorio em PDF a partir da pasta: " + caminhoCompletoRel + ". Motivo: " + ex); } }
From source file:sirjacob.BlockDEA.Display.java
/** * Opens web browser and navigates to supplied URL. * * @param url Accepts URL as string.// w ww . j a v a2 s . co m */ private void openURL(String url) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI(url)); } catch (URISyntaxException | IOException ex) { Logger.getLogger(Display.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java
private void openLocalFilejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openLocalFilejButtonActionPerformed try {/* www .j a va 2s .c o m*/ Desktop.getDesktop().open(new File(localFileNamejTextField1.getText())); } catch (Exception ex) { Logger.getLogger(AZoCamSyncJFrame.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:op.FrmMain.java
private void btnHelpActionPerformed(ActionEvent e) { if (currentVisiblePanel != null && Desktop.isDesktopSupported()) { // && currentVisiblePanel.getInternalClassID() != null && OPDE.getAppInfo().getInternalClasses().containsKey(currentVisiblePanel.getInternalClassID()) // if (OPDE.getAppInfo().getInternalClasses().get(currentVisiblePanel.getInternalClassID()).getHelpurl() != null) { // try { // URI uri = new URI(SYSTools.xx(OPDE.getAppInfo().getInternalClasses().get(currentVisiblePanel.getInternalClassID()).getHelpurl())); // Desktop.getDesktop().browse(uri); // } catch (Exception ex) { // OPDE.getDisplayManager().addSubMessage(new DisplayMessage("opde.mainframe.noHelpAvailable")); // } // } else { // OPDE.getDisplayManager().addSubMessage(new DisplayMessage("opde.mainframe.noHelpAvailable")); // } if (currentVisiblePanel.getHelpKey() != null) { try { URI uri = new URI(SYSTools.xx(currentVisiblePanel.getHelpKey())); Desktop.getDesktop().browse(uri); } catch (Exception ex) { OPDE.getDisplayManager().addSubMessage(new DisplayMessage("opde.mainframe.noHelpAvailable")); }/*from w w w. j a va2s.c o m*/ } else { OPDE.getDisplayManager().addSubMessage(new DisplayMessage("opde.mainframe.noHelpAvailable")); } } else { OPDE.getDisplayManager().addSubMessage(new DisplayMessage("opde.mainframe.noHelpAvailable")); } }
From source file:gdt.jgui.entity.bookmark.JBookmarksFacetOpenItem.java
/** * Get the popup menu for the child node of the facet node * in the digest view.//ww w . jav a 2 s . co m * @return the popup menu. */ @Override public JPopupMenu getPopupMenu(final String digestLocator$) { JPopupMenu popup = new JPopupMenu(); JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem); openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { // System.out.println("JBookmarkFacetOpenItem:open:digest locator="+digestLocator$); Properties locator = Locator.toProperties(digestLocator$); String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION); byte[] ba = Base64.decodeBase64(encodedSelection$); String selection$ = new String(ba, "UTF-8"); // System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$); locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String type$ = locator.getProperty(Locator.LOCATOR_TYPE); if (JFolderPanel.LOCATOR_TYPE_FILE.equals(type$)) { String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH); File file = new File(filePath$); Desktop.getDesktop().open(file); return; } if (JEntityDigestDisplay.LOCATOR_FACET_COMPONENT.equals(type$)) { String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JBookmarksEditor be = new JBookmarksEditor(); String beLocator$ = be.getLocator(); beLocator$ = Locator.append(beLocator$, Entigrator.ENTIHOME, entihome$); beLocator$ = Locator.append(beLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, beLocator$); return; } String bookmarkKey$ = locator.getProperty(JBookmarksEditor.BOOKMARK_KEY); Entigrator entigrator = console.getEntigrator(entihome$); String componentKey$ = locator.getProperty(JEntityDigestDisplay.COMPONENT_KEY); Sack entity = entigrator.getEntityAtKey(componentKey$); Core bookmark = entity.getElementItem("jbookmark", bookmarkKey$); // System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$); JConsoleHandler.execute(console, bookmark.value); } catch (Exception ee) { Logger.getLogger(JBookmarksFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:com.xmage.launcher.XMageLauncher.java
private static void openWebpage(String uri) { Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try {/*from w w w . java 2 s . c o m*/ desktop.browse(new URI(uri)); } catch (URISyntaxException ex) { logger.error("Error: ", ex); } catch (IOException ex) { logger.error("Error: ", ex); } } }
From source file:com.hmiard.blackwater.projects.Builder.java
/** * Asking the OS to open a directory or a file. * * @param path String/*from w ww. j a v a 2s . c o m*/ * @throws IOException */ public static void openPath(String path) throws IOException { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(new File(path)); } }
From source file:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java
private void openfolderjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openfolderjButtonActionPerformed try {// www .j av a 2 s .c o m Desktop.getDesktop().open(new File(localFileNamejTextField1.getText()).getParentFile()); } catch (Exception ex) { Logger.getLogger(AZoCamSyncJFrame.class.getName()).log(Level.SEVERE, null, ex); } }