[jbosstools-commits] JBoss Tools SVN: r42778 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse: console/properties and 1 other directories.

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


Author: dgeraskov
Date: 2012-07-30 05:18:26 -0400 (Mon, 30 Jul 2012)
New Revision: 42778

Modified:
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
Log:
https://issues.jboss.org/browse/JBIDE-12343
Check project for jpa facet instead of actual build

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java	2012-07-30 08:27:35 UTC (rev 42777)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java	2012-07-30 09:18:26 UTC (rev 42778)
@@ -17,8 +17,8 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jpt.jpa.core.JpaDataSource;
-import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaFacet;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
 import org.eclipse.osgi.util.NLS;
 import org.hibernate.console.ConnectionProfileUtil;
 import org.hibernate.console.HibernateConsoleRuntimeException;
@@ -26,6 +26,7 @@
 import org.hibernate.eclipse.console.utils.ClassLoaderHelper;
 import org.hibernate.eclipse.console.utils.DriverClassHelpers;
 import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.hibernate.util.xpl.StringHelper;
 import org.w3c.dom.Element;
 
 public class EclipseLaunchConsoleConfigurationPreferences implements ConsoleConfigurationPreferences {
@@ -142,12 +143,11 @@
 			if (projName != null){
 				IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
 				if (project != null){
-					JpaProject jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
-					if (jpaProject != null) {
-						JpaDataSource ds = jpaProject.getDataSource();
-						if (ds != null)
-							return "".equals(ds.getConnectionProfileName()) ? null : ds.getConnectionProfileName();//$NON-NLS-1$
+					if (!JpaFacet.isInstalled(project)) {
+						return null;
 					}
+					String projectCPName = JptJpaCorePlugin.getConnectionProfileName(project);
+					return StringHelper.isEmpty(projectCPName) ? null : projectCPName;
 				}
 			}
 		}
@@ -225,16 +225,17 @@
 		if (projName != null){
 			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
 			if (project != null){
-				JpaProject jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
-				if (jpaProject != null) {
-					if (jpaProject.getUserOverrideDefaultCatalog() != null){
-						prop.put("hibernate.default_catalog", jpaProject.getUserOverrideDefaultCatalog()); //$NON-NLS-1$
-					}
-					if (jpaProject.getUserOverrideDefaultSchema() != null){
-						prop.put("hibernate.default_schema", jpaProject.getUserOverrideDefaultSchema()); //$NON-NLS-1$
-					}
-					
+				if (!JpaFacet.isInstalled(project)) {
+					return null;
 				}
+				String defCatalog = JptJpaCorePlugin.getUserOverrideDefaultCatalog(project);
+				String defSchema = JptJpaCorePlugin.getUserOverrideDefaultSchema(project);
+				if (StringHelper.isNotEmpty(defCatalog)){
+					prop.put("hibernate.default_catalog", defCatalog); //$NON-NLS-1$
+				}
+				if (StringHelper.isNotEmpty(defSchema)){
+					prop.put("hibernate.default_schema", defSchema); //$NON-NLS-1$
+				}
 			}
 		}
 		return prop.size() == 0 ? null : prop;

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java	2012-07-30 08:27:35 UTC (rev 42777)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java	2012-07-30 09:18:26 UTC (rev 42778)
@@ -43,7 +43,9 @@
 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jpt.jpa.core.JpaFacet;
 import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -283,9 +285,13 @@
 	}
 	
 	private boolean isHibernateJpaProject(){
-		JpaProject jpaProject = (JpaProject) getProject().getAdapter(JpaProject.class);
-		return (jpaProject != null) && ((jpaProject.getJpaPlatform().getId().equals(HibernatePropertiesConstants.HIBERNATE_JPA_PLATFORM_ID))
-				|| (jpaProject.getJpaPlatform().getId().equals(HibernatePropertiesConstants.HIBERNATE_JPA2_0_PLATFORM_ID)));
+		IProject project = getProject();
+		if (!JpaFacet.isInstalled(project)) {
+			return false;
+		}
+		String jpaPlatformId = JptJpaCorePlugin.getJpaPlatformId(project);
+		return HibernatePropertiesConstants.HIBERNATE_JPA_PLATFORM_ID.equals(jpaPlatformId)
+				|| HibernatePropertiesConstants.HIBERNATE_JPA2_0_PLATFORM_ID.equals(jpaPlatformId);
 	}
 
 	private IProject getProject() {

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-30 08:27:35 UTC (rev 42777)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java	2012-07-30 09:18:26 UTC (rev 42778)
@@ -6,9 +6,7 @@
 import java.util.Collections;
 
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -25,8 +23,8 @@
 import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jpt.jpa.core.JpaDataSource;
-import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaFacet;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -445,13 +443,12 @@
 			}
 
 			if (ConnectionProfileCtrl.JPA_CONNECTIN_NAME.equals(cpName)){
-				JpaProject jpaProject = (JpaProject) findJavaProject.getProject().getAdapter(JpaProject.class);
-				if (jpaProject == null){
+				if (!JpaFacet.isInstalled(findJavaProject.getProject())) {
 					setErrorMessage(NLS.bind(HibernateConsoleMessages.ConsoleConfigurationMainTab_project_must_be_jpa, getProjectName()));
 					return false;
 				}
-				JpaDataSource ds = jpaProject.getDataSource();
-				if (ds == null || "".equals(ds.getConnectionProfileName())){ //$NON-NLS-1$
+				String projectCPName = JptJpaCorePlugin.getConnectionProfileName(findJavaProject.getProject());
+				if (StringHelper.isEmpty(projectCPName)){
 					setErrorMessage(NLS.bind(HibernateConsoleMessages.ConsoleConfigurationMainTab_cp_not_specified, getProjectName()));
 					return false;
 				}



More information about the jbosstools-commits mailing list