Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizard.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizardPage.java25
5 files changed, 51 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
index 5dae966ccb..7a078a8148 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
@@ -33,6 +33,7 @@ General_selectAll=Select All
GenerateEntitiesWizard_generateEntities=Generate Entities
GenerateEntitiesWizardPage_chooseEntityTable=Choose tables to generate entities from.
GenerateEntitiesWizardPage_generateEntities=Generate Entities from Tables
+GenerateEntitiesWizardPage_synchronizeClasses=Synchronize Classes in persistence.xml
GenerateEntitiesWizardPage_tables=Tables:
JpaPreferencePage_defaultJpaLib=Default JPA implementation library:
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
index 65bc70e27e..315a3314a6 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
@@ -73,6 +73,8 @@ public class JptUiMessages extends NLS
public static String GenerateEntitiesWizardPage_chooseEntityTable;
public static String GenerateEntitiesWizardPage_generateEntities;
+
+ public static String GenerateEntitiesWizardPage_synchronizeClasses;
public static String GenerateEntitiesWizardPage_tables;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java
index 5e2a9a7aae..381710e360 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java
@@ -66,6 +66,7 @@ public class GenerateEntitiesAction extends ProjectAction {
wizard.getPackageGeneratorConfig(),
wizard.getEntityGeneratorConfig(),
wizard.getSelectedTables(),
+ wizard.synchronizePersistenceXml(),
project,
new OverwriteConfirmer(this.targetPart.getSite().getShell())
);
@@ -88,6 +89,7 @@ public class GenerateEntitiesAction extends ProjectAction {
private final PackageGenerator.Config packageConfig;
private final EntityGenerator.Config entityConfig;
private final Collection selectedTables;
+ private final boolean synchronizePersistenceXml;
private final EntityGenerator.OverwriteConfirmer overwriteConfirmer;
private final IJpaProject project;
@@ -95,6 +97,7 @@ public class GenerateEntitiesAction extends ProjectAction {
PackageGenerator.Config packageConfig,
EntityGenerator.Config entityConfig,
Collection selectedTables,
+ boolean synchronizePersistenceXml,
IJpaProject project,
EntityGenerator.OverwriteConfirmer overwriteConfirmer
) {
@@ -102,6 +105,7 @@ public class GenerateEntitiesAction extends ProjectAction {
this.packageConfig = packageConfig;
this.entityConfig = entityConfig;
this.selectedTables = selectedTables;
+ this.synchronizePersistenceXml = synchronizePersistenceXml;
this.overwriteConfirmer = overwriteConfirmer;
this.project = project;
}
@@ -110,11 +114,13 @@ public class GenerateEntitiesAction extends ProjectAction {
monitor.beginTask("", 1000);
try {
PackageGenerator.generateEntities(this.packageConfig, this.entityConfig, this.selectedTables, this.overwriteConfirmer, monitor);
- // we currently only support *one* persistence.xml file per project
- IJpaFile resource = project.getPlatform().validPersistenceXmlFiles().next();
- if(resource != null){
- SynchronizeClassesJob job = new SynchronizeClassesJob(resource.getFile());
- job.schedule();
+ if (synchronizePersistenceXml) {
+ // we currently only support *one* persistence.xml file per project
+ IJpaFile resource = project.getPlatform().validPersistenceXmlFiles().next();
+ if (resource != null) {
+ SynchronizeClassesJob job = new SynchronizeClassesJob(resource.getFile());
+ job.schedule();
+ }
}
} catch (OperationCanceledException ex) {
// fall through and tell monitor we are done
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizard.java
index bb8b404b46..35e2ecb914 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizard.java
@@ -39,6 +39,8 @@ public class GenerateEntitiesWizard extends Wizard {
private EntityGenerator.Config entityGeneratorConfig;
+ private boolean synchronizePersistenceXml;
+
private Collection selectedTables;
public GenerateEntitiesWizard( IJpaProject jpaProject, IStructuredSelection selection) {
@@ -76,6 +78,8 @@ public class GenerateEntitiesWizard extends Wizard {
this.entityGeneratorConfig.setGenerateEmbeddedIdForCompoundPK( this.generateEntitiesPage.generateEmbeddedIdForCompoundPK());
this.entityGeneratorConfig.setOverrideEntityNames( this.generateEntitiesPage.getOverrideEntityNames());
+ this.synchronizePersistenceXml = this.generateEntitiesPage.synchronizePersistenceXml();
+
this.selectedTables = this.generateEntitiesPage.getSelectedTables();
return true;
}
@@ -111,6 +115,10 @@ public class GenerateEntitiesWizard extends Wizard {
return this.jpaProject.connectionProfile();
}
+ IJpaProject getJpaProject(){
+ return this.jpaProject;
+ }
+
Schema getProjectUserSchema() {
ConnectionProfile profile = this.getProjectConnectionProfile();
return profile.getDatabase().schemaNamed( profile.getUserName());
@@ -128,6 +136,10 @@ public class GenerateEntitiesWizard extends Wizard {
return this.selectedTables;
}
+ public boolean synchronizePersistenceXml(){
+ return this.synchronizePersistenceXml;
+ }
+
public boolean canFinish() {
boolean canFinish = true;
if ( ! this.generateEntitiesPage.isPageComplete()) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizardPage.java
index d8c85b7de0..297947b761 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/GenerateEntitiesWizardPage.java
@@ -69,6 +69,7 @@ class GenerateEntitiesWizardPage extends NewTypeWizardPage {
private boolean serializable = true;
private boolean generateSerialVersionUID = true;
private boolean generateEmbeddedIdForCompoundPK = true;
+ private boolean synchronizePersistenceXml = false;
private Map overrideEntityNames;
static final String[] TABLE_TABLE_COLUMN_PROPERTIES = { "table", "entityName" };
@@ -108,6 +109,18 @@ class GenerateEntitiesWizardPage extends NewTypeWizardPage {
createContainerControls(composite, nColumns);
createPackageControls(composite, nColumns);
+ final Button synchronizeClassesCheckBox = new Button(composite, SWT.CHECK);
+ synchronizeClassesCheckBox.setText(JptUiMessages.GenerateEntitiesWizardPage_synchronizeClasses);
+ synchronizeClassesCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ setSynchronizePersistenceXml(synchronizeClassesCheckBox.getSelection());
+ }
+ });
+
Group tablesGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
tablesGroup.setLayout(new GridLayout(2, false));
tablesGroup.setText(JptUiMessages.GenerateEntitiesWizardPage_tables);
@@ -126,6 +139,10 @@ class GenerateEntitiesWizardPage extends NewTypeWizardPage {
Collection possibleTables = generateEntitiesWizard.getPossibleTables();
initTablesSelectionControl(possibleTables);
+ //set initial selection state of the synchronize classes checkbox
+ synchronizeClassesCheckBox.setSelection(!generateEntitiesWizard.getJpaProject().isDiscoverAnnotatedClasses());
+ setSynchronizePersistenceXml(synchronizeClassesCheckBox.getSelection());
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(this.tableTable.getControl(), IJpaHelpContextIds.DIALOG_GENERATE_ENTITIES_TABLES);
setControl(composite);
@@ -407,6 +424,14 @@ class GenerateEntitiesWizardPage extends NewTypeWizardPage {
this.generateEmbeddedIdForCompoundPK = generateEmbeddedIdForCompoundPK;
}
+ boolean synchronizePersistenceXml() {
+ return this.synchronizePersistenceXml;
+ }
+
+ private void setSynchronizePersistenceXml(boolean synchronizePersistenceXml){
+ this.synchronizePersistenceXml = synchronizePersistenceXml;
+ }
+
/**
* key = table
* value = override entity name

Back to the top