310824 - Generate Tables should offer DDL script only generation
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java
index 85db5f1..82c382e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2009 Oracle. All rights reserved.
+* Copyright (c) 2007, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -199,7 +199,7 @@
*/
protected String getConfigPropertyAsString(String propertyKey, Map<String, String> overrides, String defaultValue){
String value = this.getConfigPropertyAsString(propertyKey, overrides);
- if (value == null){
+ if(value == null) {
value = defaultValue;
}
return value;
@@ -207,10 +207,10 @@
protected String getConfigPropertyAsString(String propertyKey, Map<String, String> overrides){
String value = null;
- if (overrides != null){
+ if(overrides != null) {
value = overrides.get(propertyKey);
}
- if (value == null){
+ if(value == null) {
value = System.getProperty(propertyKey);
}
return value;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java
index 82941b0..4678657 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2008, 2010 Oracle. All rights reserved.
+* Copyright (c) 2008, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -38,7 +38,7 @@
static final String CREATE_FILE_NAME_PROPERTY = "createFileName"; //$NON-NLS-1$
// EclipseLink key string
static final String ECLIPSELINK_CREATE_FILE_NAME = "eclipselink.create-ddl-jdbc-file-name"; //$NON-NLS-1$
- static final String DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME = "createDDL.jdbc"; //$NON-NLS-1$
+ static final String DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME = "createDDL.sql"; //$NON-NLS-1$
String getDefaultDropFileName();
String getDropFileName();
@@ -46,7 +46,7 @@
static final String DROP_FILE_NAME_PROPERTY = "dropFileName"; //$NON-NLS-1$
// EclipseLink key string
static final String ECLIPSELINK_DROP_FILE_NAME = "eclipselink.drop-ddl-jdbc-file-name"; //$NON-NLS-1$
- static final String DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME = "dropDDL.jdbc"; //$NON-NLS-1$
+ static final String DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME = "dropDDL.sql"; //$NON-NLS-1$
String getDefaultApplicationLocation();
String getApplicationLocation();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
index 0651a84..7ba94b5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
@@ -18,6 +18,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
@@ -36,6 +37,7 @@
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator;
+import org.eclipse.jpt.common.utility.internal.ReflectionTools;
import org.eclipse.jpt.jpa.core.JpaPlatform;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.internal.JptCoreMessages;
@@ -64,15 +66,17 @@
public static final String FALSE = "false"; //$NON-NLS-1$
public static final String NONE = "NONE"; //$NON-NLS-1$
- private String puName;
- private JpaProject jpaProject;
+ private final String puName;
+ private final JpaProject jpaProject;
+ private final OutputMode outputMode;
// ********** constructors **********
- protected AbstractEclipseLinkDDLGenerator(String puName, JpaProject jpaProject) {
+ protected AbstractEclipseLinkDDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) {
super(JavaCore.create(jpaProject.getProject()));
this.puName = puName;
this.jpaProject = jpaProject;
+ this.outputMode = outputMode;
}
// ********** overrides **********
@@ -209,6 +213,19 @@
protected void putProperty(Properties properties, String key, String value) {
properties.put(key, (value == null) ? "" : value); //$NON-NLS-1$
}
+
+ /**
+ * Returns the Property string value of the given property value.
+ */
+ protected String getPropertyStringValueOf(Object value) {
+ if (value == null) {
+ return null;
+ }
+ if (value.getClass().isEnum()) {
+ return (String) ReflectionTools.getStaticFieldValue(value.getClass(), value.toString().toUpperCase(Locale.ENGLISH));
+ }
+ return value.toString();
+ }
protected void buildAllProperties(Properties properties) {
this.buildConnectionProperties(properties);
@@ -229,11 +246,19 @@
private void buildDDLModeProperties(Properties properties) {
this.putProperty(properties,
+ SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE,
+ this.getPropertyStringValueOf(this.outputMode));
+
+ this.putProperty(properties,
SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
DdlGenerationType.DROP_AND_CREATE_TABLES);
+
this.putProperty(properties,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE,
- OutputMode.DATABASE);
+ SchemaGeneration.ECLIPSELINK_CREATE_FILE_NAME,
+ SchemaGeneration.DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME);
+ this.putProperty(properties,
+ SchemaGeneration.ECLIPSELINK_DROP_FILE_NAME,
+ SchemaGeneration.DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME);
}
private void buildConnectionPoolingProperties(Properties properties) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
index b95c7ff..f3b7f85 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2008, 2010 Oracle. All rights reserved.
+* Copyright (c) 2008, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -14,6 +14,7 @@
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.db.ConnectionProfile;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.connection.Connection;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
/**
* EclipseLinkDLLGenerator launches the EclipseLink DDL generator in a separate VM.
@@ -30,15 +31,15 @@
// ********** constructors **********
- public static void generate(String puName, JpaProject project, IProgressMonitor monitor) {
+ public static void generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) {
if (puName == null || puName.length() == 0 || project == null) {
throw new NullPointerException();
}
- new EclipseLinkDDLGenerator(puName, project).generate(monitor);
+ new EclipseLinkDDLGenerator(puName, project, outputMode).generate(monitor);
}
- private EclipseLinkDDLGenerator(String puName, JpaProject jpaProject) {
- super(puName, jpaProject);
+ private EclipseLinkDDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) {
+ super(puName, jpaProject, outputMode);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java
index 819eaca..2c81f1f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009, 2010 Oracle. All rights reserved.
+* Copyright (c) 2009, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -15,6 +15,7 @@
import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0;
import org.eclipse.jpt.jpa.db.ConnectionProfile;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Customization;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.AbstractEclipseLinkDDLGenerator;
/**
@@ -33,15 +34,15 @@
// ********** constructors **********
- public static void generate(String puName, JpaProject project, IProgressMonitor monitor) {
+ public static void generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) {
if (puName == null || puName.length() == 0 || project == null) {
throw new NullPointerException();
}
- new EclipseLink2_0DDLGenerator(puName, project).generate(monitor);
+ new EclipseLink2_0DDLGenerator(puName, project, outputMode).generate(monitor);
}
- private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject) {
- super(puName, jpaProject);
+ private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) {
+ super(puName, jpaProject, outputMode);
}
// ********** EclipseLink properties **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties
index daa67bc..d790343 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties
@@ -363,3 +363,8 @@
EclipseLinkDDLGeneratorUi_error = Error
ECLIPSELINK_GENERATE_TABLES_JOB = Generating Tables from Entities
ECLIPSELINK_GENERATE_TABLES_TASK = Generating
+
+GenerationOutputModeWizardPage_title = Schema Generation
+GenerationOutputModeWizardPage_desc = Select DDL generation action
+GenerationOutputModeWizardPage_generationOutputMode = Generation Output Mode
+
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java
index ebe1494..97df0fa 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java
@@ -367,6 +367,11 @@
public static String EclipseLinkDDLGeneratorUi_error;
public static String ECLIPSELINK_GENERATE_TABLES_JOB;
public static String ECLIPSELINK_GENERATE_TABLES_TASK;
+
+ public static String GenerationOutputModeWizardPage_title;
+ public static String GenerationOutputModeWizardPage_desc;
+ public static String GenerationOutputModeWizardPage_generationOutputMode;
+
private static final String BUNDLE_NAME = "eclipselink_ui"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = EclipseLinkUiMessages.class;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
index e26ed46..569513a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2010 Oracle. All rights reserved.
+* Copyright (c) 2007, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen;
import java.util.Iterator;
+
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -26,6 +27,7 @@
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.EclipseLinkDDLGenerator;
import org.eclipse.jpt.jpa.eclipselink.ui.JptJpaEclipseLinkUiPlugin;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
@@ -59,28 +61,30 @@
// ********** behavior **********
protected void generate() {
-
+
PersistenceUnit persistenceUnit = this.getPersistenceUnits().next(); // Take the first persistenceUnit
String puName = persistenceUnit.getName();
- if( ! this.displayGeneratingDDLWarning()) {
- return;
- }
-
+
GenerateDDLWizard wizard = new GenerateDDLWizard(this.project);
- WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard);
- dialog.create();
+ WizardDialog wizardDialog = new WizardDialog(this.getCurrentShell(), wizard);
+ wizardDialog.create();
if(wizard.getPageCount() > 0) {
- int returnCode = dialog.open();
+ int returnCode = wizardDialog.open();
if (returnCode == Window.CANCEL) {
return;
}
}
- WorkspaceJob job = this.buildGenerateDDLJob(puName, this.project);
+ OutputMode outputMode = wizard.getOutputMode();
+
+ if( ! this.displayGeneratingDDLWarning()) {
+ return;
+ }
+ WorkspaceJob job = this.buildGenerateDDLJob(puName, this.project, outputMode);
job.schedule();
}
- protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project) {
- return new GenerateDDLJob(puName, project);
+ protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) {
+ return new GenerateDDLJob(puName, project, outputMode);
}
private Shell getCurrentShell() {
@@ -117,18 +121,20 @@
protected static class GenerateDDLJob extends WorkspaceJob {
private final String puName;
private final JpaProject project;
+ private final OutputMode outputMode;
- public GenerateDDLJob(String puName, JpaProject project) {
+ public GenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) {
super(EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_JOB);
this.puName = puName;
this.project = project;
+ this.outputMode = outputMode;
}
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
SubMonitor sm = SubMonitor.convert(monitor, EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_TASK, 1);
try {
- this.ddlGeneratorGenerate(this.puName, this.project, sm.newChild(1));
+ this.ddlGeneratorGenerate(this.puName, this.project, this.outputMode, sm.newChild(1));
}
catch (OperationCanceledException e) {
return Status.CANCEL_STATUS;
@@ -139,8 +145,8 @@
return Status.OK_STATUS;
}
- protected void ddlGeneratorGenerate(String puName, JpaProject project, IProgressMonitor monitor) {
- EclipseLinkDDLGenerator.generate(puName, project, monitor);
+ protected void ddlGeneratorGenerate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) {
+ EclipseLinkDDLGenerator.generate(puName, project, outputMode, monitor);
}
protected void logException(RuntimeException re) {
@@ -162,7 +168,7 @@
});
}
- private Shell getShell() {
+ protected Shell getShell() {
Display display = Display.getCurrent();
Shell shell = (display == null) ? null : display.getActiveShell();
if (shell == null && display != null) {
@@ -173,4 +179,5 @@
return shell;
}
}
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java
index 27ef9d2..d52766b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2009 Oracle. All rights reserved.
+* Copyright (c) 2007, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -12,6 +12,7 @@
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.db.ConnectionProfile;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
import org.eclipse.jpt.jpa.ui.internal.wizards.DatabaseSchemaWizardPage;
@@ -23,34 +24,56 @@
private JpaProject jpaProject;
private DatabaseSchemaWizardPage dbSettingsPage;
+ private GenerationOutputModeWizardPage generationOutputModePage;
+
+ // ********** constructor **********
public GenerateDDLWizard(JpaProject jpaProject) {
super();
this.jpaProject = jpaProject;
this.setWindowTitle(JptUiMessages.GenerateDDLWizard_title);
}
-
+
+ // ********** IWizard implementation **********
+
@Override
public void addPages() {
super.addPages();
- if (this.getJpaProjectConnectionProfile() == null) {
+ if(this.getJpaProjectConnectionProfile() == null) {
this.dbSettingsPage = new DatabaseSchemaWizardPage(this.jpaProject);
this.addPage(this.dbSettingsPage);
}
+ this.generationOutputModePage = new GenerationOutputModeWizardPage();
+ this.addPage(this.generationOutputModePage);
}
@Override
public boolean performFinish() {
return (this.getJpaProjectConnectionProfile() != null);
}
-
+
@Override
public boolean canFinish() {
- return this.dbSettingsPage.isPageComplete();
+ return this.dbSettingsPageCanFinish() && this.generationOutputModePageCanFinish();
}
+ // ********** intra-wizard methods **********
+
+ public OutputMode getOutputMode() {
+ return this.generationOutputModePage.getOutputMode();
+ }
+
+ // ********** internal methods **********
+
+ private boolean dbSettingsPageCanFinish() {
+ return (this.dbSettingsPage != null) ? this.dbSettingsPage.isPageComplete() : true;
+ }
+
+ private boolean generationOutputModePageCanFinish() {
+ return this.generationOutputModePage.isPageComplete();
+ }
+
private ConnectionProfile getJpaProjectConnectionProfile() {
return this.jpaProject.getConnectionProfile();
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerationOutputModeWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerationOutputModeWizardPage.java
new file mode 100644
index 0000000..692e54c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerationOutputModeWizardPage.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+* Copyright (c) 2011 Oracle. All rights reserved.
+* This program and the accompanying materials are 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.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * GenerationOutputModeWizardPage
+ */
+public class GenerationOutputModeWizardPage extends WizardPage {
+
+ GenerationOutputModeGroup outputModeGroup;
+
+ public GenerationOutputModeWizardPage() {
+ super("Database Schema"); //$NON-NLS-1$
+ this.setTitle(EclipseLinkUiMessages.GenerationOutputModeWizardPage_title);
+ this.setMessage(EclipseLinkUiMessages.GenerationOutputModeWizardPage_desc);
+ }
+
+ public void createControl(Composite parent) {
+ this.setPageComplete(true);
+ this.setControl(this.buildTopLevelControl(parent));
+ }
+
+ private Control buildTopLevelControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ this.outputModeGroup = new GenerationOutputModeGroup(composite);
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+
+ // ********** intra-wizard methods **********
+
+ public OutputMode getOutputMode() {
+ return this.outputModeGroup.getOutputMode();
+ }
+
+
+ // ********** Generation OutputMode Group **********
+
+ class GenerationOutputModeGroup {
+ private OutputMode outputMode;
+
+ private final Button databaseButton;
+ private final Button sqlScriptButton;
+ private final Button bothButton;
+
+ // ********** constructor **********
+
+ private GenerationOutputModeGroup(Composite parent) {
+ super();
+ Group outputModeGroup = new Group(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ outputModeGroup.setLayout(layout);
+ outputModeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ outputModeGroup.setText(EclipseLinkUiMessages.GenerationOutputModeWizardPage_generationOutputMode);
+ // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp(this.group, JpaHelpContextIds.XXX);
+
+ SelectionListener outputModeButtonListener = this.buildOutputModeRadioButtonListener();
+
+ this.databaseButton = this.buildRadioButton(outputModeGroup,
+ EclipseLinkUiMessages.OutputModeComposite_database, outputModeButtonListener, 3);
+
+ this.sqlScriptButton = this.buildRadioButton(outputModeGroup,
+ EclipseLinkUiMessages.OutputModeComposite_sql_script, outputModeButtonListener, 3);
+
+ this.bothButton = this.buildRadioButton(outputModeGroup,
+ EclipseLinkUiMessages.OutputModeComposite_both, outputModeButtonListener, 3);
+
+ this.databaseButton.setSelection(true);
+ this.outputModeButtonChanged();
+ }
+
+ // ********** listeners **********
+
+ private SelectionListener buildOutputModeRadioButtonListener() {
+ return new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent event) {
+ this.widgetSelected(event);
+ }
+ public void widgetSelected(SelectionEvent event) {
+ outputModeButtonChanged();
+ }
+ };
+ }
+
+ // ********** internal methods **********
+
+ private void outputModeButtonChanged() {
+
+ if(this.databaseButton.getSelection()) {
+ this.outputMode = OutputMode.database;
+ }
+ else if(this.sqlScriptButton.getSelection()) {
+ this.outputMode = OutputMode.sql_script;
+ }
+ else if(this.bothButton.getSelection()) {
+ this.outputMode = OutputMode.both;
+ }
+ }
+
+ private Button buildRadioButton(Composite parent, String text, SelectionListener listener, int horizontalSpan) {
+ Button radioButton = new Button(parent, SWT.RADIO);
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = horizontalSpan;
+ radioButton.setLayoutData(gridData);
+ radioButton.setText(text);
+ radioButton.addSelectionListener(listener);
+ return radioButton;
+ }
+
+ private OutputMode getOutputMode() {
+ return this.outputMode;
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java
index da35e76..ad35a16 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009, 2010 Oracle. All rights reserved.
+* Copyright (c) 2009, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.ddlgen.EclipseLink2_0DDLGenerator;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.EclipseLinkDDLGeneratorUi;
@@ -36,21 +37,21 @@
// ********** behavior **********
@Override
- protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project) {
- return new Generate2_0DDLJob(puName, project);
+ protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) {
+ return new Generate2_0DDLJob(puName, project, outputMode);
}
// ********** runnable **********
protected static class Generate2_0DDLJob extends EclipseLinkDDLGeneratorUi.GenerateDDLJob {
- public Generate2_0DDLJob(String puName, JpaProject project) {
- super(puName, project);
+ public Generate2_0DDLJob(String puName, JpaProject project, OutputMode outputMode) {
+ super(puName, project, outputMode);
}
@Override
- protected void ddlGeneratorGenerate(String puName, JpaProject project, IProgressMonitor monitor) {
- EclipseLink2_0DDLGenerator.generate(puName, project, monitor);
+ protected void ddlGeneratorGenerate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) {
+ EclipseLink2_0DDLGenerator.generate(puName, project, outputMode, monitor);
}
}
}