Author: dgeraskov
Date: 2008-11-04 08:53:46 -0500 (Tue, 04 Nov 2008)
New Revision: 11499
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2679
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2008-11-04
13:53:40 UTC (rev 11498)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2008-11-04
13:53:46 UTC (rev 11499)
@@ -8,7 +8,11 @@
org.eclipse.jpt.core,
org.eclipse.wst.validation,
org.eclipse.jpt.utility;bundle-version="1.2.0",
- org.eclipse.core.resources;bundle-version="3.4.0"
+ org.eclipse.core.resources;bundle-version="3.4.0",
+ org.hibernate.eclipse.console;bundle-version="3.2.0",
+ org.hibernate.eclipse;bundle-version="3.2.0",
+ org.eclipse.jdt.launching;bundle-version="3.4.0",
+ org.eclipse.debug.core;bundle-version="3.4.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Hibernate Team
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateFactory.java 2008-11-04
13:53:40 UTC (rev 11498)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateFactory.java 2008-11-04
13:53:46 UTC (rev 11499)
@@ -10,12 +10,26 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jpt.core.JpaDataSource;
+import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.core.internal.platform.GenericJpaFactory;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
+import
org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
+import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
+
/**
* @author Dmitry Geraskov
*
@@ -27,4 +41,29 @@
return new HibernatePersistenceUnit(parent, persistenceUnit);
}
+
+ @Override
+ public JpaDataSource buildJpaDataSource(JpaProject jpaProject, String
connectionProfileName) {
+ try {
+ buildConsoleConfiguration(jpaProject, connectionProfileName);
+ } catch (CoreException e) {
+ //logErrorMessage("Can't create console configuration for project " +
jpaProject.getName(), e);
+ }
+ return super.buildJpaDataSource(jpaProject, connectionProfileName);
+ }
+
+ protected void buildConsoleConfiguration(JpaProject jpaProject, String
connectionProfileName) throws CoreException{
+ if (connectionProfileName == null || connectionProfileName.length() == 0) return;
+ ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType lct =
lm.getLaunchConfigurationType(ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID);
+ ILaunchConfigurationWorkingCopy wc = lct.newInstance(null, jpaProject.getName());
+
+ wc.setAttribute(IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY,
ConfigurationMode.JPA.toString());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
jpaProject.getName());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true );
+ wc.setAttribute(IConsoleConfigurationLaunchConstants.FILE_MAPPINGS,
(List<String>)null);
+ wc.setAttribute(IConsoleConfigurationLaunchConstants.CONNECTION_PROFILE_NAME,
connectionProfileName);
+
+ wc.doSave();
+ }
}