Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/plugin.xml11
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java45
2 files changed, 55 insertions, 1 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
index a0f658f8ab..26ccdd0e83 100644
--- a/jpa/plugins/org.eclipse.jpt.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
@@ -443,6 +443,16 @@
<extension
+ point="org.eclipse.wst.common.project.facet.core.listeners">
+
+ <listener
+ class="org.eclipse.jpt.core.internal.facet.RuntimeChangedListener"
+ eventTypes="TARGETED_RUNTIMES_CHANGED"/>
+
+ </extension>
+
+
+ <extension
point="org.eclipse.wst.common.project.facet.core.presets">
<static-preset id="jpt.jpa.1_0.preset">
@@ -471,7 +481,6 @@
</supported>
</extension>
-
<extension
point="org.eclipse.wst.validation.validatorV2"
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java
new file mode 100644
index 0000000000..4aed10fdeb
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java
@@ -0,0 +1,45 @@
+package org.eclipse.jpt.core.internal.facet;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+
+public class RuntimeChangedListener
+ implements IFacetedProjectListener {
+
+ public void handleEvent(IFacetedProjectEvent facetedProjectEvent) {
+
+ IFacetedProjectBase fpb = facetedProjectEvent.getWorkingCopy();
+ if (fpb == null) {
+ fpb = facetedProjectEvent.getProject();
+ }
+ IProjectFacetVersion pfv =
+ fpb.getProjectFacetVersion(ProjectFacetsManager.getProjectFacet(JptCorePlugin.FACET_ID));
+ if (pfv != null) {
+ Map<String, Object> enablementVariables = new HashMap<String, Object>();
+ enablementVariables.put(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, getJpaPlatformId(fpb.getProject()));
+ LibraryInstallDelegate lp = new LibraryInstallDelegate(fpb, pfv, enablementVariables);
+ try {
+ lp.execute(new NullProgressMonitor());
+ }
+ catch (CoreException ce) {
+ JptCorePlugin.log(ce);
+ }
+ }
+ }
+
+ protected String getJpaPlatformId(IProject project) {
+ JpaProject jpaProject = JptCorePlugin.getJpaProject(project);
+ return (jpaProject == null) ? null : jpaProject.getJpaPlatform().getId();
+ }
+}

Back to the top