diff options
author | itrimble | 2011-01-04 22:56:10 +0000 |
---|---|---|
committer | itrimble | 2011-01-04 22:56:10 +0000 |
commit | 55e5b565e424a3a79ec06ac3a75b4f6d4efb4f5d (patch) | |
tree | 6f39e49f8fba6064d70b23b2011148354e8ef208 /jsf | |
parent | 27cdeb7ec355386a9331f133ae97ca0dabfdaea0 (diff) | |
download | webtools.jsf-55e5b565e424a3a79ec06ac3a75b4f6d4efb4f5d.tar.gz webtools.jsf-55e5b565e424a3a79ec06ac3a75b4f6d4efb4f5d.tar.xz webtools.jsf-55e5b565e424a3a79ec06ac3a75b4f6d4efb4f5d.zip |
Bug 325490 - [JSF2.0] False warning from facelet validator when working with facelet pages in a sub-folder
Diffstat (limited to 'jsf')
-rw-r--r-- | jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java | 32 |
1 files changed, 30 insertions, 2 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 c1c8c0dc4..d01be0cdd 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,7 +14,11 @@ package org.eclipse.jst.jsf.taglibprocessing.attributevalues; import java.net.MalformedURLException; import java.net.URL; +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; @@ -39,8 +43,13 @@ public class WebPathType extends PathType implements validateFileRelativeToWebRoot(url.getPath()); } } catch (MalformedURLException e) { - //is this a valid path relative to the - validateFileRelativeToWebRoot(value); + //is this a valid path relative to the + if (value != null && value.length() > 1 && value.charAt(0) == '/') { + validateFileRelativeToWebRoot(value); + } else { + //Bug 325490 - [JSF2.0] False warning from facelet validator when working with facelet pages in a sub-folder + validateFileRelativeToCurrentFile(value); + } } return getValidationMessages().size() == 0; @@ -69,4 +78,23 @@ public class WebPathType extends PathType implements return webRoot; } + + //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)); + } + } + } + }
\ No newline at end of file |