Search in sources :

Example 46 with IHyperlink

use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.

the class SourcesFileHyperlinkDetectorTest method testDetectHyperlinksInvalidURL.

@Test
public void testDetectHyperlinksInvalidURL() throws PartInitException {
    IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
    editor = (SpecfileEditor) openEditor;
    editor.doRevertToSaved();
    SourcesFileHyperlinkDetector elementDetector = new SourcesFileHyperlinkDetector();
    elementDetector.setEditor(editor);
    // test source1 element
    IRegion region = new Region(47, 0);
    IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    // because the protocol is missing, it should not show any hyperlinks
    assertNull(returned);
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) SourcesFileHyperlinkDetector(org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.SourcesFileHyperlinkDetector) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IEditorPart(org.eclipse.ui.IEditorPart) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 47 with IHyperlink

use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.

the class URLHyperlinkWithMacroDetectorTest method testDetectHyperlinks.

@Test
public void testDetectHyperlinks() throws PartInitException {
    String testText = "Name: eclipse\nURL: http://www.%{name}.org/";
    newFile(testText);
    URLHyperlinkWithMacroDetector macroDetector = new URLHyperlinkWithMacroDetector();
    macroDetector.setSpecfile(specfile);
    IRegion region = new Region(20, 0);
    IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
    editor = (SpecfileEditor) openEditor;
    editor.doRevertToSaved();
    IHyperlink[] returned = macroDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    URLHyperlink url = (URLHyperlink) returned[0];
    assertEquals("http://www.eclipse.org/", url.getURLString());
}
Also used : URLHyperlink(org.eclipse.jface.text.hyperlink.URLHyperlink) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IEditorPart(org.eclipse.ui.IEditorPart) URLHyperlinkWithMacroDetector(org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.URLHyperlinkWithMacroDetector) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Aggregations

IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)47 Test (org.junit.Test)35 XtextResource (org.eclipse.xtext.resource.XtextResource)20 IRegion (org.eclipse.jface.text.IRegion)19 Region (org.eclipse.jface.text.Region)19 IEditorPart (org.eclipse.ui.IEditorPart)9 SourcesFileHyperlinkDetector (org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.SourcesFileHyperlinkDetector)5 IFile (org.eclipse.core.resources.IFile)4 JdtHyperlink (org.eclipse.xtext.common.types.xtext.ui.JdtHyperlink)4 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)4 AbstractEditorTest (org.eclipse.xtext.ui.testing.AbstractEditorTest)4 IDocument (org.eclipse.jface.text.IDocument)3 URLHyperlink (org.eclipse.jface.text.hyperlink.URLHyperlink)3 SpecfileEditor (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor)3 XtextHyperlink (org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink)3 XbaseImplementatorsHyperlink (org.eclipse.xtext.xbase.ui.navigation.XbaseImplementatorsHyperlink)3 JsonPointer (com.fasterxml.jackson.core.JsonPointer)2 SwaggerHyperlink (com.reprezen.swagedit.core.hyperlinks.SwaggerHyperlink)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2