Examples of IHyperlink


Examples of org.eclipse.jface.text.hyperlink.IHyperlink

    ITextViewer textViewer = new TextViewer(new Shell(), 0);
    textViewer.setDocument(document);
    IRegion region = new Region(255, 1);
    final IHyperlink[] hyperlinks = detector.detectHyperlinks(textViewer, region, false);
    assertEquals(hyperlinks.length, 1);
    final IHyperlink hyperlink = hyperlinks[0];
    assertEquals(hyperlink.getHyperlinkText(), "Open java file and jump to wicket:id \"test\"");

    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
      activePage.closeAllEditors(false);
      IDE.openEditor(activePage, file);
    } catch (PartInitException e) {
    }
    hyperlink.open();
    final IEditorPart activeEditor = activePage.getActiveEditor();
    assertTrue(activeEditor.getEditorInput() instanceof FileEditorInput);
    FileEditorInput input = (FileEditorInput) activeEditor.getEditorInput();
    assertEquals(input.getFile().getFullPath().toPortableString(), "/testproject/src/main/java/org/qwickie/test/project/issue45/web/RegistrationPage.java");
    activePage.closeAllEditors(false);
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

    ITextViewer textViewer = new TextViewer(new Shell(), 0);
    textViewer.setDocument(document);
    IRegion region = new Region(296, 1);
    final IHyperlink[] hyperlinks = detector.detectHyperlinks(textViewer, region, false);
    assertEquals(hyperlinks.length, 1);
    final IHyperlink hyperlink = hyperlinks[0];
    assertEquals(hyperlink.getHyperlinkText(), "Open properties file and jump to wicket:id \"page.test.string\"");

    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
      activePage.closeAllEditors(false);
      IDE.openEditor(activePage, file);
    } catch (PartInitException e) {
    }
    hyperlink.open();
    final IEditorPart activeEditor = activePage.getActiveEditor();
    assertTrue(activeEditor.getEditorInput() instanceof FileEditorInput);
    assertEquals(activeEditor.getClass().getCanonicalName(), "org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart");
    FileEditorInput input = (FileEditorInput) activeEditor.getEditorInput();
    assertEquals(input.getFile().getFullPath().toPortableString(), "/testproject/src/main/java/org/qwickie/test/project/xml/HomePage.properties.xml");
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

      return;
    }

    ITextSelection textSelection = (ITextSelection) selection;
    final IRegion region = new Region(textSelection.getOffset(), textSelection.getLength());
    IHyperlink hyperlink = null;

    synchronized (fHyperlinkDetectors) {
      for (int i = 0, length = fHyperlinkDetectors.length; i < length && hyperlink == null; i++) {
        final IHyperlinkDetector detector = fHyperlinkDetectors[i];
        if (detector == null)
          continue;

        /* The array is final, but its contents aren't */
        final IHyperlink[][] hyperlinks = new IHyperlink[1][];

        /*
         * Detect from within a SafeRunnable since the list of
         * detectors is extensible
         */
        SafeRunnable detectorRunnable = new SafeRunnable() {
          public void run() throws Exception {
            hyperlinks[0] = detector.detectHyperlinks(fTextViewer, region, false);
          }
        };
        SafeRunner.run(detectorRunnable);

        if (hyperlinks[0] == null)
          continue;

        if (hyperlinks.length > 0)
          hyperlink = hyperlinks[0][0];
      }
    }
    if (hyperlink != null) {
      /**
       * Force the highlight range to change when the hyperlink is
       * opened by altering the highlighted range beforehand.
       */
      getTextEditor().setHighlightRange(Math.max(0, region.getOffset() - 1), 0, false);
      hyperlink.open();
    }
  }
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

    }
    return s.toString().trim();
  }

  public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    IHyperlink hyperlink = null;

    if (textViewer != null && region != null) {
      IDocument doc = textViewer.getDocument();
      if (doc != null) {
        try {
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

   * @param uriString
   * @param hyperlinkRegion
   * @return IHyperlink
   */
  private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
    IHyperlink link = null;

    if (uriString != null) {
      String temp = uriString.toLowerCase();
      if (temp.startsWith(HTTP_PROTOCOL)) {
        // this is a URLHyperlink since this is a web address
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

* Detects hyperlinks in JSP Java content
*/
public class JSPJavaHyperlinkDetector extends AbstractHyperlinkDetector {

  private IHyperlink createHyperlink(IJavaElement element, IRegion region, IDocument document) {
    IHyperlink link = null;
    if (region != null) {
      // open local variable in the JSP file...
      if (element instanceof ISourceReference) {
        IFile file = null;
        int jspOffset = 0;
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

              for (int i = 0; i < elements.length; ++i) {
                IJavaElement element = elements[i];

                // find hyperlink range for Java element
                IRegion hyperlinkRegion = selectWord(document, region.getOffset());
                IHyperlink link = createHyperlink(element, hyperlinkRegion, document);
                if (link != null) {
                  hyperlinks.add(link);
                }
              }
            }
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

* Detects hyperlinks in JSP Java content
*/
public class JSPJavaHyperlinkDetector extends AbstractHyperlinkDetector {

  private IHyperlink createHyperlink(IJavaElement element, IRegion region, IDocument document) {
    IHyperlink link = null;
    if (region != null) {
      // open local variable in the JSP file...
      boolean isInTranslationCU = false;
      if (element instanceof ISourceReference) {
        IFile file = null;
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

              for (int i = 0; i < elements.length; ++i) {
                IJavaElement element = elements[i];

                // find hyperlink range for Java element
                IRegion hyperlinkRegion = selectWord(document, region.getOffset());
                IHyperlink link = createHyperlink(element, hyperlinkRegion, document);
                if (link != null) {
                  hyperlinks.add(link);
                }
              }
            }
View Full Code Here

Examples of org.eclipse.jface.text.hyperlink.IHyperlink

        name = document.get(hyperlinkRegion.getOffset(), hyperlinkRegion.getLength()).trim();
      }
      catch (BadLocationException e) {
      }
      if (name != null) {
        IHyperlink link = createHyperlink(name, hyperlinkRegion, document);
        if (link != null)
          return new IHyperlink[]{link};
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.