Author: yzhishko
Date: 2010-01-15 12:39:41 -0500 (Fri, 15 Jan 2010)
New Revision: 19782
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnInJarPackageFragment_JBIDE5682.java
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4509Test.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5682 - fixed
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java 2010-01-15
17:01:55 UTC (rev 19781)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java 2010-01-15
17:39:41 UTC (rev 19782)
@@ -36,6 +36,7 @@
import org.eclipse.jdt.internal.core.JarEntryFile;
import org.eclipse.jdt.internal.core.JarEntryResource;
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
+import org.eclipse.jdt.internal.core.PackageFragment;
import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.BadLocationException;
@@ -155,6 +156,9 @@
while( parent instanceof JarEntryResource) {
parent = ((JarEntryResource)parent).getParent();
}
+ while (parent instanceof PackageFragment) {
+ parent = ((PackageFragment)parent).getParent();
+ }
if( (parent instanceof JarPackageFragmentRoot) &&
(((JarPackageFragmentRoot)parent).getParent() instanceof IJavaProject)) {
return searchForClass(((IJavaProject)
((JarPackageFragmentRoot)parent).getParent()), className);
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-01-15
17:01:55 UTC (rev 19781)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-01-15
17:39:41 UTC (rev 19782)
@@ -67,6 +67,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4509Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4510Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4534Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.OpenOnInJarPackageFragment_JBIDE5682;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.OpenOnJsf20Test_JBIDE5382;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.TaglibXMLUnformatedDTD_JBIDE5642;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestFViewLocaleAttribute_JBIDE5218;
@@ -188,6 +189,7 @@
suite.addTestSuite(TestFViewLocaleAttribute_JBIDE5218.class);
suite.addTestSuite(TestOpenOnForXhtmlFiles_JBIDE5577.class);
suite.addTestSuite(TaglibXMLUnformatedDTD_JBIDE5642.class);
+ suite.addTestSuite(OpenOnInJarPackageFragment_JBIDE5682.class);
// $JUnit-END$
// added by Max Areshkau
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4509Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4509Test.java 2010-01-15
17:01:55 UTC (rev 19781)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4509Test.java 2010-01-15
17:39:41 UTC (rev 19782)
@@ -43,6 +43,7 @@
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.ui.test.OpenOnUtil;
import org.jboss.tools.vpe.ui.test.TestUtil;
import org.jboss.tools.vpe.ui.test.VpeTest;
@@ -61,7 +62,7 @@
JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT);
IFile file = (IFile)
project.findMember("WebContent/tags/facelets.taglib.xml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 12, 17,
"paginator.xhtml"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 12, 17,
"paginator.xhtml"); //$NON-NLS-1$
}
@@ -82,7 +83,7 @@
JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT);
IFile file = (IFile)
project.findMember("WebContent/tags/facelets.taglib.xml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 31, 37,
"FaceletFunctions.java"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 31, 37,
"FaceletFunctions.java"); //$NON-NLS-1$
}
//test for <function-class>
@@ -91,7 +92,7 @@
JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME);
IFile file = (IFile)
project.findMember("WebContent/WEB-INF/test.taglib.xml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 6, 25,
"CoreLibrary.java"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 6, 25,
"CoreLibrary.java"); //$NON-NLS-1$
}
//test for <function-class>
public void testJBIDE4638OpenOnForHandlerClass() throws Throwable{
@@ -99,7 +100,7 @@
JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT);
IFile file = (IFile)
project.findMember("WebContent/tags/facelets.taglib.xml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 22, 23,
"IfHandler.java"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 22, 23,
"IfHandler.java"); //$NON-NLS-1$
}
//test for <handler-class> in tag
public void testJBIDE4638OpenOnForHandlerClassWithTagAxis() throws Throwable{
@@ -107,17 +108,17 @@
JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT);
IFile file = (IFile)
project.findMember("WebContent/tags/facelets.taglib.xml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 36, 29,
"IfHandler.java"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 36, 29,
"IfHandler.java"); //$NON-NLS-1$
}
//test for
https://jira.jboss.org/jira/browse/JBIDE-4635
public void testJBIDE4635OpenOn() throws Throwable{
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME);
IFile file = (IFile) project.findMember("WebContent/pages/index.xhtml");
//$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 11, 11,
"mareshkau.taglib.xml"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 11, 11,
"mareshkau.taglib.xml"); //$NON-NLS-1$
IEditorPart activeEditor = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- JBIDE4509Test.checkOpenOnInEditor(activeEditor.getEditorInput(),getEditorId(activeEditor.getEditorInput().getName()),
+ OpenOnUtil.checkOpenOnInEditor(activeEditor.getEditorInput(),getEditorId(activeEditor.getEditorInput().getName()),
8,23,"echo.xhtml"); //$NON-NLS-1$
}
@@ -127,7 +128,7 @@
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
IFile file = (IFile)
project.findMember("WebContent/pages/JBIDE/5015/login.xhtml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 15, 17,
"loginPanel.xhtml"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 15, 17,
"loginPanel.xhtml"); //$NON-NLS-1$
}
//test for
https://jira.jboss.org/jira/browse/JBIDE-5099
@@ -136,7 +137,7 @@
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
IFile file = (IFile)
project.findMember("WebContent/pages/JBIDE/5015/login.xhtml"); //$NON-NLS-1$
IEditorInput editorInput = new FileEditorInput(file);
- JBIDE4509Test.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 14, 16,
"echo.xhtml"); //$NON-NLS-1$
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(file.getName()), 14, 16,
"echo.xhtml"); //$NON-NLS-1$
}
/**
* Function for checking openOn functionality in jar file;
@@ -150,80 +151,25 @@
*
* @author mareshkau
*/
+ @SuppressWarnings("restriction")
private static final void checkOpenOnFromJarFile(final String jarFilePath,final String
jarEntryPath,
final int line, final int position,final String expectedResult) throws Throwable {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME);
IJavaProject javaProject = JavaCore.create(project);
- IFile jarArchive = (IFile) project.findMember(jarFilePath); //$NON-NLS-1$
+ IFile jarArchive = (IFile) project.findMember(jarFilePath);
IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(jarArchive);
JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) root;
- JarEntryFile fileInJar = new JarEntryFile(jarEntryPath); //$NON-NLS-1$s
+ JarEntryFile fileInJar = new JarEntryFile(jarEntryPath);
fileInJar.setParent(jarRoot);
JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(fileInJar);
- JBIDE4509Test.checkOpenOnInEditor(jarEditorInput,
getEditorId(fileInJar.getName()),line, position,
+ OpenOnUtil.checkOpenOnInEditor(jarEditorInput, getEditorId(fileInJar.getName()),line,
position,
expectedResult);
}
- /**
- * Function for checking openOn functionality
- *
- * @param editorInput
- * @param editorId
- * @param lineNumber
- * @param lineOffset
- * @param openedOnFileName
- * @throws Throwable
- *
- * @author mareshkau
- */
- private static final void checkOpenOnInEditor(IEditorInput editorInput,String
editorId,int lineNumber, int lineOffset, String openedOnFileName) throws Throwable {
- IEditorPart editorPart = PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .openEditor(editorInput, editorId);
- StructuredTextEditor textEditor = null;
- if(editorPart instanceof MultiPageEditorPart){
- IEditorPart[] editorParts =
((MultiPageEditorPart)editorPart).findEditors(editorInput);
- ((MultiPageEditorPart)editorPart).setActiveEditor(editorParts[0]);
- textEditor = (StructuredTextEditor) editorParts[0];
- } else if(editorPart instanceof JSPMultiPageEditor) {
- textEditor = ((JSPMultiPageEditor)editorPart).getSourceEditor();
- } else if(editorPart instanceof EditorPartWrapper) {
- IEditorPart[] editorParts =
((MultiPageEditorPart)((EditorPartWrapper)editorPart).getEditor()).findEditors(editorInput);
- ((MultiPageEditorPart)((EditorPartWrapper)editorPart).getEditor()).setActiveEditor(editorParts[1]);
- textEditor = (StructuredTextEditor) editorParts[1];
- }
- int openOnPosition = TestUtil.getLinePositionOffcet(textEditor
- .getTextViewer(),lineNumber, lineOffset);
- // hack to get hyperlinks detectors, no other was have been founded
- Method method = AbstractTextEditor.class
- .getDeclaredMethod("getSourceViewerConfiguration"); //$NON-NLS-1$
- method.setAccessible(true);
- SourceViewerConfiguration sourceViewerConfiguration = (SourceViewerConfiguration)
method
- .invoke(textEditor);
- IHyperlinkDetector[] hyperlinkDetectors = sourceViewerConfiguration
- .getHyperlinkDetectors(textEditor.getTextViewer());
- for (IHyperlinkDetector iHyperlinkDetector : hyperlinkDetectors) {
- IHyperlink[] hyperLinks = iHyperlinkDetector.detectHyperlinks(
- textEditor.getTextViewer(), new Region(openOnPosition, 0),
- false);
- if (hyperLinks != null && hyperLinks.length > 0
- && hyperLinks[0] instanceof AbstractHyperlink) {
- AbstractHyperlink abstractHyperlink = (AbstractHyperlink) hyperLinks[0];
- abstractHyperlink.open();
- break;
- }
- }
- IEditorPart activeEditor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- assertEquals(
- "Active page should be ", openedOnFileName,
activeEditor.getEditorInput().getName()); //$NON-NLS-1$
-
- }
-
private static final String getEditorId(String filename) {
IWorkbench workbench = PlatformUI.getWorkbench();
IEditorRegistry editorRegistry = workbench.getEditorRegistry();
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnInJarPackageFragment_JBIDE5682.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnInJarPackageFragment_JBIDE5682.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnInJarPackageFragment_JBIDE5682.java 2010-01-15
17:39:41 UTC (rev 19782)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.JarEntryFile;
+import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
+import org.eclipse.jdt.internal.core.PackageFragment;
+import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.OpenOnUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+@SuppressWarnings("restriction")
+public class OpenOnInJarPackageFragment_JBIDE5682 extends VpeTest {
+
+ private static final String JAR_LIB_PATH =
"WebContent/WEB-INF/lib/jsf-impl-2.0.1-SNAPSHOT.jar"; //$NON-NLS-1$
+ private static final String TEST_FILE = "jstl-core.taglib.xml"; //$NON-NLS-1$
+ private static final String[] FRAGMENT_PATH = new String[] { "com",
"sun", //$NON-NLS-1$ //$NON-NLS-2$
+ "faces", "metadata", "taglib" }; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+
+ public OpenOnInJarPackageFragment_JBIDE5682(String name) {
+ super(name);
+ }
+
+ public void testOpenOnInJarPackageFragment() throws Throwable {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ JsfAllTests.IMPORT_JSF_20_PROJECT_NAME);
+ IJavaProject javaProject = JavaCore.create(project);
+ IPackageFragmentRoot fragmentRoot = javaProject
+ .getPackageFragmentRoot(javaProject.getPath().toString() + "/"
//$NON-NLS-1$
+ + JAR_LIB_PATH);
+ JarPackageFragmentRoot jarPackageFragmentRoot = (JarPackageFragmentRoot) fragmentRoot;
+ JarEntryFile fileInJar = new JarEntryFile(TEST_FILE);
+ PackageFragment fragment = jarPackageFragmentRoot
+ .getPackageFragment(FRAGMENT_PATH);
+ fileInJar.setParent(fragment);
+ JarEntryEditorInput editorInput = new JarEntryEditorInput(fileInJar);
+ OpenOnUtil.checkOpenOnInEditor(editorInput, getEditorId(fileInJar
+ .getName()), 78, 44, "IfHandler.class"); //$NON-NLS-1$
+ }
+
+ private final String getEditorId(String filename) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IEditorRegistry editorRegistry = workbench.getEditorRegistry();
+ IEditorDescriptor descriptor = editorRegistry
+ .getDefaultEditor(filename);
+ if (descriptor != null)
+ return descriptor.getId();
+ return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
+ }
+
+}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java 2010-01-15
17:01:55 UTC (rev 19781)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java 2010-01-15
17:39:41 UTC (rev 19782)
@@ -11,14 +11,20 @@
package org.jboss.tools.vpe.ui.test;
import java.lang.reflect.Method;
-
+import static junit.framework.Assert.assertEquals;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
/**
* @author Sergey Dzmitrovich
@@ -58,5 +64,62 @@
}
}
+
+ /**
+ * Function for checking openOn functionality
+ *
+ * @param editorInput
+ * @param editorId
+ * @param lineNumber
+ * @param lineOffset
+ * @param openedOnFileName
+ * @throws Throwable
+ *
+ * @author mareshkau
+ */
+
+ public static final void checkOpenOnInEditor(IEditorInput editorInput,String
editorId,int lineNumber, int lineOffset, String openedOnFileName) throws Throwable {
+ IEditorPart editorPart = PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .openEditor(editorInput, editorId);
+ StructuredTextEditor textEditor = null;
+ if(editorPart instanceof MultiPageEditorPart){
+ IEditorPart[] editorParts =
((MultiPageEditorPart)editorPart).findEditors(editorInput);
+ ((MultiPageEditorPart)editorPart).setActiveEditor(editorParts[0]);
+ textEditor = (StructuredTextEditor) editorParts[0];
+ } else if(editorPart instanceof JSPMultiPageEditor) {
+ textEditor = ((JSPMultiPageEditor)editorPart).getSourceEditor();
+ } else if(editorPart instanceof EditorPartWrapper) {
+ IEditorPart[] editorParts =
((MultiPageEditorPart)((EditorPartWrapper)editorPart).getEditor()).findEditors(editorInput);
+ ((MultiPageEditorPart)((EditorPartWrapper)editorPart).getEditor()).setActiveEditor(editorParts[1]);
+ textEditor = (StructuredTextEditor) editorParts[1];
+ }
+ int openOnPosition = TestUtil.getLinePositionOffcet(textEditor
+ .getTextViewer(),lineNumber, lineOffset);
+ // hack to get hyperlinks detectors, no other was have been founded
+ Method method = AbstractTextEditor.class
+ .getDeclaredMethod("getSourceViewerConfiguration"); //$NON-NLS-1$
+ method.setAccessible(true);
+ SourceViewerConfiguration sourceViewerConfiguration = (SourceViewerConfiguration)
method
+ .invoke(textEditor);
+ IHyperlinkDetector[] hyperlinkDetectors = sourceViewerConfiguration
+ .getHyperlinkDetectors(textEditor.getTextViewer());
+ for (IHyperlinkDetector iHyperlinkDetector : hyperlinkDetectors) {
+ IHyperlink[] hyperLinks = iHyperlinkDetector.detectHyperlinks(
+ textEditor.getTextViewer(), new Region(openOnPosition, 0),
+ false);
+ if (hyperLinks != null && hyperLinks.length > 0
+ && hyperLinks[0] instanceof AbstractHyperlink) {
+ AbstractHyperlink abstractHyperlink = (AbstractHyperlink) hyperLinks[0];
+ abstractHyperlink.open();
+ break;
+ }
+ }
+ IEditorPart activeEditor = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ assertEquals(
+ "Active page should be ", openedOnFileName,
activeEditor.getEditorInput().getName()); //$NON-NLS-1$
+ }
+
}