Author: akazakov
Date: 2011-07-18 14:58:20 -0400 (Mon, 18 Jul 2011)
New Revision: 33026
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java
Log:
https://issues.jboss.org/browse/JBIDE-9138
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java 2011-07-18
17:14:07 UTC (rev 33025)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java 2011-07-18
18:58:20 UTC (rev 33026)
@@ -14,6 +14,7 @@
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -87,21 +88,33 @@
for (IFile file : changedFiles) {
pathesToClean.add(file.getFullPath());
// If the changed file is a composition component then collect all the pages which use
this component.
- if(file.isAccessible() && notValidatedYet(file)) {
- filesToValidate.add(file);
- ITagLibrary[] libs = TagLibraryManager.getLibraries(file.getParent());
- for (ITagLibrary lib : libs) {
- if(lib instanceof ICompositeTagLibrary) {
- Set<IPath> pathes =
getValidationContext().getCoreResourcesByVariableName(SHORT_ID, getComponentUri(lib,
file), false);
- if(pathes!=null) {
- for (IPath path : pathes) {
- IFile page = root.getFile(path);
- if(page!=null && page.isAccessible()) {
- filesToValidate.add(page);
- pathesToClean.add(page.getFullPath());
+ if(notValidatedYet(file)) {
+ if(file.exists()) {
+ filesToValidate.add(file);
+ ITagLibrary[] libs = TagLibraryManager.getLibraries(file.getParent());
+ for (ITagLibrary lib : libs) {
+ if(lib instanceof ICompositeTagLibrary) {
+ collectRelatedPages(root, filesToValidate, pathesToClean,
getComponentUri(lib.getURI(), file));
+ }
+ }
+ } else {
+ // In case of deleted resource file
+ IContainer folder = file.getParent();
+ if(folder!=null) {
+ String[] segemnts = folder.getFullPath().segments();
+ StringBuffer libUri = new StringBuffer();
+ for (String segment : segemnts) {
+ if(libUri.length()==0) {
+ if(segment.equalsIgnoreCase("resources")) {
+
libUri.append("http://java.sun.com/jsf/composite");
}
+ } else {
+ libUri.append('/').append(segment);
}
}
+
if(libUri.length()>"http://java.sun.com/jsf/composite".lengt... {
+ collectRelatedPages(root, filesToValidate, pathesToClean,
getComponentUri(libUri.toString(), file));
+ }
}
}
}
@@ -118,6 +131,19 @@
return OK_STATUS;
}
+ private void collectRelatedPages(IWorkspaceRoot root, Set<IFile> filesToValidate,
Set<IPath> pathesToClean, String uri) {
+ Set<IPath> pathes =
getValidationContext().getCoreResourcesByVariableName(SHORT_ID, uri, false);
+ if(pathes!=null) {
+ for (IPath path : pathes) {
+ IFile page = root.getFile(path);
+ if(page!=null && page.isAccessible()) {
+ filesToValidate.add(page);
+ pathesToClean.add(page.getFullPath());
+ }
+ }
+ }
+ }
+
/*
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.validation.IValidator#validateAll(org.eclipse.core.resources.IProject,
org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
org.jboss.tools.jst.web.kb.validation.IProjectValidationContext,
org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
@@ -142,14 +168,14 @@
return OK_STATUS;
}
- private String getComponentUri(ITagLibrary lib, IFile file) {
+ private String getComponentUri(String libUri, IFile file) {
String fullName = file.getName();
String name = fullName;
String ext = file.getFileExtension();
if(ext!=null) {
name = name.substring(0, name.lastIndexOf("." + ext));
}
- return lib.getURI() + ":" + name;
+ return libUri + ":" + name;
}
private void validateResource(IFile file) {