Example usage for java.awt Desktop isSupported

List of usage examples for java.awt Desktop isSupported

Introduction

In this page you can find the example usage for java.awt Desktop isSupported.

Prototype

public boolean isSupported(Action action) 

Source Link

Document

Tests whether an action is supported on the current platform.

Usage

From source file:com.fratello.longevity.smooth.AppGUI.java

private void openWebPage(String urlName) {
    try {// w  w w.jav a2 s.  c  om
        URL u = new URL(urlName);
        Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
        if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
            desktop.browse(u.toURI());
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e2) {
        e2.printStackTrace();
    }
}

From source file:com.codejumble.opentube.Main.java

/**
 * Opens http://www.codejumble.com at System's default browser
 *
 * @param evt Swing event/*  ww w  . j  a  va  2  s  .co m*/
 */
private void helpPagesItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpPagesItemActionPerformed
    try {
        URI uri = new URL("http://www.codejumble.com").toURI();
        Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
        if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
            try {
                desktop.browse(uri);
            } catch (Exception e) {
                createErrorDialog(this, e.getMessage(), "Error!");
            }
        }
    } catch (Exception ex) {
        createErrorDialog(this, ex.getMessage(), "Unexpected error");
    }
}

From source file:org.interreg.docexplore.authoring.AuthoringMenu.java

public AuthoringMenu(final AuthoringToolFrame authoringTool) {
    this.tool = authoringTool;

    this.recent = new LinkedList<String>();
    readRecent();/*from   w w  w.  j a  va2 s  .com*/
    this.file = new JMenu(XMLResourceBundle.getBundledString("generalMenuFile"));
    add(file);

    newItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuNew")) {
        public void actionPerformed(ActionEvent arg0) {
            newFile();
        }
    });
    loadItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuLoad")) {
        public void actionPerformed(ActionEvent arg0) {
            load();
        }
    });
    saveItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSave")) {
        public void actionPerformed(ActionEvent arg0) {
            save();
        }
    });
    saveAsItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSaveAs")) {
        public void actionPerformed(ActionEvent arg0) {
            saveAs();
        }
    });
    exportItem = new JMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("generalMenuExport") + "...") {
                public void actionPerformed(ActionEvent arg0) {
                    GuiUtils.blockUntilComplete(new ProgressRunnable() {
                        public void run() {
                            try {
                                authoringTool.readerExporter.doExport(authoringTool.editor.link);
                            } catch (Exception ex) {
                                ErrorHandler.defaultHandler.submit(ex);
                            }
                        }

                        public float getProgress() {
                            return (float) authoringTool.readerExporter.progress[0];
                        }
                    }, authoringTool.editor);
                }
            });
    webExportItem = new JMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("generalMenuWebExport") + "...") {
                public void actionPerformed(ActionEvent arg0) {
                    GuiUtils.blockUntilComplete(new ProgressRunnable() {
                        public void run() {
                            try {
                                authoringTool.webExporter.doExport(authoringTool.editor.link);
                            } catch (Exception ex) {
                                ErrorHandler.defaultHandler.submit(ex);
                            }
                        }

                        public float getProgress() {
                            return (authoringTool.webExporter.copyComplete ? .5f : 0f)
                                    + (float) (.5 * authoringTool.webExporter.progress[0]);
                        }
                    }, authoringTool.editor);
                }
            });
    //      webExportItem = new JMenuItem(new AbstractAction("Web export") {public void actionPerformed(ActionEvent arg0)
    //      {
    //         GuiUtils.blockUntilComplete(new Runnable() {public void run()
    //         {
    //            try 
    //            {
    //               new WebStaticExporter().doExport(authoringTool.editor.link.getBook(authoringTool.editor.link.getLink().getAllBookIds().get(0)));
    //            }
    //            catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex);}
    //         }}, authoringTool.editor);
    //      }});
    //      webExportItem.setEnabled(false);
    quitItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuQuit")) {
        public void actionPerformed(ActionEvent arg0) {
            authoringTool.quit();
        }
    });
    buildFileMenu();

    JMenu edit = new JMenu(XMLResourceBundle.getBundledString("generalMenuEdit"));
    this.undoItem = new JMenuItem();
    undoItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                authoringTool.historyManager.undo();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    });
    edit.add(undoItem);
    this.redoItem = new JMenuItem();
    redoItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                authoringTool.historyManager.redo();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    });
    edit.add(redoItem);
    JMenuItem viewHistory = new JMenuItem(XMLResourceBundle.getBundledString("generalMenuEditViewHistory"));
    viewHistory.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            authoringTool.historyDialog.setVisible(true);
        }
    });
    edit.add(viewHistory);

    edit.addSeparator();

    edit.add(new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("fixChars")) {
        public void actionPerformed(ActionEvent arg0) {
            Object res = JOptionPane.showInputDialog(tool, XMLResourceBundle.getBundledString("fixCharsMsg"),
                    XMLResourceBundle.getBundledString("fixChars"), JOptionPane.QUESTION_MESSAGE, null,
                    new Object[] { XMLResourceBundle.getBundledString("fixCharsWin"),
                            XMLResourceBundle.getBundledString("fixCharsMac") },
                    XMLResourceBundle.getBundledString("fixCharsWin"));
            if (res == null)
                return;
            try {
                convertPresentation(tool.defaultFile,
                        res.equals(XMLResourceBundle.getBundledString("fixCharsWin")) ? "ISO-8859-1"
                                : "x-MacRoman");
            } catch (Exception e) {
                ErrorHandler.defaultHandler.submit(e);
            }
            try {
                tool.editor.reset();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }));

    //TODO: remove!
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               if (regions.size() > 2)
    //               {
    //                  Region highest = null;
    //                  int max = -1;
    //                  for (Region region : regions)
    //                     for (Point point : region.getOutline())
    //                        if (max < 0 || point.y < max)
    //                           {max = point.y; highest = region;}
    //                  Region middle = null;
    //                  max = -1;
    //                  for (Region region : regions)
    //                     if (region != highest)
    //                        for (Point point : region.getOutline())
    //                           if (max < 0 || point.y < max)
    //                              {max = point.y; middle = region;}
    //                  if (regions.size() > 3)
    //                  {
    //                     max = -1;
    //                     Region newMiddle = null;
    //                     for (Region region : regions)
    //                        if (region != highest && region != middle)
    //                           for (Point point : region.getOutline())
    //                              if (max < 0 || point.y < max)
    //                                 {max = point.y; newMiddle = region;}
    //                     middle = newMiddle;
    //                  }
    //                  MetaDataKey display = book.getLink().getKey("display", "");
    //                  for (Map.Entry<MetaDataKey, List<MetaData>> entry : highest.getMetaData().entrySet())
    //                     for (MetaData md : entry.getValue())
    //                        if (md.getType().equals(MetaData.textType))
    //                        {
    //                           String val = "<b>"+md.getString()+"</b>\n";
    //                           for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet())
    //                              for (MetaData md2 : entry2.getValue())
    //                                 if (md2.getType().equals(MetaData.textType) && TextElement.getStyle(md, tool.styleManager) == TextElement.getStyle(md2, tool.styleManager))
    //                                    val = val+"\n"+md2.getString();
    //                           md.setString(val);
    //                        }
    //                  boolean hasImage = false;
    //                  for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet())
    //                     for (MetaData md2 : entry2.getValue())
    //                        if (md2.getType().equals(MetaData.imageType))
    //                        {
    //                           MetaData imageMd = new MetaData(book.getLink(), display, md2.getType(), md2.getValue());
    //                           if (!hasImage)
    //                              BookImporter.insert(imageMd, highest, 0);
    //                           else BookImporter.insert(imageMd, highest, BookImporter.getHighestRank(highest)+1);
    //                           hasImage = true;
    //                        }
    //                  page.removeRegion(middle);
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            MetaDataKey display = book.getLink().getKey("display", "");
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               for (Region region : regions)
    //               {
    //                  List<MetaData> mds = region.getMetaDataListForKey(display);
    //                     for (MetaData md : mds)
    //                        if (md.getType().equals(MetaData.textType))
    //                        {
    //                           String val = md.getString().trim();
    //                           if (!val.startsWith("<i>") || !val.endsWith("</i>"))
    //                              continue;
    //                           TextElement.getStyleMD(md).setString("4");
    //                           md.setString(val.substring(3, val.length()-4));
    //                           System.out.println(md.getString());
    //                        }
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            MetaDataKey display = book.getLink().getKey("display", "");
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               for (Region region : regions)
    //               {
    //                  int max = BookImporter.getHighestRank(region);
    //                  for (int i=0;i<max;i++)
    //                  {
    //                     MetaData md1 = BookImporter.getAtRank(region, i);
    //                     if (md1 == null || !md1.getType().equals(MetaData.textType))
    //                        continue;
    //                     MetaData style1 = TextElement.getStyleMD(md1);
    //                     if (!style1.getString().equals("0"))
    //                        continue;
    //                     MetaData md2 = BookImporter.getAtRank(region, i+1);
    //                     if (md2 == null || !md2.getType().equals(MetaData.textType))
    //                        continue;
    //                     MetaData style2 = TextElement.getStyleMD(md2);
    //                     if (!style2.getString().equals("1"))
    //                        continue;
    //                     BookImporter.setRank(md1, i+1);
    //                     BookImporter.setRank(md2, i);
    //                     i++;
    //                  }
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            MetaDataKey mini = book.getLink().getOrCreateKey("mini", "");
    //            MetaDataKey dim = book.getLink().getOrCreateKey("dimension", "");
    //            int lastPage = book.getLastPageNumber();
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               List<MetaData> mds = page.getMetaDataListForKey(mini);
    //               if (mds != null)
    //                  for (MetaData md : mds)
    //                     page.removeMetaData(md);
    //               mds = page.getMetaDataListForKey(dim);
    //               if (mds != null)
    //                  for (MetaData md : mds)
    //                     page.removeMetaData(md);
    //               DocExploreDataLink.getImageDimension(page, true);
    //               DocExploreDataLink.getImageMini(page, false);
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));

    add(edit);

    JMenu view = new JMenu(XMLResourceBundle.getBundledString("generalMenuView"));
    add(view);

    JMenuItem styles = new JMenuItem(XMLResourceBundle.getBundledString("styleEdit") + "...",
            ImageUtils.getIcon("pencil-24x24.png"));
    styles.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            authoringTool.styleManager.styleDialog.setVisible(true);
        }
    });
    view.add(styles);

    helpToggle = new JCheckBoxMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("viewHelpToggle")) {
                public void actionPerformed(ActionEvent arg0) {
                    authoringTool.displayHelp = helpToggle.isSelected();
                    authoringTool.repaint();
                }
            });
    helpToggle.setSelected(tool.startup.showHelp);
    view.add(helpToggle);

    JMenu helpMenu = new JMenu(XMLResourceBundle.getString("management-lrb", "generalMenuHelp"));
    if (Desktop.isDesktopSupported()) {
        final Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            helpMenu.add(new AbstractAction(
                    XMLResourceBundle.getString("management-lrb", "generalMenuHelpContents")) {
                public void actionPerformed(ActionEvent e) {
                    try {
                        File doc = new File(DocExploreTool.getExecutableDir(), "MMT documentation.htm");
                        desktop.open(doc);
                    } catch (Exception ex) {
                        ErrorHandler.defaultHandler.submit(ex, true);
                    }
                }
            });
            helpMenu.add(new AbstractAction(
                    XMLResourceBundle.getString("management-lrb", "generalMenuHelpWebsite")) {
                public void actionPerformed(ActionEvent e) {
                    try {
                        File link = new File(DocExploreTool.getExecutableDir(), "website.url");
                        desktop.open(link);
                    } catch (Exception ex) {
                        ErrorHandler.defaultHandler.submit(ex, true);
                    }
                }
            });
        }
    }
    helpMenu.add(new AbstractAction(XMLResourceBundle.getString("management-lrb", "generalMenuHelpAbout")) {
        public void actionPerformed(ActionEvent e) {
            final JDialog splash = new JDialog(tool, true);
            splash.setLayout(new BorderLayout());
            SplashScreen screen = new SplashScreen("logoAT.png");
            splash.add(screen, BorderLayout.NORTH);
            screen.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    splash.setVisible(false);
                }
            });
            splash.setUndecorated(true);
            screen.setText(
                    "<html>DocExplore 2009-2014" + "<br/>Released under the CeCILL v2.1 license" + "</html>");
            splash.pack();
            splash.setAlwaysOnTop(true);
            GuiUtils.centerOnScreen(splash);
            splash.setVisible(true);
        }
    });
    add(helpMenu);

    historyChanged(authoringTool.historyManager);
    authoringTool.historyManager.addHistoryListener(this);
}

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 v a  2s . c o m*/
        }
    }
}

From source file:convcao.com.agent.ConvcaoNeptusInteraction.java

private void jLabel1MouseClicked(MouseEvent evt) throws URISyntaxException, IOException {
    if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();

        if (desktop.isSupported(Desktop.Action.BROWSE)) {
            URI uri = new URI("http://www.noptilus-fp7.eu/default.asp?node=page&id=321&lng=2");
            desktop.browse(uri);/*from   www .  j  a va2s.c  o m*/
        }
    }
}

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 www .j a v a 2 s.  co m*/
        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: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  w ww .j a  va2 s.c o  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:xtrememp.XtremeMP.java

@Override
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == openMenuItem) {
        playlistManager.addFilesDialog(true);
    } else if (source == openURLMenuItem) {
        String url = JOptionPane.showInputDialog(mainFrame, tr("Dialog.OpenURL.Message"), tr("Dialog.OpenURL"),
                JOptionPane.INFORMATION_MESSAGE);
        if (url != null && Utilities.startWithProtocol(url)) {
            boolean isPlaylistFile = false;
            for (String ext : PlaylistFileFilter.PlaylistFileExt) {
                if (url.endsWith(ext)) {
                    isPlaylistFile = true;
                }/*from w w  w .ja  v  a  2  s  .  co  m*/
            }
            if (isPlaylistFile) {
                playlistManager.clearPlaylist();
                playlistManager.loadPlaylist(url);
                playlist.begin();
            } else {
                PlaylistItem newPli = new PlaylistItem(url, url, -1, false);
                playlistManager.add(newPli);
                playlist.setCursor(newPli);
            }
            acOpenAndPlay();
        }
    } else if (source == openPlaylistMenuItem) {
        playlistManager.openPlaylistDialog();
    } else if (source == savePlaylistMenuItem) {
        playlistManager.savePlaylistDialog();
    } else if (source == preferencesMenuItem) {
        PreferencesDialog preferencesDialog = new PreferencesDialog(audioPlayer, this);
        preferencesDialog.setVisible(true);
    } else if (source == exitMenuItem) {
        exit();
    } else if (source == playPauseMenuItem || source == playPauseButton) {
        acPlayPause();
    } else if (source == previousMenuItem || source == previousButton) {
        acPrevious();
    } else if (source == nextMenuItem || source == nextButton) {
        acNext();
    } else if (source == randomizePlaylistMenuItem) {
        playlistManager.randomizePlaylist();
    } else if (source == stopMenuItem || source == stopButton) {
        acStop();
    } else if (source == playlistManagerMenuItem) {
        if (visualizationManager.isVisible()) {
            visualizationManager.setDssEnabled(false);
            CardLayout cardLayout = (CardLayout) (mainPanel.getLayout());
            cardLayout.show(mainPanel, Utilities.PLAYLIST_MANAGER);
            playlistManagerMenuItem.setSelected(true);
            Settings.setLastView(Utilities.PLAYLIST_MANAGER);
        }
    } else if (source == visualizationMenuItem) {
        if (playlistManager.isVisible()) {
            visualizationManager.setDssEnabled(true);
            CardLayout cardLayout = (CardLayout) (mainPanel.getLayout());
            cardLayout.show(mainPanel, Utilities.VISUALIZATION_PANEL);
            visualizationMenuItem.setSelected(true);
            Settings.setLastView(Utilities.VISUALIZATION_PANEL);
        }
    } else if (source == updateMenuItem) {
        SoftwareUpdate.checkForUpdates(true);
        SoftwareUpdate.showCheckForUpdatesDialog();
    } else if (source == aboutMenuItem) {
        Object[] options = { tr("Button.Close") };
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.BROWSE)) {
                options = new Object[] { tr("Button.Close"), tr("Button.Website") };
            }
        }
        StringBuffer message = new StringBuffer();
        message.append("<html><b><font color='red' size='5'>").append(tr("Application.title"));
        message.append("</font></b><br>").append(tr("Application.description"));
        message.append("<br>Copyright  2005-2014 The Xtreme Media Player Project");
        message.append("<br><br><b>").append(tr("Dialog.About.Authors")).append(": </b>")
                .append(tr("Application.authors"));
        message.append("<br><b>").append(tr("Dialog.About.Version")).append(": </b>").append(currentVersion);
        message.append("<br><b>").append(tr("Dialog.About.Codename")).append(": </b>")
                .append(currentVersion.getCodename());
        message.append("<br><b>").append(tr("Dialog.About.ReleaseDate")).append(": </b>")
                .append(currentVersion.getReleaseDate());
        message.append("<br><b>").append(tr("Dialog.About.Homepage")).append(": </b>")
                .append(tr("Application.homepage"));
        message.append("<br><br><b>").append(tr("Dialog.About.JavaVersion")).append(": </b>")
                .append(System.getProperty("java.version"));
        message.append("<br><b>").append(tr("Dialog.About.JavaVendor")).append(": </b>")
                .append(System.getProperty("java.vendor"));
        message.append("<br><b>").append(tr("Dialog.About.JavaHome")).append(": </b>")
                .append(System.getProperty("java.home"));
        message.append("<br><b>").append(tr("Dialog.About.OSName")).append(": </b>")
                .append(System.getProperty("os.name"));
        message.append("<br><b>").append(tr("Dialog.About.OSArch")).append(": </b>")
                .append(System.getProperty("os.arch"));
        message.append("<br><b>").append(tr("Dialog.About.UserName")).append(": </b>")
                .append(System.getProperty("user.name"));
        message.append("<br><b>").append(tr("Dialog.About.UserHome")).append(": </b>")
                .append(System.getProperty("user.home"));
        message.append("<br><b>").append(tr("Dialog.About.UserDir")).append(": </b>")
                .append(System.getProperty("user.dir"));
        message.append("</html>");
        int n = JOptionPane.showOptionDialog(mainFrame, message, tr("Dialog.About"),
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, Utilities.APP_256_ICON, options,
                options[0]);
        if (n == 1 && desktop != null) {
            try {
                URL url = new URL(tr("Application.homepage"));
                desktop.browse(url.toURI());
            } catch (IOException | URISyntaxException ex) {
                logger.error(ex.getMessage(), ex);
            }
        }
    } else if (source.equals(playModeRepeatNoneMenuItem)) {
        playlist.setPlayMode(Playlist.PlayMode.REPEAT_NONE);
    } else if (source.equals(playModeRepeatOneMenuItem)) {
        playlist.setPlayMode(Playlist.PlayMode.REPEAT_ONE);
    } else if (source.equals(playModeRepeatAllMenuItem)) {
        playlist.setPlayMode(Playlist.PlayMode.REPEAT_ALL);
    } else if (source.equals(playModeShuffleMenuItem)) {
        playlist.setPlayMode(Playlist.PlayMode.SHUFFLE);
    }
}

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 w  w.j  av a2s  .com

    // 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.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);/*w  w w . j  a v a2s.  c  o  m*/
            } catch (IOException | URISyntaxException ex) {
                LOG.error(ex.getLocalizedMessage());
            }
        }
    } else {
        //open popup with link
        JOptionPane.showMessageDialog(this, i18n.msg("goto") + url);
    }
}