Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java70
1 files changed, 46 insertions, 24 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java
index d01be0cdd..eb8865c7b 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java
@@ -14,17 +14,17 @@ package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
import java.net.MalformedURLException;
import java.net.URL;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues;
import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage;
import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualContainer;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
/**
* Path relative to web root
@@ -56,12 +56,16 @@ public class WebPathType extends PathType implements
}
private void validateFileRelativeToWebRoot(String value) {
- IVirtualContainer webRoot = getWebRoot();
+ IContainer webRoot = getWebRoot();
+ if (webRoot == null)
+ {
+ return;
+ }
if (! webRoot.exists()){
getValidationMessages().add(new ValidationMessage( Messages.WebPathType_1));
}
else {
- IVirtualFile file = webRoot.getFile(new Path(value));
+ IFile file = webRoot.getFile(new Path(value));
if (!file.exists()) {
//was this a valid file path string, or bogus url?
getValidationMessages().add(new ValidationMessage(Messages.WebPathType_2));
@@ -71,29 +75,47 @@ public class WebPathType extends PathType implements
}
- private IVirtualContainer getWebRoot()
+ /**
+ * @return the web root
+ */
+ protected IContainer getWebRoot()
{
- IVirtualContainer webRoot =
- ComponentCore.createComponent(getProject()).getRootFolder();
-
- return webRoot;
+ IProject project = getProject2();
+ if (project != null)
+ {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component != null)
+ {
+ return component.getRootFolder().getUnderlyingFolder();
+ }
+ }
+ return null;
}
//Bug 325490 - [JSF2.0] False warning from facelet validator when working with facelet pages in a sub-folder
private void validateFileRelativeToCurrentFile(String value) {
- IPath webContentPath = ComponentCore.createComponent(getProject()).getRootFolder().getUnderlyingFolder().getFullPath();
- final IWorkspaceContextResolver wkspaceResolver =
- IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver( getStructuredDocumentContext() );
- IResource resource = wkspaceResolver.getResource();
- IPath filePath = resource.getFullPath();
- if (filePath.matchingFirstSegments(webContentPath) == webContentPath.segmentCount()) {
- filePath = filePath.removeFirstSegments(webContentPath.segmentCount());
- filePath = filePath.removeLastSegments(1);
- filePath = filePath.append(value);
- IVirtualFile file = getWebRoot().getFile(filePath);
- if (!file.exists()){
- getValidationMessages().add(new ValidationMessage(Messages.WebPathType_2));
- }
+ IProject project = getProject2();
+ if (project != null)
+ {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component != null)
+ {
+ IPath webContentPath = component.getRootFolder().getUnderlyingFolder().getFullPath();
+ IResource resource = getFile2();
+ if (resource != null)
+ {
+ IPath filePath = resource.getFullPath();
+ if (filePath.matchingFirstSegments(webContentPath) == webContentPath.segmentCount()) {
+ filePath = filePath.removeFirstSegments(webContentPath.segmentCount());
+ filePath = filePath.removeLastSegments(1);
+ filePath = filePath.append(value);
+ IFile file = getWebRoot().getFile(filePath);
+ if (!file.exists()){
+ getValidationMessages().add(new ValidationMessage(Messages.WebPathType_2));
+ }
+ }
+ }
+ }
}
}

Back to the top