private void doJSPELHyperlinkTestForELInTagBodyTest( String pageName, String template, String editorName) throws BadLocationException { IEditorPart editor = WorkbenchUtils.openEditor(pageName); assertTrue(editor instanceof JSPMultiPageEditor); JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor; ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer(); assertNotNull("Viewer couldn't be found for " + pageName, viewer); IDocument document = viewer.getDocument(); IRegion reg = new FindReplaceDocumentAdapter(document).find(0, template, true, true, false, false); assertNotNull("Text: " + template + " not found", reg); IHyperlink[] links = elHyperlinkDetector.detectHyperlinks( viewer, new Region(reg.getOffset() + reg.getLength() - 1, 0), true); assertNotNull("Hyperlinks for EL:#{" + template + "} are not found", links); assertTrue("Hyperlinks for EL: #{" + template + "} are not found", links.length != 0); boolean found = false; for (IHyperlink link : links) { assertNotNull(link.toString()); link.open(); IEditorPart resultEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editorName.equals(resultEditor.getTitle())) { found = true; return; } } assertTrue("OpenOn have not opened " + editorName + " editor", found); }
public void clicked(MouseEvent e) { IHyperlink hyperlink = getHyperlink(e); if (hyperlink != null) { disarm(); hyperlink.open(); } }