Author: max.andersen(a)jboss.com
Date: 2008-11-24 13:31:34 -0500 (Mon, 24 Nov 2008)
New Revision: 11993
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/launch/CodeGenerationLaunchDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java
Log:
JBIDE-3270 one-to-one in ui.
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 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -394,6 +394,7 @@
public static String CodeGenerationSettingsTab_console_configuration;
public static String CodeGenerationSettingsTab_create_new;
public static String CodeGenerationSettingsTab_detect_many_to_many_tables;
+ public static String CodeGenerationSettingsTab_detect_one_to_one_associations;
public static String CodeGenerationSettingsTab_detect_optimistic_lock_columns;
public static String CodeGenerationSettingsTab_do_you_want_create_reveng_xml;
public static String CodeGenerationSettingsTab_does_not_exist;
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 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2008-11-24
18:31:34 UTC (rev 11993)
@@ -386,6 +386,7 @@
CodeGenerationSettingsTab_console_configuration=Console &configuration:
CodeGenerationSettingsTab_create_new=Create &new...
CodeGenerationSettingsTab_detect_many_to_many_tables=Detect many-to-many tables
+CodeGenerationSettingsTab_detect_one_to_one_associations=Detect one-to-one associations
CodeGenerationSettingsTab_detect_optimistic_lock_columns=Detect optimistic lock columns
CodeGenerationSettingsTab_do_you_want_create_reveng_xml=Do you want to create a new
reveng.xml or use an existing file ?
CodeGenerationSettingsTab_does_not_exist=\ does not exist
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -307,6 +307,7 @@
ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings(res)
.setDefaultPackageName(attributes.getPackageName())
.setDetectManyToMany( attributes.detectManyToMany() )
+ .setDetectOneToOne( attributes.detectOneToOne() )
.setDetectOptimisticLock( attributes.detectOptimisticLock() );
res.setSettings(qqsettings);
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -27,7 +27,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -84,6 +83,7 @@
private SelectionButtonDialogField preferRawCompositeIds;
private SelectionButtonDialogField autoVersioning;
private SelectionButtonDialogField autoManyToMany;
+ private SelectionButtonDialogField autoOneToOne;
private SelectionButtonDialogField useOwnTemplates;
private DirectoryBrowseField templatedir;
@@ -223,13 +223,19 @@
autoManyToMany.setSelection(true);
autoManyToMany.setDialogFieldListener(fieldlistener);
+ autoOneToOne = new SelectionButtonDialogField(SWT.CHECK);
+
autoOneToOne.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_detect_one_to_one_associations);
+ autoOneToOne.setSelection(true);
+ autoOneToOne.setDialogFieldListener(fieldlistener);
+
+
autoVersioning = new SelectionButtonDialogField(SWT.CHECK);
autoVersioning.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_detect_optimistic_lock_columns);
autoVersioning.setSelection(true);
autoVersioning.setDialogFieldListener(fieldlistener);
useOwnTemplates.attachDialogField(templatedir);
- reverseengineer.attachDialogFields(new DialogField[] { packageName,
preferRawCompositeIds, reverseEngineeringSettings, reverseEngineeringStrategy,
autoManyToMany, autoVersioning });
+ reverseengineer.attachDialogFields(new DialogField[] { packageName,
preferRawCompositeIds, reverseEngineeringSettings, reverseEngineeringStrategy,
autoManyToMany, autoOneToOne, autoVersioning });
consoleConfigurationName.doFillIntoGrid(container, 4);
Control[] controls = outputdir.doFillIntoGrid(container, 4);
@@ -246,6 +252,8 @@
autoVersioning.doFillIntoGrid(container, 3);
fillLabel(container);
autoManyToMany.doFillIntoGrid(container, 3);
+ fillLabel(container);
+ autoOneToOne.doFillIntoGrid(container, 3);
useOwnTemplates.doFillIntoGrid(container, 4);
controls = templatedir.doFillIntoGrid(container, 4);
// Hack to tell the text field to stretch!
@@ -409,6 +417,7 @@
preferRawCompositeIds.setSelection(attributes.isPreferBasicCompositeIds());
autoManyToMany.setSelection( attributes.detectManyToMany() );
autoVersioning.setSelection( attributes.detectOptimisticLock() );
+ autoOneToOne.setSelection( attributes.detectOneToOne());
outputdir.setText(safeText(attributes.getOutputPath()));
reverseengineer.setSelection(attributes.isReverseEngineer());
reverseEngineeringSettings.setText(safeText(attributes.getRevengSettings()));
@@ -437,6 +446,7 @@
configuration.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR,
strOrNull(outputdir.getText()));
configuration.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS,
preferRawCompositeIds.isSelected());
configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY,
autoManyToMany.isSelected());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE,
autoOneToOne.isSelected());
configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING,
autoVersioning.isSelected());
configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER,
isReverseEngineerEnabled());
configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY,
strOrNull(reverseEngineeringStrategy.getText()));
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -73,8 +73,9 @@
private String outputPath;
private String templatePath;
private List exporterFactories;
- // if set then build reveng strategy relying on the list of tables
+
private boolean autoManyToManyDetection;
+ private boolean autoOneToOneDetection;
private boolean autoVersioning;
public ExporterAttributes () { }
@@ -101,6 +102,7 @@
templatePath =
configuration.getAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR,"");
//$NON-NLS-1$
preferBasicCompositeIds =
configuration.getAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS,
true);
autoManyToManyDetection = configuration.getAttribute(
HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
+ autoOneToOneDetection = configuration.getAttribute(
HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE, true);
autoVersioning = configuration.getAttribute(
HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
@@ -353,4 +355,8 @@
return autoVersioning;
}
+ public boolean detectOneToOne() {
+ return autoOneToOneDetection;
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -61,6 +61,7 @@
public static final String ATTR_PREFER_BASIC_COMPOSITE_IDS = ATTR_PREFIX +
"prefercompositeids"; //$NON-NLS-1$
public static final String ATTR_AUTOMATIC_MANY_TO_MANY = ATTR_PREFIX +
"reveng.detect_many_to_many"; //$NON-NLS-1$
public static final String ATTR_AUTOMATIC_VERSIONING = ATTR_PREFIX +
"reveng.detect_optimistc_lock"; //$NON-NLS-1$
+ public static final String ATTR_AUTOMATIC_ONE_TO_ONE = ATTR_PREFIX +
"reveng.detect_one_to_one"; //$NON-NLS-1$
public static final String ATTR_REVENG_TABLES = ATTR_PREFIX +
"reveng.tables";//$NON-NLS-1$
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -87,7 +87,12 @@
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
params.get(IParameter.SEAM_PROJECT_NAME));
+
try {
+
+ ISeamProject seamProject = (ISeamProject)project.getNature(ISeamProject.NATURE_ID);
+ boolean seam2 = seamProject.getRuntime().getVersion().compareTo(SeamVersion.SEAM_2_0)
>= 0;
+
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType("org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType");
//$NON-NLS-1$
@@ -115,6 +120,10 @@
wc.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
+
+ boolean seam21 =
seamProject.getRuntime().getVersion().compareTo(SeamVersion.SEAM_2_1) >= 0;
+ // Only Seam 2.1 does not break when generating from one-to-one
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE, seam21);
}
SeamRuntime seamRt = getRuntime(project);
@@ -250,9 +259,6 @@
final String actionpackage =
seamFacetPrefs.get(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME,
"");
final String actionDir = actionpackage.replace('.','/');
- ISeamProject sprj = (ISeamProject)project.getNature(ISeamProject.NATURE_ID);
- boolean seam2 = sprj.getRuntime().getVersion().equals(SeamVersion.SEAM_2_0);
-
hbmtemplateAttributes = new HashMap<String, String>();
if(seam2) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java 2008-11-24
18:28:48 UTC (rev 11992)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java 2008-11-24
18:31:34 UTC (rev 11993)
@@ -131,7 +131,9 @@
IResource resource = (IResource) adaptable
.getAdapter(IResource.class);
- return resource.getProject();
+ if(resource!=null) {
+ project = resource.getProject();
+ }
}
}