Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-10-27 15:51:23 +0000
committerpfullbright2010-10-27 15:51:23 +0000
commit9c0606d1ba86e4a5ca782b82e351074c40d9ac82 (patch)
tree92c7e116d323ea04a3826f8ffa29637d54a99044 /jpa/plugins/org.eclipse.jpt.core
parent19ecffc9efe2027ae643e9a8f89b58dd412b8167 (diff)
downloadwebtools.dali-9c0606d1ba86e4a5ca782b82e351074c40d9ac82.tar.gz
webtools.dali-9c0606d1ba86e4a5ca782b82e351074c40d9ac82.tar.xz
webtools.dali-9c0606d1ba86e4a5ca782b82e351074c40d9ac82.zip
added metadata cleanup on facet uninstall
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core')
-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
2 files changed, 38 insertions, 5 deletions
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