Author: akazakov
Date: 2008-10-23 09:27:19 -0400 (Thu, 23 Oct 2008)
New Revision: 11107
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2959 Fixed in trunk (cr1) and brunch (beta1)
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-10-23
13:27:19 UTC (rev 11107)
@@ -113,6 +113,8 @@
public static String
SEAM_FORM_WIZARD_PAGE1_JAVA_INTERFACE_SLSB_AND_KEY_SEAMEJB3_ANNOTATIONS_WILL_BE_CREATED;
+ public static String SEAM_INSTALL_WIZARD_PROJECT_NAME_WITH_UPPERCASE;
+
public static String SEAM_FORM_WIZARD_PAGE1_SEAM_FORM;
public static String SEAM_FORM_WIZARD_PAGE1_SELECT_THE_NAME_OF_THE_NEW_SEAM_FORM;
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/DataModelValidatorDelegate.java 2008-10-23
13:27:19 UTC (rev 11107)
@@ -15,6 +15,8 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
@@ -84,25 +86,40 @@
*
*/
public void validateUntillError() {
- page.setErrorMessage(getFirstValidationError());
+ IStatus message = getFirstValidationError();
+ if(message == null) {
+ page.setMessage(null);
+ page.setErrorMessage(null);
+ } else {
+ if(message.getSeverity()==IStatus.ERROR) {
+ page.setErrorMessage(message.getMessage());
+ } else {
+ page.setErrorMessage(null);
+ page.setMessage(message.getMessage(), DialogPage.WARNING);
+ }
+ }
page.setPageComplete(page.getErrorMessage()==null);
- if(page.getErrorMessage()==null) page.setMessage(null);
}
/**
*
* @return
*/
- public String getFirstValidationError() {
+ public IStatus getFirstValidationError() {
+ IStatus firstWarning = null;
for (String validatorName : validationOrder) {
- Map<String,String> errors = getValidator(validatorName).validate(
+ Map<String,IStatus> errors = getValidator(validatorName).validate(
model.getProperty(validatorName),model);
- String message = errors.get(validatorName);
+ IStatus message = errors.get(validatorName);
if(message!=null) {
- return message;
+ if(message.getSeverity()==IStatus.ERROR) {
+ return message;
+ } else if(message.getSeverity()==IStatus.WARNING && firstWarning==null) {
+ firstWarning = message;
+ }
}
}
- return null;
+ return firstWarning;
}
/**
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/IValidator.java 2008-10-23
13:27:19 UTC (rev 11107)
@@ -12,6 +12,8 @@
import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+
/**
* Simple validator interface
* @author eskimo
@@ -27,5 +29,5 @@
* @param context - a contextual data that can be used during validation
* @return map from editor name to error text
*/
- Map<String,String> validate(Object value, Object context);
+ Map<String, IStatus> validate(Object value, Object context);
}
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-10-23
13:27:19 UTC (rev 11107)
@@ -20,11 +20,13 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.wizard.IWizard;
@@ -98,7 +100,7 @@
// Database group
private IFieldEditor connProfileSelEditor =
SeamWizardFactory.createConnectionProfileSelectionFieldEditor(getConnectionProfileDefaultValue(),
new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
SeamInstallWizardPage.this.validate();
return ValidatorFactory.NO_ERRORS;
}
@@ -379,6 +381,12 @@
validatorDelegate.addValidatorForProperty(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
getDeploymentTypeValidator(getWizard()));
+ validatorDelegate.addValidatorForProperty(
+ IFacetDataModelProperties.FACET_PROJECT_NAME,
+ new ProjectNamesDuplicationValidator(
+ IFacetDataModelProperties.FACET_PROJECT_NAME));
+ validatorDelegate.addValidatorForProperty(IFacetDataModelProperties.FACET_PROJECT_NAME,
+ new ProjectNameValidator(IFacetDataModelProperties.FACET_PROJECT_NAME));
}
jBossHibernateDbTypeEditor
@@ -479,11 +487,24 @@
}
private void validate() {
- final String message = validatorDelegate.getFirstValidationError();
+ final IStatus message = validatorDelegate.getFirstValidationError();
Display.getDefault().syncExec(new Runnable() {
public void run() {
- setPageComplete(message == null);
- setErrorMessage(message);
+ if(message==null) {
+ setMessage(null);
+ setErrorMessage(null);
+ setPageComplete(true);
+ return;
+ }
+ if(message.getSeverity()==IStatus.ERROR) {
+ setErrorMessage(message.getMessage());
+ setPageComplete(false);
+ return;
+ }
+ setErrorMessage(null);
+ setMessage(message.getMessage(), DialogPage.WARNING);
+ setPageComplete(true);
+ return;
}
});
}
@@ -505,18 +526,45 @@
/**
* @see IValidator#validate(Object, Object)
*/
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
IStatus status = JavaConventions.validatePackageName(value
.toString(), CompilerOptions.VERSION_1_5,
CompilerOptions.VERSION_1_5);
- if (!status.isOK()) {
+ if (status.getSeverity()==IStatus.ERROR) {
return ValidatorFactory.createErrormessage(fieldName,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_PACKAGE_NAME_FOR + targetName +
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_IS_NOT_VALID);
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_PACKAGE_NAME_FOR + targetName +
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_IS_NOT_VALID));
+ } else if (status.getSeverity()==IStatus.WARNING) {
+ return ValidatorFactory.createErrormessage(fieldName,
+ new Status(IStatus.WARNING, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_PACKAGE_NAME_FOR + targetName +
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_IS_NOT_VALID));
}
return ValidatorFactory.NO_ERRORS;
}
}
+ class ProjectNameValidator implements IValidator {
+ String propertyName;
+
+ public ProjectNameValidator(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public Map<String, IStatus> validate(Object value, Object context) {
+ if(value==null) {
+ return ValidatorFactory.NO_ERRORS;
+ }
+ final String projectName = (String)value;
+ if(projectName.length()==0) {
+ return ValidatorFactory.NO_ERRORS;
+ }
+ char firstLetter = projectName.charAt(0);
+ if(Character.isUpperCase(firstLetter)) {
+ return ValidatorFactory.createErrormessage(propertyName,
+ new Status(IStatus.WARNING, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.SEAM_INSTALL_WIZARD_PROJECT_NAME_WITH_UPPERCASE));
+ }
+ return ValidatorFactory.NO_ERRORS;
+ }
+ }
+
class ProjectNamesDuplicationValidator implements IValidator {
String propertyName;
@@ -529,35 +577,52 @@
/**
* @see IValidator#validate(Object, Object)
*/
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
final String projectName = (String)value;
final String deployAs = model.getStringProperty(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS);
final String testProjectName = projectName + "-test"; //$NON-NLS-1$
IStatus status = ProjectCreationDataModelProviderNew.validateName(testProjectName);
- if (!status.isOK())
+ if (status.getSeverity()==IStatus.ERROR) {
return ValidatorFactory.createErrormessage(propertyName,
- SeamUIMessages.VALIDATOR_FACTORY_TEST_PROJECT +
- testProjectName +
- SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS);
-
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_TEST_PROJECT +
+ testProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS));
+ } else if (status.getSeverity()==IStatus.WARNING) {
+ return ValidatorFactory.createErrormessage(propertyName,
+ new Status(IStatus.WARNING, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_TEST_PROJECT +
+ testProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS));
+ }
if (ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equals(deployAs)) {
final String earProjectName = projectName + "-ear"; //$NON-NLS-1$
status = ProjectCreationDataModelProviderNew.validateName(earProjectName);
- if (!status.isOK())
+ if (status.getSeverity()==IStatus.ERROR) {
return ValidatorFactory.createErrormessage(propertyName,
- SeamUIMessages.VALIDATOR_FACTORY_EAR_PROJECT +
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_EAR_PROJECT +
earProjectName +
- SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS);
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS));
+ } else if (status.getSeverity()==IStatus.WARNING) {
+ return ValidatorFactory.createErrormessage(propertyName,
+ new Status(IStatus.WARNING, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_EAR_PROJECT +
+ earProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS));
+ }
final String ejbProjectName = projectName + "-ejb"; //$NON-NLS-1$
status = ProjectCreationDataModelProviderNew.validateName(ejbProjectName);
- if (!status.isOK())
+ if (status.getSeverity()==IStatus.ERROR) {
return ValidatorFactory.createErrormessage(propertyName,
- SeamUIMessages.VALIDATOR_FACTORY_EJB_PROJECT +
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_EJB_PROJECT +
ejbProjectName +
- SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS);
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS));
+ } else if (status.getSeverity()==IStatus.WARNING) {
+ return ValidatorFactory.createErrormessage(propertyName,
+ new Status(IStatus.WARNING, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_EJB_PROJECT +
+ ejbProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS));
+ }
}
return ValidatorFactory.NO_ERRORS;
}
@@ -569,7 +634,7 @@
}
// return new DeploymentTypeValidator(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
model);
return new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
return ValidatorFactory.NO_ERRORS;
}
};
@@ -599,7 +664,7 @@
/**
* @see IValidator#validate(Object, Object)
*/
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
final String deploymentType = value.toString();
if(!ISeamFacetDataModelProperties.DEPLOY_AS_WAR.equals(deploymentType)) {
Object runtimeName =
model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
@@ -608,7 +673,7 @@
if(!rt.supports(EJB_30) || !rt.supports(EAR_50)) {
return ValidatorFactory.createErrormessage(
propertyName,
- NLS.bind(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CANNOT_USE_SELECTED_DEPLOYMENT6 ,
new String[]{deploymentType.toUpperCase(),runtimeName.toString()}));
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
NLS.bind(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CANNOT_USE_SELECTED_DEPLOYMENT6 , new
String[]{deploymentType.toUpperCase(),runtimeName.toString()})));
}
}
}
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2008-10-23
13:27:19 UTC (rev 11107)
@@ -21,6 +21,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
import org.eclipse.jdt.core.IJavaProject;
@@ -56,14 +57,14 @@
/**
*
*/
- static public final Map<String, String> NO_ERRORS = Collections
- .unmodifiableMap(new HashMap<String, String>());
+ static public final Map<String, IStatus> NO_ERRORS = Collections
+ .unmodifiableMap(new HashMap<String, IStatus>());
/**
*
*/
static public IValidator NO_ERRORS_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
return NO_ERRORS;
}
};
@@ -82,8 +83,8 @@
*
* @return
*/
- public static Map<String, String> createErrorMap() {
- return new HashMap<String, String>();
+ public static Map<String, IStatus> createErrorMap() {
+ return new HashMap<String, IStatus>();
}
/**
@@ -91,9 +92,9 @@
* @param text
* @return
*/
- public static Map<String, String> createErrormessage(String text) {
- Map<String, String> map = createErrorMap();
- map.put(IValidator.DEFAULT_ERROR, text);
+ public static Map<String, IStatus> createErrormessage(IStatus message) {
+ Map<String, IStatus> map = createErrorMap();
+ map.put(IValidator.DEFAULT_ERROR, message);
return map;
}
@@ -102,10 +103,10 @@
* @param text
* @return
*/
- public static Map<String, String> createErrormessage(String propertyName,
- String text) {
- Map<String, String> map = createErrorMap();
- map.put(propertyName, text);
+ public static Map<String, IStatus> createErrormessage(String propertyName,
+ IStatus message) {
+ Map<String, IStatus> map = createErrorMap();
+ map.put(propertyName, message);
return map;
}
@@ -114,7 +115,7 @@
*/
public static final IValidator FILE_SYSTEM_FOLDER_EXISTS = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
if (value == null)
throw new IllegalArgumentException(
SeamUIMessages.VALIDATOR_FACTORY_PATH_TO_A_FOLDER_CANNOT_BE_NULL);
@@ -122,13 +123,13 @@
File folder = new File(folderPath);
if (!folder.exists())
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_FOLDER
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_FOLDER
+ folderPath
- + SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXISTS);
+ + SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXISTS));
if (!folder.isDirectory())
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PATH
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_PATH
+ folderPath
- + SeamUIMessages.VALIDATOR_FACTORY_POINTS_TO_FILE);
+ + SeamUIMessages.VALIDATOR_FACTORY_POINTS_TO_FILE));
return NO_ERRORS;
}
};
@@ -137,15 +138,13 @@
*
*/
public static final IValidator JBOSS_SEAM_HOME_FOLDER_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
- Map<String, String> errors = FILE_SYSTEM_FOLDER_EXISTS.validate(
+ public Map<String, IStatus> validate(Object value, Object context) {
+ Map<String, IStatus> errors = FILE_SYSTEM_FOLDER_EXISTS.validate(
value, context);
if (errors.size() > 0) {
errors = createErrorMap();
- errors
- .put(
- ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_HOME_FOLDER_DOES_NOT_EXISTS);
+ errors.put(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME, new Status(IStatus.ERROR,
SeamCorePlugin.PLUGIN_ID,
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_HOME_FOLDER_DOES_NOT_EXISTS));
return errors;
}
String version = (String) context;
@@ -155,21 +154,19 @@
"lib/jboss-seam.jar"); //$NON-NLS-1$
if (!seamJarFile.isFile()) {
errors = createErrorMap();
- errors
- .put(
- ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ errors.put(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_HOME_FOLDER_POINTS_TO
- +
SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER);
+ +
SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER));
}
} else {
File seamJarFile = new File(value.toString(), "jboss-seam.jar");
//$NON-NLS-1$
if (!seamJarFile.isFile()) {
errors = createErrorMap();
- errors
- .put(
- ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ errors.put(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_HOME_FOLDER_POINTS_TO
- +
SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER);
+ +
SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER));
}
}
@@ -181,23 +178,21 @@
*
*/
public static final IValidator JBOSS_AS_HOME_FOLDER_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
- Map<String, String> errors = FILE_SYSTEM_FOLDER_EXISTS.validate(
+ public Map<String, IStatus> validate(Object value, Object context) {
+ Map<String, IStatus> errors = FILE_SYSTEM_FOLDER_EXISTS.validate(
value, context);
if (errors.size() > 0) {
errors = createErrorMap();
- errors
- .put(
- ISeamFacetDataModelProperties.JBOSS_AS_HOME,
- SeamUIMessages.VALIDATOR_FACTORY_JBOSS_AS_HOME_FOLDER_DOES_NOT_EXIST);
+ errors.put(ISeamFacetDataModelProperties.JBOSS_AS_HOME,
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
+ SeamUIMessages.VALIDATOR_FACTORY_JBOSS_AS_HOME_FOLDER_DOES_NOT_EXIST));
return errors;
}
if (!new File(value.toString(), "bin/twiddle.jar").isFile()) {
//$NON-NLS-1$
- errors
- .put(
- ISeamFacetDataModelProperties.JBOSS_AS_HOME,
- SeamUIMessages.VALIDATOR_FACTORY_JBOSS_AS_HOME_FOLDER_POINT_TO_LOCATION_THAT_DOES_NOT
- + SeamUIMessages.VALIDATOR_FACTORY_LOOK_LIKE_JBOSS_AS_HOME_FOLDER);
+ errors.put(ISeamFacetDataModelProperties.JBOSS_AS_HOME,
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
+ SeamUIMessages.VALIDATOR_FACTORY_JBOSS_AS_HOME_FOLDER_POINT_TO_LOCATION_THAT_DOES_NOT
+ + SeamUIMessages.VALIDATOR_FACTORY_LOOK_LIKE_JBOSS_AS_HOME_FOLDER));
}
return errors;
}
@@ -207,34 +202,29 @@
*
*/
public static final IValidator CLASS_QNAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
String classDecl = "class " + value.toString() + " {}";
//$NON-NLS-1$ //$NON-NLS-2$
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(classDecl.toCharArray());
parser.setProject((IJavaProject) context);
- CompilationUnit compilationUnit = (CompilationUnit) parser
- .createAST(null);
+ CompilationUnit compilationUnit = (CompilationUnit)parser.createAST(null);
IProblem[] problems = compilationUnit.getProblems();
if (problems.length > 0) {
- return createErrormessage(Messages
- .format(
- SeamUIMessages.VALIDATOR_FACTORY_COMPONENT_NAME_IS_NOT_VALID,
- problems[0].getMessage()));
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
+ Messages.format(SeamUIMessages.VALIDATOR_FACTORY_COMPONENT_NAME_IS_NOT_VALID,
+ problems[0].getMessage())));
}
return ValidatorFactory.NO_ERRORS;
}
};
public static final IValidator PACKAGE_NAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
IStatus status = JavaConventions.validatePackageName(value
.toString(), CompilerOptions.VERSION_1_5,
CompilerOptions.VERSION_1_5);
if (status.getSeverity() == IStatus.ERROR) {
- return createErrormessage((Messages
- .format(
- NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName,
- status.getMessage())));
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName,
status.getMessage())));
}
return ValidatorFactory.NO_ERRORS;
@@ -245,7 +235,7 @@
*
*/
public static final IValidator FILESYSTEM_FILE_EXISTS_VALIDATOR = new IValidator() {
- public java.util.Map<String, String> validate(Object value,
+ public java.util.Map<String, IStatus> validate(Object value,
Object context) {
return ValidatorFactory.NO_ERRORS;
};
@@ -258,14 +248,14 @@
*/
public static final IValidator SEAM_COMPONENT_NAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
IStatus status = JavaConventions.validateClassFileName(value
.toString()
+ ".class", "5.0", "5.0"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
if (status.isOK()) {
return NO_ERRORS;
} else {
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID);
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID));
}
}
};
@@ -277,7 +267,7 @@
*/
public static final IValidator SEAM_JAVA_INTEFACE_NAME_CONVENTION_VALIDATOR = new
IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
if (!(context instanceof Object[])) {
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
@@ -295,8 +285,8 @@
IStatus status = JavaConventions.validateJavaTypeName(value
.toString(), sourceLevel, compliance);
if (status.getSeverity() == IStatus.WARNING) {
- return
createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_LOCAL_INTERFACE_NAME_IS_NOT_VALID
- + status.getMessage());
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_LOCAL_INTERFACE_NAME_IS_NOT_VALID
+ + status.getMessage()));
}
return NO_ERRORS;
}
@@ -304,7 +294,7 @@
public static final IValidator SEAM_METHOD_NAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
if (!(context instanceof Object[])) {
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
@@ -321,8 +311,8 @@
IProblem[] problems = compilationUnit.getProblems();
if (problems.length > 0) {
- return createErrormessage(targetName
- + SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2);
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
targetName
+ + SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2));
}
return NO_ERRORS;
@@ -331,7 +321,7 @@
public static final IValidator FILE_NAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
if (!(context instanceof Object[])) {
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
@@ -343,27 +333,27 @@
if ("".equals(value) //$NON-NLS-1$
|| !project.getLocation().isValidSegment(value.toString()))
- return createErrormessage(targetName
- + SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2);
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
targetName
+ + SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2));
return NO_ERRORS;
}
};
public static final IValidator SEAM_PROJECT_NAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
if (value == null || "".equals(value)) { //$NON-NLS-1$
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PRJ_NOT_SELECTED);
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_PRJ_NOT_SELECTED));
}
IResource project = ResourcesPlugin.getWorkspace().getRoot()
.findMember(value.toString());
if (project == null || !(project instanceof IProject)
|| !project.exists()) {
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PROJECT
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_PROJECT
+ value
- + SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXIST);
+ + SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXIST));
} else {
IProject selection = (IProject) project;
try {
@@ -376,19 +366,19 @@
// .class)).hasProjectFacet(ProjectFacetsManager
// .getProjectFacet("jst.web"))
||
"" .equals(SeamCorePlugin.getSeamPreferences(selection).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
""))) { //$NON-NLS-1$
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_SELECTED_PROJECT
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_SELECTED_PROJECT
+ project.getName()
- + SeamUIMessages.VALIDATOR_FACTORY_IS_NOT_A_SEAM_WEB_PROJECT);
+ + SeamUIMessages.VALIDATOR_FACTORY_IS_NOT_A_SEAM_WEB_PROJECT));
} else {
// TODO validate project(s) structure
}
} catch (CoreException e) {
// it might happen only if project is closed and project
// name typed by hand
- return createErrormessage(NLS
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SELECTED_PRJ_IS_CLOSED,
- project.getName()));
+ project.getName())));
}
}
return NO_ERRORS;
@@ -403,11 +393,11 @@
this.allowEmptyConnection = allowEmptyConnection;
}
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
if (!allowEmptyConnection && (value == null ||
"".equals(value.toString().trim()))) { //$NON-NLS-1$
return createErrormessage(
ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
- SeamUIMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE_IS_NOT_SELECTED);
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE_IS_NOT_SELECTED));
} else {
IConnectionProfile connProfile = ProfileManager.getInstance()
.getProfileByName(value.toString());
@@ -418,9 +408,9 @@
if (driverClass == null || "".equals(driverClass)) { //$NON-NLS-1$
return createErrormessage(
ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
- SeamUIMessages.VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_EMPTY_FOR_SELECTED
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_EMPTY_FOR_SELECTED
+ value
- + SeamUIMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE);
+ + SeamUIMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE));
}
}
return NO_ERRORS;
@@ -432,58 +422,58 @@
public static final IValidator CONNECTION_DRIVER_VALIDATOR = new
ConnectionProfileValidator(true);
public static final IValidator SEAM_RUNTIME_NAME_VALIDATOR = new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
+ public Map<String, IStatus> validate(Object value, Object context) {
- Map<String, String> errors = NO_ERRORS;
+ Map<String, IStatus> errors = NO_ERRORS;
if (value == null || "".equals(value.toString().trim())) { //$NON-NLS-1$
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RUNTIME_IS_NOT_SELECTED);
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RUNTIME_IS_NOT_SELECTED));
} else {
SeamRuntime rt = SeamRuntimeManager.getInstance()
.findRuntimeByName(value.toString());
if (rt == null) {
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_CANNOT_FIND_SEAM_RUNTIME,
- value));
+ value)));
} else if (!new File(rt.getHomeDir()).exists()) {
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_IS_MISSING,
- value));
+ value)));
} else if (!new File(rt.getSeamGenDir()).exists()) {
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_IS_MISSING,
- value));
+ value)));
} else if (!new File(rt.getSrcTemplatesDir()).exists()) {
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_SRC_DIR_IS_MISSING,
- value));
+ value)));
} else if (!new File(rt.getViewTemplatesDir()).exists()) {
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_VIEW_DIR_IS_MISSING,
- value));
+ value)));
} else if (!new File(rt.getResourceTemplatesDir()).exists()) {
errors = createErrormessage(
ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS
+ new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_RESOURCES_DIR_IS_MISSING,
- value));
+ value)));
}
}
return errors;
@@ -491,41 +481,41 @@
};
public static final IValidator SEAM_RUNTIME_VALIDATOR = new IValidator() {
- public java.util.Map<String, String> validate(Object value,
+ public java.util.Map<String, IStatus> validate(Object value,
Object context) {
- Map<String, String> errors = NO_ERRORS;
+ Map<String, IStatus> errors = NO_ERRORS;
String rtName = value.toString();
if (value == null || "".equals(value)) { //$NON-NLS-1$
- errors =
createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_NOT_CONFIGURED);
+ errors = createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_NOT_CONFIGURED));
} else {
SeamRuntime rt = SeamRuntimeManager.getInstance()
.findRuntimeByName(value.toString());
if (rt == null) {
- errors = createErrormessage(NLS
+ errors = createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_CANNOT_BE_FOUND,
- value));
+ value)));
} else if (!new File(rt.getHomeDir()).exists()) {
- errors = createErrormessage(NLS
+ errors = createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_DOES_NOT_EXIST,
- value));
+ value)));
} else if (!new File(rt.getSeamGenDir()).exists()) {
- errors = createErrormessage(NLS
+ errors = createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_DOES_NOT_EXIST,
- value));
+ value)));
} else if (!new File(rt.getSrcTemplatesDir()).exists()) {
- errors = createErrormessage(NLS
+ errors = createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_SOURCE_TEMPLATES_DIR_DOES_NOT_EXIST,
- value));
+ value)));
} else if (!new File(rt.getViewTemplatesDir()).exists()) {
- errors = createErrormessage(NLS
+ errors = createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS
.bind(
SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_VIE_TEMPLATE_DIR_DOES_NOT_EXIST,
- value));
+ value)));
// } else if(!new
// File(rt.getResourceTemplatesDir()).exists()) {
// errors = createErrormessage(NLS.bind(
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-10-23
13:27:19 UTC (rev 11107)
@@ -107,6 +107,7 @@
SEAM_WIZARD_FACTORY_METHOD_NAME=Method name:
SEAM_INSTALL_WIZARD_PAGE_NEW=New...
SEAM_INSTALL_WIZARD_PAGE_PACKAGE_NAME_FOR=Package name for
+SEAM_INSTALL_WIZARD_PROJECT_NAME_WITH_UPPERCASE=Project names which start with a capital
letter may break Seam/JSF applications; use lower case.
SEAM_INSTALL_WIZARD_PAGE_IS_NOT_VALID=\ is not valid
SEAM_BASE_WIZARD_PAGE_POJO_CLASS_NAME=POJO class name:
SEAM_BASE_WIZARD_PAGE_SEAM_COMPONENTS=Seam component
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2008-10-23
13:22:32 UTC (rev 11106)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2008-10-23
13:27:19 UTC (rev 11107)
@@ -14,12 +14,12 @@
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.wizard.IWizardPage;
@@ -67,10 +67,15 @@
projectEditor = SeamWizardFactory.createSeamProjectSelectionFieldEditor(projectName);
projectEditor.addPropertyChangeListener(this);
if(projectName!=null && projectName.length()>0) {
- Map<String, String> errors =
ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
+ Map<String, IStatus> errors =
ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
if(errors.size()>0) {
- setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
- setPageComplete(false);
+ IStatus message = errors.get(IValidator.DEFAULT_ERROR);
+ if(message.getSeverity()==IStatus.ERROR) {
+ setErrorMessage(message.getMessage());
+ setPageComplete(false);
+ } else {
+ setMessage(message.getMessage());
+ }
} else {
setMessage(null);
}
@@ -202,15 +207,20 @@
}
private void validate() {
- Map<String, String> errors =
ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
+ Map<String, IStatus> errors =
ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
if(errors.size()>0 || !isProjectSettingsOk()) {
- Object errorMessage = errors.get(IValidator.DEFAULT_ERROR);
+ IStatus errorMessage = errors.get(IValidator.DEFAULT_ERROR);
if(errorMessage==null) {
- errorMessage = SeamUIMessages.VALIDATOR_INVALID_SETTINGS;
+ setErrorMessage(SeamUIMessages.VALIDATOR_INVALID_SETTINGS);
}
- setErrorMessage(errorMessage.toString());
- setPageComplete(false);
+ if(errorMessage.getSeverity()==IStatus.ERROR) {
+ setErrorMessage(errorMessage.getMessage());
+ setPageComplete(false);
+ } else {
+ setMessage(errorMessage.getMessage());
+ }
+
return;
}
String config = (String)configEditor.getValue();