[196172] WST Editors should be aware of remote resources shared via EFS (partial for 2.0.1)
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/htmlcss/URLModelProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/htmlcss/URLModelProvider.java
index bfa1547..821b118 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/htmlcss/URLModelProvider.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/htmlcss/URLModelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -415,7 +415,13 @@
final IContainer container = (resolver != null) ? resolver.getRootLocation() : null;
String docroot = null;
if (container != null) {
- docroot = container.getLocation().toString();
+ IPath containerLocation = container.getLocation();
+ if (containerLocation != null) {
+ docroot = containerLocation.toString();
+ }
+ else if (container.getLocationURI() != null) {
+ docroot = container.getLocationURI().toString();
+ }
}
if (docroot == null) {
docroot = baseModel.getBaseLocation();
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java
index c9dc850..c65f1c3 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java
@@ -12,11 +12,8 @@
-import java.io.File;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
import org.eclipse.wst.html.core.internal.Logger;
@@ -98,7 +95,18 @@
String baseLocation = model.getBaseLocation();
IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
if (baseFile != null) {
- baseLocation = baseFile.getLocation().toString();
+ if (baseFile.getLocation() != null) {
+ baseLocation = baseFile.getLocation().toString();
+ }
+ if (baseLocation == null && baseFile.getLocationURI() != null) {
+ baseLocation = baseFile.getLocationURI().toString();
+ }
+ if (baseLocation == null) {
+ baseLocation = baseFile.getFullPath().toString();
+ }
+ }
+ else {
+ baseLocation = model.getBaseLocation();
}
modelQueryAdapter.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver()));
}
@@ -164,33 +172,19 @@
modelStateNotifier.addModelStateListener(getInternalModelStateListener());
IStructuredModel model = xmlNode.getModel();
- String baseLocation = null;
- String modelsBaseLocation = model.getBaseLocation();
- if (modelsBaseLocation != null) {
- File file = new Path(modelsBaseLocation).toFile();
- if (file.exists()) {
- baseLocation = file.getAbsolutePath();
- }
- else {
- IPath basePath = new Path(model.getBaseLocation());
- IPath derivedPath = null;
- if (basePath.segmentCount() > 1)
- derivedPath = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath).getLocation();
- else
- derivedPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(basePath);
- if (derivedPath != null) {
- baseLocation = derivedPath.toString();
- }
- }
- }
- if (Debug.displayInfo)
- System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + baseLocation); //$NON-NLS-1$
-
- URIResolver idResolver = null;
-
org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
- if (baseLocation != null || resolver != null) {
- idResolver = new XMLCatalogIdResolver(baseLocation, resolver);
+ if (Debug.displayInfo)
+ System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + resolver.getFileBaseLocation()); //$NON-NLS-1$
+
+ /**
+ * XMLCatalogIdResolver currently requires a filesystem
+ * location string. Customarily this will be what is in the
+ * deprecated SSE URIResolver and required by the Common URI
+ * Resolver.
+ */
+ URIResolver idResolver = null;
+ if (resolver != null) {
+ idResolver = new XMLCatalogIdResolver(resolver.getFileBaseLocation(), resolver);
}
CMDocumentCache documentCache = new CMDocumentCache();
ModelQuery modelQuery = new HTMLModelQueryImpl(documentCache, idResolver);
diff --git a/bundles/org.eclipse.wst.sse.core/src-contentproperties/org/eclipse/wst/sse/internal/contentproperties/ContentSettings.java b/bundles/org.eclipse.wst.sse.core/src-contentproperties/org/eclipse/wst/sse/internal/contentproperties/ContentSettings.java
index fc7c7b5..0c797e3 100644
--- a/bundles/org.eclipse.wst.sse.core/src-contentproperties/org/eclipse/wst/sse/internal/contentproperties/ContentSettings.java
+++ b/bundles/org.eclipse.wst.sse.core/src-contentproperties/org/eclipse/wst/sse/internal/contentproperties/ContentSettings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,10 +28,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.sse.core.internal.Logger;
+import org.eclipse.wst.sse.core.internal.SSECorePlugin;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -477,44 +477,28 @@
}
private String getContentSettingsPath(IResource resource) {
- String projectPath = getProjectOf(resource);
- StringBuffer strbuf = new StringBuffer(""); //$NON-NLS-1$
- if (projectPath != null) {
- strbuf.append(projectPath);
- strbuf.append(IPath.SEPARATOR);
- strbuf.append(contentSettingsName);
- }
+ IProject project = null;
+ if (resource.getType() == IResource.PROJECT)
+ project = (IProject) resource;
else
- return null;
+ project = resource.getProject();
- String str = strbuf.toString();
- strbuf.delete(0, strbuf.length());
- return str;
+ IPath projectLocation = project.getLocation();
+ if (projectLocation == null) {
+ /**
+ * As a deprecated class, perfect operation in new scenarios such
+ * as with EFS is not promised.
+ */
+ return SSECorePlugin.getDefault().getStateLocation().append(rootElementName).append(project.getName()).toString();
+ }
+
+ return projectLocation.addTrailingSeparator().append(contentSettingsName).toString();
}
public final String getPathAttr() {
return PATHATTR;
}
-
- private String getProjectOf(IResource resource) {
- // if (resource==null) return null;
- currProject = resource.getProject();
- // String projectPath=null;
-
- IPath path = currProject.getLocation();
- if (path == null) {
- path = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- if (path != null) {
- path = path.addTrailingSeparator();
- path = path.append(currProject.getName());
- }
- }
- return (path != null) ? path.toString() : null;
-
- }
-
-
public synchronized Map getProperties(final IResource resource) {
if (resource == null)
return null;
diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java
index 130e5dc..8cad417 100644
--- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java
+++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -214,7 +214,7 @@
Logger.logException("Exception with " + file.getFullPath().toString(), e); //$NON-NLS-1$
}
catch (CharacterCodingException e) {
- Logger.log(Logger.INFO, "StructuredFileTaskScanner encountered CharacterCodingException reading " + file.getLocation()); //$NON-NLS-1$
+ Logger.log(Logger.INFO, "StructuredFileTaskScanner encountered CharacterCodingException reading " + file.getFullPath()); //$NON-NLS-1$
}
catch (Exception e) {
Logger.logException("Exception with " + file.getFullPath().toString(), e); //$NON-NLS-1$
@@ -239,7 +239,7 @@
findTasks(file, taskTags, monitor);
}
if (Logger.DEBUG_TASKSPERF) {
- System.out.println("" + (System.currentTimeMillis() - time0) + "ms for " + file.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("" + (System.currentTimeMillis() - time0) + "ms for " + file.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$
}
return (Map[]) fNewMarkerAttributeMaps.toArray(new Map[fNewMarkerAttributeMaps.size()]);
}
diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java
index 3f93260..1ae5680 100644
--- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java
+++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java
index c088206..0f9471d 100644
--- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java
+++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java
index 4df7b05..fe464f2 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java
@@ -146,6 +146,7 @@
}
public void setFileBaseLocation(String newLocation) {
+ fLocation = new Path(newLocation);
}
public void setProject(IProject newProject) {
@@ -157,18 +158,19 @@
* resolver
*/
class CommonURIResolver implements URIResolver {
- IPath fLocation;
+ String fLocation;
IPath fPath;
+ private IProject fProject;
final static String SEPARATOR = "/"; //$NON-NLS-1$
final static String FILE_PREFIX = "file://"; //$NON-NLS-1$
- CommonURIResolver(IPath path, IPath location) {
- fLocation = location;
- fPath = path;
+ CommonURIResolver(IFile workspaceFile) {
+ fPath = workspaceFile.getFullPath();
+ fProject = workspaceFile.getProject();
}
public String getFileBaseLocation() {
- return fLocation.toString();
+ return fLocation;
}
public String getLocationByURI(String uri) {
@@ -203,7 +205,7 @@
}
public IProject getProject() {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(fPath.segment(0));
+ return fProject;
}
public IContainer getRootLocation() {
@@ -211,7 +213,7 @@
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(root));
for (int i = 0; i < files.length; i++) {
if ((files[i].getType() & IResource.FOLDER) == IResource.FOLDER) {
- if (((IFolder) files[i]).getFullPath().isPrefixOf(fPath)) {
+ if (fPath.isPrefixOf(((IFolder) files[i]).getFullPath())) {
return (IFolder) files[i];
}
}
@@ -224,9 +226,11 @@
}
public void setFileBaseLocation(String newLocation) {
+ fLocation = newLocation;
}
public void setProject(IProject newProject) {
+ fProject = newProject;
}
}
@@ -414,9 +418,20 @@
IProject project = workspaceFile.getProject();
resolver = (URIResolver) project.getAdapter(URIResolver.class);
if (resolver == null) {
- resolver = new CommonURIResolver(workspaceFile.getFullPath(), workspaceFile.getLocation());
+ resolver = new CommonURIResolver(workspaceFile);
}
- resolver.setFileBaseLocation(workspaceFile.getLocation().toString());
+
+ String baseLocation = null;
+ if (workspaceFile.getLocation() != null) {
+ baseLocation = workspaceFile.getLocation().toString();
+ }
+ if (baseLocation == null && workspaceFile.getLocationURI() != null) {
+ baseLocation = workspaceFile.getLocationURI().toString();
+ }
+ if (baseLocation == null) {
+ baseLocation = workspaceFile.getFullPath().toString();
+ }
+ resolver.setFileBaseLocation(baseLocation);
}
else {
resolver = new ExternalURIResolver(location);
@@ -572,7 +587,7 @@
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
try {
if (Logger.DEBUG_FILEBUFFERMODELMANAGEMENT) {
- Logger.log(Logger.INFO, "FileBufferModelManager connecting to IFile " + file.getLocation()); //$NON-NLS-1$
+ Logger.log(Logger.INFO, "FileBufferModelManager connecting to IFile " + file.getFullPath()); //$NON-NLS-1$
}
// see TextFileDocumentProvider#createFileInfo about why we use
// IFile#getFullPath
@@ -622,7 +637,7 @@
}
}
catch (CoreException e) {
- Logger.logException("Error getting model for " + file.getLocation(), e); //$NON-NLS-1$
+ Logger.logException("Error getting model for " + file.getFullPath(), e); //$NON-NLS-1$
}
return model;
}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java
index 26702b3..78fa1e2 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -484,7 +484,19 @@
URIResolver resolver = (URIResolver) project.getAdapter(URIResolver.class);
if (resolver == null)
resolver = new ProjectResolver(project);
- resolver.setFileBaseLocation(file.getLocation().toString());
+
+ String locationString = null;
+ if (file.getLocation() != null) {
+ locationString = file.getLocation().toString();
+ }
+ if (locationString == null && file.getLocationURI() != null) {
+ locationString = file.getLocationURI().toString();
+ }
+ if (locationString == null) {
+ locationString = file.getFullPath().toString();
+ }
+ resolver.setFileBaseLocation(locationString);
+
return resolver;
}
@@ -1611,7 +1623,7 @@
public void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, CoreException, IOException {
if (FileBufferModelManager.getInstance().isExistingBuffer(structuredDocument)) {
ITextFileBuffer buffer = FileBufferModelManager.getInstance().getBuffer(structuredDocument);
- if (iFile.getLocation().equals(buffer.getLocation())) {
+ if (buffer.getLocation().equals(iFile.getLocation())) {
buffer.commit(new NullProgressMonitor(), true);
}
}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/JarUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/JarUtilities.java
index a1a2a7d..5582df1 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/JarUtilities.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/JarUtilities.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,8 +23,12 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.sse.core.internal.Logger;
@@ -121,10 +125,40 @@
}
return cache;
}
+
+ private static InputStream copyAndCloseStream(InputStream original) {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ InputStream cachedCopy = null;
+
+ if (original != null) {
+ int c;
+ // array dim restriction?
+ byte bytes[] = new byte[2048];
+ try {
+ while ((c = original.read(bytes)) >= 0) {
+ buffer.write(bytes, 0, c);
+ }
+ cachedCopy = new ByteArrayInputStream(buffer.toByteArray());
+ closeStream(original);
+ }
+ catch (IOException ioe) {
+ // no cleanup can be done
+ }
+ }
+ return cachedCopy;
+ }
public static String[] getEntryNames(IResource jarResource) {
- if (jarResource == null || jarResource.getLocation() == null)
+ if (jarResource == null || jarResource.getType() != IResource.FILE)
return new String[0];
+ if(jarResource.getLocation() == null) {
+ try {
+ return getEntryNames(new ZipInputStream(((IFile)jarResource).getContents()), true);
+ }
+ catch (CoreException e) {
+ Logger.logException("Problem reading contents of " + jarResource.getFullPath(), e); //$NON-NLS-1$
+ }
+ }
return getEntryNames(jarResource.getLocation().toString());
}
@@ -132,6 +166,38 @@
return getEntryNames(jarFilename, true);
}
+ private static String[] getEntryNames(ZipInputStream jarInputStream, boolean excludeDirectories) {
+ List entryNames = new ArrayList();
+ try {
+ ZipEntry z = jarInputStream.getNextEntry();
+ while (z != null) {
+ if (!(z.isDirectory() && excludeDirectories))
+ entryNames.add(z.getName());
+ z = jarInputStream.getNextEntry();
+ }
+ }
+ catch (ZipException zExc) {
+ Logger.log(Logger.WARNING, "JarUtilities ZipException: (stream) " + zExc.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (IOException ioExc) {
+ Logger.log(Logger.WARNING, "JarUtilities IOException: (stream) " + ioExc.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ finally {
+ closeStream(jarInputStream);
+ }
+ String[] names = (String[]) entryNames.toArray(new String[0]);
+ return names;
+ }
+
+ private static void closeStream(InputStream inputStream) {
+ try {
+ inputStream.close();
+ }
+ catch (IOException e) {
+ // nothing to do
+ }
+ }
+
public static String[] getEntryNames(String jarFilename, boolean excludeDirectories) {
ZipFile jarfile = null;
List entryNames = new ArrayList();
@@ -158,9 +224,43 @@
}
public static InputStream getInputStream(IResource jarResource, String entryName) {
- if (jarResource == null)
+ if (jarResource == null || jarResource.getType() != IResource.FILE)
return null;
- return getInputStream(jarResource.getLocation().toString(), entryName);
+ IPath location = jarResource.getLocation();
+ if(location == null) {
+ try {
+ InputStream zipStream = ((IFile)jarResource).getContents();
+ return getInputStream(new ZipInputStream(zipStream), entryName);
+ }
+ catch (CoreException e) {
+ Logger.logException("Problem reading contents of " + jarResource.getFullPath(), e); //$NON-NLS-1$
+ return null;
+ }
+ }
+ return getInputStream(location.toString(), entryName);
+ }
+
+ private static InputStream getInputStream(ZipInputStream zip, String entryName) {
+ InputStream result = null;
+ try {
+ ZipEntry z = zip.getNextEntry();
+ while (z != null && !z.getName().equals(entryName)) {
+ z = zip.getNextEntry();
+ }
+ if(z != null) {
+ result = copyAndCloseStream(zip);
+ }
+ }
+ catch (ZipException zExc) {
+ Logger.log(Logger.WARNING, "JarUtilities ZipException: (stream) " + zExc.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (IOException ioExc) {
+ Logger.log(Logger.WARNING, "JarUtilities IOException: (stream) " + ioExc.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ finally {
+ closeStream(zip);
+ }
+ return result;
}
public static InputStream getInputStream(String jarFilename, String entryName) {
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/ProjectResolver.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/ProjectResolver.java
index 5acbd21..9c658cf 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/ProjectResolver.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/ProjectResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,13 +15,15 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import com.ibm.icu.util.StringTokenizer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
+import com.ibm.icu.util.StringTokenizer;
+
/**
* @deprecated The URIResolver interface is deprecated. Use the resolver from
* org.eclipse.wst.common.uriresolver.
@@ -96,13 +98,24 @@
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=71223
// Workaround for problem in URIHelper; uris starting with '/' are
// returned as-is.
- String location = uri;
+ String location = null;
if (uri.startsWith("/")) { //$NON-NLS-1$
IProject p = getProject();
- if (p != null && p.exists())
- location = p.getLocation().toString() + uri;
+ if (p != null && p.isAccessible()) {
+ IFile file = p.getFile(uri);
+
+ if (file.getLocation() != null) {
+ location = file.getLocation().toString();
+ }
+ if (location == null && file.getLocationURI() != null) {
+ location = file.getLocationURI().toString();
+ }
+ if (location == null) {
+ location = file.getFullPath().toString();
+ }
+ }
}
- else {
+ if(location == null) {
location = URIHelper.normalize(uri, baseReference, getRootLocationString());
}
return location;
@@ -188,7 +201,17 @@
}
protected String getRootLocationString() {
- return fProject.getLocation().toString();
+ String location = null;
+ if (fProject.getLocation() != null) {
+ location = fProject.getLocation().toString();
+ }
+ if (location == null && fProject.getLocationURI() != null) {
+ location = fProject.getLocationURI().toString();
+ }
+ if (location == null) {
+ location = fProject.getFullPath().toString();
+ }
+ return location;
}
public InputStream getURIStream(String uri) {
diff --git a/bundles/org.eclipse.wst.sse.ui/plugin.xml b/bundles/org.eclipse.wst.sse.ui/plugin.xml
index 411f02b..bcd236d 100644
--- a/bundles/org.eclipse.wst.sse.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.sse.ui/plugin.xml
@@ -44,18 +44,14 @@
</actionSetPartAssociation>
<actionSetPartAssociation
targetID="org.eclipse.ui.NavigateActionSet">
- <!--
- <part id="org.eclipse.ui.views.ResourceNavigator"/>
- <part id="org.eclipse.ui.views.ContentOutline"/>
- -->
- <!--
- should probably only "force" association of action sets for workbench parts that we own
- or only if the view is focusse in the XMLPerspective
- -->
<part
id="org.eclipse.wst.sse.ui.StructuredTextEditor">
</part>
</actionSetPartAssociation>
+ <actionSetPartAssociation
+ targetID="org.eclipse.debug.ui.launchActionSet">
+ <part id="org.eclipse.wst.sse.ui.StructuredTextEditor"/>
+ </actionSetPartAssociation>
</extension>
<!-- Keywords for preference and properties pages -->
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentproperties/ui/ContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentproperties/ui/ContentSettingsPropertyPage.java
index be9d8d4..f937860 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentproperties/ui/ContentSettingsPropertyPage.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentproperties/ui/ContentSettingsPropertyPage.java
@@ -68,19 +68,19 @@
if (!(file.isReadOnly()))
return STATUS_OK;
- IPath fullIPath = file.getLocation();
+ IPath location = file.getLocation();
- final long beforeModifiedFromJavaIO = fullIPath.toFile().lastModified();
+ final long beforeModifiedFromJavaIO = (location != null) ? location.toFile().lastModified() : IResource.NULL_STAMP;
final long beforeModifiedFromIFile = file.getModificationStamp();
IStatus status = ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{file}, context);
if (!status.isOK())
return status;
- final long afterModifiedFromJavaIO = fullIPath.toFile().lastModified();
+ final long afterModifiedFromJavaIO = (location != null) ? location.toFile().lastModified() : IResource.NULL_STAMP;
final long afterModifiedFromIFile = file.getModificationStamp();
- if (beforeModifiedFromJavaIO != afterModifiedFromJavaIO) {
+ if (beforeModifiedFromJavaIO != afterModifiedFromJavaIO || beforeModifiedFromIFile != afterModifiedFromIFile) {
IModelManager manager = StructuredModelManager.getModelManager();
IStructuredModel model = manager.getExistingModelForRead(file);
if (model != null) {
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
index 3dea1cd..e77fcc2 100644
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
+++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
@@ -21,7 +21,6 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -176,7 +175,7 @@
*/
public void validate(IValidationContext arg0, IReporter arg1) throws ValidationException
{
- // This method should not be implemented by validtors implementing the validateInJob
+ // This method should not be implemented by validators implementing the validateInJob
// method.
}
@@ -224,8 +223,17 @@
Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, file.getFullPath().toString());
reporter.displaySubtask(this, message);
- IPath path = file.getLocation();
- String uri = createURIForFilePath(path.toString());
+ String locationString = null;
+ if (file.getLocation() != null) {
+ locationString = file.getLocation().toString();
+ }
+ if (locationString == null && file.getLocationURI() != null) {
+ locationString = file.getLocationURI().toString();
+ }
+ if (locationString == null) {
+ locationString = file.getFullPath().toString();
+ }
+ String uri = createURIForFilePath(locationString);
clearMarkers(file, this, reporter);
ValidationReport valreport = validate(uri, inputstream, context);
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
index b02377f..fe80336 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
@@ -14,11 +14,8 @@
-import java.io.File;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
@@ -27,6 +24,7 @@
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.util.Debug;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
@@ -141,39 +139,24 @@
IStructuredModel model = xmlNode.getModel();
stateNotifier = xmlNode.getModel();
stateNotifier.addModelStateListener(getInternalModelStateListener());
- String baseLocation = null;
- String modelBaseLocation = model.getBaseLocation();
- if (modelBaseLocation != null) {
- File file = new Path(modelBaseLocation).toFile();
- if (file.exists()) {
- baseLocation = file.getAbsolutePath();
- }
- else {
- IPath basePath = new Path(modelBaseLocation);
- IPath derivedPath = null;
- if (basePath.segmentCount() > 1)
- derivedPath = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath).getLocation();
- else
- derivedPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(basePath);
- if (derivedPath != null) {
- baseLocation = derivedPath.toString();
- }
- }
+
+ org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
+ if (Debug.displayInfo)
+ System.out.println("----------------ModelQueryAdapterFactoryForXML... baseLocation : " + resolver.getFileBaseLocation()); //$NON-NLS-1$
+
+ /**
+ * XMLCatalogIdResolver currently requires a filesystem
+ * location string. Customarily this will be what is in the
+ * deprecated SSE URIResolver and required by the Common URI
+ * Resolver.
+ */
+ URIResolver idResolver = null;
+ if (resolver != null) {
+ idResolver = new XMLCatalogIdResolver(resolver.getFileBaseLocation(), resolver);
}
- if (org.eclipse.wst.sse.core.internal.util.Debug.displayInfo)
- System.out.println("----------------ModelQueryAdapterFactoryForXML... baseLocation : " + baseLocation); //$NON-NLS-1$
CMDocumentCache cmDocumentCache = new CMDocumentCache();
- ModelQuery modelQuery = null;
- URIResolver idResolver = null;
-
- if (org.eclipse.wst.sse.core.internal.util.Debug.displayInfo)
- System.out.println("********XMLModelQueryImpl"); //$NON-NLS-1$
- org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
- if (baseLocation != null || resolver != null) {
- idResolver = new XMLCatalogIdResolver(baseLocation, resolver);
- }
- modelQuery = new XMLModelQueryImpl(cmDocumentCache, idResolver);
+ ModelQuery modelQuery = new XMLModelQueryImpl(cmDocumentCache, idResolver);
// cs todo...
// for now we create a CMDocumentCache on a 'per editor' basis
@@ -200,10 +183,22 @@
}
protected void updateResolver(IStructuredModel model) {
+
String baseLocation = model.getBaseLocation();
IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
if (baseFile != null) {
- baseLocation = baseFile.getLocation().toString();
+ if (baseFile.getLocation() != null) {
+ baseLocation = baseFile.getLocation().toString();
+ }
+ if (baseLocation == null && baseFile.getLocationURI() != null) {
+ baseLocation = baseFile.getLocationURI().toString();
+ }
+ if (baseLocation == null) {
+ baseLocation = baseFile.getFullPath().toString();
+ }
+ }
+ else {
+ baseLocation = model.getBaseLocation();
}
modelQueryAdapterImpl.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver()));
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
index 3645b5b..ee4f913 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
@@ -150,23 +150,30 @@
* Get the base location from the current model (local file system)
*/
private String getBaseLocation(IDocument document) {
- String baseLoc = null;
+ String result = null;
// get the base location from the current model
IStructuredModel sModel = null;
try {
sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (sModel != null) {
- IPath location = new Path(sModel.getBaseLocation());
- if (location.toFile().exists()) {
- baseLoc = location.toString();
- }
- else {
- if (location.segmentCount() > 1) {
- baseLoc = ResourcesPlugin.getWorkspace().getRoot().getFile(location).getLocation().toString();
- }
- else {
- baseLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(location).toString();
+ result = sModel.getBaseLocation();
+
+ IPath path = new Path(result);
+ if (path.segmentCount() > 1) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file.exists()) {
+ String baseLocation = null;
+ if (file.getLocation() != null) {
+ baseLocation = file.getLocation().toString();
+ }
+ if (baseLocation == null && file.getLocationURI() != null) {
+ baseLocation = file.getLocationURI().toString();
+ }
+ if (baseLocation == null) {
+ baseLocation = file.getFullPath().toString();
+ }
+ result = baseLocation;
}
}
}
@@ -176,7 +183,7 @@
sModel.releaseFromRead();
}
}
- return baseLoc;
+ return result;
}
/**
@@ -264,7 +271,11 @@
IFile file = null;
if (fileString != null) {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString));
+ Path filePath = new Path(fileString);
+ if (filePath.segmentCount() > 1 && ResourcesPlugin.getWorkspace().getRoot().getFile(filePath).exists()) {
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
+ }
+ IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath);
for (int i = 0; (i < files.length) && (file == null); i++) {
if (files[i].exists()) {
file = files[i];
@@ -504,6 +515,9 @@
if (file != null) {
isValid = file.isFile();
}
+ if(!isValid) {
+ }
+
}
return isValid;
}