Search in sources :

Example 21 with IHyperlink

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

the class MailHyperlinkDetectorTest method testDetectHyperlinks.

@Test
public void testDetectHyperlinks() throws PartInitException {
    String testText = "Version: 0.0\n" + "Release: 0\n" + "%changelog\n" + "* Fri Feb 27 2009 Test <someone@smth.com> 3.3.2.4-6\n-\n" + "* Fri Feb 27 2009 Test someone@smth.com 3.3.2.4-6\n-\n";
    newFile(testText);
    IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
    editor = (SpecfileEditor) openEditor;
    editor.doRevertToSaved();
    MailHyperlinkDetector elementDetector = new MailHyperlinkDetector();
    elementDetector.setEditor(editor);
    // test mail
    IRegion region = new Region(38, 0);
    IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    assertEquals(1, returned.length);
    assertTrue(returned[0] instanceof MailHyperlink);
    region = new Region(124, 0);
    returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    assertEquals(1, returned.length);
    assertTrue(returned[0] instanceof MailHyperlink);
}
Also used : MailHyperlink(org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.MailHyperlink) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) MailHyperlinkDetector(org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.MailHyperlinkDetector) IEditorPart(org.eclipse.ui.IEditorPart) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 22 with IHyperlink

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

the class SourcesFileHyperlinkDetectorTest method testDetectNoPatchInProject.

@Test
public void testDetectNoPatchInProject() 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 patch element
    IRegion region = new Region(27, 0);
    IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    // 1 = Create test.patch because test.patch doesn't exist in current project
    assertEquals(1, returned.length);
}
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 23 with IHyperlink

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

the class SourcesFileHyperlinkDetectorTest method testDetectHyperlinksValidURL.

@Test
public void testDetectHyperlinksValidURL() 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 source2 element
    IRegion region = new Region(82, 0);
    IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    // 1 = Download from URL (Open in browser should not show up because URLHyperlinkWithMacroDetector detects that)
    assertEquals(1, returned.length);
}
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 24 with IHyperlink

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

the class SourcesFileHyperlinkDetectorTest method testDetectHyperlinks.

@Test
public void testDetectHyperlinks() 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 source0 element
    IRegion region = new Region(10, 0);
    IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
    // because test.zip does not exist, and is not a valid url
    // it should not have 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 25 with IHyperlink

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

the class SpecfileElementHyperlinkDetectorTest method testDetectHyperlinksNoRegionAndTextViewer.

@Test
public void testDetectHyperlinksNoRegionAndTextViewer() {
    SpecfileElementHyperlinkDetector elementDetector = new SpecfileElementHyperlinkDetector();
    elementDetector.setSpecfile(specfile);
    IHyperlink[] returned = elementDetector.detectHyperlinks(null, null, false);
    assertNull(returned);
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) SpecfileElementHyperlinkDetector(org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.SpecfileElementHyperlinkDetector) 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