Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authornhauge2007-05-08 18:04:06 +0000
committernhauge2007-05-08 18:04:06 +0000
commitcf550dd2a99223ea442f1b68d0a1246af5e517bc (patch)
tree06d74563f36843d8f30f65bd1c854773b395a19d /jpa
parent8d7e9637af1a4d5372d7f5c3d5f54292e843a7c4 (diff)
downloadwebtools.dali-cf550dd2a99223ea442f1b68d0a1246af5e517bc.tar.gz
webtools.dali-cf550dd2a99223ea442f1b68d0a1246af5e517bc.tar.xz
webtools.dali-cf550dd2a99223ea442f1b68d0a1246af5e517bc.zip
175175 - Attempt to synchronize the persistence.xml after generating entities.
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateEntitiesAction.java15
4 files changed, 33 insertions, 1 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
index 2ae1db8526..95df73fa83 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
@@ -10,7 +10,9 @@
package org.eclipse.jpt.core.internal;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+
import org.eclipse.jpt.core.internal.content.java.IJavaAttributeMapping;
import org.eclipse.jpt.core.internal.content.java.IJavaTypeMapping;
import org.eclipse.jpt.core.internal.platform.IContext;
@@ -54,6 +56,11 @@ public interface IJpaPlatform
void setProject(IJpaProject jpaProject);
/**
+ * Get the valid persistence XML files from the project
+ */
+ Iterator<IJpaFile> validPersistenceXmlFiles();
+
+ /**
* Return a collection of IJpaFileContentProviders. These will be used to
* determine which files will be read from an IProject based on contentType.
* These contentProviders should have unique contentTypes.
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java
index 4eb2388c2f..ede0e25ac1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java
@@ -11,7 +11,11 @@ package org.eclipse.jpt.core.internal.platform;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jpt.core.internal.IJpaFile;
import org.eclipse.jpt.core.internal.IJpaFileContentProvider;
import org.eclipse.jpt.core.internal.IJpaPlatform;
import org.eclipse.jpt.core.internal.IJpaProject;
@@ -100,6 +104,10 @@ public abstract class BaseJpaPlatform implements IJpaPlatform
return this.context;
}
+ public Iterator<IJpaFile> validPersistenceXmlFiles(){
+ return ((BaseJpaProjectContext)this.context).validPersistenceXmlFiles();
+ }
+
public IContext buildJavaTypeContext(IContext parentContext, IJavaTypeMapping typeMapping) {
String key = typeMapping.getKey();
if (key == IMappingKeys.ENTITY_TYPE_MAPPING_KEY) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java
index b581d430ea..65f9023326 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java
@@ -141,6 +141,10 @@ public class BaseJpaProjectContext extends BaseContext
return this.project.getPlatform();
}
+ protected Iterator<IJpaFile> validPersistenceXmlFiles(){
+ return validPersistenceXmlFiles.iterator();
+ }
+
public void refreshDefaults() {
refreshDefaults(null);
}
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 2ea9fad874..5e2a9a7aae 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
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal.actions;
import java.util.Collection;
+
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -21,7 +22,9 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jpt.core.internal.IJpaFile;
import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.synch.SynchronizeClassesJob;
import org.eclipse.jpt.gen.internal.EntityGenerator;
import org.eclipse.jpt.gen.internal.PackageGenerator;
import org.eclipse.jpt.ui.internal.JptUiMessages;
@@ -63,6 +66,7 @@ public class GenerateEntitiesAction extends ProjectAction {
wizard.getPackageGeneratorConfig(),
wizard.getEntityGeneratorConfig(),
wizard.getSelectedTables(),
+ project,
new OverwriteConfirmer(this.targetPart.getSite().getShell())
);
try {
@@ -85,11 +89,13 @@ public class GenerateEntitiesAction extends ProjectAction {
private final EntityGenerator.Config entityConfig;
private final Collection selectedTables;
private final EntityGenerator.OverwriteConfirmer overwriteConfirmer;
-
+ private final IJpaProject project;
+
GenerateEntitiesRunnable(
PackageGenerator.Config packageConfig,
EntityGenerator.Config entityConfig,
Collection selectedTables,
+ IJpaProject project,
EntityGenerator.OverwriteConfirmer overwriteConfirmer
) {
super();
@@ -97,12 +103,19 @@ public class GenerateEntitiesAction extends ProjectAction {
this.entityConfig = entityConfig;
this.selectedTables = selectedTables;
this.overwriteConfirmer = overwriteConfirmer;
+ this.project = project;
}
public void run(IProgressMonitor monitor) throws CoreException {
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();
+ }
} catch (OperationCanceledException ex) {
// fall through and tell monitor we are done
}

Back to the top