List of usage examples for java.awt Desktop getDesktop
public static synchronized Desktop getDesktop()
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Displays about window./*from w w w . ja va2 s . co m*/ */ private void about() { String msg = "<html>DrillBook " + State.VERSION + "<br>Created by Evan Belcher, 2016<br><a href=\"https://github.com/EbMinor3/DrillBook\">GitHub</a><br><a href=\"http://evanbelcher.com\">Website</a><br><br><a href=\"https://icons8.com\">Icon pack by Icons8</a></html>"; JEditorPane editorPane = new JEditorPane("text/html", msg); editorPane.setEditable(false); editorPane.setBackground(new JLabel().getBackground()); editorPane.addHyperlinkListener(e -> { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } }); if (!(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE))) { editorPane.setContentType("text"); editorPane.setText("DrillBook " + State.VERSION + "\nCreated by Evan Belcher, 2016\nGitHub: https://github.com/EbMinor3/DrillBook\nWebsite: http://evanbelcher.com\n\nIcon pack by Icons8: https://icons8.com"); } JOptionPane.showMessageDialog(this, editorPane, "About", JOptionPane.PLAIN_MESSAGE); }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try {/*from w w w . j a va 2 s. c o m*/ URL url = e.getURL(); if (url != null) { if (url.getPath().endsWith(".cer") || url.getPath().endsWith(".crt")) { X509Certificate[] certs = downloadCert(url); if (certs != null && certs.length > 0) { DViewCertificate dViewCertificate = new DViewCertificate(this, MessageFormat .format(res.getString("DViewExtensions.ViewCert.Title"), url.toString()), certs, null, DViewCertificate.NONE); dViewCertificate.setLocationRelativeTo(this); dViewCertificate.setVisible(true); } } else if (url.getPath().endsWith(".crl")) { X509CRL crl = downloadCrl(url); if (crl != null) { DViewCrl dViewCrl = new DViewCrl(this, MessageFormat .format(res.getString("DViewExtensions.ViewCrl.Title"), url.toString()), ModalityType.DOCUMENT_MODAL, crl); dViewCrl.setLocationRelativeTo(this); dViewCrl.setVisible(true); } } else { Desktop.getDesktop().browse(url.toURI()); } } } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:se.trixon.toolbox.idiot.IdiotTopComponent.java
private void openDirectoryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openDirectoryButtonActionPerformed if (!Desktop.isDesktopSupported()) { return;/*w w w .j a va2 s . c om*/ } try { Desktop desktop = Desktop.getDesktop(); File dest = new File(tasksPanel.getSelectedTask().getDestination()).getParentFile(); desktop.open(dest); } catch (Exception ex) { NbMessage.error(Dict.Dialog.TITLE_IO_ERROR.toString(), Dict.Dialog.ERROR_CANT_OPEN_DIRECTORY.toString()); } }
From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java
private void setupTableWithChanges(TableView<Change> tv, Dataset tp) { tv.setEditable(true);/*from ww w. j ava 2 s.co m*/ tv.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); tv.getColumns().clear(); TableColumn<Change, ChangeType> colChangeType = new TableColumn<>("Type"); colChangeType.setCellFactory(ComboBoxTableCell.forTableColumn(new ChangeTypeStringConverter(), ChangeType.ADDITION, ChangeType.DELETION, ChangeType.RENAME, ChangeType.LUMP, ChangeType.SPLIT, ChangeType.COMPLEX, ChangeType.ERROR)); colChangeType.setCellValueFactory(new PropertyValueFactory<>("type")); colChangeType.setPrefWidth(100.0); colChangeType.setEditable(true); tv.getColumns().add(colChangeType); TableColumn<Change, ObservableSet<Name>> colChangeFrom = new TableColumn<>("From"); colChangeFrom.setCellFactory(TextFieldTableCell.forTableColumn(new NameSetStringConverter())); colChangeFrom.setCellValueFactory(new PropertyValueFactory<>("from")); colChangeFrom.setPrefWidth(200.0); colChangeFrom.setEditable(true); tv.getColumns().add(colChangeFrom); TableColumn<Change, ObservableSet<Name>> colChangeTo = new TableColumn<>("To"); colChangeTo.setCellFactory(TextFieldTableCell.forTableColumn(new NameSetStringConverter())); colChangeTo.setCellValueFactory(new PropertyValueFactory<>("to")); colChangeTo.setPrefWidth(200.0); colChangeTo.setEditable(true); tv.getColumns().add(colChangeTo); TableColumn<Change, String> colExplicit = new TableColumn<>("Explicit or implicit?"); colExplicit.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( features.getValue().getDataset().isChangeImplicit(features.getValue()) ? "Implicit" : "Explicit")); tv.getColumns().add(colExplicit); ChangeFilter cf = datasetView.getProjectView().getProject().getChangeFilter(); TableColumn<Change, String> colFiltered = new TableColumn<>("Eliminated by filter?"); colFiltered.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( cf.test(features.getValue()) ? "Allowed" : "Eliminated")); tv.getColumns().add(colFiltered); TableColumn<Change, String> colNote = new TableColumn<>("Note"); colNote.setCellFactory(TextFieldTableCell.forTableColumn()); colNote.setCellValueFactory(new PropertyValueFactory<>("note")); colNote.setPrefWidth(100.0); colNote.setEditable(true); tv.getColumns().add(colNote); TableColumn<Change, String> colCitations = new TableColumn<>("Citations"); colCitations.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( features.getValue().getCitationStream().map(citation -> citation.getCitation()).sorted() .collect(Collectors.joining("; ")))); tv.getColumns().add(colCitations); TableColumn<Change, String> colGenera = new TableColumn<>("Genera"); colGenera.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( String.join(", ", features.getValue().getAllNames().stream().map(n -> n.getGenus()) .distinct().sorted().collect(Collectors.toList())))); tv.getColumns().add(colGenera); TableColumn<Change, String> colSpecificEpithet = new TableColumn<>("Specific epithets"); colSpecificEpithet.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(String .join(", ", features.getValue().getAllNames().stream().map(n -> n.getSpecificEpithet()) .filter(s -> s != null).distinct().sorted().collect(Collectors.toList())))); tv.getColumns().add(colSpecificEpithet); // The infraspecific string. TableColumn<Change, String> colInfraspecificEpithet = new TableColumn<>("Infraspecific epithets"); colInfraspecificEpithet.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( String.join(", ", features.getValue().getAllNames().stream() .map(n -> n.getInfraspecificEpithetsAsString()).filter(s -> s != null) .distinct().sorted().collect(Collectors.toList())))); tv.getColumns().add(colInfraspecificEpithet); // The very last epithet of all TableColumn<Change, String> colTerminalEpithet = new TableColumn<>("Terminal epithet"); colTerminalEpithet.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( String.join(", ", features.getValue().getAllNames().stream().map(n -> { List<Name.InfraspecificEpithet> infraspecificEpithets = n.getInfraspecificEpithets(); if (!infraspecificEpithets.isEmpty()) { return infraspecificEpithets.get(infraspecificEpithets.size() - 1).getValue(); } else { return n.getSpecificEpithet(); } }).filter(s -> s != null).distinct().sorted().collect(Collectors.toList())))); tv.getColumns().add(colTerminalEpithet); // Properties TableColumn<Change, String> colProperties = new TableColumn<>("Properties"); colProperties.setCellValueFactory( (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper( features.getValue().getProperties().entrySet().stream() .map(entry -> entry.getKey() + ": " + entry.getValue()).sorted() .collect(Collectors.joining("; ")))); tv.getColumns().add(colProperties); fillTableWithChanges(tv, tp); // When someone selects a cell in the Table, try to select the appropriate data in the // additional data view. tv.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Change>) lcl -> { AdditionalData aData = additionalDataCombobox.getSelectionModel().getSelectedItem(); if (aData != null) { aData.onSelectChange(tv.getSelectionModel().getSelectedItems()); } }); // Create a right-click menu for table rows. changesTableView.setRowFactory(table -> { TableRow<Change> row = new TableRow<>(); row.setOnContextMenuRequested(event -> { if (row.isEmpty()) return; // We don't currently use the clicked change, since currently all options // change *all* the selected changes, but this may change in the future. Change change = row.getItem(); ContextMenu changeMenu = new ContextMenu(); Menu searchForName = new Menu("Search for name"); searchForName.getItems().addAll( change.getAllNames().stream().sorted().map(n -> createMenuItem(n.getFullName(), action -> { datasetView.getProjectView().openDetailedView(n); })).collect(Collectors.toList())); changeMenu.getItems().add(searchForName); changeMenu.getItems().add(new SeparatorMenuItem()); changeMenu.getItems().add(createMenuItem("Edit note", action -> { List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems()); String combinedNotes = changes.stream().map(ch -> ch.getNote().orElse("").trim()).distinct() .collect(Collectors.joining("\n")).trim(); Optional<String> result = askUserForTextArea( "Modify the note for these " + changes.size() + " changes:", combinedNotes); if (result.isPresent()) { String note = result.get().trim(); LOGGER.info("Using 'Edit note' to set note to '" + note + "' on changes " + changes); changes.forEach(ch -> ch.noteProperty().set(note)); } })); changeMenu.getItems().add(new SeparatorMenuItem()); // Create a submenu for tags and urls. String note = change.noteProperty().get(); Menu removeTags = new Menu("Tags"); removeTags.getItems().addAll(change.getTags().stream().sorted() .map(tag -> new MenuItem(tag.getName())).collect(Collectors.toList())); Menu lookupURLs = new Menu("Lookup URL"); change.getURIs().stream().sorted().map(uri -> { return createMenuItem(uri.toString(), evt -> { try { Desktop.getDesktop().browse(uri); } catch (IOException ex) { LOGGER.warning("Could not open URL '" + uri + "': " + ex); } }); }).forEach(mi -> lookupURLs.getItems().add(mi)); changeMenu.getItems().add(lookupURLs); changeMenu.getItems().add(new SeparatorMenuItem()); changeMenu.getItems().add(createMenuItem("Prepend text to all notes", action -> { List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems()); Optional<String> result = askUserForTextField( "Enter tags to prepend to notes in " + changes.size() + " changes:"); if (result.isPresent()) { String tags = result.get().trim(); changes.forEach(ch -> { String prevValue = change.getNote().orElse("").trim(); LOGGER.info("Prepending tags '" + tags + "' to previous value '" + prevValue + "' for change " + ch); ch.noteProperty().set((tags + " " + prevValue).trim()); }); } })); changeMenu.getItems().add(createMenuItem("Append text to all notes", action -> { List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems()); Optional<String> result = askUserForTextField( "Enter tags to append to notes in " + changes.size() + " changes:"); if (result.isPresent()) { String tags = result.get().trim(); changes.forEach(ch -> { String prevValue = ch.getNote().orElse("").trim(); LOGGER.info("Appending tags '" + tags + "' to previous value '" + prevValue + "' for change " + ch); ch.noteProperty().setValue((prevValue + " " + tags).trim()); }); } })); changeMenu.show(datasetView.getScene().getWindow(), event.getScreenX(), event.getScreenY()); }); return row; }); LOGGER.info("setupTableWithChanges() completed"); }
From source file:fr.vdl.android.holocolors.HoloColorsDialog.java
private void openWebpage(String url) { Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try {/*from w ww .j a v a 2 s .c o m*/ desktop.browse(new URL(url).toURI()); } catch (Exception e) { // no matter, nothing to do e.printStackTrace(); } } }
From source file:com.mycompany.trader.LoginUI.java
private void resetLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_resetLabelMouseClicked // TODO add your handling code here: try {// ww w.j ava 2 s. c o m Desktop.getDesktop() .browse(new URL("http://104.155.25.165:8080/services/forgot_password.html").toURI()); } catch (Exception e) { e.printStackTrace(); } }
From source file:gdt.jgui.entity.webset.JWebsetFacetOpenItem.java
/** * Get the popup menu for the child node of the facet node * in the digest view.//from w w w . j av a 2 s.c o 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("JWebsetFacetOpenItem: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("JWebsetFacetOpenItem:open:selection="+selection$); locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); String type$ = locator.getProperty(Locator.LOCATOR_TYPE); if (LOCATOR_TYPE_WEB_ADDRESS.equals(type$)) { try { String url$ = locator.getProperty(JWeblinksPanel.WEB_LINK_URL); // System.out.println("weblinkEditor:browseUrl:url="+url$); Desktop.getDesktop().browse(new URI(url$)); } catch (Exception ee) { Logger.getLogger(JFileOpenItem.class.getName()).info(ee.toString()); } return; } if (JEntityDigestDisplay.LOCATOR_FACET_COMPONENT.equals(type$)) { // String entityKey$=locator.getProperty(EntityHandler.ENTITY_KEY); JWeblinkEditor we = new JWeblinkEditor(); String weLocator$ = we.getLocator(); weLocator$ = Locator.append(weLocator$, Entigrator.ENTIHOME, entihome$); weLocator$ = Locator.append(weLocator$, EntityHandler.ENTITY_KEY, entityKey$); //JConsoleHandler.execute(console,beLocator$); return; } String weblinkKey$ = locator.getProperty(JWeblinksPanel.WEB_LINK_KEY); JWeblinkEditor we = new JWeblinkEditor(); String weLocator$ = we.getLocator(); weLocator$ = Locator.append(weLocator$, Entigrator.ENTIHOME, entihome$); weLocator$ = Locator.append(weLocator$, EntityHandler.ENTITY_KEY, entityKey$); weLocator$ = Locator.append(weLocator$, JWeblinksPanel.WEB_LINK_KEY, weblinkKey$); /* Entigrator entigrator=console.getEntigrator(entihome$); String componentKey$=locator.getProperty(JEntityDigestDisplay.COMPONENT_KEY); Sack entity=entigrator.getEntityAtKey(componentKey$); Core weblink=entity.getElementItem("web", weblinkKey$); */ // System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$); JConsoleHandler.execute(console, weLocator$); } catch (Exception ee) { Logger.getLogger(JWebsetFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:pcgen.gui2.dialog.ExportDialog.java
private void maybeOpenFile(File file) { UIPropertyContext context = UIPropertyContext.getInstance(); String value = context.getProperty(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE); Boolean openFile = StringUtils.isEmpty(value) ? null : Boolean.valueOf(value); if (openFile == null) { JCheckBox checkbox = new JCheckBox(); checkbox.setText("Always perform this action"); JPanel message = PCGenFrame.buildMessageLabelPanel("Do you want to open " + file.getName() + "?", checkbox);//from w w w.j a va2 s.co m int ret = JOptionPane.showConfirmDialog(this, message, "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.CLOSED_OPTION) { return; } openFile = BooleanUtils.toBoolean(ret, JOptionPane.YES_OPTION, JOptionPane.NO_OPTION); if (checkbox.isSelected()) { context.setBoolean(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE, openFile); } } if (!openFile) { return; } if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { pcgenFrame.showErrorMessage("Cannot Open " + file.getName(), "Operating System does not support this operation"); return; } try { Desktop.getDesktop().open(file); } catch (IOException ex) { String message = "Failed to open " + file.getName(); pcgenFrame.showErrorMessage(Constants.APPLICATION_NAME, message); Logging.errorPrint(message, ex); } }
From source file:esmska.gui.AboutFrame.java
private void creditsButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_creditsButtonActionPerformed //show credits try {/*from www . j a v a2 s .c o m*/ logger.fine("Showing credits..."); String credits = IOUtils.toString(getClass().getResourceAsStream(RES + "credits.html"), "UTF-8"); String translators = l10n.getString("Translators"); if ("translator-credits".equals(translators)) { //there are no translators mentioned translators = ""; } else { translators = translators.replaceAll("\n", "<br>\n").replaceAll("\n ", "\n "); //add hyperlinks to the Launchpad URLs translators = translators.replaceAll("(https://[^<]*)", "<a href=\"$1\">$1</a>"); } String document = MessageFormat.format(credits, l10n.getString("Credits.authors"), l10n.getString("Credits.contributors"), l10n.getString("Credits.graphics"), l10n.getString("Credits.sponsors"), l10n.getString("Credits.translators"), translators, Links.DONATORS, l10n.getString("Credits.moreDonators"), MessageFormat.format(l10n.getString("Credits.packagers"), Links.DOWNLOAD)); JTextPane tp = new JTextPane(); tp.setContentType("text/html; charset=UTF-8"); tp.setText(document); tp.setEditable(false); tp.setPreferredSize(new Dimension(450, 400)); tp.setCaretPosition(0); //make links clickable tp.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { logger.fine("Browsing URL: " + e.getURL()); Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { logger.log(Level.SEVERE, "Can't browse hyperlink: " + e.getURL(), ex); } } } }); String option = l10n.getString("AboutFrame.Thank_you"); JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option); JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.Credits")); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { logger.log(Level.WARNING, "Could not show credits", e); } }
From source file:com.versul.main.MainClass.java
private ComponentBuilder<?, ?> createTitleComponent(String label) throws MalformedURLException { URL logo = new URL("http://static-files04.cdnandroid.com/76/43/3e/08/imagen-rotativo-rondon-0thumb.jpg"); String urlOperacao = "https://rondonopolis.s2way.com/"; HyperLinkBuilder link = hyperLink(urlOperacao); JRHyperlinkListener a = new JRHyperlinkListener() { @Override/* w w w .jav a2 s. c o m*/ public void gotoHyperlink(JRPrintHyperlink jrph) throws JRException { try { Desktop.getDesktop().browse(new URI(jrph.getHyperlinkAnchor())); } catch (Exception ex) { // Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex); } } }; ComponentBuilder<?, ?> dynamicReportsComponent = cmp.horizontalList( cmp.text(reportTitle).setStyle(templateDefault.bold22CenteredStyle) .setHorizontalAlignment(HorizontalAlignment.LEFT), cmp.text("Total Records: " + totalRows).setStyle(templateDefault.testecapiroto) // cmp.verticalList( // )).setFixedWidth(300) ); return cmp.horizontalList().add(dynamicReportsComponent).newRow().add(cmp.line()).newRow() .add(cmp.verticalGap(10)); // ComponentBuilder<?, ?> dynamicReportsComponent // = cmp.horizontalList( // cmp.image(logo).setFixedDimension(60, 60), // cmp.verticalList( //// cmp.text("s2Way - Rotativo Rondon").setStyle(templateDefault.bold22CenteredStyle).setHorizontalAlignment(HorizontalAlignment.LEFT), // cmp.text("s2Way - Rotativo Rondon").setStyle(templateDefault.bold22CenteredStyle).setHorizontalAlignment(HorizontalAlignment.LEFT), // cmp.text(urlOperacao).setStyle(templateDefault.italicStyle).setHyperLink(link))).setFixedWidth(300); // // return cmp.horizontalList() // .add( // dynamicReportsComponent, // cmp.text(label).setStyle(templateDefault.bold18CenteredStyle).setHorizontalAlignment(HorizontalAlignment.RIGHT)) // .newRow() // .add(cmp.line()) // .newRow() // .add(cmp.verticalGap(10)); }