Search in sources :

Example 1 with XSLHyperlinkDetector

use of org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector in project webtools.sourceediting by eclipse.

the class TestXSLHyperlinkDetector method testWithParmVariableLink.

@Test
public void testWithParmVariableLink() throws Exception {
    setUpTest("DraftReleaseCRs.xsl");
    try {
        XSLHyperlinkDetector linkDetector = new XSLHyperlinkDetector();
        IRegion region = new Region(sourceViewer.getDocument().getLineOffset(74) + 44, 0);
        boolean canShowMultipleLinks = true;
        IHyperlink[] links = linkDetector.detectHyperlinks(sourceViewer, region, canShowMultipleLinks);
        assertNotNull("No links returned", links);
        assertEquals("Unexpected number of links", 1, links.length);
        IHyperlink link = links[0];
        assertTrue("Wrong file returned.", link.getHyperlinkText().contains("utils.xsl"));
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XSLHyperlinkDetector(org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test) AbstractXSLUITest(org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)

Example 2 with XSLHyperlinkDetector

use of org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector in project webtools.sourceediting by eclipse.

the class TestXSLHyperlinkDetector method testDetectHyperlinksViewer.

@Test
public void testDetectHyperlinksViewer() throws Exception {
    setUpTest("DraftReleaseCRs.xsl");
    try {
        XSLHyperlinkDetector linkDetector = new XSLHyperlinkDetector();
        IRegion region = new Region(sourceViewer.getDocument().getLineOffset(28) + 54, 0);
        boolean canShowMultipleLinks = true;
        IHyperlink[] links = linkDetector.detectHyperlinks(sourceViewer, region, canShowMultipleLinks);
        assertNotNull("No links returned", links);
        assertEquals("Unexpected number of links", 1, links.length);
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XSLHyperlinkDetector(org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test) AbstractXSLUITest(org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)

Example 3 with XSLHyperlinkDetector

use of org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector in project webtools.sourceediting by eclipse.

the class TestXSLHyperlinkDetector method testDetectHyperlinksDocument.

@Test
public void testDetectHyperlinksDocument() throws Exception {
    setUpTest("DraftReleaseCRs.xsl");
    try {
        XSLHyperlinkDetector linkDetector = new XSLHyperlinkDetector();
        IRegion region = new Region(sourceViewer.getDocument().getLineOffset(28) + 54, 0);
        boolean canShowMultipleLinks = true;
        IHyperlink[] links = linkDetector.detectHyperlinks(document, region, canShowMultipleLinks);
        assertNotNull("No links returned", links);
        assertEquals("Unexpected number of links", 1, links.length);
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XSLHyperlinkDetector(org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test) AbstractXSLUITest(org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)

Example 4 with XSLHyperlinkDetector

use of org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector in project webtools.sourceediting by eclipse.

the class StructuredTextViewerConfigurationXSL method getHyperlinkDetectors.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
 */
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
        return null;
    IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
    IHyperlinkDetector[] allDetectors = new IHyperlinkDetector[superDetectors.length + 1];
    allDetectors[0] = new XSLHyperlinkDetector();
    System.arraycopy(superDetectors, 0, allDetectors, 1, superDetectors.length);
    return allDetectors;
}
Also used : IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) XSLHyperlinkDetector(org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector)

Aggregations

XSLHyperlinkDetector (org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector)4 IRegion (org.eclipse.jface.text.IRegion)3 Region (org.eclipse.jface.text.Region)3 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)3 AbstractXSLUITest (org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)3 Test (org.junit.Test)3 IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)1