[jbosstools-commits] JBoss Tools SVN: r42667 - in trunk/hibernatetools/plugins: org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Jul 23 05:30:23 EDT 2012


Author: dgeraskov
Date: 2012-07-23 05:30:23 -0400 (Mon, 23 Jul 2012)
New Revision: 42667

Modified:
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizardPage.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConnectionProfileCtrl.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/ConfigurationFactory.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConfigurationFactory.java
Log:
https://issues.jboss.org/browse/JBIDE-7996
use DTP connection for database connection settings

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -395,26 +395,7 @@
 		IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(
 				connProfileName);
 		if (profile != null) {
-			final Properties cpProperties = profile.getProperties(profile.getProviderId());
-			// seems we should not setup dialect here
-			//String dialect = "org.hibernate.dialect.HSQLDialect";
-			//invoke.setProperty(Environment.DIALECT, dialect);
-			String driverClass = ConnectionProfileUtil.getDriverClass(connProfileName);
-			localCfg.setProperty(Environment.DRIVER, driverClass);
-			//String driverJarPath = driverInstance != null ?
-			//	driverInstance.getJarList() : ""; //$NON-NLS-1$
-			String url = cpProperties.getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
-			// url += "/";// +
-			// cpProperties.getProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
-			localCfg.setProperty(Environment.URL, url);
-			String user = cpProperties.getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
-			if (null != user && user.length() > 0) {
-				localCfg.setProperty(Environment.USER, user);
-			}
-			String pass = cpProperties.getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
-			if (null != pass && pass.length() > 0) {
-				localCfg.setProperty(Environment.PASS, pass);
-			}
+			localCfg.addProperties(ConnectionProfileUtil.getHibernateConnectionProperties(profile));
 		} else {
 			String out = NLS.bind(
 					ConsoleMessages.ConsoleConfiguration_connection_profile_not_found,

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -21,11 +21,14 @@
  */
 package org.hibernate.console;
 
+import java.util.Properties;
+
 import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
 import org.eclipse.datatools.connectivity.IConnectionProfile;
 import org.eclipse.datatools.connectivity.ProfileManager;
 import org.eclipse.datatools.connectivity.drivers.DriverInstance;
 import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+import org.hibernate.cfg.Environment;
 
 /**
  * @author Vitali Yemialyanchyk
@@ -71,4 +74,30 @@
 			di.getProperty(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID) : ""; //$NON-NLS-1$
 		return driverClass;
 	}
+	
+	/**
+	 * This method extracts connection properties from connection profile and convert them to
+	 * hiberante properties (uses other "keys" for them)
+	 * @param profile
+	 * @return
+	 */
+	public static Properties getHibernateConnectionProperties(IConnectionProfile profile){
+		Properties props = new Properties();
+		if (profile != null) {
+			final Properties cpProperties = profile.getProperties(profile.getProviderId());
+			String driverClass = ConnectionProfileUtil.getDriverClass(profile.getName());
+			props.setProperty(Environment.DRIVER, driverClass);
+			String url = cpProperties.getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
+			props.setProperty(Environment.URL, url);
+			String user = cpProperties.getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
+			if (null != user && user.length() > 0) {
+				props.setProperty(Environment.USER, user);
+			}
+			String pass = cpProperties.getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
+			if (null != pass && pass.length() > 0) {
+				props.setProperty(Environment.PASS, pass);
+			}
+		}
+		return props;
+	}
 }

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -50,6 +50,7 @@
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
@@ -119,6 +120,8 @@
 
 	private boolean initializingTabs;
 	
+	private boolean firstShow = true;
+	
 	/**
 	 * Constructor for SampleNewWizardPage.
 	 * 
@@ -586,5 +589,24 @@
 		dialogChanged();
 	}
 
+	@Override
+	public void setPreviousPage(IWizardPage page) {
+		if (page != null){
+			if (firstShow && page instanceof NewConfigurationWizardPage) {
+				NewConfigurationWizardPage newCfgFile = (NewConfigurationWizardPage) page;
+				String cpName = newCfgFile.getConnectionProfileName();
+				if (cpName != null){
+					for (ILaunchConfigurationTab tab :  tabGroup.getTabs()) {
+						if (tab instanceof ConsoleConfigurationMainTab) {
+							ConsoleConfigurationMainTab main = (ConsoleConfigurationMainTab) tab;
+							main.selectConnectionProfile(cpName);
+						}
+					}
+				}
+			}
+			firstShow = false;
+		}
+		super.setPreviousPage(page);
+	}
 
 }

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -36,6 +36,9 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.IPackageFragmentRoot;
 import org.eclipse.jdt.core.JavaCore;
@@ -56,6 +59,7 @@
 import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
 import org.eclipse.ui.ide.IDE;
 import org.hibernate.cfg.Environment;
+import org.hibernate.console.ConnectionProfileUtil;
 import org.hibernate.console.ImageConstants;
 import org.hibernate.eclipse.console.HibernateConsoleMessages;
 import org.hibernate.eclipse.console.HibernateConsolePlugin;
@@ -183,14 +187,23 @@
 	 */
 	public boolean performFinish() {
 		final Properties props = new Properties();
-        putIfNotNull(props, Environment.SESSION_FACTORY_NAME, connectionInfoPage.getSessionFactoryName() );
-        putIfNotNull(props, Environment.DIALECT, connectionInfoPage.getDialect() );
-        putIfNotNull(props, Environment.DRIVER, connectionInfoPage.getDriver() );
-        putIfNotNull(props, Environment.URL, connectionInfoPage.getConnectionURL() );
-        putIfNotNull(props, Environment.USER, connectionInfoPage.getUsername() );
-        putIfNotNull(props, Environment.PASS, connectionInfoPage.getPassword() );
-        putIfNotNull(props, Environment.DEFAULT_CATALOG, connectionInfoPage.getDefaultCatalog() );
+		putIfNotNull(props, Environment.SESSION_FACTORY_NAME, connectionInfoPage.getSessionFactoryName() );
+		putIfNotNull(props, Environment.DIALECT, connectionInfoPage.getDialect() );
+		putIfNotNull(props, Environment.DEFAULT_CATALOG, connectionInfoPage.getDefaultCatalog() );
         putIfNotNull(props, Environment.DEFAULT_SCHEMA, connectionInfoPage.getDefaultSchema() );
+		if (connectionInfoPage.getConnectionProfileName() != null){
+			String cpName = connectionInfoPage.getConnectionProfileName();
+			IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(cpName);
+			if (profile != null) {
+				props.putAll(ConnectionProfileUtil.getHibernateConnectionProperties(profile));
+			}
+		} else {
+	        putIfNotNull(props, Environment.DRIVER, connectionInfoPage.getDriver() );
+	        putIfNotNull(props, Environment.URL, connectionInfoPage.getConnectionURL() );
+	        putIfNotNull(props, Environment.USER, connectionInfoPage.getUsername() );
+	        putIfNotNull(props, Environment.PASS, connectionInfoPage.getPassword() );
+		}
+		
         final IFile file = cPage.createNewFile();
 
 		IRunnableWithProgress op = new IRunnableWithProgress() {
@@ -353,4 +366,6 @@
 		}
 		return super.canFinish();
 	}
+	
+	
 }
\ No newline at end of file

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizardPage.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizardPage.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -38,11 +38,14 @@
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
 import org.hibernate.eclipse.console.HibernateConsoleMessages;
 import org.hibernate.eclipse.console.utils.DriverClassHelpers;
+import org.hibernate.eclipse.launch.ConnectionProfileCtrl;
 
 /**
  * Wizard for creating basic hibernate.cfg.xml
@@ -56,6 +59,12 @@
     private Label fileText;
 
     private Text sessionFactoryNameText;
+    
+    private Button useDTPConnection;
+    
+    private Label dtpConnection;
+    
+    private ConnectionProfileCtrl connectionProfileCtrl;
 
     private Combo dialectCombo;
 
@@ -77,6 +86,8 @@
     private final WizardNewFileCreationPage fileCreation;
 
     private boolean beenShown = false;
+    
+    private Group driverManagerTabContainer;
 
     /**
      * Constructor for SampleNewWizardPage.
@@ -146,7 +157,7 @@
         gd = new GridData(GridData.FILL_HORIZONTAL);
         sessionFactoryNameText.setLayoutData(gd);
         sessionFactoryNameText.addModifyListener(listener);
-
+        
         label = new Label(container, SWT.NULL);
         label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_database_dialect);
         dialectCombo = new Combo(container, SWT.NULL);
@@ -167,8 +178,41 @@
         gd.horizontalAlignment = SWT.TOP;
         gd.verticalAlignment = SWT.TOP;
         label.setLayoutData(gd);
+        
+        
+        
+        useDTPConnection = new Button(container, SWT.CHECK);
+        useDTPConnection.setText("Use DTP Connection");
+        useDTPConnection.addSelectionListener(selectionListener);
 
-        Composite driverManagerTabContainer = container;
+        GridData gd2 = new GridData(SWT.NULL, SWT.NULL, false, false, 2, 1);
+        useDTPConnection.setLayoutData(gd2);
+        
+        dtpConnection = new Label(container, SWT.NULL);
+        dtpConnection.setText("DTP Connection");
+        dtpConnection.setLayoutData(gd);
+        dtpConnection.setEnabled(false);
+        
+        connectionProfileCtrl = new ConnectionProfileCtrl(container, 1, ""); //$NON-NLS-1$
+		connectionProfileCtrl.addModifyListener(new ModifyListener() {
+			@Override
+			public void modifyText(ModifyEvent e) {
+				if (connectionProfileCtrl.hasConnectionProfileSelected()){
+					setPageComplete(connectionProfileCtrl.hasConnectionProfileSelected());
+				}
+			}
+		});
+		connectionProfileCtrl.setEnabled(false);
+
+ 
+		driverManagerTabContainer = new Group(container, SWT.NONE);
+		driverManagerTabContainer.setText("Custom");
+		driverManagerTabContainer.setLayout(layout);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = 2;
+		driverManagerTabContainer.setLayoutData(gd);
+		
+        //Composite driverManagerTabContainer = container;
         label = new Label(driverManagerTabContainer, SWT.NULL);
         label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_driver_class);
         driver_classCombo = new Combo(driverManagerTabContainer, SWT.NULL);
@@ -195,20 +239,6 @@
         urlCombo.addModifyListener(listener);
 
         label = new Label(driverManagerTabContainer, SWT.NULL);
-        label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_default_schema);
-        defaultSchemaText = new Text(driverManagerTabContainer, SWT.BORDER | SWT.SINGLE);
-        gd = new GridData(GridData.FILL_HORIZONTAL);
-        defaultSchemaText.setLayoutData(gd);
-        defaultSchemaText.addModifyListener(listener);
-
-        label = new Label(driverManagerTabContainer, SWT.NULL);
-        label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_default_catalog);
-        defaultCatalogText = new Text(driverManagerTabContainer, SWT.BORDER | SWT.SINGLE);
-        gd = new GridData(GridData.FILL_HORIZONTAL);
-        defaultCatalogText.setLayoutData(gd);
-        defaultCatalogText.addModifyListener(listener);
-
-        label = new Label(driverManagerTabContainer, SWT.NULL);
         label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_user_name);
         usernameText = new Text(driverManagerTabContainer, SWT.BORDER | SWT.SINGLE);
         gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -221,10 +251,23 @@
         gd = new GridData(GridData.FILL_HORIZONTAL);
         passwordText.setLayoutData(gd);
         passwordText.addModifyListener(listener);
+        
+        label = new Label(container, SWT.NULL);
+        label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_default_schema);
+        defaultSchemaText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        defaultSchemaText.setLayoutData(gd);
+        defaultSchemaText.addModifyListener(listener);
 
+        label = new Label(container, SWT.NULL);
+        label.setText(HibernateConsoleMessages.NewConfigurationWizardPage_default_catalog);
+        defaultCatalogText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        defaultCatalogText.setLayoutData(gd);
+        defaultCatalogText.addModifyListener(listener);
+
         fillLabel(container);
         fillLabel(container);
-
         fillLabel(container);
 
         createConsoleConfiguration = new Button(container, SWT.CHECK);
@@ -293,6 +336,19 @@
      * Ensures that contents is ok.
      */
     private void dialogChanged() {
+    	dtpConnection.setEnabled(useDTPConnection.getSelection());
+		connectionProfileCtrl.setEnabled(useDTPConnection.getSelection());
+		if (useDTPConnection.getSelection()){
+			setPageComplete(connectionProfileCtrl.hasConnectionProfileSelected());
+		} else {
+			setPageComplete(true);
+		}
+		
+		driverManagerTabContainer.setEnabled(!useDTPConnection.getSelection());
+		for (Control control : driverManagerTabContainer.getChildren()) {
+			control.setEnabled(!useDTPConnection.getSelection());
+		}
+		
         IResource container = ResourcesPlugin.getWorkspace().getRoot()
                 .findMember(new Path(getContainerName() ) );
         String fileName = getFileName();
@@ -425,4 +481,18 @@
 	public String getDefaultSchema() {
 		return nullIfEmpty(defaultSchemaText.getText());
 	}
+	
+	public void setConnectionProfileName(String cpName){
+		if (cpName != null){
+			useDTPConnection.setSelection(true);
+			connectionProfileCtrl.selectValue(cpName);
+		}
+	}
+	
+	public String getConnectionProfileName(){
+		if (useDTPConnection.getSelection()){
+			return connectionProfileCtrl.getSelectedConnectionName();
+		}
+		return null;
+	}
 }
\ No newline at end of file

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConnectionProfileCtrl.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConnectionProfileCtrl.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConnectionProfileCtrl.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -56,6 +56,7 @@
 	protected ComboViewer comboControl;
 	protected Button buttonNew;
 	protected Button buttonEdit;
+	private boolean useSynteticValues = false;
 	
 	static final String NO_CONNECTIN_NAME = HibernateConsoleMessages.ConnectionProfileCtrl_HibernateConfiguredConnection;
 	static final String JPA_CONNECTIN_NAME = HibernateConsoleMessages.ConnectionProfileCtrl_JPAConfiguredConnection;
@@ -102,6 +103,10 @@
 		createComboWithTwoButtons(comp, hspan, defaultValue,
 				new NewConnectionProfileAction(), new EditConnectionProfileAction());
 	}
+	
+	public void setUseSynteticValue(boolean value){
+		this.useSynteticValues = value;
+	}
 
 	public class ButtonPressedAction extends Action implements SelectionListener {
 
@@ -235,7 +240,7 @@
 	public Composite createComboWithTwoButtons(Composite container, int hspan, 
 			String defaultValue, ButtonPressedAction action1, ButtonPressedAction action2) {
 
-		Composite comp = SWTFactory.createComposite(container, container.getFont(), 3, 1, GridData.FILL_BOTH, 0, 0);
+		Composite comp = SWTFactory.createComposite(container, container.getFont(), 3, 1, GridData.FILL_HORIZONTAL, 0, 0);
 		Combo combo;
 		combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
 		combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
@@ -339,8 +344,10 @@
 		IConnectionProfile[] profiles = ProfileManager.getInstance()
 				.getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
 		List<ConnectionWrapper> names = new ArrayList<ConnectionWrapper>();
-		names.add(JPA_CONNECTION_PLACEHOLDER);
-		names.add(NO_CONNECTION_PLACEHOLDER);
+		if (useSynteticValues){
+			names.add(JPA_CONNECTION_PLACEHOLDER);
+			names.add(NO_CONNECTION_PLACEHOLDER);
+		}
 		for (IConnectionProfile connectionProfile : profiles) {
 			names.add(new ConnectionWrapper(connectionProfile.getName(), connectionProfile));
 		}

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -213,6 +213,12 @@
 		}
 	}
 	
+	public void selectConnectionProfile(String cpName){
+		if (cpName != null){
+			connectionProfileCtrl.selectValue(cpName);
+		}
+	}
+	
 	public void initializeFrom(ILaunchConfiguration configuration) {
 
 		try {
@@ -376,6 +382,11 @@
 		IWizardPage configPage = wizard.getPage(HibernateConsoleMessages.ConsoleConfigurationMainTab_wizard_page);
 		if (configPage != null && configPage instanceof NewConfigurationWizardPage){
 			((NewConfigurationWizardPage)configPage).setCreateConsoleConfigurationVisible(false);
+			String cpName = nonEmptyTrimOrNull(connectionProfileCtrl.getSelectedConnectionName());
+			if (cpName != null
+					&& !ConnectionProfileCtrl.JPA_CONNECTIN_NAME.equals(cpName)
+					&& !ConnectionProfileCtrl.NO_CONNECTIN_NAME.equals(cpName))
+				((NewConfigurationWizardPage)configPage).setConnectionProfileName(connectionProfileCtrl.getSelectedConnectionName());
 		}
 		// This opens a dialog
 		if (wdialog.open() == Window.OK){

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/ConfigurationFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/ConfigurationFactory.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/ConfigurationFactory.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -31,7 +31,6 @@
 import org.dom4j.io.DOMWriter;
 import org.eclipse.datatools.connectivity.IConnectionProfile;
 import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
 import org.eclipse.osgi.util.NLS;
 import org.hibernate.HibernateException;
 import org.hibernate.MappingException;
@@ -387,26 +386,7 @@
 		IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(
 				connProfileName);
 		if (profile != null) {
-			final Properties cpProperties = profile.getProperties(profile.getProviderId());
-			// seems we should not setup dialect here
-			//String dialect = "org.hibernate.dialect.HSQLDialect";
-			//invoke.setProperty(Environment.DIALECT, dialect);
-			String driverClass = ConnectionProfileUtil.getDriverClass(connProfileName);
-			localCfg.setProperty(Environment.DRIVER, driverClass);
-			//String driverJarPath = driverInstance != null ?
-			//	driverInstance.getJarList() : ""; //$NON-NLS-1$
-			String url = cpProperties.getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
-			// url += "/";// +
-			// cpProperties.getProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
-			localCfg.setProperty(Environment.URL, url);
-			String user = cpProperties.getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
-			if (null != user && user.length() > 0) {
-				localCfg.setProperty(Environment.USER, user);
-			}
-			String pass = cpProperties.getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
-			if (null != pass && pass.length() > 0) {
-				localCfg.setProperty(Environment.PASS, pass);
-			}
+			localCfg.addProperties(ConnectionProfileUtil.getHibernateConnectionProperties(profile));
 		} else {
 			String out = NLS.bind(
 					ConsoleMessages.ConsoleConfiguration_connection_profile_not_found,

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConfigurationFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConfigurationFactory.java	2012-07-23 09:11:26 UTC (rev 42666)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConfigurationFactory.java	2012-07-23 09:30:23 UTC (rev 42667)
@@ -42,7 +42,6 @@
 import org.dom4j.io.DOMWriter;
 import org.eclipse.datatools.connectivity.IConnectionProfile;
 import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
 import org.eclipse.osgi.util.NLS;
 import org.hibernate.HibernateException;
 import org.hibernate.MappingException;
@@ -402,26 +401,7 @@
 		IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(
 				connProfileName);
 		if (profile != null) {
-			final Properties cpProperties = profile.getProperties(profile.getProviderId());
-			// seems we should not setup dialect here
-			//String dialect = "org.hibernate.dialect.HSQLDialect";
-			//invoke.setProperty(Environment.DIALECT, dialect);
-			String driverClass = ConnectionProfileUtil.getDriverClass(connProfileName);
-			localCfg.setProperty(Environment.DRIVER, driverClass);
-			//String driverJarPath = driverInstance != null ?
-			//	driverInstance.getJarList() : ""; //$NON-NLS-1$
-			String url = cpProperties.getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
-			// url += "/";// +
-			// cpProperties.getProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
-			localCfg.setProperty(Environment.URL, url);
-			String user = cpProperties.getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
-			if (null != user && user.length() > 0) {
-				localCfg.setProperty(Environment.USER, user);
-			}
-			String pass = cpProperties.getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
-			if (null != pass && pass.length() > 0) {
-				localCfg.setProperty(Environment.PASS, pass);
-			}
+			localCfg.addProperties(ConnectionProfileUtil.getHibernateConnectionProperties(profile));
 		} else {
 			String out = NLS.bind(
 					ConsoleMessages.ConsoleConfiguration_connection_profile_not_found,



More information about the jbosstools-commits mailing list