Author: akazakov
Date: 2008-10-07 12:40:52 -0400 (Tue, 07 Oct 2008)
New Revision: 10717
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.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/internal/project/facet/ValidatorFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2731
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-10-07
15:56:58 UTC (rev 10716)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-10-07
16:40:52 UTC (rev 10717)
@@ -221,7 +221,7 @@
* @return
*/
static boolean isWarConfiguration(IDataModel model) {
- return
"war".equals(model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
//$NON-NLS-1$
+ return
ISeamFacetDataModelProperties.DEPLOY_AS_WAR.equals(model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
}
static void createComponentsProperties(final File seamGenResFolder, String projectName,
Boolean embedded) {
@@ -289,8 +289,10 @@
if(ejbVersion!=null) {
doExecuteForEjb(project, fv, model, monitor);
} else if(webVersion!=null) {
+ model.setProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
doExecuteForWar(project, fv, model, monitor);
} else if(earVersion!=null) {
+ model.setProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
doExecuteForEar(project, fv, model, monitor);
}
}
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 2008-10-07
15:56:58 UTC (rev 10716)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-10-07
16:40:52 UTC (rev 10717)
@@ -17,6 +17,8 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
@@ -24,7 +26,9 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -33,6 +37,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
@@ -40,6 +45,7 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import
org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
@@ -47,7 +53,6 @@
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
-import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard;
import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
import org.hibernate.eclipse.console.utils.DriverClassHelpers;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -63,6 +68,7 @@
import org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor;
import org.jboss.tools.seam.ui.wizard.SeamFormWizard;
import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
+import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
/**
* @author eskimo
@@ -159,8 +165,33 @@
* @return
*/
private Object getDeployAsDefaultValue() {
- return SeamProjectPreferences.getStringPreference(
- SeamProjectPreferences.JBOSS_AS_DEFAULT_DEPLOY_AS);
+ String result =
SeamProjectPreferences.getStringPreference(SeamProjectPreferences.JBOSS_AS_DEFAULT_DEPLOY_AS);
+ if(!isNewProjectWizard()) {
+ ISelection sel =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ IProject project = SeamWizardUtils.getInitialProject(sel);
+ if(project == null) {
+ SeamCorePlugin.getPluginLog().logError("Can't get project name to initialize
SeamInstallWizardPage for ModifyFacetedProjectWizard");
+ return result;
+ }
+ IFacetedProject facetedProject;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ if(facetedProject==null) {
+ SeamCorePlugin.getPluginLog().logError("Can't get faceted project to
initialize SeamInstallWizardPage for ModifyFacetedProjectWizard");
+ return result;
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return result;
+ }
+ IProjectFacetVersion webVersion =
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET);
+ if(webVersion!=null) {
+ return ISeamFacetDataModelProperties.DEPLOY_AS_WAR;
+ } else {
+ return ISeamFacetDataModelProperties.DEPLOY_AS_EAR;
+ }
+ }
+ return result;
}
/**
@@ -353,11 +384,13 @@
validatorDelegate.addValidatorForProperty(sessionBeanPkgNameditor
.getName(), new PackageNameValidator(
sessionBeanPkgNameditor.getName(), "session beans")); //$NON-NLS-1$
+ if(isNewProjectWizard()) {
+ validatorDelegate.addValidatorForProperty(
+ IFacetDataModelProperties.FACET_PROJECT_NAME,
+ new ProjectNamesDuplicationValidator(
+ IFacetDataModelProperties.FACET_PROJECT_NAME));
+ }
validatorDelegate.addValidatorForProperty(
- IFacetDataModelProperties.FACET_PROJECT_NAME,
- new ProjectNamesDuplicationValidator(
- IFacetDataModelProperties.FACET_PROJECT_NAME));
- validatorDelegate.addValidatorForProperty(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
getDeploymentTypeValidator(getWizard()));
}
@@ -375,6 +408,11 @@
initDefaultWizardProperties();
}
+ private boolean isNewProjectWizard() {
+ // ModifyFacetedProjectWizard or NewProjectDataModelFacetWizard
+ return getWizard() instanceof NewProjectDataModelFacetWizard;
+ }
+
/**
*
*/
@@ -542,15 +580,14 @@
IValidator getDeploymentTypeValidator(IWizard wizard) {
if(wizard instanceof NewProjectDataModelFacetWizard) {
return new DeploymentTypeValidator(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
((NewProjectDataModelFacetWizard)wizard).getDataModel());
- } else if(wizard instanceof ModifyFacetedProjectWizard) {
- ModifyFacetedProjectWizard mfpw = (ModifyFacetedProjectWizard)wizard;
}
- return new IValidator() {
- public Map<String, String> validate(Object value, Object context) {
- SeamInstallWizardPage.this.validate();
- return ValidatorFactory.NO_ERRORS;
- }
- };
+ return new DeploymentTypeValidator(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
model);
+// return new IValidator() {
+// public Map<String, String> validate(Object value, Object context) {
+// SeamInstallWizardPage.this.validate();
+// return ValidatorFactory.NO_ERRORS;
+// }
+// };
}
static class DeploymentTypeValidator implements IValidator {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2008-10-07
15:56:58 UTC (rev 10716)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2008-10-07
16:40:52 UTC (rev 10717)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.ui.internal.project.facet;
import java.io.File;
@@ -34,12 +34,8 @@
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.core.SeamPreferences;
-import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
@@ -55,8 +51,7 @@
/**
*
*/
- static public Map<String, IValidator> validators
- = new HashMap<String, IValidator>();
+ static public Map<String, IValidator> validators = new HashMap<String,
IValidator>();
/**
*
@@ -107,8 +102,8 @@
* @param text
* @return
*/
- public static Map<String, String> createErrormessage(String propertyName,
- String text) {
+ public static Map<String, String> createErrormessage(String propertyName,
+ String text) {
Map<String, String> map = createErrorMap();
map.put(propertyName, text);
return map;
@@ -127,10 +122,12 @@
File folder = new File(folderPath);
if (!folder.exists())
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_FOLDER + folderPath
+ return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_FOLDER
+ + folderPath
+ SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXISTS);
if (!folder.isDirectory())
- return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PATH + folderPath
+ return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PATH
+ + folderPath
+ SeamUIMessages.VALIDATOR_FACTORY_POINTS_TO_FILE);
return NO_ERRORS;
}
@@ -145,29 +142,36 @@
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,
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_HOME_FOLDER_DOES_NOT_EXISTS);
return errors;
}
String version = (String) context;
- if(version.startsWith("2.")) { //$NON-NLS-1$
- File seamJarFile = new File(value.toString(), "lib/jboss-seam.jar");
//$NON-NLS-1$
+ if (version.startsWith("2.")) { //$NON-NLS-1$
+ File seamJarFile = new File(value.toString(),
+ "lib/jboss-seam.jar"); //$NON-NLS-1$
if (!seamJarFile.isFile()) {
errors = createErrorMap();
- errors.put(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
- SeamUIMessages.VALIDATOR_FACTORY_HOME_FOLDER_POINTS_TO +
- SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER);
- }
+ errors
+ .put(
+ ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ SeamUIMessages.VALIDATOR_FACTORY_HOME_FOLDER_POINTS_TO
+ +
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,
- SeamUIMessages.VALIDATOR_FACTORY_HOME_FOLDER_POINTS_TO +
- SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER);
- }
- }
+ errors
+ .put(
+ ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ SeamUIMessages.VALIDATOR_FACTORY_HOME_FOLDER_POINTS_TO
+ +
SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER);
+ }
+ }
return errors;
}
@@ -182,15 +186,18 @@
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,
+ 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,
+ SeamUIMessages.VALIDATOR_FACTORY_JBOSS_AS_HOME_FOLDER_POINT_TO_LOCATION_THAT_DOES_NOT
+ + SeamUIMessages.VALIDATOR_FACTORY_LOOK_LIKE_JBOSS_AS_HOME_FOLDER);
}
return errors;
}
@@ -209,9 +216,10 @@
.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(Messages
+ .format(
+ SeamUIMessages.VALIDATOR_FACTORY_COMPONENT_NAME_IS_NOT_VALID,
+ problems[0].getMessage()));
}
return ValidatorFactory.NO_ERRORS;
}
@@ -223,7 +231,10 @@
.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((Messages
+ .format(
+ NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName,
+ status.getMessage())));
}
return ValidatorFactory.NO_ERRORS;
@@ -248,13 +259,13 @@
public static final IValidator SEAM_COMPONENT_NAME_VALIDATOR = new IValidator() {
public Map<String, String> 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$
+ 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(SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID);
}
}
};
@@ -267,7 +278,7 @@
public static final IValidator SEAM_JAVA_INTEFACE_NAME_CONVENTION_VALIDATOR = new
IValidator() {
public Map<String, String> validate(Object value, Object context) {
- if(!(context instanceof Object[])) {
+ if (!(context instanceof Object[])) {
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
}
@@ -294,7 +305,7 @@
public static final IValidator SEAM_METHOD_NAME_VALIDATOR = new IValidator() {
public Map<String, String> validate(Object value, Object context) {
- if(!(context instanceof Object[])) {
+ if (!(context instanceof Object[])) {
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
}
@@ -305,12 +316,13 @@
CompilationUnit compilationUnit = createCompilationUnit(
"class ClassName {public void " //$NON-NLS-1$
- + value.toString() + "() {}}",project); //$NON-NLS-1$
+ + value.toString() + "() {}}", project); //$NON-NLS-1$
IProblem[] problems = compilationUnit.getProblems();
if (problems.length > 0) {
- return createErrormessage(targetName +
SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2);
+ return createErrormessage(targetName
+ + SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2);
}
return NO_ERRORS;
@@ -320,7 +332,7 @@
public static final IValidator FILE_NAME_VALIDATOR = new IValidator() {
public Map<String, String> validate(Object value, Object context) {
- if(!(context instanceof Object[])) {
+ if (!(context instanceof Object[])) {
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
}
@@ -331,7 +343,8 @@
if ("".equals(value) //$NON-NLS-1$
|| !project.getLocation().isValidSegment(value.toString()))
- return createErrormessage(targetName +
SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2);
+ return createErrormessage(targetName
+ + SeamUIMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID2);
return NO_ERRORS;
}
@@ -340,7 +353,7 @@
public static final IValidator SEAM_PROJECT_NAME_VALIDATOR = new IValidator() {
public Map<String, String> validate(Object value, Object context) {
- if(value==null || "".equals(value)) { //$NON-NLS-1$
+ if (value == null || "".equals(value)) { //$NON-NLS-1$
return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PRJ_NOT_SELECTED);
}
IResource project = ResourcesPlugin.getWorkspace().getRoot()
@@ -348,90 +361,129 @@
if (project == null || !(project instanceof IProject)
|| !project.exists()) {
- return createErrormessage(
- SeamUIMessages.VALIDATOR_FACTORY_PROJECT + value +
SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXIST);
+ return createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_PROJECT
+ + value
+ + SeamUIMessages.VALIDATOR_FACTORY_DOES_NOT_EXIST);
} else {
- IProject selection = (IProject)project;
+ IProject selection = (IProject) project;
try {
- if (!selection.hasNature(ISeamProject.NATURE_ID)
- || SeamCorePlugin.getSeamPreferences(selection)==null
-// || selection.getAdapter(IFacetedProject.class)==null
-// ||
!((IFacetedProject)selection.getAdapter(IFacetedProject.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 + project.getName() +
SeamUIMessages.VALIDATOR_FACTORY_IS_NOT_A_SEAM_WEB_PROJECT);
- } else {
- //TODO validate project(s) structure
+ if (!selection.hasNature(ISeamProject.NATURE_ID)
+ || SeamCorePlugin.getSeamPreferences(selection) == null
+ // ||
+ // selection.getAdapter(IFacetedProject.class)==null
+ // || !((IFacetedProject)selection.getAdapter(
+ // IFacetedProject
+ // .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
+ + project.getName()
+ + 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
+ // it might happen only if project is closed and project
// name typed by hand
- return
createErrormessage(NLS.bind(SeamUIMessages.VALIDATOR_FACTORY_SELECTED_PRJ_IS_CLOSED,
project.getName()));
+ return createErrormessage(NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SELECTED_PRJ_IS_CLOSED,
+ project.getName()));
}
}
return NO_ERRORS;
}
};
- public static final IValidator CONNECTION_PROFILE_VALIDATOR =
- new IValidator() {
+ private static class ConnectionProfileValidator implements IValidator {
+
+ private boolean allowEmptyConnection;
+
+ public ConnectionProfileValidator(boolean allowEmptyConnection) {
+ this.allowEmptyConnection = allowEmptyConnection;
+ }
+
public Map<String, String> validate(Object value, Object context) {
- if (value == null || "".equals(value.toString().trim())) { //$NON-NLS-1$
+ 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);
} else {
- IConnectionProfile connProfile
- = ProfileManager.getInstance().getProfileByName(value.toString());
+ IConnectionProfile connProfile = ProfileManager.getInstance()
+ .getProfileByName(value.toString());
Properties props = connProfile.getBaseProperties();
- Object driverClass
- = props.get("org.eclipse.datatools.connectivity.db.driverClass");
//$NON-NLS-1$
+ Object driverClass = props
+ .get("org.eclipse.datatools.connectivity.db.driverClass"); //$NON-NLS-1$
- if(driverClass==null || "".equals(driverClass)) { //$NON-NLS-1$
+ if (driverClass == null || "".equals(driverClass)) { //$NON-NLS-1$
return createErrormessage(
ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
- SeamUIMessages.VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_EMPTY_FOR_SELECTED
- + value + SeamUIMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE);
+ SeamUIMessages.VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_EMPTY_FOR_SELECTED
+ + value
+ + SeamUIMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE);
}
}
return NO_ERRORS;
}
- };
+ }
+ public static final IValidator CONNECTION_PROFILE_VALIDATOR = new
ConnectionProfileValidator(false);
+
+ 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) {
- Map<String,String> errors = NO_ERRORS;
+ Map<String, String> 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);
- } else {
+ } else {
SeamRuntime rt = SeamRuntimeManager.getInstance()
- .findRuntimeByName(value.toString());
+ .findRuntimeByName(value.toString());
if (rt == null) {
- errors = createErrormessage(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS.bind(SeamUIMessages.VALIDATOR_FACTORY_CANNOT_FIND_SEAM_RUNTIME, value));
+ errors = createErrormessage(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_CANNOT_FIND_SEAM_RUNTIME,
+ value));
} else if (!new File(rt.getHomeDir()).exists()) {
- errors = createErrormessage(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_IS_MISSING,value));
+ errors = createErrormessage(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_IS_MISSING,
+ value));
} else if (!new File(rt.getSeamGenDir()).exists()) {
- errors = createErrormessage(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_IS_MISSING,value));
+ errors = createErrormessage(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_IS_MISSING,
+ value));
} else if (!new File(rt.getSrcTemplatesDir()).exists()) {
- errors = createErrormessage(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_SRC_DIR_IS_MISSING,value));
+ errors = createErrormessage(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_SRC_DIR_IS_MISSING,
+ value));
} else if (!new File(rt.getViewTemplatesDir()).exists()) {
- errors = createErrormessage(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_VIEW_DIR_IS_MISSING,value));
- } else if(!new File(rt.getResourceTemplatesDir()).exists()) {
- errors = createErrormessage(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_RESOURCES_DIR_IS_MISSING,value));
+ errors = createErrormessage(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_VIEW_DIR_IS_MISSING,
+ value));
+ } else if (!new File(rt.getResourceTemplatesDir()).exists()) {
+ errors = createErrormessage(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_RESOURCES_DIR_IS_MISSING,
+ value));
}
}
return errors;
@@ -441,39 +493,52 @@
public static final IValidator SEAM_RUNTIME_VALIDATOR = new IValidator() {
public java.util.Map<String, String> validate(Object value,
Object context) {
- Map<String,String> errors = NO_ERRORS;
+ Map<String, String> errors = NO_ERRORS;
String rtName = value.toString();
- if(value==null || "".equals(value)) { //$NON-NLS-1$
+ if (value == null || "".equals(value)) { //$NON-NLS-1$
errors =
createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_NOT_CONFIGURED);
} else {
SeamRuntime rt = SeamRuntimeManager.getInstance()
.findRuntimeByName(value.toString());
if (rt == null) {
- errors =
createErrormessage(NLS.bind(SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_CANNOT_BE_FOUND,
value));
+ errors = createErrormessage(NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_CANNOT_BE_FOUND,
+ value));
} else if (!new File(rt.getHomeDir()).exists()) {
- errors = createErrormessage(NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_DOES_NOT_EXIST,value));
+ errors = createErrormessage(NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_DOES_NOT_EXIST,
+ value));
} else if (!new File(rt.getSeamGenDir()).exists()) {
- errors = createErrormessage(NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_DOES_NOT_EXIST,value));
+ errors = createErrormessage(NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_DOES_NOT_EXIST,
+ value));
} else if (!new File(rt.getSrcTemplatesDir()).exists()) {
- errors = createErrormessage(NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_SOURCE_TEMPLATES_DIR_DOES_NOT_EXIST,value));
+ errors = createErrormessage(NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_SOURCE_TEMPLATES_DIR_DOES_NOT_EXIST,
+ value));
} else if (!new File(rt.getViewTemplatesDir()).exists()) {
- errors = createErrormessage(NLS.bind(
- SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_VIE_TEMPLATE_DIR_DOES_NOT_EXIST,value));
-// } else if(!new File(rt.getResourceTemplatesDir()).exists()) {
-// errors = createErrormessage(NLS.bind(
-// "Seam Runtime '{0)' resource templates directory doesn't exist
for selected Seam Web Project",value));
+ errors = createErrormessage(NLS
+ .bind(
+ SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_VIE_TEMPLATE_DIR_DOES_NOT_EXIST,
+ value));
+ // } else if(!new
+ // File(rt.getResourceTemplatesDir()).exists()) {
+ // errors = createErrormessage(NLS.bind(
+ // "Seam Runtime '{0)' resource templates directory doesn't exist
for selected Seam Web Project"
+ // ,value));
}
}
return errors;
}
};
- public static CompilationUnit createCompilationUnit(String classDecl,
- IProject project) {
+ public static CompilationUnit createCompilationUnit(String classDecl,
+ IProject project) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(classDecl.toCharArray());
parser.setProject(JavaCore.create(project));