Author: scabanovich
Date: 2011-05-27 19:54:21 -0400 (Fri, 27 May 2011)
New Revision: 31566
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidationMessages.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
Log:
JBIDE-9028
https://issues.jboss.org/browse/JBIDE-9028
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java 2011-05-27
23:52:41 UTC (rev 31565)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java 2011-05-27
23:54:21 UTC (rev 31566)
@@ -22,6 +22,8 @@
NLS.initializeMessages(BUNDLE_NAME, KbMessages.class);
}
+ public static String WRONG_BUILDER_ORDER;
+
public static String VALIDATION_CONTEXT_LINKED_RESOURCE_PATH_MUST_NOT_BE_NULL;
public static String VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL;
public static String KBNATURE_NOT_FOUND;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties 2011-05-27
23:52:41 UTC (rev 31565)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties 2011-05-27
23:54:21 UTC (rev 31566)
@@ -1,3 +1,5 @@
+WRONG_BUILDER_ORDER=Wrong order of builders in project {0}: Validation Builder should
follow builder {1}. Validation is aborted.
+
VALIDATION_CONTEXT_LINKED_RESOURCE_PATH_MUST_NOT_BE_NULL=Linked resource path must not be
null\!
VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL=Variable name must not be null\!
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidationMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidationMessages.java 2011-05-27
23:52:41 UTC (rev 31565)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidationMessages.java 2011-05-27
23:54:21 UTC (rev 31566)
@@ -4,7 +4,7 @@
public class ELValidationMessages {
private static final String BUNDLE_NAME =
"org.jboss.tools.jst.web.kb.internal.validation.messages"; //$NON-NLS-1$
-
+
public static String UNKNOWN_EL_VARIABLE_NAME;
public static String UNKNOWN_EL_VARIABLE_PROPERTY_NAME;
public static String UNPAIRED_GETTER_OR_SETTER;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java 2011-05-27
23:52:41 UTC (rev 31565)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java 2011-05-27
23:54:21 UTC (rev 31566)
@@ -14,16 +14,19 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
+import org.jboss.tools.jst.web.kb.KbMessages;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
import org.jboss.tools.jst.web.kb.validation.IValidationContextManager;
@@ -73,6 +76,12 @@
if(validatingProjects.contains(rootProject)) {
return OK_STATUS;
}
+ if(!checkBuilderOrder(validationHelper, rootProject)) {
+ //TODO activate this return after duly testing
+ // it would be too dangerous to abort validation now
+ // while some test project have wrong builder order.
+// return OK_STATUS;
+ }
validatingProjects.add(rootProject);
}
}
@@ -102,6 +111,40 @@
}
}
+ private static String WTP_VALIDATOR_ID =
"org.eclipse.wst.validation.validationbuilder"; //$NON-NLS-1$
+
+ private boolean checkBuilderOrder(ContextValidationHelper validationHelper, IProject
project) {
+ IValidationContextManager validationContextManager =
validationHelper.getValidationContextManager();
+ List<IValidator> validators = validationContextManager.getValidators();
+ Set<String> requiredBuilders = new HashSet<String>();
+ for (IValidator v: validators) {
+ String builderId = v.getBuilderId();
+ if(builderId != null) {
+ requiredBuilders.add(builderId);
+ }
+ }
+ try {
+ boolean validationFound = false;
+ ICommand[] cs = project.getDescription().getBuildSpec();
+ for (ICommand c: cs) {
+ String name = c.getBuilderName();
+ if(WTP_VALIDATOR_ID.equals(name)) {
+ validationFound = true;
+ }
+ if(requiredBuilders.contains(name) && validationFound) {
+ String message = NLS.bind(KbMessages.WRONG_BUILDER_ORDER, project.getName(), name);
+ WebKbPlugin.getDefault().logError(message);
+ return false;
+ }
+ }
+
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+
+ return true;
+ }
+
private IStatus validate(Set<IFile> changedFiles, ContextValidationHelper
validationHelper, IReporter reporter) throws ValidationException {
IValidationContextManager validationContextManager =
validationHelper.getValidationContextManager();
List<IValidator> validators = validationContextManager.getValidators();