Author: dgeraskov
Date: 2009-11-16 09:01:10 -0500 (Mon, 16 Nov 2009)
New Revision: 18694
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java
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/SeamFacetFilterSetFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4987
Use jpa-connection profile if the facet is installed.
Use the profile in launch configuration instead of hibernate.properties.
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java 2009-11-16
13:45:01 UTC (rev 18693)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java 2009-11-16
14:01:10 UTC (rev 18694)
@@ -59,7 +59,7 @@
protected boolean checkPreConditions(IProject project){
try {
ILaunchConfiguration lc = getLaunchConfiguration(project);
- if (lc != null){
+ if (lc != null && lc.exists()){
ProjectUtils.toggleHibernateOnProject(project, true, lc.getName());
return false;
}
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 2009-11-16
13:45:01 UTC (rev 18693)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2009-11-16
14:01:10 UTC (rev 18694)
@@ -307,7 +307,7 @@
protected File webInfClassesMetaInf;
protected File persistenceFile;
protected File hibernateConsoleLaunchFile;
- protected File hibernateConsolePropsFile;
+ //protected File hibernateConsolePropsFile;
/**
*
@@ -491,15 +491,17 @@
new File(resources, project.getName() + "-ds.xml"), //$NON-NLS-1$
viewFilterSetCollection, false);
- AntCopyUtils.copyFileToFile(
- hibernateConsoleLaunchFile,
- new File(project.getLocation().toFile(), project.getName() + ".launch"),
//$NON-NLS-1$
- viewFilterSetCollection, false);
+ if (hibernateConsoleLaunchFile != null) {
+ AntCopyUtils.copyFileToFile(
+ hibernateConsoleLaunchFile,
+ new File(project.getLocation().toFile(), project.getName() + ".launch"),
//$NON-NLS-1$
+ viewFilterSetCollection, false);
+ }
- AntCopyUtils.copyFileToFolder(
+ /*AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
project.getLocation().toFile(),
- hibernateDialectFilterSet, false);
+ hibernateDialectFilterSet, false);*/
WtpUtils.setClasspathEntryAsExported(project, new
Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
} else {
@@ -682,8 +684,8 @@
ejbProjectFolder, ejbProjectFolder.getName() + ".launch"), //$NON-NLS-1$
new FilterSetCollection(ejbFilterSet), false);
- AntCopyUtils.copyFileToFolder(hibernateConsolePropsFile,
- ejbProjectFolder, hibernateDialectFilterSet, false);
+ /*AntCopyUtils.copyFileToFolder(hibernateConsolePropsFile,
+ ejbProjectFolder, hibernateDialectFilterSet, false);*/
}
enum ProjectType {
@@ -716,6 +718,7 @@
IProjectFacetVersion ejbVersion =
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.EJB_FACET);
IProjectFacetVersion webVersion =
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET);
IProjectFacetVersion earVersion =
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_FACET);
+ IProjectFacetVersion jpaVersion =
facetedProject.getProjectFacetVersion(ProjectFacetsManager.getProjectFacet("jpt.jpa"));
initDefaultModelValues(model, webVersion!=null);
model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
@@ -760,8 +763,32 @@
dataSourceDsFile = new File(seamGenResFolder, "datasource-ds.xml");
//$NON-NLS-1$
componentsFile = new File(seamGenResFolder, "WEB-INF/components" +
(isWarConfiguration(model) ? "-war" : "") + ".xml");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- hibernateConsoleLaunchFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
- hibernateConsolePropsFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
+ if (jpaVersion != null) {
+ IScopeContext context = new ProjectScope(project);
+ IEclipsePreferences prefs = context.getNode("org.eclipse.jpt.core");
+ String platformId = prefs.get("org.eclipse.jpt.core.platform", null);
+ if ("hibernate".equals(platformId)){
+ /*
+ * Hibernate automatically creates console configuration
+ */
+ hibernateConsoleLaunchFile = null;
+ } else {
+ try {
+ hibernateConsoleLaunchFile = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"hibernatetools/hibernate-console_jpa.launch");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ //hibernateConsoleLaunchFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console_jpa.launch"); //$NON-NLS-1$
+ }
+ } else {
+ try {
+ hibernateConsoleLaunchFile = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"hibernatetools/hibernate-console.launch");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ //hibernateConsoleLaunchFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
+ }
+ //hibernateConsolePropsFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
//final File hibernateConsolePref = new File(seamGenHomeFolder,
"hibernatetools/.settings/org.hibernate.eclipse.console.prefs"); //$NON-NLS-1$
persistenceFile = new File(seamGenResFolder, "META-INF/persistence-" +
(isWarConfiguration(model) ? DEV_WAR_PROFILE : DEV_EAR_PROFILE) + ".xml");
//$NON-NLS-1$ //$NON-NLS-2$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2009-11-16
13:45:01 UTC (rev 18693)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2009-11-16
14:01:10 UTC (rev 18694)
@@ -44,6 +44,7 @@
PROJECT_TEMPLATE.addFilter("debug","true"); //$NON-NLS-1$
//$NON-NLS-2$
//todo: keep this local for seam2 ?
PROJECT_TEMPLATE.addFilter("skin","blueSky"); //$NON-NLS-1$
//$NON-NLS-2$
+ PROJECT_TEMPLATE.addFilter("connectionProfile","${seam.project.connection.profile}");
//$NON-NLS-1$ //$NON-NLS-2$
FILTERS_TEMPLATE = new FilterSet();
FILTERS_TEMPLATE.addFilter("interfaceName","${interface.name}");
//$NON-NLS-1$ //$NON-NLS-2$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2009-11-16
13:45:01 UTC (rev 18693)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2009-11-16
14:01:10 UTC (rev 18694)
@@ -90,7 +90,7 @@
protected File seamGenResFolder;
protected File persistenceFile;
protected File hibernateConsoleLaunchFile;
- protected File hibernateConsolePropsFile;
+ //protected File hibernateConsolePropsFile;
protected FilterSet jdbcFilterSet;
protected FilterSet encodedJdbcFilterSet;
@@ -134,8 +134,14 @@
filtersFilterSet = SeamFacetFilterSetFactory.createFiltersFilterSet(model);
seamGenResFolder = new File(seamGenHomeFolder, "resources"); //$NON-NLS-1$
persistenceFile = new File(seamGenResFolder, "META-INF/persistence-" +
(SeamFacetAbstractInstallDelegate.isWarConfiguration(model) ? DEV_WAR_PROFILE :
DEV_EAR_PROFILE) + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- hibernateConsoleLaunchFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
- hibernateConsolePropsFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
+
+ try {
+ hibernateConsoleLaunchFile = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"hibernatetools/hibernate-console.launch");
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ //hibernateConsoleLaunchFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
+ //hibernateConsolePropsFile = new File(seamGenHomeFolder,
"hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
dataSourceDsFile = new File(seamGenResFolder, "datasource-ds.xml");
//$NON-NLS-1$
IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
@@ -422,16 +428,17 @@
FilterSet ejbFilterSet = new FilterSet();
ejbFilterSet.addFilter("projectName", ejbProjectFolder.getName());
//$NON-NLS-1$
+ ejbFilterSet.addFilter("connectionProfile",
model.getStringProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE));//$NON-NLS-1$
AntCopyUtils.copyFileToFile(
- hibernateConsoleLaunchFile,
- new File(ejbProjectFolder, ejbProjectFolder.getName() + ".launch"),
//$NON-NLS-1$
- new FilterSetCollection(ejbFilterSet), true);
+ hibernateConsoleLaunchFile,
+ new File(ejbProjectFolder, ejbProjectFolder.getName() + ".launch"),
//$NON-NLS-1$
+ new FilterSetCollection(ejbFilterSet), true);
- AntCopyUtils.copyFileToFolder(
+ /*AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
ejbProjectFolder,
- hibernateDialectFilterSet, true);
+ hibernateDialectFilterSet, true);*/
}
protected void createEarProject() {
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console.launch 2009-11-16
14:01:10 UTC (rev 18694)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Hibernate Console launch configuration -->
+<launchConfiguration
type="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType">
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="@projectName@"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONFIGURATION_FACTORY"
value="JPA"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONNECTION_PROFILE_NAME"
value="@connectionProfile@"/>
+</launchConfiguration>
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/templates/hibernatetools/hibernate-console_jpa.launch 2009-11-16
14:01:10 UTC (rev 18694)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Hibernate Console launch configuration -->
+<launchConfiguration
type="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType">
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="@projectName@"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONFIGURATION_FACTORY"
value="JPA"/>
+<stringAttribute key="org.hibernate.eclipse.launch.USE_JPA_PROJECT_PROFILE"
value="true"/>
+</launchConfiguration>
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 2009-11-16
13:45:01 UTC (rev 18693)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2009-11-16
14:01:10 UTC (rev 18694)
@@ -36,6 +36,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.PlatformUI;
@@ -48,13 +49,16 @@
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.IFacetedProjectWorkingCopy;
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;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
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;
@@ -65,7 +69,6 @@
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDataModelProvider;
-import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
@@ -109,45 +112,17 @@
getDeployAsDefaultValue());
// Database group
- private IFieldEditor connProfileSelEditor = SeamWizardFactory
- .createConnectionProfileSelectionFieldEditor(
- getConnectionProfileDefaultValue(), new IValidator() {
- public Map<String, IStatus> validate(Object value,
- Object context) {
- SeamInstallWizardPage.this.validate();
- return ValidatorFactory.NO_ERRORS;
- }
- });
+ private IFieldEditor connProfileSelEditor;
- 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 jBossHibernateDbTypeEditor ;
- private IFieldEditor dbSchemaName = IFieldEditorFactory.INSTANCE
- .createTextEditor(
- ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_SCHEMA_NAME,
- ""); //$NON-NLS-1$
+ private IFieldEditor dbSchemaName;
- private IFieldEditor dbCatalogName = IFieldEditorFactory.INSTANCE
- .createTextEditor(
- ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_CATALOG_NAME,
- ""); //$NON-NLS-1$
+ private IFieldEditor dbCatalogName;
- private IFieldEditor dbTablesExists = IFieldEditorFactory.INSTANCE
- .createCheckboxEditor(
- ISeamFacetDataModelProperties.DB_ALREADY_EXISTS,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DB_TABLES_ALREADY_EXISTS,
- false);
+ private IFieldEditor dbTablesExists;
- private IFieldEditor recreateTablesOnDeploy = IFieldEditorFactory.INSTANCE
- .createCheckboxEditor(
- ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_RECREATE_DATABASE_TABLES_AND_DATA_ON_DEPLOY,
- false);
+ private IFieldEditor recreateTablesOnDeploy;
private IFieldEditor sessionBeanPkgNameditor = IFieldEditorFactory.INSTANCE
.createTextEditor(
@@ -166,6 +141,8 @@
ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_TEST_PACKAGE_NAME,
"com.mydomain.projectname.test"); //$NON-NLS-1$
+
+ private Group databaseGroup;
/**
*
@@ -266,8 +243,7 @@
public void setConfig(Object config) {
model = (IDataModel) config;
model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
- HIBERNATE_HELPER.getDialectClass(jBossHibernateDbTypeEditor
- .getValueAsString()));
+ HIBERNATE_HELPER.getDialectClass(getDefaultDbType()));
}
/**
@@ -289,20 +265,66 @@
if (seamRuntime != null) {
SeamRuntimeManager.getInstance().setDefaultRuntime(seamRuntime);
}
+
+ if (connProfileSelEditor != null) {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
+ connProfileSelEditor.getValueAsString());
+ } else {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
+ getJpaConnectionProfile());
+ model.setStringProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
getJpaConnectionProfile());
+ }
+
+ if (jBossHibernateDbTypeEditor != null) {
+ 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());
+ this.jBossAsDeployAsEditor.getValueAsString());
}
+
+ /*
+ * Don't want to add jpa as required plugin, so use String constant instead of
JptCorePlugin.FACET_ID
+ */
+ private IProjectFacetVersion getJpaFacetVersion(){
+ IFacetedProjectWorkingCopy facetedProject = ( (ModifyFacetedProjectWizard) getWizard()
).getFacetedProjectWorkingCopy();
+ return
facetedProject.getProjectFacetVersion(ProjectFacetsManager.getProjectFacet("jpt.jpa")); //$NON-NLS-1$
+ }
+
+ /**
+ * Used to save connection profile from jpa facet.
+ * If not null then used as seam connection profile.
+ */
+ private String jpaConnectioProfile;
+
+ public void setJpaConnectionProfile(String jpaConnectioProfile){
+ this.jpaConnectioProfile = jpaConnectioProfile;
+ }
+
+ private String getJpaConnectionProfile(){
+ if (jpaConnectioProfile != null) return jpaConnectioProfile;
+ IProjectFacetVersion jpaVersion = getJpaFacetVersion();
+ if (jpaVersion == null) throw new NullPointerException("Jpa facet version is
null");
+ try {
+ Object config = context.getConfig(jpaVersion, Action.Type.INSTALL,
context.getProjectName());
+ if (config instanceof IDataModel) {
+ /*
+ * Don't want to add jpa as required plugin, so use String constant instead of
JpaFacetDataModelProperties.CONNECTION
+ */
+ return
((IDataModel)config).getStringProperty("JpaFacetDataModelProperties.CONNECTION");
//$NON-NLS-1$
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return null;
+ }
+
/**
* Registers editor in data synchronizer and put SWT controls for it at
* wizard page.
@@ -365,19 +387,14 @@
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = false;
- Group databaseGroup = new Group(root, SWT.NONE);
+ databaseGroup = new Group(root, SWT.NONE);
databaseGroup.setLayoutData(gd);
databaseGroup.setText(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE);
gridLayout = new GridLayout(4, false);
databaseGroup.setLayout(gridLayout);
- registerEditor(jBossHibernateDbTypeEditor, databaseGroup, 4);
- registerEditor(connProfileSelEditor, databaseGroup, 4);
- registerEditor(dbSchemaName, databaseGroup, 4);
- registerEditor(dbCatalogName, databaseGroup, 4);
- registerEditor(dbTablesExists, databaseGroup, 4);
- registerEditor(recreateTablesOnDeploy, databaseGroup, 4);
- // registerEditor(pathToJdbcDriverJar,databaseGroup, 4);
+ createDatabaseGoupControl();
+
Group generationGroup = new Group(root, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 1;
@@ -422,16 +439,7 @@
getDeploymentTypeValidator(getWizard()));
}
- jBossHibernateDbTypeEditor
- .addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- SeamInstallWizardPage.this.model
- .setProperty(
- ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
- HIBERNATE_HELPER.getDialectClass(evt
- .getNewValue().toString()));
- }
- });
+
Dialog.applyDialogFont(parent);
initDefaultWizardProperties();
@@ -442,6 +450,85 @@
}
}
+ public void createDatabaseGoupControl() {
+ disposeControls(jBossHibernateDbTypeEditor);
+ disposeControls(connProfileSelEditor);
+ disposeControls(dbSchemaName);
+ disposeControls(dbCatalogName);
+ disposeControls(dbTablesExists);
+ disposeControls(recreateTablesOnDeploy);
+ if (!needToShowConnectionProfile){
+ jBossHibernateDbTypeEditor = null;
+ connProfileSelEditor = null;
+ dbSchemaName = null;
+ dbCatalogName = null;
+ } else {
+ jBossHibernateDbTypeEditor = IFieldEditorFactory.INSTANCE
+ .createComboEditor(ISeamFacetDataModelProperties.DB_TYPE,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_TYPE,
+ Arrays.asList(HIBERNATE_HELPER.getDialectNames()),
+ getDefaultDbType(), false);
+ connProfileSelEditor = SeamWizardFactory
+ .createConnectionProfileSelectionFieldEditor(
+ getConnectionProfileDefaultValue(), new IValidator() {
+ public Map<String, IStatus> validate(Object value,
+ Object context) {
+ SeamInstallWizardPage.this.validate();
+ return ValidatorFactory.NO_ERRORS;
+ }
+ });
+ dbSchemaName = IFieldEditorFactory.INSTANCE
+ .createTextEditor(
+ ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_SCHEMA_NAME,
+ ""); //$NON-NLS-1$
+ dbCatalogName = IFieldEditorFactory.INSTANCE
+ .createTextEditor(
+ ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_CATALOG_NAME,
+ ""); //$NON-NLS-1$
+
+ jBossHibernateDbTypeEditor
+ .addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ SeamInstallWizardPage.this.model
+ .setProperty(
+ ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
+ HIBERNATE_HELPER.getDialectClass(evt
+ .getNewValue().toString()));
+ }
+ });
+ registerEditor(jBossHibernateDbTypeEditor, databaseGroup, 4);
+ registerEditor(connProfileSelEditor, databaseGroup, 4);
+ registerEditor(dbSchemaName, databaseGroup, 4);
+ registerEditor(dbCatalogName, databaseGroup, 4);
+ }
+ dbTablesExists = IFieldEditorFactory.INSTANCE
+ .createCheckboxEditor(
+ ISeamFacetDataModelProperties.DB_ALREADY_EXISTS,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DB_TABLES_ALREADY_EXISTS,
+ false);
+ recreateTablesOnDeploy = IFieldEditorFactory.INSTANCE
+ .createCheckboxEditor(
+ ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_RECREATE_DATABASE_TABLES_AND_DATA_ON_DEPLOY,
+ false);
+ registerEditor(dbTablesExists, databaseGroup, 4);
+ registerEditor(recreateTablesOnDeploy, databaseGroup, 4);
+ databaseGroup.getParent().layout(true);
+ }
+
+ private void disposeControls(IFieldEditor editor){
+ if (editor != null){
+ Object[] controls = editor.getEditorControls();
+ for (int i = 0; i < controls.length; i++) {
+ Control control = (Control) controls[i];
+ if (!control.isDisposed()) control.dispose();
+ }
+ editor.dispose();
+ }
+ }
+
private boolean isNewSeamProjectWizard() {
return getWizard() == null || getWizard() instanceof SeamProjectWizard;
}
@@ -478,6 +565,8 @@
getTestPkgName(p));
}
}
+
+ private boolean needToShowConnectionProfile = true;
/**
* It is overridden to fill Code Generation group with the default package
@@ -489,6 +578,16 @@
if (visible) {
setCodeGenerationProperties();
setDefaultSeamRuntime();
+ boolean jpaFacetAdded = getJpaFacetVersion() != null;
+ if (jpaFacetAdded == needToShowConnectionProfile){
+
+ needToShowConnectionProfile = !jpaFacetAdded;
+ createDatabaseGoupControl();
+ }
+ //update selected connection profile
+ if (!needToShowConnectionProfile){
+ model.setStringProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
getJpaConnectionProfile());
+ }
validate();
}
super.setVisible(visible);