Author: mareshkau
Date: 2009-08-17 13:02:20 -0400 (Mon, 17 Aug 2009)
New Revision: 17112
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/jbide/JBIDE4509Test.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4638
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 2009-08-17
15:46:26 UTC (rev 17111)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java 2009-08-17
17:02:20 UTC (rev 17112)
@@ -33,6 +33,10 @@
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
+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.ui.javaeditor.JarEntryEditorInput;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
@@ -132,7 +136,7 @@
return null;
}
- private IJavaElement searchForClass(String className) {
+ private IJavaElement searchForClass(final String className) {
IFile documentFile = getFile();
try {
@@ -142,7 +146,21 @@
IWorkbenchPage workbenchPage =
ExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart activeEditorPart = workbenchPage.getActiveEditor();
IEditorInput editorInput = activeEditorPart.getEditorInput();
- if (editorInput instanceof IStorageEditorInput) {
+ //added by Maksim Areshkau, fix for
https://jira.jboss.org/jira/browse/JBIDE-4638
+ //in this code we looking for java resource if editor has been opened in resource
which packed into jar file
+ if (editorInput instanceof JarEntryEditorInput) {
+ JarEntryEditorInput jarEntryEditorInput = (JarEntryEditorInput) editorInput;
+ JarEntryResource jarEntryFile = (JarEntryResource)
jarEntryEditorInput.getStorage();
+ Object parent = jarEntryFile.getParent();
+ while( parent instanceof JarEntryResource) {
+ parent = ((JarEntryResource)parent).getParent();
+ }
+ if( (parent instanceof JarPackageFragmentRoot) &&
+ (((JarPackageFragmentRoot)parent).getParent() instanceof IJavaProject)) {
+ return searchForClass(((IJavaProject)
((JarPackageFragmentRoot)parent).getParent()), className);
+ }
+
+ } else if (editorInput instanceof IStorageEditorInput) {
IStorageEditorInput moeInput = (IStorageEditorInput)editorInput;
IPath p = moeInput.getStorage().getFullPath();
String s0 = p.segment(0);
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 2009-08-17
15:46:26 UTC (rev 17111)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4509Test.java 2009-08-17
17:02:20 UTC (rev 17112)
@@ -62,22 +62,15 @@
//test openon for taglib from in file
public void testOpenOnForTaglibInJarFile() throws Throwable {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME);
- IJavaProject javaProject = JavaCore.create(project);
-
- IFile jarArchive = (IFile)
project.findMember("WebContent/WEB-INF/lib/mareshkau.jar"); //$NON-NLS-1$
-
- IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(jarArchive);
-
- JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) root;
- JarEntryFile fileInJar = new JarEntryFile("META-INF/mareshkau.taglib.xml");
//$NON-NLS-1$s
- fileInJar.setParent(jarRoot);
- JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(fileInJar);
- JBIDE4509Test.checkOpenOnInEditor(jarEditorInput, getEditorId(fileInJar.getName()),12,
25,
- "components/paginator.xhtml"); //$NON-NLS-1$
+ checkOpenOnFromJarFile("WebContent/WEB-INF/lib/mareshkau.jar", //$NON-NLS-1$
+ "META-INF/mareshkau.taglib.xml", 12, 25,
"components/paginator.xhtml"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ public void testOpenOnForJavaElementFromDeclarationInJar() throws Throwable {
+ checkOpenOnFromJarFile("WebContent/WEB-INF/lib/jsf-facelets.jar",
"META-INF/jsf-ui.taglib.xml", //$NON-NLS-1$ //$NON-NLS-2$
+ 25, 33, "UILibrary.class"); //$NON-NLS-1$
+ }
+
//test for <function-class>
public void testJBIDE4638OpenOnForFunctionClass() throws Throwable{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
@@ -102,8 +95,48 @@
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$
- }
-
+ }
+ /**
+ * Function for checking openOn functionality in jar file;
+ *
+ * @param jarFilePath
+ * @param jarEntryPath
+ * @param line
+ * @param position
+ * @param expectedResult
+ * @throws Throwable
+ *
+ * @author mareshkau
+ */
+ 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$
+
+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(jarArchive);
+
+ JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) root;
+ JarEntryFile fileInJar = new JarEntryFile(jarEntryPath); //$NON-NLS-1$s
+ fileInJar.setParent(jarRoot);
+ JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(fileInJar);
+ JBIDE4509Test.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 {
MultiPageEditorPart editorPart = (MultiPageEditorPart) PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage()