Author: akazakov
Date: 2007-12-26 13:05:16 -0500 (Wed, 26 Dec 2007)
New Revision: 5456
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.test/seam/
trunk/seam/tests/org.jboss.tools.seam.ui.test/seam/seam-gen/
trunk/seam/tests/org.jboss.tools.seam.ui.test/seam/seam-gen/resources/
trunk/seam/tests/org.jboss.tools.seam.ui.test/seam/seam-gen/src/
trunk/seam/tests/org.jboss.tools.seam.ui.test/seam/seam-gen/view/
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1111 Fixed the bug and added JUnit Test of it.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java 2007-12-26
16:07:59 UTC (rev 5455)
+++
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java 2007-12-26
18:05:16 UTC (rev 5456)
@@ -56,29 +56,28 @@
public class JBossASAdapterInitializer implements IStartup {
public static final String JBOSS_AS_HOME = "../../../../jboss-eap/jboss-as";
// JBoss AS home directory (relative to plugin)- <RHDS_HOME>/jbossas.
-
+
public static final String JBOSS_AS_RUNTIME_TYPE_ID
= "org.jboss.ide.eclipse.as.runtime.42";
-
+
public static final String JBOSS_AS_TYPE_ID = "org.jboss.ide.eclipse.as.42";
-
+
public static final String JBOSS_AS_NAME = "JBoss Application Server 4.2";
-
+
public static final String JBOSS_AS_HOST = "localhost";
-
+
public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default";
public static final String FIRST_START_PREFERENCE_NAME = "FIRST_START";
-
-
+
public static final String HSQL_DRIVER_DEFINITION_ID
= "DriverDefn.Hypersonic DB";
-
+
public static final String HSQL_DRIVER_NAME = "Hypersonic DB";
public static final String HSQL_DRIVER_TEMPLATE_ID
= "org.eclipse.datatools.enablement.hsqldb.1_8.driver";
-
+
public static final String DTP_DB_URL_PROPERTY_ID
= "org.eclipse.datatools.connectivity.db.URL";
/**
@@ -93,7 +92,6 @@
* Compare this method with JBossServerWizardFragment#performFinish()
*/
try {
-
JstFirstRunPlugin.getDefault().getPreferenceStore().setDefault(FIRST_START_PREFERENCE_NAME,
true);
boolean firstStart =
JstFirstRunPlugin.getDefault().getPreferenceStore().getBoolean(FIRST_START_PREFERENCE_NAME);
if(!firstStart) {
@@ -111,8 +109,6 @@
}
IPath jbossAsLocationPath = new Path(jbossASLocation);
- String type = null;
- String version = null;
IServer[] servers = ServerCore.getServers();
for(int i=0; i<servers.length; i++) {
@@ -124,120 +120,22 @@
IRuntimeWorkingCopy runtime = null;
IRuntime[] runtimes = ServerCore.getRuntimes();
- String runtimeId = null;
for(int i=0; i<runtimes.length; i++) {
if(runtimes[0].getLocation().equals(jbossASLocation)) {
runtime = runtimes[0].createWorkingCopy();
- runtimeId = null;
break;
}
}
IProgressMonitor progressMonitor = new NullProgressMonitor();
if(runtime==null) {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version,
JBOSS_AS_RUNTIME_TYPE_ID);
- if(runtimeTypes.length>0) {
- runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
- runtime.setLocation(jbossAsLocationPath);
- IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
- // IJBossServerRuntime.PROPERTY_VM_ID
- ((RuntimeWorkingCopy)runtime).setAttribute("PROPERTY_VM_ID",
defaultVM.getId());
- // IJBossServerRuntime.PROPERTY_VM_TYPE_ID
- ((RuntimeWorkingCopy)runtime).setAttribute("PROPERTY_VM_TYPE_ID",
defaultVM.getVMInstallType().getId());
- // IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME
- ((RuntimeWorkingCopy)runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName",
JBOSS_AS_DEFAULT_CONFIGURATION_NAME);
-
- runtime.save(false, progressMonitor);
- }
+ runtime = createRuntime(jbossASLocation, progressMonitor);
}
-
if(runtime!=null) {
- IServerType serverType = ServerCore.findServerType(JBOSS_AS_TYPE_ID);
- IServerWorkingCopy server = serverType.createServer(null, null, runtime,
progressMonitor);
-
- server.setHost(JBOSS_AS_HOST);
- server.setName(JBOSS_AS_NAME);
- // JBossServer.DEPLOY_DIRECTORY
- String deployVal = runtime.getLocation().append(
"server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString();
- ((ServerWorkingCopy)server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory",
deployVal);
-
- // IDeployableServer.TEMP_DEPLOY_DIRECTORY
- String deployTmpFolderVal = runtime.getLocation().append(
"server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString();
- ((ServerWorkingCopy)server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory",
deployTmpFolderVal);
-
- // If we'd need to set up a username / pw for JMX, do it here.
-// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_USERNAME, authUser);
-// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_PASSWORD, authPass);
-
- server.save(false, progressMonitor);
+ createServer(progressMonitor, runtime);
}
-
- DriverInstance driver = DriverManager.getInstance()
- .getDriverInstanceByName(HSQL_DRIVER_NAME);
- if(driver==null) {
- TemplateDescriptor descr = TemplateDescriptor
- .getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
- IPropertySet instance = new PropertySetImpl(
- HSQL_DRIVER_NAME,HSQL_DRIVER_DEFINITION_ID);
- instance.setName(HSQL_DRIVER_NAME);
- instance.setID(HSQL_DRIVER_DEFINITION_ID);
- Properties props = new Properties();
- IConfigurationElement[] template = descr.getProperties();
- for (int i = 0; i < template.length; i++) {
- IConfigurationElement prop = template[i];
- String id = prop.getAttribute("id"); //$NON-NLS-1$
-
- String value = prop.getAttribute("value"); //$NON-NLS-1$
- props.setProperty(id, value == null ? ""
- : value);
- }
- props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:.");
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE,
- descr.getId());
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST,
- jbossASLocation+"/server/default/lib/hsqldb.jar");
-
- instance.setBaseProperties(props);
- DriverManager.getInstance().removeDriverInstance(instance.getID());
- System.gc();
- DriverManager.getInstance().addDriverInstance(instance);
-
- }
-
- driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- if(driver!=null) {
- // create profile
- Properties props = new Properties();
- props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
- HSQL_DRIVER_DEFINITION_ID);
- props.setProperty(
- IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
- "");
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
- driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID,
- driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
- driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
- "Default");
- props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
- props.setProperty(
- IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false");
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,
- driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
- driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
-
- ProfileManager.getInstance().createProfile(
- "DefaultDS",
- "The JBoss AS Hypersonic embedded database",
- IDBConnectionProfileConstants.CONNECTION_PROFILE_ID,
- props,
- "", false);
- }
-
+ createDriver(jbossASLocation);
} catch (CoreException e) {
JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
JstFirstRunPlugin.PLUGIN_ID,"Can't create new JBoss Server", e));
@@ -250,4 +148,134 @@
"Connection Profile for JBoss AS Hypersonic embedded database", e));
}
}
-}
+
+ /**
+ * Creates new JBoss AS Runtime, Server and hsqldb driver
+ * @param jbossASLocation location of JBoss Server
+ * @param progressMonitor
+ * @return server working copy
+ * @throws CoreException
+ * @throws ConnectionProfileException
+ */
+ public static IServerWorkingCopy initJBossAS(String jbossASLocation, IProgressMonitor
progressMonitor) throws CoreException, ConnectionProfileException {
+ IRuntimeWorkingCopy runtime = createRuntime(jbossASLocation, progressMonitor);
+ IServerWorkingCopy server = null;
+ if(runtime!=null) {
+ createServer(progressMonitor, runtime);
+ }
+ createDriver(jbossASLocation);
+ return server;
+ }
+
+ /**
+ * Creates new JBoss AS Runtime
+ * @param jbossASLocation location of JBoss AS
+ * @param progressMonitor
+ * @return runtime working copy
+ * @throws CoreException
+ */
+ private static IRuntimeWorkingCopy createRuntime(String jbossASLocation,
IProgressMonitor progressMonitor) throws CoreException {
+ IRuntimeWorkingCopy runtime = null;
+ String type = null;
+ String version = null;
+ String runtimeId = null;
+ IPath jbossAsLocationPath = new Path(jbossASLocation);
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version,
JBOSS_AS_RUNTIME_TYPE_ID);
+ if(runtimeTypes.length>0) {
+ runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
+ runtime.setLocation(jbossAsLocationPath);
+ IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
+ // IJBossServerRuntime.PROPERTY_VM_ID
+ ((RuntimeWorkingCopy)runtime).setAttribute("PROPERTY_VM_ID",
defaultVM.getId());
+ // IJBossServerRuntime.PROPERTY_VM_TYPE_ID
+ ((RuntimeWorkingCopy)runtime).setAttribute("PROPERTY_VM_TYPE_ID",
defaultVM.getVMInstallType().getId());
+ // IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME
+ ((RuntimeWorkingCopy)runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName",
JBOSS_AS_DEFAULT_CONFIGURATION_NAME);
+
+ runtime.save(false, progressMonitor);
+ }
+ return runtime;
+ }
+
+ /**
+ * Creates new JBoss Server
+ * @param progressMonitor
+ * @param runtime parent JBoss AS Runtime
+ * @return server working copy
+ * @throws CoreException
+ */
+ private static IServerWorkingCopy createServer(IProgressMonitor progressMonitor,
IRuntimeWorkingCopy runtime) throws CoreException {
+ IServerType serverType = ServerCore.findServerType(JBOSS_AS_TYPE_ID);
+ IServerWorkingCopy server = serverType.createServer(null, null, runtime,
progressMonitor);
+
+ server.setHost(JBOSS_AS_HOST);
+ server.setName(JBOSS_AS_NAME);
+ // JBossServer.DEPLOY_DIRECTORY
+ String deployVal =
runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString();
+ ((ServerWorkingCopy)server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory",
deployVal);
+
+ // IDeployableServer.TEMP_DEPLOY_DIRECTORY
+ String deployTmpFolderVal =
runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString();
+ ((ServerWorkingCopy)server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory",
deployTmpFolderVal);
+
+ // If we'd need to set up a username / pw for JMX, do it here.
+// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_USERNAME, authUser);
+// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_PASSWORD, authPass);
+
+ server.save(false, progressMonitor);
+ return server;
+ }
+
+ /**
+ * Creates HSQL DB Driver
+ * @param jbossASLocation location of JBoss AS
+ * @throws ConnectionProfileException
+ * @return driver instance
+ */
+ private static DriverInstance createDriver(String jbossASLocation) throws
ConnectionProfileException {
+ DriverInstance driver =
DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if (driver == null) {
+ TemplateDescriptor descr =
TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
+ IPropertySet instance = new PropertySetImpl(HSQL_DRIVER_NAME,
HSQL_DRIVER_DEFINITION_ID);
+ instance.setName(HSQL_DRIVER_NAME);
+ instance.setID(HSQL_DRIVER_DEFINITION_ID);
+ Properties props = new Properties();
+
+ IConfigurationElement[] template = descr.getProperties();
+ for (int i = 0; i < template.length; i++) {
+ IConfigurationElement prop = template[i];
+ String id = prop.getAttribute("id"); //$NON-NLS-1$
+
+ String value = prop.getAttribute("value"); //$NON-NLS-1$
+ props.setProperty(id, value == null ? "" : value);
+ }
+ props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:.");
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, jbossASLocation +
"/server/default/lib/hsqldb.jar");
+
+ instance.setBaseProperties(props);
+ DriverManager.getInstance().removeDriverInstance(instance.getID());
+ System.gc();
+ DriverManager.getInstance().addDriverInstance(instance);
+ }
+
+ driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if (driver != null) {
+ // create profile
+ Properties props = new Properties();
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
HSQL_DRIVER_DEFINITION_ID);
+ props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
"");
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
"Default");
+ props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
+ props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
"false");
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
+
+ ProfileManager.getInstance().createProfile("DefaultDS", "The JBoss AS
Hypersonic embedded database", IDBConnectionProfileConstants.CONNECTION_PROFILE_ID,
props, "", false);
+ }
+ return driver;
+ }
+}
\ No newline at end of file
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-12-26
16:07:59 UTC (rev 5455)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-12-26
18:05:16 UTC (rev 5456)
@@ -80,29 +80,20 @@
public static final String PAGE_DESCRIPTION =
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CONFIGURE_SEAM_FACET_SETTINGS;
- /**
- *
- */
private static final DriverClassHelpers HIBERNATE_HELPER = new DriverClassHelpers();
-
+
private static final List<String> DIALECT_CLASSES = getDialectClasses();
- /**
- *
- */
private IDataModel model = null;
- /**
- *
- */
private DataModelValidatorDelegate validatorDelegate;
-
+
private IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
.createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_RUNTIME, getRuntimeNames(),
getSeamRuntimeDefaultValue(),
true, new NewSeamRuntimeAction(), (IValidator)null);
-
+
private IFieldEditor jBossAsDeployAsEditor = IFieldEditorFactory.INSTANCE
.createRadioEditor(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
@@ -123,25 +114,25 @@
false, new EditConnectionProfileAction(),
new NewConnectionProfileAction(),
ValidatorFactory.NO_ERRORS_VALIDATOR);
-
+
private IFieldEditor jBossHibernateDbTypeEditor = IFieldEditorFactory.INSTANCE
.createComboEditor(ISeamFacetDataModelProperties.DB_TYPE,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_TYPE,
Arrays.asList(HIBERNATE_HELPER
.getDialectNames()), getDefaultDbType(), false);
-
+
private IFieldEditor dbSchemaName = IFieldEditorFactory.INSTANCE.createTextEditor(
ISeamFacetDataModelProperties.DB_SCHEMA_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_SCHEMA_NAME, "");
//$NON-NLS-1$
-
+
private IFieldEditor dbCatalogName = IFieldEditorFactory.INSTANCE.createTextEditor(
ISeamFacetDataModelProperties.DB_CATALOG_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_CATALOG_NAME, "");
//$NON-NLS-1$
-
+
private IFieldEditor dbTablesExists = IFieldEditorFactory.INSTANCE
.createCheckboxEditor(
ISeamFacetDataModelProperties.DB_ALREADY_EXISTS,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DB_TABLES_ALREADY_EXISTS, false);
-
+
private IFieldEditor recreateTablesOnDeploy = IFieldEditorFactory.INSTANCE
.createCheckboxEditor(
ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY,
@@ -151,13 +142,13 @@
.createTextEditor(
ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SESSION_BEAN_PACKAGE_NAME, "");
//$NON-NLS-1$
-
+
private IFieldEditor entityBeanPkgNameditor = IFieldEditorFactory.INSTANCE
.createTextEditor(
ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_ENTITY_BEAN_PACKAGE_NAME,
"com.mydomain.projectname.entity"); //$NON-NLS-1$
-
+
private IFieldEditor testsPkgNameditor = IFieldEditorFactory.INSTANCE
.createTextEditor(
ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME,
@@ -177,7 +168,7 @@
/**
* @return
*/
- private static List getDialectClasses() {
+ private static List<String> getDialectClasses() {
List<String> dialects = new ArrayList<String>();
for (String dialectName : HIBERNATE_HELPER.getDialectNames()) {
dialects.add(HIBERNATE_HELPER.getDialectClass(dialectName));
@@ -189,7 +180,6 @@
* @return
*/
private String getDefaultDbType() {
- // TODO Auto-generated method stub
return SeamProjectPreferences.getStringPreference(
SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE);
}
@@ -224,9 +214,6 @@
.getStringPreference(SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME));
}
- /**
- *
- */
private DataModelSynchronizer sync;
/**
@@ -253,23 +240,21 @@
* Finish has been pressed.
*/
public void transferStateToConfig() {
-
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME,
- jBossSeamHomeEditor.getValueAsString());
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME,
+ jBossSeamHomeEditor.getValueAsString());
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
- connProfileSelEditor.getValueAsString());
-
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.JBOSS_AS_DEFAULT_DEPLOY_AS,
- this.jBossAsDeployAsEditor.getValueAsString());
-
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE,
- this.jBossHibernateDbTypeEditor.getValueAsString());
-
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
+ connProfileSelEditor.getValueAsString());
+
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.JBOSS_AS_DEFAULT_DEPLOY_AS,
+ this.jBossAsDeployAsEditor.getValueAsString());
+
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE,
+ this.jBossHibernateDbTypeEditor.getValueAsString());
}
/**
@@ -303,7 +288,7 @@
}
return result;
}
-
+
/**
* Creates Seam Facet Wizard Page contents
*/
@@ -364,10 +349,7 @@
registerEditor(testsPkgNameditor, generationGroup, 3);
setControl(root);
- NewProjectDataModelFacetWizard wizard = (NewProjectDataModelFacetWizard) getWizard();
- IDataModel model = wizard.getDataModel();
-
if (validatorDelegate == null) {
validatorDelegate = new DataModelValidatorDelegate(this.model, this);
validatorDelegate.addValidatorForProperty(jBossSeamHomeEditor
@@ -406,7 +388,7 @@
);
Dialog.applyDialogFont(parent);
- setPageComplete(false);
+ initDefaultWizardProperties();
}
/**
@@ -421,9 +403,6 @@
}
}
- /*
- *
- */
private List<String> getProfileNameList() {
IConnectionProfile[] profiles = ProfileManager.getInstance()
.getProfilesByCategory("org.eclipse.datatools.connectivity.db.category");
//$NON-NLS-1$
@@ -480,7 +459,6 @@
* selected ConnectionProfile
*
* @author eskimo
- *
*/
public class NewConnectionProfileAction extends
ButtonFieldEditor.ButtonPressedAction {
@@ -530,11 +508,27 @@
/**
* It is overridden to fill Code Generation group with the default package
* names
- * TODO: should be changed to enable finish button on a first step,
- * right after project name is entered and valid
*/
@Override
public void setVisible(boolean visible) {
+ setCodeGenerationProperties();
+ if(visible) {
+ setDefaultSeamRuntime();
+ validate();
+ }
+ super.setVisible(visible);
+ };
+
+ private void initDefaultWizardProperties() {
+ setCodeGenerationProperties();
+ setDefaultSeamRuntime();
+ validate();
+ }
+
+ /*
+ * Fills Code Generation group with the default package names.
+ */
+ private void setCodeGenerationProperties() {
sessionBeanPkgNameditor
.setValue("org.domain." //$NON-NLS-1$
+ model
@@ -550,31 +544,32 @@
+ model
.getProperty(IFacetDataModelProperties.FACET_PROJECT_NAME)
+ ".test"); //$NON-NLS-1$
- if (visible) {
- ITaggedFieldEditor runtimesField =
(ITaggedFieldEditor)((CompositeEditor)jBossSeamHomeEditor).getEditors().get(1);
- Object oldValue = runtimesField.getValue();
- Object newValue = ""; //$NON-NLS-1$
- List<String> runtimes =
getRuntimeNames(model.getProperty(IFacetDataModelProperties.FACET_VERSION_STR).toString());
- if(oldValue==null || !runtimes.contains(oldValue)) {
- Object defaultRnt = getSeamRuntimeDefaultValue();
- if(defaultRnt!=null && runtimes.contains(defaultRnt)) {
- newValue = defaultRnt;
- } else if(runtimes.size()>0) {
- newValue = runtimes.get(0);
- }
- } else {
- newValue = oldValue;
+ }
+
+ /*
+ * Sets seam runtime field in default value.
+ */
+ private void setDefaultSeamRuntime() {
+ ITaggedFieldEditor runtimesField = (ITaggedFieldEditor) ((CompositeEditor)
jBossSeamHomeEditor)
+ .getEditors().get(1);
+ Object oldValue = runtimesField.getValue();
+ Object newValue = ""; //$NON-NLS-1$
+ List<String> runtimes = getRuntimeNames(model.getProperty(
+ IFacetDataModelProperties.FACET_VERSION_STR).toString());
+ if (oldValue == null || !runtimes.contains(oldValue)) {
+ Object defaultRnt = getSeamRuntimeDefaultValue();
+ if (defaultRnt != null && runtimes.contains(defaultRnt)) {
+ newValue = defaultRnt;
+ } else if (runtimes.size() > 0) {
+ newValue = runtimes.get(0);
}
- runtimesField.setValue(newValue);
- runtimesField.setTags(runtimes.toArray(new String[0]));
- validate();
+ } else {
+ newValue = oldValue;
}
- super.setVisible(visible);
- };
+ runtimesField.setValue(newValue);
+ runtimesField.setTags(runtimes.toArray(new String[0]));
+ }
- /**
- *
- */
private void validate() {
String message = validatorDelegate.getFirstValidationError();
this.setPageComplete(message == null);
@@ -657,17 +652,17 @@
}
static class DeploymentTypeValidator implements IValidator {
-
+
String propertyName;
-
+
IDataModel model;
-
+
static final IProjectFacet EJB_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EJB_MODULE);
-
+
static final IProjectFacetVersion EJB_30 = EJB_FACET.getVersion("3.0");
//$NON-NLS-1$
static final IProjectFacet EAR_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EAR_MODULE);
-
+
static final IProjectFacetVersion EAR_50 = EAR_FACET.getVersion("5.0");
//$NON-NLS-1$
/**
@@ -681,7 +676,7 @@
* @see IValidator#validate(Object, Object)
*/
public Map<String, String> validate(Object value, Object context) {
-
+
final String deploymentType = value.toString();
if(!ISeamFacetDataModelProperties.DEPLOY_AS_WAR.equals(deploymentType)) {
String runtimeName =
model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_TARGET_RUNTIME).toString();
@@ -692,10 +687,10 @@
NLS.bind(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CANNOT_USE_SELECTED_DEPLOYMENT6 ,
new String[]{deploymentType.toUpperCase(),runtimeName}));
}
}
- return ValidatorFactory.NO_ERRORS;
+ return ValidatorFactory.NO_ERRORS;
}
}
-
+
public class NewSeamRuntimeAction extends
ButtonFieldEditor.ButtonPressedAction {
/**
@@ -728,7 +723,7 @@
}
}
}
-
+
public class ConnectionProfileChangeListener implements IProfileListener {
/* (non-Javadoc)
* @see
org.eclipse.datatools.connectivity.IProfileListener#profileAdded(org.eclipse.datatools.connectivity.IConnectionProfile)
@@ -761,6 +756,6 @@
*
*/
public void finishPressed() {
- model.removeListener(validatorDelegate);
+ model.removeListener(validatorDelegate);
};
}
\ No newline at end of file
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2007-12-26 16:07:59
UTC (rev 5455)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2007-12-26 18:05:16
UTC (rev 5456)
@@ -15,7 +15,14 @@
org.jboss.tools.common.model,
org.eclipse.ui.navigator,
org.jboss.tools.seam.core.test,
- org.jboss.tools.seam.core
+ org.jboss.tools.seam.core,
+ org.eclipse.wst.web.ui,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.common.frameworks,
+ org.jboss.tools.jst.firstrun,
+ org.eclipse.wst.server.core,
+ org.eclipse.datatools.connectivity
Export-Package: org.jboss.tools.seam.ui.test,
org.jboss.tools.seam.ui.test.view,
org.jboss.tools.seam.ui.test.wizard
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2007-12-26
16:07:59 UTC (rev 5455)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2007-12-26
18:05:16 UTC (rev 5456)
@@ -10,43 +10,117 @@
******************************************************************************/
package org.jboss.tools.seam.ui.test.wizard;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
import junit.framework.TestCase;
-import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.PlatformUI;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
import org.jboss.tools.common.util.WorkbenchUtils;
+import org.jboss.tools.jst.firstrun.JBossASAdapterInitializer;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.ui.ISeamUiConstants;
+import org.osgi.framework.Bundle;
/**
- * @author eskimo
+ * @author eskimo, akazakov
*
*/
public class SeamProjectNewWizardTest extends TestCase{
-
+
+ NewProjectDataModelFacetWizard wizard;
+ IWizardPage startSeamPrjWzPg;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ wizard =
(NewProjectDataModelFacetWizard)WorkbenchUtils.findWizardByDefId(ISeamUiConstants.NEW_SEAM_PROJECT_WIZARD_ID);
+ WizardDialog dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.create();
+ startSeamPrjWzPg = wizard.getStartingPage();
+ assertNotNull("Cannot create seam start wizard page", startSeamPrjWzPg);
+ }
+
/**
*
*/
public void testSeamProjectNewWizardInstanceIsCreated() {
- IWizard
- aWizard =
WorkbenchUtils.findWizardByDefId(ISeamUiConstants.NEW_SEAM_PROJECT_WIZARD_ID);
-
-
- WizardDialog dialog = new WizardDialog(
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- aWizard);
- dialog.create();
- IWizardPage startSeamPrjWzPg = aWizard.getStartingPage();
- assertNotNull("Cannot create seam start wizard page",startSeamPrjWzPg);
- IWizardPage projectFacetsWizPg = aWizard.getNextPage(startSeamPrjWzPg);
+ IWizardPage projectFacetsWizPg = wizard.getNextPage(startSeamPrjWzPg);
assertNotNull("Cannot create select facets wizard page",projectFacetsWizPg);
- IWizardPage webModuleWizPg = aWizard.getNextPage(projectFacetsWizPg);
+ IWizardPage webModuleWizPg = wizard.getNextPage(projectFacetsWizPg);
assertNotNull("Cannot create dynamic web project wizard
page",webModuleWizPg);
- IWizardPage jsfCapabilitiesWizPg = aWizard.getNextPage(webModuleWizPg);
+ IWizardPage jsfCapabilitiesWizPg = wizard.getNextPage(webModuleWizPg);
assertNotNull("Cannot create JSF capabilities wizard
page",jsfCapabilitiesWizPg);
- IWizardPage seamWizPg = aWizard.getNextPage(jsfCapabilitiesWizPg);
+ IWizardPage seamWizPg = wizard.getNextPage(jsfCapabilitiesWizPg);
assertNotNull("Cannot create seam facet wizard page",seamWizPg);
- aWizard.performCancel();
+ wizard.performCancel();
}
-}
+
+ /**
+ * If all fields of all pages are valid then
+ * first page of New Seam Project Wizard must enable Finish button.
+ * See
http://jira.jboss.com/jira/browse/JBIDE-1111
+ */
+ public void testSeamProjectNewWizardAllowsToFinishAtFirstPage() {
+ // Check Finish button
+ boolean canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled at first wizard page before all requerd
fileds are valid.", canFinish);
+ wizard.performCancel();
+
+ // Create JBoss AS Runtime, Server, HSQL DB Driver
+ try {
+ JBossASAdapterInitializer.initJBossAS("", new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Cannot create JBoss AS Runtime, Server or HSQL Driver for unexisted AS
location to test New Seam Project Wizard. " + e.getMessage());
+ } catch (ConnectionProfileException e) {
+ fail("Cannot create HSQL Driver for nonexistent AS location to test New Seam
Project Wizard. " + e.getMessage());
+ }
+
+ // Create Seam Runtime and set proper field
+ SeamRuntimeManager manager = SeamRuntimeManager.getInstance();
+
+ Bundle seamTest = Platform.getBundle("org.jboss.tools.seam.ui.test");
+ try {
+ URL seamUrl = FileLocator.resolve(seamTest.getEntry("/seam"));
+ File folder = new File(seamUrl.getPath());
+ manager.addRuntime("Seam 1.2.1", folder.getAbsolutePath(),
SeamVersion.SEAM_1_2, true);
+ manager.addRuntime("Seam 2.0", folder.getAbsolutePath(),
SeamVersion.SEAM_2_0, true);
+ } catch (IOException e) {
+ fail("Cannot create Seam Runtime to test New Seam Project Wizard. " +
e.getMessage());
+ }
+
+ try {
+ setUp();
+ } catch (Exception e) {
+ fail("Cannot create New Seam Project Wizard. " + e.getMessage());
+ }
+
+ // Check Finish button
+ canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled at first wizard page before user entered the
project name.", canFinish);
+
+ // Set project name
+ IDataModel model = wizard.getDataModel();
+ model.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME,
"testSeamProjectNewWizardAllowsToFinishAtFirstPageProjectName");
+
+ // Check Finish button
+ canFinish = wizard.canFinish();
+ assertTrue("Finish button is disabled at first wizard page in spite of created
JBoss AS Runtime, Server, DB Connection and Seam Runtime and valid project name.",
canFinish);
+
+ wizard.performCancel();
+ }
+}
\ No newline at end of file