Author: dgeraskov
Date: 2009-08-21 08:04:33 -0400 (Fri, 21 Aug 2009)
New Revision: 17214
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertiesConstants.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
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/utils/ProjectUtils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/nature/HibernateNature.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ContentAssistTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4803
project rebuild updated
added option to disable using naming strategy
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -103,6 +103,7 @@
public static String HibernatePropertyPage_enable_hibernate3_support;
public static String HibernatePropertyPage_open_url;
public static String HibernatePropertyPage_unable_open_webbrowser_for_url;
+ public static String HibernatePropertyPage_use_naming_strategy;
//
public static String AutoResizeTableLayout_unknown_column_layout_data;
public static String ClassLoaderHelper_could_not_determine_physical_location_for;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-08-21
12:04:33 UTC (rev 17214)
@@ -96,6 +96,7 @@
HibernatePropertyPage_enable_hibernate3_support=Enable Hibernate 3 support
HibernatePropertyPage_open_url=Open URL
HibernatePropertyPage_unable_open_webbrowser_for_url=Unable to open webbrowser for url:
+HibernatePropertyPage_use_naming_strategy=Use NamingStrategy for validation.
AutoResizeTableLayout_unknown_column_layout_data=Unknown column layout data
ClassLoaderHelper_could_not_determine_physical_location_for=Could not determine physical
location for
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertiesConstants.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertiesConstants.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertiesConstants.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.hibernate.eclipse.console.properties;
+
+import org.hibernate.eclipse.nature.HibernateNature;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernatePropertiesConstants {
+
+ public static final String HIBERNATE_NATURE = HibernateNature.ID;
+
+ public static final String NAMING_STRATEGY_ENABLED = "namingStrategy.enabled";
//$NON-NLS-1$
+
+ public static final String DEFAULT_CONFIGURATION = "default.configuration";
//$NON-NLS-1$
+
+ public static final String HIBERNATE3_ENABLED = "hibernate3.enabled";
//$NON-NLS-1$
+
+ public static final String HIBERNATE_CONSOLE_NODE =
"org.hibernate.eclipse.console"; //$NON-NLS-1$
+
+ public static final String HIBERNATE_JPA_PLATFORM_ID = "hibernate";
//$NON-NLS-1$
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertiesConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
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 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -21,18 +21,29 @@
*/
package org.hibernate.eclipse.console.properties;
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.internal.JpaModelManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -55,6 +66,7 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.EclipseImages;
import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
public class HibernatePropertyPage extends PropertyPage {
@@ -64,6 +76,12 @@
private Button enableHibernate;
private Combo selectedConfiguration;
+
+ private Button enableNamingStrategy;
+
+ private Label nsSeparator;
+
+ private boolean initNamingStrategy;
/**
@@ -99,9 +117,6 @@
enableSettings(selection);
}
});
-
-
-
}
private void createLogoButtons(Composite composite) {
@@ -159,12 +174,13 @@
return retu.toString();
}
- private void addSeparator(Composite parent) {
+ private Label addSeparator(Composite parent) {
Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
separator.setLayoutData(gridData);
+ return separator;
}
private void addSecondSection(Composite parent) {
@@ -187,8 +203,15 @@
}
settings = new Control[] { ownerLabel, selectedConfiguration };
-
}
+
+ private void addThirdSection(Composite parent) {
+ Composite settingsPart = createDefaultComposite(parent,2);
+
+ enableNamingStrategy = new Button(settingsPart, SWT.CHECK);
+ enableNamingStrategy.setText(HibernateConsoleMessages.HibernatePropertyPage_use_naming_strategy);
+ enableNamingStrategy.setSelection(initNamingStrategy);
+ }
/**
* @see PreferencePage#createContents(Composite)
@@ -203,8 +226,11 @@
addFirstSection(composite);
addSeparator(composite);
- addSecondSection(composite);
+ addSecondSection(composite);
addSeparator(composite);
+ addThirdSection(composite);
+ nsSeparator = addSeparator(composite);
+
addLogoSection(composite);
loadValues();
enableSettings(enableHibernate.getSelection() );
@@ -230,6 +256,11 @@
enableHibernate.setSelection(false);
selectedConfiguration.setText(""); //$NON-NLS-1$
}
+
+ private boolean isHibernateJpaProject(){
+ JpaProject jpaProject = (JpaProject) getProject().getAdapter(JpaProject.class);
+ return (jpaProject != null) &&
(jpaProject.getJpaPlatform().getId().equals(HibernatePropertiesConstants.HIBERNATE_JPA_PLATFORM_ID));
+ }
private IProject getProject() {
IAdaptable adaptable= getElement();
@@ -242,27 +273,89 @@
return null;
}
+ @Override
+ public void setVisible(boolean visible) {
+ //loadValues();
+ nsSeparator.setVisible(isHibernateJpaProject());
+ enableNamingStrategy.setVisible(isHibernateJpaProject());
+ super.setVisible(visible);
+ }
public void loadValues() {
IProject project = getProject();
IScopeContext scope = new ProjectScope(project);
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
//$NON-NLS-1$
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if(node!=null) {
- enableHibernate.setSelection(node.getBoolean("hibernate3.enabled", false) );
//$NON-NLS-1$
- String cfg = node.get("default.configuration", project.getName() );
//$NON-NLS-1$
+ enableHibernate.setSelection(node.getBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED,
false) );
+ String cfg = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION,
project.getName() );
ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(cfg);
if(configuration==null) {
selectedConfiguration.setText(""); //$NON-NLS-1$
} else {
selectedConfiguration.setText(cfg);
}
+ initNamingStrategy =
node.getBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED, true);
+ enableNamingStrategy.setSelection(initNamingStrategy);
}
+ }
+
+ protected boolean saveNamigStrategyChanges(){
+ if (initNamingStrategy == enableNamingStrategy.getSelection()) return true;
+ IScopeContext scope = new ProjectScope(getProject());
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
+
+ if(node!=null) {
+ node.putBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED,
enableNamingStrategy.getSelection() );
+ try {
+ node.flush();
+ final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+ @SuppressWarnings("restriction")
+ public void run(IProgressMonitor monitor)
+ throws CoreException {
+ JpaModelManager.instance().rebuildJpaProject(getProject());
+ getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ }
+ };
+
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ try {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
+ }
+ catch(CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ };
+
+ try {
+ new ProgressMonitorDialog(getShell()).run(true, false, op);
+ }
+ catch (InterruptedException e) {
+ return false;
+ }
+ catch (InvocationTargetException e) {
+ final Throwable te = e.getTargetException();
+ throw new RuntimeException(te);
+ }
+ return true;
+ } catch (BackingStoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.ProjectUtils_could_not_save_changes_to_preferences,
e);
+ return false;
+ }
+ } else {
+ return false;
+ }
}
+
public boolean performOk() {
- ProjectUtils.toggleHibernateOnProject( getProject(), enableHibernate.getSelection(),
selectedConfiguration.getText() );
+ ProjectUtils.toggleHibernateOnProject( getProject(), enableHibernate.getSelection(),
selectedConfiguration.getText());
+ saveNamigStrategyChanges();
return true;
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -67,6 +67,7 @@
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.properties.HibernatePropertiesConstants;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.hibernate.util.StringHelper;
import org.osgi.service.prefs.BackingStoreException;
@@ -83,11 +84,11 @@
public static boolean toggleHibernateOnProject(IProject project, boolean enable,String
defaultConsoleName) {
IScopeContext scope = new ProjectScope(project);
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
//$NON-NLS-1$
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if(node!=null) {
- node.putBoolean("hibernate3.enabled", enable ); //$NON-NLS-1$
- node.put("default.configuration", defaultConsoleName ); //$NON-NLS-1$
+ node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, enable );
+ node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, defaultConsoleName );
try {
node.flush();
} catch (BackingStoreException e) {
@@ -100,9 +101,9 @@
try {
if(enable) {
- return ProjectUtils.addProjectNature(project,
"org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
//$NON-NLS-1$
+ return ProjectUtils.addProjectNature(project,
HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor() );
} else {
- return ProjectUtils.removeProjectNature(project,
"org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
//$NON-NLS-1$
+ return ProjectUtils.removeProjectNature(project,
HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor() );
}
} catch(CoreException ce) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.ProjectUtils_could_not_activate_hibernate_nature_on_project
+ project.getName(), ce);
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/nature/HibernateNature.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/nature/HibernateNature.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/nature/HibernateNature.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -50,6 +50,7 @@
import org.hibernate.eclipse.builder.HibernateBuilder;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.properties.HibernatePropertiesConstants;
import org.hibernate.mapping.Table;
import org.osgi.service.prefs.Preferences;
@@ -106,10 +107,10 @@
IJavaProject prj = JavaCore.create(project);
IScopeContext scope = new ProjectScope(prj.getProject() );
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
//$NON-NLS-1$
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if(node!=null) {
- String cfg = node.get("default.configuration", prj.getProject().getName() );
//$NON-NLS-1$
+ String cfg = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION,
prj.getProject().getName() );
return cfg;
} else {
return null;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -20,6 +20,7 @@
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.properties.HibernatePropertiesConstants;
import org.osgi.service.prefs.Preferences;
/**
@@ -29,6 +30,8 @@
@SuppressWarnings("restriction")
public class HibernateJpaProject extends AbstractJpaProject {
+ private Boolean cachedNamingStrategyEnable;
+
public HibernateJpaProject(JpaProject.Config config) throws CoreException {
super(config);
@@ -50,11 +53,26 @@
public String getDefaultConsoleConfigurationName(){
IScopeContext scope = new ProjectScope(getProject());
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
//$NON-NLS-1$
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if(node!=null) {
- return node.get("default.configuration", getName() ); //$NON-NLS-1$
+ return node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, getName() );
}
return null;
}
+
+ public boolean isNamingStrategyEnabled(){
+ // as this flag cannot be changed without cleaning up and
+ // rebuilding ( == creating new instance) of jpa project we cache it
+ if (cachedNamingStrategyEnable == null){
+ IScopeContext scope = new ProjectScope(getProject());
+ Preferences node =
scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
+ if(node!=null) {
+ cachedNamingStrategyEnable =
node.getBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED, true );
+ } else {
+ cachedNamingStrategyEnable = true;
+ }
+ }
+ return cachedNamingStrategyEnable;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -10,11 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal;
+import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.jpt.core.JpaProject;
@@ -104,7 +111,8 @@
if (jpaProject instanceof HibernateJpaProject) {
String ccName =
((HibernateJpaProject)jpaProject).getDefaultConsoleConfigurationName();
if (ccfg.getName().equals(ccName)){
- jpaProject.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD,
null);
+ rebuildJpaProject(jpaProject.getJavaProject().getProject());
+ //jpaProject.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD,
null);
}
}
}
@@ -133,5 +141,27 @@
}
});
}
-
+
+ private void rebuildJpaProject(final IProject project){
+ try {
+ final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor)
+ throws CoreException {
+ JpaModelManager.instance().rebuildJpaProject(project);
+ project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ }
+ };
+
+ try {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
+ } catch(CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ } catch (InvocationTargetException e) {
+ final Throwable te = e.getTargetException();
+ throw new RuntimeException(te);
+ }
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -15,7 +15,6 @@
import org.eclipse.jpt.core.context.JoinColumn;
import org.eclipse.jpt.core.context.RelationshipMapping;
import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.db.Database;
import org.eclipse.jpt.db.Table;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -48,8 +47,10 @@
if (targetTableName == null) {
return null;
}
- NamingStrategy ns
=((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
- if (ns != null){
+
+ HibernateJpaProject hibernateJpaProject =
(HibernateJpaProject)targetEntity.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (ns != null && hibernateJpaProject.isNamingStrategyEnabled()){
try{
String name =
ns.collectionTableName(relationshipMapping.getEntity().getPersistentType().getName(),
owningTableName, targetEntity.getPersistentType().getName(), targetTableName,
relationshipMapping.getName());
@@ -78,8 +79,9 @@
if (targetTable == null) {
return null;
}
- NamingStrategy ns =
((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
- if (ns != null){
+ HibernateJpaProject hibernateJpaProject =
(HibernateJpaProject)targetEntity.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (ns != null && hibernateJpaProject.isNamingStrategyEnabled()){
try {
String name =
ns.collectionTableName(relationshipMapping.getEntity().getPersistentType().getName(),
owningTable.getName(), targetEntity.getPersistentType().getName(),
targetTable.getName(), relationshipMapping.getName());
@@ -115,8 +117,9 @@
// Column targetColumn = joinColumn.getTargetPrimaryKeyDbColumn();
String targetColumnName = joinColumn.getReferencedColumnName();
- NamingStrategy ns =
((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
- if (ns != null){
+ HibernateJpaProject hibernateJpaProject =
(HibernateJpaProject)targetEntity.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (ns != null && hibernateJpaProject.isNamingStrategyEnabled()){
String logicalTargetColumnName = null;
try {
if (targetColumnName != null || prefix != null){
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -26,7 +26,7 @@
@Override
protected String buildDefaultName() {
NamingStrategy ns = getJpaProject().getNamingStrategy();
- if (ns != null && super.buildDefaultName() != null){
+ if ( getJpaProject().isNamingStrategyEnabled() && ns != null &&
super.buildDefaultName() != null){
try {
return ns.propertyToColumnName(super.buildDefaultName());
} catch (Exception e) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -471,7 +471,7 @@
protected String getResourceDefaultName() {
NamingStrategy ns = getJpaProject().getNamingStrategy();
- if (ns != null){
+ if (getJpaProject().isNamingStrategyEnabled() && ns != null){
try {
return ns.classToTableName(javaResourcePersistentType.getQualifiedName());
} catch (Exception e) {
@@ -522,8 +522,9 @@
return null;
}
Entity parentEntity = HibernateJavaEntityImpl.this.getParentEntity();
- NamingStrategy ns = HibernateJavaEntityImpl.this.getJpaProject().getNamingStrategy();
- if (ns != null) {
+ HibernateJpaProject hibernateJpaProject =
HibernateJavaEntityImpl.this.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (hibernateJpaProject.isNamingStrategyEnabled() && ns != null) {
try {
String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
parentEntity.getPrimaryTableName());
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -42,7 +42,7 @@
@Override
public String getDefaultColumnName() {
NamingStrategy ns = getJpaProject().getNamingStrategy();
- if (ns != null) {
+ if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
try {
return ns.propertyToColumnName(getName());
} catch (Exception e) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -105,7 +105,7 @@
}
Entity parentEntity = HibernateOrmEntity.this.getParentEntity();
NamingStrategy ns = HibernateOrmEntity.this.getJpaProject().getNamingStrategy();
- if (ns != null){
+ if (getJpaProject().isNamingStrategyEnabled() && ns != null){
try {
String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
parentEntity.getPrimaryTableName());
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -41,7 +41,7 @@
@Override
public String getDefaultColumnName() {
NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
- if (namingStrategy != null && getName() != null){
+ if (getJpaProject().isNamingStrategyEnabled() && namingStrategy != null
&& getName() != null){
try {
return namingStrategy.propertyToColumnName(getName());
} catch (Exception e) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -42,7 +42,7 @@
filename.setText("schema.ddl"); //$NON-NLS-1$
filename.setDialogFieldListener(fieldlistener);
filename.doFillIntoGrid(container, numColumns);
- }
+ }
protected void dialogChanged() {
setErrorMessage(null);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -27,7 +27,7 @@
* @author Dmitry Geraskov
*
*/
-
+
@SuppressWarnings("restriction")
public class GenerateEntitiesWizardPage extends GenerateInitWizardPage {
@@ -39,18 +39,22 @@
public GenerateEntitiesWizardPage(HibernateJpaProject jpaProject) {
super(jpaProject);
}
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.hibernate.jpt.ui.wizard.GenerateInitWizardPage#createChildControls(org.eclipse.swt.widgets.Composite)
- */
+
@Override
protected void createChildControls(Composite container) {
packageName = new StringDialogField();
packageName.setDialogFieldListener(fieldlistener);
packageName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_package);
- packageName.doFillIntoGrid(container, numColumns);
+ packageName.doFillIntoGrid(container, numColumns);
}
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ if (!"".equals(getOutputDir())){//$NON-NLS-1$
+ packageName.setFocus();
+ }
+ }
protected void dialogChanged() {
setErrorMessage(null);
@@ -69,25 +73,25 @@
} else {
setWarningMessage(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
}
-
+
String msg = PathHelper.checkDirectory(getOutputDir(),
HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, false);
-
+
if (msg!=null) {
setErrorMessage( msg );
setPageComplete( false );
return;
}
-
+
super.dialogChanged();
}
-
+
private static IStatus validatePackageName(String text, JpaProject project) {
if (project == null || !project.getJavaProject().exists()) {
return JavaConventions.validatePackageName(text, JavaCore.VERSION_1_3,
JavaCore.VERSION_1_3);
}
return JavaConventionsUtil.validatePackageName(text, project.getJavaProject());
}
-
+
public String getPackageName(){
return packageName.getText();
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ContentAssistTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ContentAssistTest.java 2009-08-21
12:02:04 UTC (rev 17213)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ContentAssistTest.java 2009-08-21
12:04:33 UTC (rev 17214)
@@ -5,6 +5,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jdt.core.IJavaProject;
+import org.hibernate.eclipse.console.properties.HibernatePropertiesConstants;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -21,14 +22,14 @@
IScopeContext scope = new ProjectScope(prj.getProject() );
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
//$NON-NLS-1$
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
- node.putBoolean("hibernate3.enabled", true ); //$NON-NLS-1$
- node.put("default.configuration", "testcfg" ); //$NON-NLS-1$
//$NON-NLS-2$
+ node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, true );
+ node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, "testcfg" );
//$NON-NLS-1$
node.flush();
- ProjectUtils.addProjectNature(prj.getProject(),
"org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
//$NON-NLS-1$
- ProjectUtils.removeProjectNature(prj.getProject(),
"org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
//$NON-NLS-1$
+ ProjectUtils.addProjectNature(prj.getProject(),
HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor() );
+ ProjectUtils.removeProjectNature(prj.getProject(),
HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor() );
}
}
\ No newline at end of file