List of usage examples for java.awt Desktop browse
public void browse(URI uri) throws IOException
From source file:convcao.com.caoAgent.convcaoNeptusInteraction.java
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) throws URISyntaxException, IOException { if (java.awt.Desktop.isDesktopSupported()) { java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { java.net.URI uri = new java.net.URI( "http://www.noptilus-fp7.eu/default.asp?node=page&id=321&lng=2"); desktop.browse(uri); }/* w w w . j a va 2s . com*/ } }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MITable.java
public MITable(MITableModel model, IgbService service, final MIQuery query) { super(model); this.query = query; igbLogger = IGBLogger.getInstance(query.getLabel()); this.igbService = service; this.SymSelectionListener = new MouseListener() { @SuppressWarnings("unchecked") @Override//from w w w . jav a 2 s.c om public void mouseClicked(MouseEvent e) { if (e.getComponent().isEnabled() && e.getButton() == MouseEvent.BUTTON1) { if (getSelectedRow() >= 0) { int modelRow = convertRowIndexToModel(getSelectedRow()); MIResult interaction = ((MITableModel) getModel()).getResult(modelRow); structuresPanel.setCurrentInteraction(interaction); } MITable table = (MITable) e.getComponent(); int modelRow = convertRowIndexToModel(table.getSelectedRow()); int column = table.getSelectedColumn(); if (e.getClickCount() == 1) { if (column == MITableModel.TRACK_COLUMN) { Object value = table.getValueAt(table.getSelectedRow(), column); if (value instanceof JButton) { MIResult result = ((MITableModel) table.getModel()).getResult(modelRow); TypeContainerAnnot interactorTrack = result.createTrack(); igbService.addTrack(interactorTrack, interactorTrack.getID()); igbService.getSeqMapView().updatePanel(); for (TierGlyph t : igbService.getAllTierGlyphs()) { if (TierGlyph.TierType.ANNOTATION.equals(t.getTierType()) && (t.getAnnotStyle().getTrackName().equals(interactorTrack.getID()))) { SimpleTrackStyle style = new SimpleTrackStyle(interactorTrack.getID(), false) { @Override public boolean drawCollapseControl() { return false; } }; t.getAnnotStyle().copyPropertiesFrom(style); t.getAnnotStyle().setColorProvider(new RGB()); interactorTrack.setProperty(TrackLineParser.ITEM_RGB, "on"); } } igbService.getSeqMapView().updatePanel(); ((JButton) value).setText(interactorTrack.getID()); ((JButton) value).setEnabled(false); updateUI(); } } } else { // symmetry: zoom-in if (column == MITableModel.SYMS1_COLUMN) { MoleculeEntry entry = ((MITableModel) table.getModel()).getResult(modelRow) .getInteractor1(); if (query.getTaxid().equals(entry.getTaxid())) { Collection<SeqSymmetry> syms = ((MITableModel) table.getModel()).getResult(modelRow) .getSymmetries1(); zoomToSym(syms); } } else if (column == MITableModel.SYMS2_COLUMN) { MoleculeEntry entry = ((MITableModel) table.getModel()).getResult(modelRow) .getInteractor2(); if (query.getTaxid().equals(entry.getTaxid())) { Collection<SeqSymmetry> syms = ((MITableModel) table.getModel()).getResult(modelRow) .getSymmetries2(); zoomToSym(syms); } } // Protein: link to uniprot if (column == MITableModel.INTERACTOR1_COLUMN || column == MITableModel.INTERACTOR2_COLUMN) { MIResult miResult = ((MITableModel) table.getModel()).getResult(modelRow); String id; String taxid; MoleculeEntry interactor; if (column == MITableModel.INTERACTOR1_COLUMN) { interactor = miResult.getInteractor1(); } else { interactor = miResult.getInteractor2(); } taxid = interactor.getTaxid(); String query; String anchor = ""; switch (taxid) { case MoleculeEntry.TAXID_DNA: case MoleculeEntry.TAXID_RNA: if (miResult.getInteractionStructures().isEmpty()) { return; } query = "http://www.pdb.org/pdb/explore/explore.do?structureId=" + miResult.getInteractionStructures().iterator().next().getStructureID(); break; case MoleculeEntry.TAXID_LIGAND: if (miResult.getInteractionStructures().isEmpty()) { return; } query = DrugBankMapper.getInstance().isDrug(interactor.getGeneName()) ? DrugBankMapper.getInstance().getDrugBankLink(interactor.getGeneName()) : "http://www.ebi.ac.uk/pdbe-srv/pdbechem/chemicalCompound/show/" + interactor.getGeneName(); break; case MoleculeEntry.TAXID_MODIFICATION: query = "http://www.uniprot.org/uniprot/" + miResult.getInteractor1().getUniprotAc(); anchor = "#ptm_processing"; break; default: id = interactor.getUniprotAc(); query = "http://www.uniprot.org/uniprot/" + id; break; } try { URI uri = new URI(URIUtil.encodeQuery(query) + anchor); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(uri); } } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Cannot reach Uniprot website."); return; } catch (URISyntaxException ue) { JOptionPane.showMessageDialog(null, "Cannot reach Uniprot website: " + query); } } // interaction type: link to psicquic if (column == MITableModel.INTERACTION_TYPE_COLUMN) { MIResult miResult = ((MITableModel) table.getModel()).getResult(modelRow); String queryURL; String idA = miResult.getInteractor1().getUniprotAc(); String idB = miResult.getInteractor2().getUniprotAc(); if (null == miResult.getPsicquicUrl()) { // from the structure database if (query.searchDSysMap()) { queryURL = "http://http://dsysmap.irbbarcelona.org/results.php?type=proteins&neigh=2&value=" + idA + "," + idB; } else if (query.searchInteractome3D()) { try { queryURL = "http://interactome3d.irbbarcelona.org/interaction.php?ids=" + idA + ";" + idB + "&dataset=" + it.iit.genomics.cru.bridges.interactome3d.ws.Utils .getDataset(query.getTaxid()); } catch (Interactome3DException e3d) { // it will never happend: if the taxid was not known by // I3D, we wouldn't have an interaction return; } } else { return; } } else { if (false == idA.equals(idB)) { queryURL = miResult.getPsicquicUrl() + "query/id:" + miResult.getInteractor1().getUniprotAc() + "* AND id:" + miResult.getInteractor2().getUniprotAc() + "*"; } else { queryURL = miResult.getPsicquicUrl() + "query/idA:" + miResult.getInteractor1().getUniprotAc() + "* AND idB:" + miResult.getInteractor2().getUniprotAc() + "*"; } } try { URI uri = new URI(URIUtil.encodeQuery(queryURL)); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(uri); } } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Cannot reach psicquic server."); } catch (URISyntaxException ue) { JOptionPane.showMessageDialog(null, "Cannot reach psicquic server: " + queryURL); } } } } } @Override public void mousePressed(MouseEvent me) { } @Override public void mouseReleased(MouseEvent me) { } @Override public void mouseEntered(MouseEvent me) { } @Override public void mouseExited(MouseEvent me) { } }; TableRowSorter<MITableModel> sorter = new MITableRowSorter(model); setRowSorter(sorter); sorter.setRowFilter(evidenceRowFilter()); model.fireTableDataChanged(); this.getTableHeader().setReorderingAllowed(false); TableCellRenderer rend = getTableHeader().getDefaultRenderer(); TableColumnModel tcm = getColumnModel(); for (int j = 0; j < tcm.getColumnCount(); j += 1) { TableColumn tc = tcm.getColumn(j); TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null if (rendCol == null) { rendCol = rend; } Component c = rendCol.getTableCellRendererComponent(this, tc.getHeaderValue(), false, false, 0, j); tc.setPreferredWidth(c.getPreferredSize().width); } TableCellRenderer buttonRenderer = new JTableButtonRenderer(); getColumn(model.getColumnName(MITableModel.TRACK_COLUMN)).setCellRenderer(buttonRenderer); getColumn(model.getColumnName(MITableModel.SYMS1_COLUMN)).setCellRenderer(new GeneRenderer()); getColumn(model.getColumnName(MITableModel.SYMS2_COLUMN)).setCellRenderer(new GeneRenderer()); getColumn(model.getColumnName(MITableModel.INTERACTOR1_COLUMN)).setCellRenderer(new MoleculeRenderer()); getColumn(model.getColumnName(MITableModel.INTERACTOR2_COLUMN)).setCellRenderer(new MoleculeRenderer()); getColumn(model.getColumnName(MITableModel.INTERACTION_TYPE_COLUMN)) .setCellRenderer(new EvidenceRenderer()); getColumn(model.getColumnName(MITableModel.STRUCTURES_COLUMN)).setCellRenderer(new StructuresRenderer()); setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); int smallWidth = 75; int mediumWidth = 120; int largeWidth = 200; getColumnModel().getColumn(MITableModel.TRACK_COLUMN).setMinWidth(smallWidth); getColumnModel().getColumn(MITableModel.STRUCTURES_COLUMN).setMinWidth(smallWidth); getColumnModel().getColumn(MITableModel.STRUCTURES_COLUMN).setMaxWidth(smallWidth); getColumnModel().getColumn(MITableModel.STRUCTURES_COLUMN).setPreferredWidth(smallWidth); addMouseListener(SymSelectionListener); getSelectionModel().addListSelectionListener(new RowSelectionListener()); }
From source file:com.opendoorlogistics.studio.AppFrame.java
private SimpleAction initGotoWebsiteAction() { return new SimpleAction("Go to help website", "Go to www.opendoorlogistics for help", "help 16x16.png", "help 32x32.png") { @Override/*w ww. j a v a 2 s .co m*/ public void actionPerformed(ActionEvent e) { if (Desktop.isDesktopSupported() && Desktop.getDesktop() != null) { Desktop desktop = Desktop.getDesktop(); ExecutionReportImpl report = new ExecutionReportImpl(); try { desktop.browse(java.net.URI.create("www.opendoorlogistics.com")); } catch (Exception e2) { report.setFailed(e2); ExecutionReportDialog.show(AppFrame.this, "Failed to open website", report); } } } }; }
From source file:GUI.GraphicalInterface.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; String homepage = "https://sourceforge.net/projects/grafcom/"; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try {//from ww w .j a v a 2s . co m desktop.browse(java.net.URI.create(homepage)); } catch (IOException e) { System.out.println("Error occured while opening Project homepage at SourceForge.net"); } } }
From source file:com.farouk.projectapp.FirstGUI.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed jPanel10.setVisible(true);//from ww w .j a v a 2 s. com StringBuilder temp = new StringBuilder(); int row = jTable2.getSelectedRow(); String name = (jTable2.getModel().getValueAt(row, 0).toString()); for (YahooNews y : YahooNews.getRss(SQLConnect.getSymbolOfCompanyFromDB(name))) { temp.append(y.toString()); } jEditorPane1.setContentType("text/html"); jEditorPane1.setText(temp.toString()); jEditorPane1.setCaretPosition(0); jEditorPane1.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { System.out.println(e.getURL()); Desktop desktop = Desktop.getDesktop(); try { desktop.browse(e.getURL().toURI()); } catch (Exception ex) { System.err.println("Problem in link click.\n" + ex); } } } }); jEditorPane1.setEditable(false); }
From source file:Main.Interface_Main.java
private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed // for copying style JLabel label = new JLabel(); Font font = label.getFont();//from w ww. j a v a2 s . c o m // create some css from the label's font StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";"); style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";"); style.append("font-size:" + font.getSize() + "pt;"); // html content JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" // + "This application was designed by <A HREF=http://www.friedcircuits.us>FriedCircuits</A> for the USB Tester." // + "<br><br><center>App Version: " + appVersion + "<br>FW Version: " + FW_VERSION + "</center><br><br>*Connect once to get FW version.</body></html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); URI uri; try { uri = new java.net.URI("www.friedcircuits.us"); if (desktop.isSupported(Desktop.Action.BROWSE)) { try { desktop.browse(uri); } catch (IOException ex) { Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex); } } } catch (URISyntaxException ex) { Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex); } } // roll your own link launcher or use Desktop if J6+ } }); Color bgColor = label.getBackground(); UIDefaults defaults = new UIDefaults(); defaults.put("EditorPane[Enabled].backgroundPainter", bgColor); ep.putClientProperty("Nimbus.Overrides", defaults); ep.putClientProperty("Nimbus.Overrides.InheritDefaults", true); ep.setEditable(false); ep.setBackground(bgColor); // show ImageIcon myCustomIcon = new ImageIcon(getClass().getResource("/faviconbot2edit.png")); JOptionPane.showMessageDialog(plCurrent, ep, "About", JOptionPane.INFORMATION_MESSAGE, myCustomIcon); }
From source file:com.bibisco.servlet.BibiscoServlet.java
public void openUrlExternalBrowser(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException { mLog.debug("Start openUrlExternalBrowser(HttpServletRequest, HttpServletResponse)"); String lStrUrl = pRequest.getParameter("url"); mLog.debug("url= ", lStrUrl); if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try {/*from w w w .j av a 2 s.c o m*/ desktop.browse(new URI(lStrUrl)); } catch (Exception e) { mLog.error(e); throw new BibiscoException(e, BibiscoException.IO_EXCEPTION); } } else { Runtime runtime = Runtime.getRuntime(); try { runtime.exec("xdg-open " + lStrUrl); } catch (Exception e) { mLog.error(e); throw new BibiscoException(e, BibiscoException.IO_EXCEPTION); } } pResponse.setContentType("text/html; charset=UTF-8"); Writer lWriter = pResponse.getWriter(); lWriter.write("ok"); mLog.debug("End openUrlExternalBrowser(HttpServletRequest, HttpServletResponse)"); }
From source file:com.freedomotic.jfrontend.MainWindow.java
private void mnuTutorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuTutorialActionPerformed String url = "http://freedomotic-user-manual.readthedocs.io/"; if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { try { URI uri = new URI(url); // url is a string containing the URL desktop.browse(uri); } catch (IOException | URISyntaxException ex) { LOG.error(ex.getLocalizedMessage()); }/*from w ww .j av a 2 s .c om*/ } } else { //open popup with link JOptionPane.showMessageDialog(this, i18n.msg("goto") + url); } }
From source file:com.freedomotic.jfrontend.MainWindow.java
/** * /* w w w . ja v a 2 s . c o m*/ */ private void openGoogleForm() {//GEN-FIRST:event_jMenuItem1ActionPerformed // TODO add your handling code here: String url = "https://goo.gl/CC65By"; if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { try { URI uri = new URI(url); // url is a string containing the URL desktop.browse(uri); } catch (IOException | URISyntaxException ex) { LOG.error(ex.getLocalizedMessage()); } } } else { //open popup with link JOptionPane.showMessageDialog(this, i18n.msg("goto") + url); } }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
private void showHelpContent() { try {// www. j a va 2 s . c om URI helpLink = new URI("https://github.com/bigwiv/BlastGraph/blob/master/doc/BlastGraph_Manual.md"); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(helpLink); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }