|
Lines 18-23
Link Here
|
| 18 |
import java.io.IOException; |
18 |
import java.io.IOException; |
| 19 |
import java.io.InputStream; |
19 |
import java.io.InputStream; |
| 20 |
import java.net.MalformedURLException; |
20 |
import java.net.MalformedURLException; |
|
|
21 |
import java.net.URI; |
| 21 |
import java.net.URL; |
22 |
import java.net.URL; |
| 22 |
import java.util.Hashtable; |
23 |
import java.util.Hashtable; |
| 23 |
import java.util.Map; |
24 |
import java.util.Map; |
|
Lines 149-160
Link Here
|
| 149 |
* resolver |
150 |
* resolver |
| 150 |
*/ |
151 |
*/ |
| 151 |
class CommonURIResolver implements URIResolver { |
152 |
class CommonURIResolver implements URIResolver { |
| 152 |
IPath fLocation; |
153 |
URI fLocation; |
| 153 |
IPath fPath; |
154 |
IPath fPath; |
| 154 |
final static String SEPARATOR = "/"; //$NON-NLS-1$ |
155 |
final static String SEPARATOR = "/"; //$NON-NLS-1$ |
| 155 |
final static String FILE_PREFIX = "file://"; //$NON-NLS-1$ |
156 |
//final static String FILE_PREFIX = "file://"; //$NON-NLS-1$ |
| 156 |
|
157 |
|
| 157 |
CommonURIResolver(IPath path, IPath location) { |
158 |
CommonURIResolver(IPath path, URI location) { |
| 158 |
fLocation = location; |
159 |
fLocation = location; |
| 159 |
fPath = path; |
160 |
fPath = path; |
| 160 |
} |
161 |
} |
|
Lines 175-196
Link Here
|
| 175 |
return getLocationByURI(uri, baseReference, false); |
176 |
return getLocationByURI(uri, baseReference, false); |
| 176 |
} |
177 |
} |
| 177 |
|
178 |
|
| 178 |
public String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks) { |
179 |
public String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks) { |
| 179 |
boolean baseHasPrefix = baseReference != null && baseReference.startsWith(FILE_PREFIX); |
180 |
String result = URIResolverPlugin.createResolver().resolve(baseReference, null, uri); |
| 180 |
String reference = null; |
|
|
| 181 |
if (baseHasPrefix) { |
| 182 |
reference = baseReference; |
| 183 |
} |
| 184 |
else { |
| 185 |
reference = FILE_PREFIX + baseReference; |
| 186 |
} |
| 187 |
String result = URIResolverPlugin.createResolver().resolve(reference, null, uri); |
| 188 |
// Logger.log(Logger.INFO_DEBUG, |
| 189 |
// "URIResolverPlugin.createResolver().resolve(" |
| 190 |
// + reference + ", null, " +uri+") = " + result); |
| 191 |
if (!baseHasPrefix && result.startsWith(FILE_PREFIX) && result.length() > FILE_PREFIX.length()) { |
| 192 |
result = result.substring(FILE_PREFIX.length()); |
| 193 |
} |
| 194 |
return result; |
181 |
return result; |
| 195 |
} |
182 |
} |
| 196 |
|
183 |
|
|
Lines 199-205
Link Here
|
| 199 |
} |
186 |
} |
| 200 |
|
187 |
|
| 201 |
public IContainer getRootLocation() { |
188 |
public IContainer getRootLocation() { |
| 202 |
String root = URIResolverPlugin.createResolver().resolve(FILE_PREFIX + getFileBaseLocation(), null, SEPARATOR); |
189 |
String root = URIResolverPlugin.createResolver().resolve(getFileBaseLocation(), null, SEPARATOR); |
| 203 |
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(root)); |
190 |
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(root)); |
| 204 |
for (int i = 0; i < files.length; i++) { |
191 |
for (int i = 0; i < files.length; i++) { |
| 205 |
if ((files[i].getType() & IResource.FOLDER) == IResource.FOLDER) { |
192 |
if ((files[i].getType() & IResource.FOLDER) == IResource.FOLDER) { |
|
Lines 406-414
Link Here
|
| 406 |
IProject project = workspaceFile.getProject(); |
393 |
IProject project = workspaceFile.getProject(); |
| 407 |
resolver = (URIResolver) project.getAdapter(URIResolver.class); |
394 |
resolver = (URIResolver) project.getAdapter(URIResolver.class); |
| 408 |
if (resolver == null) { |
395 |
if (resolver == null) { |
| 409 |
resolver = new CommonURIResolver(workspaceFile.getFullPath(), workspaceFile.getLocation()); |
396 |
resolver = new CommonURIResolver(workspaceFile.getFullPath(), workspaceFile.getLocationURI()); |
| 410 |
} |
397 |
} |
| 411 |
resolver.setFileBaseLocation(workspaceFile.getLocation().toString()); |
|
|
| 412 |
} |
398 |
} |
| 413 |
else { |
399 |
else { |
| 414 |
resolver = new ExternalURIResolver(location); |
400 |
resolver = new ExternalURIResolver(location); |