Author: vrubezhny
Date: 2007-10-16 09:19:33 -0400 (Tue, 16 Oct 2007)
New Revision: 4226
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
Log:
http://jira.jboss.com/jira/browse/JBIDE-991 Validate seam project names before creating
them
Issue is fixed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-10-16
13:14:30 UTC (rev 4225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-10-16
13:19:33 UTC (rev 4226)
@@ -342,6 +342,14 @@
public static String VALIDATOR_FACTORY_SEAM_RUNTIME_IS_NOT_SELECTED;
public static String VALIDATOR_FACTORY_SELECTED_PROJECT;
+
+ public static String VALIDATOR_FACTORY_TEST_PROJECT;
+
+ public static String VALIDATOR_FACTORY_EAR_PROJECT;
+
+ public static String VALIDATOR_FACTORY_EJB_PROJECT;
+
+ public static String VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS;
public static String SEAM_TARGET_RUNTIME;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-10-16
13:14:30 UTC (rev 4225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-10-16
13:19:33 UTC (rev 4226)
@@ -48,6 +48,7 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
+import
org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew;
import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
import org.hibernate.eclipse.console.utils.DriverClassHelpers;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -372,6 +373,10 @@
validatorDelegate.addValidatorForProperty(sessionBeanPkgNameditor
.getName(), new PackageNameValidator(
sessionBeanPkgNameditor.getName(), "session beans")); //$NON-NLS-1$
+ validatorDelegate.addValidatorForProperty(
+ IFacetDataModelProperties.FACET_PROJECT_NAME,
+ new ProjectNamesDuplicationValidator(
+ IFacetDataModelProperties.FACET_PROJECT_NAME));
}
jBossHibernateDbTypeEditor
@@ -568,6 +573,54 @@
}
}
+ class ProjectNamesDuplicationValidator implements IValidator {
+ String propertyName;
+
+ /**
+ */
+ public ProjectNamesDuplicationValidator (String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ /**
+ * @see IValidator#validate(Object, Object)
+ */
+ public Map<String, String> validate(Object value, Object context) {
+ final String projectName = (String)value;
+
+ IDataModel model = (IDataModel)context;
+ final String deployAs = model.getStringProperty(
+ ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS);
+
+ final String testProjectName = projectName + "-test";
+ IStatus status = ProjectCreationDataModelProviderNew.validateName(testProjectName);
+ if (!status.isOK())
+ return ValidatorFactory.createErrormessage(propertyName,
+ SeamUIMessages.VALIDATOR_FACTORY_TEST_PROJECT +
+ testProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS);
+
+ if (ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equals(deployAs)) {
+ final String earProjectName = projectName + "-ear";
+ status = ProjectCreationDataModelProviderNew.validateName(earProjectName);
+ if (!status.isOK())
+ return ValidatorFactory.createErrormessage(propertyName,
+ SeamUIMessages.VALIDATOR_FACTORY_TEST_PROJECT +
+ earProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS);
+
+ final String ejbProjectName = projectName + "-ejb";
+ status = ProjectCreationDataModelProviderNew.validateName(ejbProjectName);
+ if (!status.isOK())
+ return ValidatorFactory.createErrormessage(propertyName,
+ SeamUIMessages.VALIDATOR_FACTORY_TEST_PROJECT +
+ ejbProjectName +
+ SeamUIMessages.VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS);
+ }
+ return ValidatorFactory.NO_ERRORS;
+ }
+ }
+
public class NewSeamRuntimeAction extends
ButtonFieldEditor.ButtonPressedAction {
/**
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-10-16
13:14:30 UTC (rev 4225)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-10-16
13:19:33 UTC (rev 4226)
@@ -135,6 +135,10 @@
VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_EMPTY_FOR_SELECTED=Driver Class proberty is
empty for selected '
VALIDATOR_FACTORY_CONNECTION_PROFILE=' connection profile
VALIDATOR_FACTORY_SEAM_RUNTIME_IS_NOT_SELECTED=Seam Runtime is not selected
+VALIDATOR_FACTORY_TEST_PROJECT=Test project '
+VALIDATOR_FACTORY_EAR_PROJECT=EAR project '
+VALIDATOR_FACTORY_EJB_PROJECT=EJB project '
+VALIDATOR_FACTORY_PROJECT_ALREADY_EXISTS=' already exists. Please select other name
for new Seam project.
SEAM_PROJECT_WIZARD_PAGE1_FILE_CONTAINER_MUST_BE_SPECIFIED=File container must be
specified
SEAM_RUNTIME_LIST_FIELD_EDITOR_RUNTIME_NAME_IS_NOT_CORRECT=Runtime name is not correct
SEAM_GENERATE_ENTITIES_WIZARD_CAN_NOT_GENERATE_SEAM_ENTITIES=Can't generate seam
entities