コード例 #1
0
  /**
   * @param he hiperlik Event.
   * @see
   *     javax.help.plaf.basic.BasicContentViewerUI#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
   */
  @Override
  public void hyperlinkUpdate(final HyperlinkEvent he) {

    if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      URL u = he.getURL();
      if ("mailto".equalsIgnoreCase(u.getProtocol())
          || "http".equalsIgnoreCase(u.getProtocol())
          || "ftp".equalsIgnoreCase(u.getProtocol())) {
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
          desktop = Desktop.getDesktop();
          if (desktop.isSupported(Desktop.Action.BROWSE)) {
            try {
              desktop.browse(u.toURI());
            } catch (MalformedURLException e1) {
              DialogUtils.showGeneralErrorDialog(
                  new Frame(), "MalformedURLException", "Invalid URL.");
            } catch (IOException e1) {
              DialogUtils.showGeneralErrorDialog(new Frame(), "IOException", "Resource not found.");
            } catch (URISyntaxException uriSyntaxEx) {
              DialogUtils.showGeneralErrorDialog(new Frame(), "URISyntaxException", "Invalid URI.");
            }
          }
        }
      } else {
        super.hyperlinkUpdate(he);
      }
    }
  }
コード例 #2
0
 public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
   HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
   final URL url = hyperlinkEvent.getURL();
   //             if (type == HyperlinkEvent.EventType.ENTERED) {
   //               Utility.debugPrintln("patterns","Entered " + url.toString());
   //             } else if (type == HyperlinkEvent.EventType.EXITED) {
   //               Utility.debugPrintln("patterns","Exited");
   //             }
   if (type == HyperlinkEvent.EventType.ACTIVATED) {
     // Utility.debugPrintln("Activated");
     Runnable runner =
         new Runnable() {
           public void run() {
             // Retain reference to original
             Document doc = editorPane.getDocument();
             try {
               editorPane.setPage(url);
             } catch (IOException ioException) {
               JOptionPane.showMessageDialog(
                   frame,
                   "Error following link " + url.toString(),
                   "GIPO Error",
                   JOptionPane.ERROR_MESSAGE);
               editorPane.setDocument(doc);
             }
           }
         };
     SwingUtilities.invokeLater(runner);
   }
 }
コード例 #3
0
 /**
  * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
  */
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == EventType.ACTIVATED) {
     if (e.getSource() == fPaneSelectTimeIntervalOne) {
       handleSelectTimeIntervalOne();
     }
   }
 }
コード例 #4
0
 @Override
 public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
   if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED
       && event.getDescription().equals("saver")) {
     showSavedChanges();
   }
 }
コード例 #5
0
 /**
  * Update the browser links
  *
  * @param event on hyperlink event
  */
 @Override
 public void hyperlinkUpdate(HyperlinkEvent event) {
   if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     if (event.getDescription().startsWith("http://")
         || event.getDescription().startsWith("https://")
         || event.getDescription().startsWith("ftp://")) {
       WebBrowser.openUrl(event.getURL(), event.getDescription());
     } else if (event.getDescription().startsWith(SCILAB_PROTO)) {
       if (helpSets == null) {
         initHelpSets(x.getModel().getHelpSet());
       }
       URL url = resolvScilabLink(event);
       if (url != null) {
         super.hyperlinkUpdate(
             new HyperlinkEvent(event.getSource(), event.getEventType(), url, ""));
       }
     } else if (event.getDescription().startsWith(FILE_PROTO)) {
       String url = event.getDescription();
       url = url.replaceFirst("SCI", Matcher.quoteReplacement(SCI));
       WebBrowser.openUrl(url);
     } else {
       super.hyperlinkUpdate(event);
     }
   }
 }
コード例 #6
0
    @Override
    public void hyperlinkUpdate(@NotNull HyperlinkEvent e) {
      if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
        return;
      }

      String description = e.getDescription();
      if (StringUtil.isEmpty(description)
          || !description.startsWith(DocumentationManager.PSI_ELEMENT_PROTOCOL)) {
        return;
      }

      String elementName =
          e.getDescription().substring(DocumentationManager.PSI_ELEMENT_PROTOCOL.length());

      final PsiElement targetElement =
          myProvider.getDocumentationElementForLink(
              PsiManager.getInstance(myProject), elementName, myContext);
      if (targetElement != null) {
        LightweightHint hint = myHint;
        if (hint != null) {
          hint.hide(true);
        }
        myDocumentationManager.showJavaDocInfo(targetElement, myContext, true, null);
      }
    }
コード例 #7
0
ファイル: JBrowser.java プロジェクト: aliwebir/JBrowser
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
      Tab tabee = tabAccess.get(tab.getSelectedIndex());
      addressBar.setText(e.getURL().toString());
      MyEditorPane pane = new MyEditorPane(addressBar.getText());
      pane.addHyperlinkListener(HYHandler);
      JScrollPane scPane = new JScrollPane(pane);
      tabee.addPane(pane);
      pane.setEditable(false);

      int i = tab.getSelectedIndex();
      tabcreate = false;
      change = false;
      tab.remove(i);
      change = false;
      tabcreate = false;
      tab.insertTab(tabee.getPane().getAddress(), null, scPane, null, i);
      addCloseButton(i, tabee.getPane().getAddress());
      change = false;
      tabcreate = false;
      tab.setSelectedIndex(i);
      change = false;
      tabcreate = false;
      loadPage(pane, tabee.getPane().getAddress());
      tabcreate = true;
    }
コード例 #8
0
 private void _htmlPaneUserFeed_hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
   try {
     if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
       WebBrowser.openURL(hyperlinkEvent.getURL().toString());
     }
   } catch (Exception exception) {
     Debug.displayStack(this, exception);
   }
 }
コード例 #9
0
ファイル: HelpWindow.java プロジェクト: Pitel/dZama
 /*
  * Obsluha kliknuti na odkaz
  *
  * @param event Udalost odkazu
  */
 public void hyperlinkUpdate(HyperlinkEvent event) {
   if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     try {
       htmlPane.setPage(event.getURL());
     } catch (IOException ioe) {
       System.err.println("Page doesn't exist!");
     }
   }
 }
コード例 #10
0
ファイル: Utils.java プロジェクト: CGU-CERTH/BioPAX.Viz
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
  */
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     OpenBrowser openBrowser =
         ServiceController.getInstance()
             .getAdapter()
             .getCyServiceRegistrar()
             .getService(OpenBrowser.class);
     openBrowser.openURL(e.getURL().toString());
   }
 }
コード例 #11
0
  /** @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent) */
  public void hyperlinkUpdate(HyperlinkEvent event) {

    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      if (event.getURL().toString().startsWith("http")) {
        return;
      }
      if (event.getURL().toString().endsWith("sdx")) {
        String file = event.getURL().toString();
        file = file.substring(file.lastIndexOf('/') + 1);
        fireHyperlinkClicked("example:" + file);
      } else if (event.getURL().toString().indexOf('#') > 0) {
        try {
          JEditorPane pane = (JEditorPane) event.getSource();
          pane.setPage(event.getURL());
        } catch (Exception e) {
          /* empty */
        }
      } else if (event.getURL().toString().endsWith("html")) {

        String file = event.getURL().toString();
        file = file.substring(file.lastIndexOf('/') + 1);
        fireHyperlinkClicked("help:" + file);
      }
    }
  }
コード例 #12
0
ファイル: ColopediaPanel.java プロジェクト: Thue/FreeCol
 public void hyperlinkUpdate(HyperlinkEvent e) {
   HyperlinkEvent.EventType type = e.getEventType();
   if (type == HyperlinkEvent.EventType.ACTIVATED) {
     String[] path = e.getURL().getPath().split("/");
     if (FreeColObject.ID_ATTRIBUTE_TAG.equals(path[1])) {
       select(path[2]);
     } else if ("action".equals(path[1])) {
       getFreeColClient().getActionManager().getFreeColAction(path[2]).actionPerformed(null);
     }
   }
 }
コード例 #13
0
  /** Changes the cursor on hyperlink actions */
  public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      // Load some cursors
      Cursor cursor = output.getCursor();
      Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
      output.setCursor(waitCursor);

      // Handle the hyperlink change
      SwingUtilities.invokeLater(new LinkLoader(output, event.getURL(), cursor));
    }
  }
コード例 #14
0
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     URL url = e.getURL();
     //            String protocol = e.getURL().getProtocol();
     int index = url.getPort();
     gotoIndex(index + 1);
     if (!timeWarpMode) {
       activateTimeWarp();
     }
   }
 }
コード例 #15
0
 @Override
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     if (java.awt.Desktop.isDesktopSupported()) {
       try {
         java.awt.Desktop.getDesktop().browse(e.getURL().toURI());
       } catch (Exception ex) {
         log.error("Error opening URL in browser:" + e.getURL());
       }
     }
   }
 }
コード例 #16
0
ファイル: DialogHelp.java プロジェクト: XRen615/QuantMinerAPI
  public void hyperlinkUpdate(HyperlinkEvent event) {
    HTMLDocument documentHTML = null;

    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      m_sPageCourante = event.getURL().toString();

      if (event instanceof HTMLFrameHyperlinkEvent) {
        documentHTML = (HTMLDocument) jEditorPaneHTML.getDocument();
        documentHTML.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) event);
      } else ChargerPageActive();
    }
  }
コード例 #17
0
  /**
   * User has clicked on a HyperLink.
   *
   * @param evt HyperLink Event Object.
   */
  public void hyperlinkUpdate(HyperlinkEvent evt) {
    URL url = evt.getURL();

    if (url != null) {
      if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
        // CytoscapeWrapper.setStatusBarMsg(url.toString());
      } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
        // CytoscapeWrapper.clearStatusBar();
      } else if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        browser.openURL(url.toString());
      }
    }
  }
コード例 #18
0
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     JEditorPane pane = (JEditorPane) e.getSource();
     if (e instanceof HTMLFrameHyperlinkEvent) {
       HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
       HTMLDocument doc = (HTMLDocument) pane.getDocument();
       doc.processHTMLFrameHyperlinkEvent(evt);
     } else {
       String url = e.getURL().toString();
       Loader loader = LoaderFactory.getInstance().newLoader();
       loader.download(url, new Target(Library.PRIMARY_FRAME, null));
     }
   }
 }
コード例 #19
0
  /** Notification of a change relative to a hyperlink. From: java.swing.event.HyperlinkListener */
  public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      URL target = e.getURL();
      // System.out.println("linkto: " + target);

      // Get the help panel's cursor and the wait cursor
      Cursor oldCursor = help.getCursor();
      Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
      help.setCursor(waitCursor);

      // Now arrange for the page to get loaded asynchronously,
      // and the cursor to be set back to what it was.
      SwingUtilities.invokeLater(new PageLoader(target, oldCursor));
    }
  }
コード例 #20
0
    /** @param e */
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        StringTokenizer st = new StringTokenizer(e.getDescription(), " ");
        if (st.hasMoreTokens()) {
          String selectedID = st.nextToken();

          if (selectedID.startsWith("play=")) {
            selectedID = selectedID.replace("play=", "");
            playResult(selectedID);
          } else if (selectedID.startsWith("show=")) {
            selectedID = selectedID.replace("show=", "");
            showResult(selectedID);
          }
        }
      }
    }
コード例 #21
0
 @Override
 protected void hyperlinkActivated(HyperlinkEvent e) {
   final Module moduleByName =
       ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
   if (moduleByName != null) {
     myConfiguration.getConfigurationModule().setModule(moduleByName);
     try {
       final Executor executor =
           myConsoleProperties.isDebug()
               ? DefaultDebugExecutor.getDebugExecutorInstance()
               : DefaultRunExecutor.getRunExecutorInstance();
       final ProgramRunner runner =
           RunnerRegistry.getInstance().getRunner(executor.getId(), myConfiguration);
       assert runner != null;
       runner.execute(
           executor,
           new ExecutionEnvironment(
               myConfiguration,
               myProject,
               getRunnerSettings(),
               getConfigurationSettings(),
               null));
       final Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId);
       if (balloon != null) {
         balloon.hide();
       }
     } catch (ExecutionException e1) {
       LOG.error(e1);
     }
   }
 }
コード例 #22
0
ファイル: TriUMQueryGUI.java プロジェクト: ngphloc/zebra
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     if (e instanceof HTMLFrameHyperlinkEvent) {
       HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
       HTMLDocument doc = (HTMLDocument) this.getDocument();
       doc.processHTMLFrameHyperlinkEvent(evt);
     } else {
       try {
         URL url = e.getURL();
         if (url != null) this.setPage(url);
       } catch (Throwable t) {
         t.printStackTrace();
       }
     }
   }
 }
コード例 #23
0
ファイル: SwingEngine.java プロジェクト: cinquin/pathvisio
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     try {
       openUrl(e.getURL());
     } catch (UnsupportedOperationException ex) {
       Logger.log.error("Unable to open URL", ex);
       JOptionPane.showMessageDialog(
           mainPanel,
           "No browser launcher specified",
           "Unable to open link",
           JOptionPane.ERROR_MESSAGE);
     }
   } else {
     // TODO: show URL in status bar when mousing over
   }
 }
コード例 #24
0
 @Override
 public void hyperlinkUpdate(
     @NotNull final Notification notification, @NotNull HyperlinkEvent event) {
   if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED
       && event.getDescription().equals("resolve")) {
     notification.expire();
     ApplicationManager.getApplication()
         .executeOnPooledThread(
             new Runnable() {
               @Override
               public void run() {
                 mergeNoProceed();
               }
             });
   }
 }
コード例 #25
0
ファイル: HelpBrowser.java プロジェクト: harrymahar/josm
 @Override
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
   if (e.getURL() == null || e.getURL().toString().startsWith(url + "#")) {
     // Probably hyperlink event on a an A-element with a href consisting of
     // a fragment only, i.e. "#ALocalFragment".
     //
     String fragment = getUrlFragment(e);
     if (fragment != null) {
       // first try to scroll to an element with id==fragment. This is the way
       // table of contents are built in the JOSM wiki. If this fails, try to
       // scroll to a <A name="..."> element.
       //
       if (!scrollToElementWithId(fragment)) {
         help.scrollToReference(fragment);
       }
     } else {
       HelpAwareOptionPane.showOptionDialog(
           Main.parent,
           tr("Failed to open help page. The target URL is empty."),
           tr("Failed to open help page"),
           JOptionPane.ERROR_MESSAGE,
           null, /* no icon */
           null, /* standard options, just OK button */
           null, /* default is standard */
           null /* no help context */);
     }
   } else if (e.getURL().toString().endsWith("action=edit")) {
     OpenBrowser.displayUrl(e.getURL().toString());
   } else {
     url = e.getURL().toString();
     openUrl(e.getURL().toString());
   }
 }
コード例 #26
0
ファイル: HelpViewer.java プロジェクト: hmuhsen/jEdit
 // {{{ hyperlinkUpdate() method
 public void hyperlinkUpdate(HyperlinkEvent evt) {
   if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     if (evt instanceof HTMLFrameHyperlinkEvent) {
       ((HTMLDocument) viewer.getDocument())
           .processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
       historyUpdated();
     } else {
       URL url = evt.getURL();
       if (url != null) {
         gotoURL(url.toString(), true, 0);
       }
     }
   } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
     viewer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
     viewer.setCursor(Cursor.getDefaultCursor());
   }
 } // }}}
コード例 #27
0
  @Override
  public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      panel.history.goTo(Integer.parseInt(e.getDescription()));
      panel.refresh();
    } else {
      final Element element = e.getSourceElement();
      final int start = element.getStartOffset();
      final int length = element.getEndOffset() - start;
      final HTMLDocument html = ((HTMLDocument) getDocument());

      if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
        html.setParagraphAttributes(start, length, hoverAttr, false);
      }
      if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
        html.setParagraphAttributes(start, length, normalAttr, false);
      }
    }
  }
コード例 #28
0
ファイル: HelpBrowser.java プロジェクト: harrymahar/josm
 /**
  * Checks whether the hyperlink event originated on a &lt;a ...&gt; element with a relative href
  * consisting of a URL fragment only, i.e. &lt;a href="#thisIsALocalFragment"&gt;. If so,
  * replies the fragment, i.e. "thisIsALocalFragment".
  *
  * <p>Otherwise, replies <code>null</code>
  *
  * @param e the hyperlink event
  * @return the local fragment or <code>null</code>
  */
 protected String getUrlFragment(HyperlinkEvent e) {
   AttributeSet set = e.getSourceElement().getAttributes();
   Object value = set.getAttribute(Tag.A);
   if (!(value instanceof SimpleAttributeSet)) return null;
   SimpleAttributeSet atts = (SimpleAttributeSet) value;
   value = atts.getAttribute(javax.swing.text.html.HTML.Attribute.HREF);
   if (value == null) return null;
   String s = (String) value;
   if (s.matches("#.*")) return s.substring(1);
   return null;
 }
コード例 #29
0
  @Override
  public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType().equals(EventType.ACTIVATED)) {
      String code = e.getDescription();

      if (code.matches("v[0-9]+")) {
        int register = Integer.parseInt(code.substring(1));

        rend.setSelectedInstruction(ih);
        rend.setSelectedRegister(register);

        ArrayList<InstructionHandle> result =
            new ArrayList<InstructionHandle>(AnalysisGraph.lastInstruction(ih, register));

        rend.setLastInstructions(result);
        rend.showResults();

      } else throw new IllegalArgumentException("Wrong Event");
    }
  }
コード例 #30
0
  @Override
  public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e instanceof FormSubmitEvent) {
      FormSubmitEvent event = (FormSubmitEvent) e;

      // Just pushed the download the file button...
      LOG.debugf("File offer download requested. FileId: {0}", event.getData());

      try {
        String dataStr = event.getData();
        String fileIdEncoded = dataStr.substring(dataStr.indexOf("=") + 1).trim();
        String fileId = URLDecoder.decode(fileIdEncoded, "UTF-8");
        downloadFileOffer(fileId);
      } catch (UnsupportedEncodingException uee) {
        throw new RuntimeException(uee); // impossible
      }
    } else if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
      handleLinkClick(e.getDescription(), e.getURL());
    }
  }