Exemple #1
0
 public static void showURL(String href) {
   try {
     HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault();
     if (displayer != null) {
       displayer.showURL(new URL(href));
     }
   } catch (Exception e) {
   }
 }
 @Override
 public void mouseClicked(MouseEvent e) {
   JTable table = (JTable) e.getSource();
   Point point = e.getPoint();
   int clickedRow = table.rowAtPoint(point);
   int clickedCol = table.columnAtPoint(point);
   if ((clickedCol == -1) || (clickedRow == -1)) {
     return;
   }
   if (table.getValueAt(clickedRow, clickedCol) instanceof StringUrl) {
     // retrieve the link to go to
     String sUrl = ((StringUrl) table.getValueAt(clickedRow, clickedCol)).getUrl();
     URL url;
     try {
       url = new URL(sUrl);
       log.debug("showing url for " + url);
       HtmlBrowser.URLDisplayer.getDefault().showURL(url);
       // prevent this from getting called again as it works it's way up the component stack
       e.consume();
     } catch (MalformedURLException ex) {
       StatusBar.getInstance()
           .setStatusText("\"" + sUrl + "\" is not a valid URL. Cannot open in browser.");
       log.warn(
           "\""
               + sUrl
               + "\" is not a valid URL. Cannot open in browser.\n\n"
               + ex.getLocalizedMessage());
     }
   }
 }
 @NbBundle.Messages("AddPluignsPanel.invalid.plugin.url=Plugin url is invalid.")
 private void availablePluginsListMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_availablePluginsListMouseClicked
   int clickCount = evt.getClickCount();
   if (clickCount == 1) {
     changePlugin();
   } else if (clickCount == 2) {
     int selectedIndex = availablePluginsList.getSelectedIndex();
     VagrantPluginItem item = filteredPlugins.get(selectedIndex);
     try {
       HtmlBrowser.URLDisplayer.getDefault().showURL(new URL(item.getUrl())); // NOI18N
     } catch (MalformedURLException ex) {
       VagrantUtils.showWarnigDialog(Bundle.AddPluignsPanel_invalid_plugin_url());
     }
   }
 } // GEN-LAST:event_availablePluginsListMouseClicked