Author: vrubezhny
Date: 2008-02-06 12:26:57 -0500 (Wed, 06 Feb 2008)
New Revision: 6135
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1741 OpenOn doesn't work for
xsi:schemaLocation in web.xml
Issue is fixed
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2008-02-06
17:26:43 UTC (rev 6134)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2008-02-06
17:26:57 UTC (rev 6135)
@@ -38,5 +38,6 @@
org.eclipse.jst.jsp.core;visibility:=reexport,
org.eclipse.jst.j2ee.web;visibility:=reexport,
org.eclipse.wst.common.modulecore;visibility:=reexport,
- org.eclipse.emf.ecore
+ org.eclipse.emf.ecore,
+ org.eclipse.pde.ui
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java 2008-02-06
17:26:43 UTC (rev 6134)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java 2008-02-06
17:26:57 UTC (rev 6135)
@@ -12,18 +12,20 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.zip.ZipFile;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.jdt.internal.core.JarEntryFile;
-import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.pde.internal.ui.editor.JarEntryEditorInput;
+import org.eclipse.pde.internal.ui.editor.JarEntryFile;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPersistableElement;
@@ -137,14 +139,18 @@
try {
// IFile f = getFileFromCatalog(getURI(region));
// IFile f = getFileFromCatalog(getPublicId(region), getSystemId(region));
-
- String filename = getFilenameFromCatalog(getPublicId(region), getSystemId(region));
+
+ String mappedSystemId = getMappedSystemIdFromCatalog(getPublicId(region),
getSystemId(region));
+ String filename = getFilenameFromMappedSystemId(mappedSystemId);
IEditorPart part = null;
if (filename != null) {
// openFileInEditor(filename);
part = openExternalFile(filename);
- }
- if (part == null)
+ if (part == null)
+ openFileFailed();
+ } else if (mappedSystemId != null) {
+ openFileInEditor(mappedSystemId);
+ } else
openFileFailed();
} catch (Exception x) {
@@ -178,6 +184,7 @@
}
protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
+ protected final String JAR_FILE = "jar:file:";//$NON-NLS-1$
/* (non-Javadoc)
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
@@ -189,6 +196,11 @@
IEditorInput jarEditorInput = createEditorInput(fileString);
IEditorPart part = openFileInEditor(jarEditorInput, fileString);
if (part == null) openFileFailed();
+ } else if (fileString.startsWith(JAR_FILE)) {
+ fileString = fileString.substring(JAR_FILE.length());
+ IEditorInput jarEditorInput = createEditorInputAlternate(fileString);
+ IEditorPart part = openFileInEditor(jarEditorInput, fileString);
+ if (part == null) openFileFailed();
} else {
super.openFileInEditor(fileString);
}
@@ -196,7 +208,28 @@
openFileFailed();
}
}
-
+
+ protected IEditorInput createEditorInputAlternate(String fileString) {
+ String jarName = fileString.substring(0,fileString.indexOf("!"));
+ String entryName =
fileString.substring(fileString.indexOf("!")+2,fileString.length());
+
+ ZipFile jarFile = null;
+ try {
+ jarFile = new ZipFile(jarName);
+ } catch (IOException e) {
+ return null;
+ }
+ JarEntryFile jarEntryFile = new JarEntryFile(jarFile, entryName);
+
+ JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(jarEntryFile) {
+ public boolean equals(Object arg) {
+ try {return this.toString().equals(arg.toString());}
+ catch (Exception x) {return false;}
+ }
+ };
+ return jarEditorInput;
+ }
+
String getURI(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
@@ -234,40 +267,36 @@
}
}
- private String getFilenameFromCatalog(String publicId, String systemId) {
-// IStructuredModel model = null;
-
+ private String getMappedSystemIdFromCatalog(String publicId, String systemId) {
+ String mappedSystemId = null;
try {
- String mappedSystemId = null;
-
if (publicId != null)
mappedSystemId =
XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolvePublic(publicId, systemId);
if (mappedSystemId == null)
mappedSystemId =
XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveSystem(systemId);
- if(mappedSystemId == null) return null;
-
- String fileName = null;
-
+ if (systemId != null)
+ mappedSystemId =
XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveURI(systemId);
+ } catch (Exception e) {
+ // Ignore, just return null as result
+ }
+ return mappedSystemId;
+ }
+
+ private String getFilenameFromMappedSystemId(String mappedSystemId) {
+ String fileName = null;
+ try {
if(mappedSystemId!=null) {
- try {
- File file = new File(new URL(mappedSystemId).getFile());
- if(file.isFile()) {
- fileName = file.getAbsolutePath();
- }
- } catch(Exception e) {
-// ExtensionsPlugin.log(e);
+ File file = new File(new URL(mappedSystemId).getFile());
+ if(file.isFile()) {
+ fileName = file.getAbsolutePath();
}
}
-
- return fileName;
} catch (Exception x) {
//ignore
- return null;
- } finally {
}
+ return fileName;
}
-
/**
* @seecom.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
*/
@@ -328,5 +357,4 @@
}
}
-
}