Author: akazakov
Date: 2007-07-19 13:49:11 -0400 (Thu, 19 Jul 2007)
New Revision: 2530
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
Log:
http://jira.jboss.com/jira/browse/EXIN-327 Peferences
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2007-07-19
17:49:11 UTC (rev 2530)
@@ -14,7 +14,6 @@
import java.util.Set;
import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -52,6 +51,8 @@
public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE =
createSeverityOption("statefulComponentDoesNotContainRemove");
public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY =
createSeverityOption("statefulComponentDoesNotContainDestroy");
public static final String STATEFUL_COMPONENT_WRONG_SCOPE =
createSeverityOption("statefulComponentHasWrongScope");
+ public static final String UNKNOWN_COMPONENT_CLASS_NAME =
createSeverityOption("unknownComponentClassName");
+ public static final String UNKNOWN_COMPONENT_PROPERTY =
createSeverityOption("unknownComponentProperty");
//Entities
public static final String ENTITY_COMPONENT_WRONG_SCOPE =
createSeverityOption("entityComponentHasWrongScope");
@@ -75,7 +76,7 @@
//Context variables
public static final String DUPLICATE_VARIABLE_NAME =
createSeverityOption("duplicateVariableName");
- public static final String UNKNOWN_INJECTION_NAME =
createSeverityOption("unknownInjectionName");
+ public static final String UNKNOWN_VARIABLE_NAME =
createSeverityOption("unknownVariableName");
private static String createSeverityOption(String shortName) {
String name = SeamCorePlugin.PLUGIN_ID + ".validator.problem." + shortName;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2007-07-19
17:49:11 UTC (rev 2530)
@@ -42,7 +42,6 @@
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
-import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamProperty;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
@@ -50,6 +49,7 @@
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamPreferences;
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamProject;
@@ -63,27 +63,7 @@
private static final String MARKED_SEAM_RESOURCE_MESSAGE_GROUP =
"markedSeamResource";
- private static final String NONUNIQUE_COMPONENT_NAME_MESSAGE_ID =
"NONUNIQUE_COMPONENT_NAME_MESSAGE";
- private static final String UNKNOWN_INJECTION_NAME_MESSAGE_ID =
"UNKNOWN_INJECTION_NAME";
- private static final String STATEFUL_COMPONENT_DOES_NOT_CONTAIN_METHOD_SUFIX_MESSAGE_ID
= "STATEFUL_COMPONENT_DOES_NOT_CONTAIN_";
- private static final String DUPLICATE_METHOD_PREFIX_MESSAGE_ID =
"DUPLICATE_";
- private static final String REMOVE_METHOD_SUFIX_MESSAGE_ID = "REMOVE";
- private static final String DESTROY_METHOD_SUFIX_MESSAGE_ID = "DESTROY";
- private static final String CREATE_METHOD_SUFIX_MESSAGE_ID = "CREATE";
- private static final String UNWRAP_METHOD_SUFIX_MESSAGE_ID = "UNWRAP";
- private static final String OBSERVER_METHOD_SUFIX_MESSAGE_ID = "OBSERVER";
- private static final String NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID =
"_DOESNT_BELONG_TO_COMPONENT";
- private static final String STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID =
"STATEFUL_COMPONENT_WRONG_SCOPE";
- private static final String ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID =
"ENTITY_COMPONENT_WRONG_SCOPE";
- private static final String UNKNOWN_FACTORY_NAME_MESSAGE_ID =
"UNKNOWN_FACTORY_NAME";
- private static final String MULTIPLE_DATA_BINDER_MESSAGE_ID =
"MULTIPLE_DATA_BINDER";
- private static final String DUPLICATE_VARIABLE_NAME_MESSAGE_ID =
"DUPLICATE_VARIABLE_NAME";
- private static final String UNKNOWN_DATA_MODEL_MESSAGE_ID =
"UNKNOWN_DATA_MODEL";
- private static final String UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID =
"UNKNOWN_COMPONENT_CLASS_NAME";
- private static final String UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID =
"UNKNOWN_COMPONENT_PROPERTY";
-
private SeamValidationContext validationContext;
- private ISeamProject project;
public ISchedulingRule getSchedulingRule(IValidationContext helper) {
return null;
@@ -91,7 +71,6 @@
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
super.validateInJob(helper, reporter);
- project = coreHelper.getSeamProject();
validationContext = ((SeamProject)project).getValidationContext();
Set<IFile> changedFiles = coreHelper.getChangedFiles();
validationContext.getRemovedFiles().clear();
@@ -265,14 +244,14 @@
// mark original factory
validationContext.addLinkedResource(factoryName, factory.getSourcePath());
location = coreHelper.getLocationOfName(factory);
- this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID, new String[]{factoryName},
location, factory.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location,
factory.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
// mark duplicate variable
IResource resource = coreHelper.getComponentResourceWithName(variable);
if(!coreHelper.isJar(resource)) {
validationContext.addLinkedResource(factoryName, resource.getFullPath());
location = coreHelper.getLocationOfName(variable);
- this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID, new String[]{factoryName},
location, resource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location, resource,
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
markedDuplicateFactoryNames.add(factoryName);
}
@@ -286,7 +265,7 @@
// mark unknown factory name
// save link to factory resource
validationContext.addLinkedResource(factoryName, factory.getSourcePath());
- this.addError(UNKNOWN_FACTORY_NAME_MESSAGE_ID, new String[]{factoryName},
coreHelper.getLocationOfName(factory), factory.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ this.addError(UNKNOWN_FACTORY_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_FACTORY_NAME,
new String[]{factoryName}, coreHelper.getLocationOfName(factory), factory.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
@@ -356,7 +335,7 @@
IResource checkedDeclarationResource = checkedDeclaration.getResource();
ISeamTextSourceReference location =
((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
if(location!=null) {
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, new String[]{component.getName()},
location, checkedDeclarationResource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{component.getName()}, location,
checkedDeclarationResource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
markedDeclarations.add(checkedDeclaration);
}
@@ -364,7 +343,7 @@
markedDeclarations.add(javaDeclaration);
ISeamTextSourceReference location =
((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
if(location!=null) {
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, new String[]{component.getName()},
location, javaDeclarationResource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{component.getName()}, location,
javaDeclarationResource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
}
@@ -390,10 +369,12 @@
validationContext.addLinkedResource(componentName, declaration.getSourcePath());
String className = declaration.getClassName();
if(className!=null) {
+ IType type = null;
// validate class name
try {
IProject p = project.getProject();
- IType type = EclipseResourceUtil.getJavaProject(p).findType(className);
+// type = EclipseJavaUtil.findType(EclipseResourceUtil.getJavaProject(p),
className);
+ type = EclipseResourceUtil.getJavaProject(p).findType(className);
if(type==null) {
// Mark wrong class name
ISeamTextSourceReference location =
((SeamComponentDeclaration)declaration).getLocationFor(ISeamXmlComponentDeclaration.CLASS);
@@ -403,7 +384,9 @@
if(location==null) {
location = declaration;
}
- addError(UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID, new String[]{className},
location, declaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_COMPONENT_CLASS_NAME, new String[]{className}, location,
declaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ } else if(!type.isBinary()) {
+ validationContext.addLinkedResource(componentName,
type.getResource().getFullPath());
}
} catch (JavaModelException e) {
SeamCorePlugin.getDefault().logError(e);
@@ -418,15 +401,9 @@
if(name==null) {
return;
}
- ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
- if(javaDeclaration==null) {
- return;
- }
-
- IType type = (IType)javaDeclaration.getSourceMember();
boolean ok = type.isBinary() || coreHelper.findSetter(type, name)!=null;
if(!ok) {
- addError(UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID, new
String[]{type.getElementName(), componentName, name}, property, declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID,
SeamPreferences.UNKNOWN_COMPONENT_PROPERTY, new String[]{type.getElementName(),
componentName, name}, property, declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
}
@@ -440,7 +417,7 @@
ScopeType scope = component.getScope();
if(scope == ScopeType.STATELESS) {
ISeamTextSourceReference location = getScopeLocation(component);
- addError(ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID, new String[]{component.getName()},
location, javaDeclaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID,
SeamPreferences.ENTITY_COMPONENT_WRONG_SCOPE, new String[]{component.getName()}, location,
javaDeclaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
}
@@ -469,40 +446,40 @@
private void validateStatefulComponent(ISeamComponent component) {
if(component.isStateful()) {
ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
- validateStatefulComponentMethods(SeamComponentMethodType.DESTROY, component,
DESTROY_METHOD_SUFIX_MESSAGE_ID);
- validateStatefulComponentMethods(SeamComponentMethodType.REMOVE, component,
REMOVE_METHOD_SUFIX_MESSAGE_ID);
+ validateStatefulComponentMethods(SeamComponentMethodType.DESTROY, component,
DESTROY_METHOD_SUFIX_MESSAGE_ID,
SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY);
+ validateStatefulComponentMethods(SeamComponentMethodType.REMOVE, component,
REMOVE_METHOD_SUFIX_MESSAGE_ID,
SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE);
ScopeType scope = component.getScope();
if(scope == ScopeType.PAGE || scope == ScopeType.STATELESS) {
ISeamTextSourceReference location = getScopeLocation(component);
- addError(STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID, new
String[]{component.getName()}, location, javaDeclaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID,
SeamPreferences.STATEFUL_COMPONENT_WRONG_SCOPE, new String[]{component.getName()},
location, javaDeclaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
}
- private void validateStatefulComponentMethods(SeamComponentMethodType methodType,
ISeamComponent component, String postfixMessageId) {
+ private void validateStatefulComponentMethods(SeamComponentMethodType methodType,
ISeamComponent component, String postfixMessageId, String preferenceKey) {
ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
ISeamTextSourceReference classNameLocation = getClassNameLocation(javaDeclaration);
Set<ISeamComponentMethod> methods =
javaDeclaration.getMethodsByType(methodType);
if(methods==null || methods.size()==0) {
- addError(STATEFUL_COMPONENT_DOES_NOT_CONTAIN_METHOD_SUFIX_MESSAGE_ID +
postfixMessageId, new String[]{component.getName()}, classNameLocation,
javaDeclaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(STATEFUL_COMPONENT_DOES_NOT_CONTAIN_METHOD_SUFIX_MESSAGE_ID +
postfixMessageId, preferenceKey, new String[]{component.getName()}, classNameLocation,
javaDeclaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
private void validateDuplicateComponentMethods(ISeamComponent component) {
- validateDuplicateComponentMethod(SeamComponentMethodType.DESTROY, component,
DESTROY_METHOD_SUFIX_MESSAGE_ID);
- validateDuplicateComponentMethod(SeamComponentMethodType.REMOVE, component,
REMOVE_METHOD_SUFIX_MESSAGE_ID);
- validateDuplicateComponentMethod(SeamComponentMethodType.CREATE, component,
CREATE_METHOD_SUFIX_MESSAGE_ID);
- validateDuplicateComponentMethod(SeamComponentMethodType.UNWRAP, component,
UNWRAP_METHOD_SUFIX_MESSAGE_ID);
+ validateDuplicateComponentMethod(SeamComponentMethodType.DESTROY, component,
DESTROY_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_DESTROY);
+ validateDuplicateComponentMethod(SeamComponentMethodType.REMOVE, component,
REMOVE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_REMOVE);
+ validateDuplicateComponentMethod(SeamComponentMethodType.CREATE, component,
CREATE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_CREATE);
+ validateDuplicateComponentMethod(SeamComponentMethodType.UNWRAP, component,
UNWRAP_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_UNWRAP);
}
- private void validateDuplicateComponentMethod(SeamComponentMethodType methodType,
ISeamComponent component, String postfixMessageId) {
+ private void validateDuplicateComponentMethod(SeamComponentMethodType methodType,
ISeamComponent component, String postfixMessageId, String preferenceKey) {
ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
Set<ISeamComponentMethod> methods =
javaDeclaration.getMethodsByType(methodType);
if(methods!=null && methods.size()>1) {
for (ISeamComponentMethod method : methods) {
IMethod javaMethod = (IMethod)method.getSourceMember();
String methodName = javaMethod.getElementName();
- addError(DUPLICATE_METHOD_PREFIX_MESSAGE_ID + postfixMessageId, new
String[]{methodName}, method, javaDeclaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(DUPLICATE_METHOD_PREFIX_MESSAGE_ID + postfixMessageId, preferenceKey, new
String[]{methodName}, method, javaDeclaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
}
@@ -543,7 +520,7 @@
if(variables==null || variables.size()<1) {
// Injection has unknown name. Mark it.
IResource declarationResource = declaration.getResource();
- addError(UNKNOWN_INJECTION_NAME_MESSAGE_ID, new String[]{name}, bijection,
declarationResource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(UNKNOWN_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_VARIABLE_NAME, new
String[]{name}, bijection, declarationResource, MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
}
@@ -555,7 +532,7 @@
Set<IBijectedAttribute> dataBinders =
declaration.getBijectedAttributesByType(BijectedAttributeType.DATA_BINDER);
if(dataBinders.size()>0) {
for (IBijectedAttribute dataBinder : dataBinders) {
- addError(MULTIPLE_DATA_BINDER_MESSAGE_ID, dataBinder, declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(MULTIPLE_DATA_BINDER_MESSAGE_ID, SeamPreferences.MULTIPLE_DATA_BINDER,
dataBinder, declaration.getResource(), MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
} else {
@@ -567,7 +544,7 @@
return;
}
}
- addError(UNKNOWN_DATA_MODEL_MESSAGE_ID, new String[]{name},
coreHelper.getLocationOfName(bijection), declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(UNKNOWN_DATA_MODEL_MESSAGE_ID, SeamPreferences.UNKNOWN_DATA_MODEL, new
String[]{name}, coreHelper.getLocationOfName(bijection), declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
}
}
@@ -579,19 +556,19 @@
validationContext.removeUnnamedResource(declaration.getSourcePath());
return;
}
- validateMethodOfUnknownComponent(SeamComponentMethodType.DESTROY, declaration,
DESTROY_METHOD_SUFIX_MESSAGE_ID);
- validateMethodOfUnknownComponent(SeamComponentMethodType.CREATE, declaration,
CREATE_METHOD_SUFIX_MESSAGE_ID);
- validateMethodOfUnknownComponent(SeamComponentMethodType.UNWRAP, declaration,
UNWRAP_METHOD_SUFIX_MESSAGE_ID);
- validateMethodOfUnknownComponent(SeamComponentMethodType.OBSERVER, declaration,
OBSERVER_METHOD_SUFIX_MESSAGE_ID);
+ validateMethodOfUnknownComponent(SeamComponentMethodType.DESTROY, declaration,
DESTROY_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DESTROY_DOESNT_BELONG_TO_COMPONENT);
+ validateMethodOfUnknownComponent(SeamComponentMethodType.CREATE, declaration,
CREATE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.CREATE_DOESNT_BELONG_TO_COMPONENT);
+ validateMethodOfUnknownComponent(SeamComponentMethodType.UNWRAP, declaration,
UNWRAP_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.UNWRAP_DOESNT_BELONG_TO_COMPONENT);
+ validateMethodOfUnknownComponent(SeamComponentMethodType.OBSERVER, declaration,
OBSERVER_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.OBSERVER_DOESNT_BELONG_TO_COMPONENT);
}
- private void validateMethodOfUnknownComponent(SeamComponentMethodType methodType,
ISeamJavaComponentDeclaration declaration, String sufixMessageId) {
+ private void validateMethodOfUnknownComponent(SeamComponentMethodType methodType,
ISeamJavaComponentDeclaration declaration, String sufixMessageId, String preferenceKey) {
Set<ISeamComponentMethod> methods = declaration.getMethodsByType(methodType);
if(methods!=null && methods.size()>0) {
for (ISeamComponentMethod method : methods) {
IMethod javaMethod = (IMethod)method.getSourceMember();
String methodName = javaMethod.getElementName();
- addError(sufixMessageId + NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID, new
String[]{methodName}, method, declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
+ addError(sufixMessageId + NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID, preferenceKey, new
String[]{methodName}, method, declaration.getResource(),
MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
validationContext.addUnnamedResource(declaration.getSourcePath());
}
} else {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2007-07-19
17:49:11 UTC (rev 2530)
@@ -14,13 +14,16 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
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.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
+import org.jboss.tools.seam.core.SeamPreferences;
/**
* Basic seam validator.
@@ -28,9 +31,30 @@
*/
public abstract class SeamValidator implements IValidatorJob {
+ protected static final String NONUNIQUE_COMPONENT_NAME_MESSAGE_ID =
"NONUNIQUE_COMPONENT_NAME_MESSAGE";
+ protected static final String UNKNOWN_VARIABLE_NAME_MESSAGE_ID =
"UNKNOWN_VARIABLE_NAME";
+ protected static final String
STATEFUL_COMPONENT_DOES_NOT_CONTAIN_METHOD_SUFIX_MESSAGE_ID =
"STATEFUL_COMPONENT_DOES_NOT_CONTAIN_";
+ protected static final String DUPLICATE_METHOD_PREFIX_MESSAGE_ID =
"DUPLICATE_";
+ protected static final String REMOVE_METHOD_SUFIX_MESSAGE_ID = "REMOVE";
+ protected static final String DESTROY_METHOD_SUFIX_MESSAGE_ID = "DESTROY";
+ protected static final String CREATE_METHOD_SUFIX_MESSAGE_ID = "CREATE";
+ protected static final String UNWRAP_METHOD_SUFIX_MESSAGE_ID = "UNWRAP";
+ protected static final String OBSERVER_METHOD_SUFIX_MESSAGE_ID = "OBSERVER";
+ protected static final String NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID =
"_DOESNT_BELONG_TO_COMPONENT";
+ protected static final String STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID =
"STATEFUL_COMPONENT_WRONG_SCOPE";
+ protected static final String ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID =
"ENTITY_COMPONENT_WRONG_SCOPE";
+ protected static final String UNKNOWN_FACTORY_NAME_MESSAGE_ID =
"UNKNOWN_FACTORY_NAME";
+ protected static final String MULTIPLE_DATA_BINDER_MESSAGE_ID =
"MULTIPLE_DATA_BINDER";
+ protected static final String DUPLICATE_VARIABLE_NAME_MESSAGE_ID =
"DUPLICATE_VARIABLE_NAME";
+ protected static final String UNKNOWN_DATA_MODEL_MESSAGE_ID =
"UNKNOWN_DATA_MODEL";
+ protected static final String UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID =
"UNKNOWN_COMPONENT_CLASS_NAME";
+ protected static final String UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID =
"UNKNOWN_COMPONENT_PROPERTY";
+
protected SeamCoreValidationHelper coreHelper;
protected IReporter reporter;
+ protected ISeamProject project;
+
public SeamValidator() {
super();
}
@@ -38,6 +62,7 @@
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
this.coreHelper = (SeamCoreValidationHelper)helper;
this.reporter = reporter;
+ this.project = coreHelper.getSeamProject();
return OK_STATUS;
}
@@ -53,20 +78,31 @@
return "org.jboss.tools.seam.internal.core.validation.messages";
}
- protected void addError(String messageId, String[] messageArguments,
ISeamTextSourceReference location, IResource target, String messageGroup) {
- addError(messageId, messageArguments, location.getLength(),
location.getStartPosition(), target, messageGroup);
+ protected void addError(String preferenceKey, String messageId, String[]
messageArguments, ISeamTextSourceReference location, IResource target, String
messageGroup) {
+ addError(preferenceKey, messageId, messageArguments, location.getLength(),
location.getStartPosition(), target, messageGroup);
}
- protected void addError(String messageId, String[] messageArguments, int length, int
offset, IResource target, String messageGroup) {
- IMessage message = new Message(getBaseName(), IMessage.HIGH_SEVERITY, messageId,
messageArguments, target, messageGroup);
+ protected void addError(String preferenceKey, String messageId, String[]
messageArguments, int length, int offset, IResource target, String messageGroup) {
+ String preferenceValue = SeamPreferences.getProjectPreference(project, preferenceKey);
+ boolean ignore = false;
+ int messageSeverity = IMessage.HIGH_SEVERITY;
+ if(SeamPreferences.WARNING.equals(preferenceValue)) {
+ messageSeverity = IMessage.HIGH_SEVERITY;
+ } else if(SeamPreferences.IGNORE.equals(preferenceValue)) {
+ ignore = true;
+ }
+
+ IMessage message = new Message(getBaseName(), messageSeverity, messageId,
messageArguments, target, messageGroup);
message.setLength(length);
message.setOffset(offset);
message.setSeverity(IMessage.HIGH_SEVERITY);
- reporter.addMessage(this, message);
+ if(!ignore) {
+ reporter.addMessage(this, message);
+ }
}
- protected void addError(String messageId, ISeamTextSourceReference location, IResource
target, String messageGroup) {
- addError(messageId, new String[0], location, target, messageGroup);
+ protected void addError(String preferenceKey, String messageId, ISeamTextSourceReference
location, IResource target, String messageGroup) {
+ addError(preferenceKey, messageId, new String[0], location, target, messageGroup);
}
protected void removeMessagesFromResources(Set<IResource> resources, String
messageGroup) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2007-07-19
17:49:11 UTC (rev 2530)
@@ -38,4 +38,4 @@
#Context variables
DUPLICATE_VARIABLE_NAME=Duplicate variable name: {0}
-UNKNOWN_INJECTION_NAME=Unknown context variable name: {0}
\ No newline at end of file
+UNKNOWN_VARIABLE_NAME=Unknown context variable name: {0}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2007-07-19
17:49:11 UTC (rev 2530)
@@ -31,6 +31,8 @@
public static String
SeamValidatorConfigurationBlock_pb_statefulComponentDoesNotContainRemove_label;
public static String
SeamValidatorConfigurationBlock_pb_statefulComponentDoesNotContainDestroy_label;
public static String
SeamValidatorConfigurationBlock_pb_statefulComponentHasWrongScope_label;
+ public static String
SeamValidatorConfigurationBlock_pb_unknownComponentClassName_label;
+ public static String SeamValidatorConfigurationBlock_pb_unknownComponentProperty_label;
//Section Entities
public static String SeamValidatorConfigurationBlock_section_entities;
@@ -59,7 +61,7 @@
//Section Context variables
public static String SeamValidatorConfigurationBlock_section_variable;
public static String SeamValidatorConfigurationBlock_pb_duplicateVariableName_label;
- public static String SeamValidatorConfigurationBlock_pb_unknownInjectionName_label;
+ public static String SeamValidatorConfigurationBlock_pb_unknownVariableName_label;
static {
NLS.initializeMessages(BUNDLE_NAME, SeamPreferencesMessages.class);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2007-07-19
17:49:11 UTC (rev 2530)
@@ -11,6 +11,8 @@
SeamValidatorConfigurationBlock_pb_statefulComponentDoesNotContainRemove_label=Stateful
component does not contain remove:
SeamValidatorConfigurationBlock_pb_statefulComponentDoesNotContainDestroy_label=Stateful
component does not contain destroy:
SeamValidatorConfigurationBlock_pb_statefulComponentHasWrongScope_label=Stateful
component has wrong scope:
+SeamValidatorConfigurationBlock_pb_unknownComponentClassName_label=Component class name
cannot be resolved to a type:
+SeamValidatorConfigurationBlock_pb_unknownComponentProperty_label=Component class does
not contain setter for property:
##Section Entities
SeamValidatorConfigurationBlock_section_entities=Entities
@@ -39,4 +41,4 @@
##Section Context variables
SeamValidatorConfigurationBlock_section_variable=Context variables
SeamValidatorConfigurationBlock_pb_duplicateVariableName_label=Duplicate variable name:
-SeamValidatorConfigurationBlock_pb_unknownInjectionName_label=Unknown injection name:
+SeamValidatorConfigurationBlock_pb_unknownVariableName_label=Unknown variable name:
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2007-07-19
17:33:15 UTC (rev 2529)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2007-07-19
17:49:11 UTC (rev 2530)
@@ -15,9 +15,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock;
-import org.eclipse.jdt.internal.ui.preferences.PreferencesMessages;
import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent;
-import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.Key;
import org.eclipse.jdt.internal.ui.util.PixelConverter;
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -54,7 +52,7 @@
*/
public class SeamValidatorConfigurationBlock extends OptionsConfigurationBlock {
private static final String SETTINGS_SECTION_NAME =
"SeamValidatorConfigurationBlock";
-
+
private static SectionDescription SECTION_COMPONENT = new SectionDescription(
SeamPreferencesMessages.SeamValidatorConfigurationBlock_section_component,
new String[][]{
@@ -62,6 +60,8 @@
{SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_statefulComponentDoesNotContainRemove_label},
{SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_statefulComponentDoesNotContainDestroy_label},
{SeamPreferences.STATEFUL_COMPONENT_WRONG_SCOPE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_statefulComponentHasWrongScope_label},
+ {SeamPreferences.UNKNOWN_COMPONENT_CLASS_NAME,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_unknownComponentClassName_label},
+ {SeamPreferences.UNKNOWN_COMPONENT_PROPERTY,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_unknownComponentProperty_label}
}
);
@@ -105,10 +105,10 @@
SeamPreferencesMessages.SeamValidatorConfigurationBlock_section_variable,
new String[][]{
{SeamPreferences.DUPLICATE_VARIABLE_NAME,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateVariableName_label},
- {SeamPreferences.UNKNOWN_INJECTION_NAME,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_unknownInjectionName_label},
+ {SeamPreferences.UNKNOWN_VARIABLE_NAME,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_unknownVariableName_label},
}
);
-
+
private static SectionDescription[] ALL_SECTIONS = new SectionDescription[]{
SECTION_COMPONENT,
SECTION_ENTITY,
@@ -125,7 +125,7 @@
private static final String IGNORE = SeamPreferences.IGNORE;
private PixelConverter fPixelConverter;
-
+
private static Key[] getKeys() {
ArrayList<Key> keys = new ArrayList<Key>();
for (int i = 0; i < ALL_SECTIONS.length; i++) {
@@ -146,55 +146,55 @@
protected Control createContents(Composite parent) {
fPixelConverter = new PixelConverter(parent);
setShell(parent.getShell());
-
+
Composite mainComp = new Composite(parent, SWT.NONE);
mainComp.setFont(parent.getFont());
GridLayout layout= new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
mainComp.setLayout(layout);
-
+
Composite commonComposite = createStyleTabContent(mainComp);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
gridData.heightHint = fPixelConverter.convertHeightInCharsToPixels(20);
commonComposite.setLayoutData(gridData);
-
+
validateSettings(null, null, null);
-
+
return mainComp;
}
private Composite createStyleTabContent(Composite folder) {
String[] errorWarningIgnore = new String[] {ERROR, WARNING, IGNORE};
-
+
String[] errorWarningIgnoreLabels = new String[] {
"Error",
"Warning",
"Ignore"
};
-
+
int nColumns = 3;
-
+
final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
-
+
Composite composite = sc1.getBody();
GridLayout layout= new GridLayout(nColumns, false);
layout.marginHeight= 0;
layout.marginWidth= 0;
composite.setLayout(layout);
-
+
Label description= new Label(composite, SWT.LEFT | SWT.WRAP);
description.setFont(description.getFont());
description.setText(SeamPreferencesMessages.SeamValidatorConfigurationBlock_common_description);
description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true,
false, nColumns - 1, 1));
-
+
int defaultIndent = 0;
for (int i = 0; i < ALL_SECTIONS.length; i++) {
SectionDescription section = ALL_SECTIONS[i];
String label = section.label;
ExpandableComposite excomposite = createStyleSection(composite, label, nColumns);
-
+
Composite inner = new Composite(excomposite, SWT.NONE);
inner.setFont(composite.getFont());
inner.setLayout(new GridLayout(nColumns, false));
@@ -206,10 +206,10 @@
addComboBox(inner, label, option.key, errorWarningIgnore, errorWarningIgnoreLabels,
defaultIndent);
}
}
-
+
IDialogSettings section =
SeamCorePlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
restoreSectionExpansionStates(section);
-
+
return sc1;
}
@@ -231,20 +231,20 @@
if (!areSettingsEnabled()) {
return;
}
-
+
//updateEnableStates();
-
+
fContext.statusChanged(new StatusInfo());
}
protected static Key getSeamKey(String key) {
return getKey(SeamCorePlugin.PLUGIN_ID, key);
}
-
+
static class SectionDescription {
String label;
OptionDescription[] options;
-
+
public SectionDescription(String label, String[][] optionLabelsAndKeys) {
this.label = label;
options = new OptionDescription[optionLabelsAndKeys.length];
@@ -253,15 +253,14 @@
}
}
}
-
+
static class OptionDescription {
String label;
Key key;
-
+
public OptionDescription(String keyName, String label) {
this.label = label;
key = getSeamKey(keyName);
}
}
-
-}
+}
\ No newline at end of file