Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-10-27 11:51:23 -0400
committerpfullbright2010-10-27 11:51:23 -0400
commit9c0606d1ba86e4a5ca782b82e351074c40d9ac82 (patch)
tree92c7e116d323ea04a3826f8ffa29637d54a99044
parent19ecffc9efe2027ae643e9a8f89b58dd412b8167 (diff)
downloadwebtools.dali-9c0606d1ba86e4a5ca782b82e351074c40d9ac82.tar.gz
webtools.dali-9c0606d1ba86e4a5ca782b82e351074c40d9ac82.tar.xz
webtools.dali-9c0606d1ba86e4a5ca782b82e351074c40d9ac82.zip
added metadata cleanup on facet uninstall
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetUninstallDelegate.java8
4 files changed, 46 insertions, 12 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
index e5c53f2530..c00001e5e0 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
@@ -88,6 +88,10 @@ public class JptJaxbCorePlugin
return INSTANCE.getProjectManager_();
}
+ public static JaxbPlatformManager getJaxbPlatformManager() {
+ return JaxbPlatformManagerImpl.instance();
+ }
+
/**
* Set the {@link JaxbPlatformDescription} associated with the specified Eclipse project.
@@ -167,8 +171,8 @@ public class JptJaxbCorePlugin
return null;
}
- public static JaxbPlatformManager getJaxbPlatformManager() {
- return JaxbPlatformManagerImpl.instance();
+ public static void clearProjectPreferences(IProject project) {
+ JptCorePlugin.clearProjectPreferences(project, JAXB_PLATFORM_PREF_KEY);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java
index 1c24b1dfd8..86229d8d5e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.jaxb.core.internal.facet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -22,10 +23,6 @@ public class JaxbFacetUninstallDelegate
public void execute(IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
- // There is nothing to do here. Everything is taken care of by the
- // JaxbModelManager *whenever* the facet is removed (even via meta-file
- // editing and CVS updating), but this delegate needs to be here because
- // it is required by the facet extension point action element, and that
- // is required by the facet UI to allow uninstallation of this facet.
+ JptJaxbCorePlugin.clearProjectPreferences(project);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
index 3db6ddb406..9b529da384 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
@@ -425,6 +425,26 @@ public class JptCorePlugin extends Plugin {
}
/**
+ * Clears the project of JPA-specific preferences
+ */
+ public static void clearProjectPreferences(IProject project) {
+ clearProjectPreferences(
+ project,
+ JPA_PLATFORM_PREF_KEY, DISCOVER_ANNOTATED_CLASSES, METAMODEL_SOURCE_FOLDER_NAME);
+ }
+
+ /**
+ * Clears the specified preferences
+ */
+ public static void clearProjectPreferences(IProject project, String ... preferenceKeys) {
+ IEclipsePreferences prefs = getProjectPreferences(project);
+ for (String preferenceKey : preferenceKeys) {
+ prefs.remove(preferenceKey);
+ }
+ flush(prefs);
+ }
+
+ /**
* Return the Dali preferences for the specified context.
*/
private static IEclipsePreferences getPreferences(IScopeContext context) {
@@ -580,6 +600,7 @@ public class JptCorePlugin extends Plugin {
* Flush preferences in an asynchronous Job because the flush request will
* trigger a lock on the project, which can cause us some deadlocks (e.g.
* when deleting the metamodel source folder).
+ * Note: the flush will also remove the prefs node if it is empty
*/
private static void flush(IEclipsePreferences prefs) {
if (flushPreferences) {
@@ -681,6 +702,20 @@ public class JptCorePlugin extends Plugin {
log(ex);
}
}
+
+ /**
+ * Clear the JPA-specific project properties
+ */
+ public static void clearProjectPersistentProperties(IProject project) {
+ try {
+ project.setPersistentProperty(DATA_SOURCE_CONNECTION_PROFILE_NAME, null);
+ project.setPersistentProperty(USER_OVERRIDE_DEFAULT_CATALOG, null);
+ project.setPersistentProperty(USER_OVERRIDE_DEFAULT_SCHEMA, null);
+ }
+ catch (CoreException ce) {
+ log(ce);
+ }
+ }
public static boolean nodeIsJpa2_0Compatible(JpaNode jpaNode) {
return jpaNode.getJpaProject().getJpaPlatform().getJpaVersion().isCompatibleWithJpaVersion(JpaFacet.VERSION_2_0.getVersionString());
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetUninstallDelegate.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetUninstallDelegate.java
index f4c83701af..83697cf9df 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetUninstallDelegate.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetUninstallDelegate.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.core.internal.facet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -21,10 +22,7 @@ public class JpaFacetUninstallDelegate
public void execute(IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
- // There is nothing to do here. Everything is taken care of by the
- // JpaModelManager *whenever* the facet is removed (even via meta-file
- // editing and CVS updating), but this delegate needs to be here because
- // it is required by the facet extension point action element, and that
- // is required by the facet UI to allow uninstallation of this facet.
+ JptCorePlugin.clearProjectPreferences(project);
+ JptCorePlugin.clearProjectPersistentProperties(project);
}
}

Back to the top