Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSnjezana Peco2018-09-05 13:34:46 -0400
committerSnjezana Peco2018-09-05 13:35:14 -0400
commitc32dfdd1f8645b94065e0a12229eeac1bb2e6289 (patch)
tree92e8c7669a1a7d75aed11e28b7649bb3a79c9e5f
parent70f5a54a8d9587484c90d8284e1f8af1dd616eb7 (diff)
downloadm2e-core-c32dfdd1f8645b94065e0a12229eeac1bb2e6289.tar.gz
m2e-core-c32dfdd1f8645b94065e0a12229eeac1bb2e6289.tar.xz
m2e-core-c32dfdd1f8645b94065e0a12229eeac1bb2e6289.zip
Bug 538609: Call writeWorkspaceState in a save participant instead of in MavenPluginActivator.stop()
Change-Id: I2155c321a14e826003b6e68ac06177d5d5820ffe Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
index 4556c8e9..67eb4d8a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
@@ -27,8 +27,11 @@ import com.google.inject.Module;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.ISaveContext;
+import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
@@ -139,6 +142,28 @@ public class MavenPluginActivator extends Plugin {
}
};
+ private ISaveParticipant saveParticipant = new ISaveParticipant() {
+
+ @Override
+ public void saving(ISaveContext context) throws CoreException {
+ if(managerImpl != null) {
+ managerImpl.writeWorkspaceState();
+ }
+ }
+
+ @Override
+ public void rollback(ISaveContext context) {
+ }
+
+ @Override
+ public void prepareToSave(ISaveContext context) throws CoreException {
+ }
+
+ @Override
+ public void doneSaving(ISaveContext context) {
+ }
+ };
+
private MavenImpl maven;
private IProjectConversionManager projectConversionManager;
@@ -258,6 +283,7 @@ public class MavenPluginActivator extends Plugin {
this.projectConversionManager = new ProjectConversionManager();
this.workspaceClassifierResolverManager = new WorkspaceClassifierResolverManager();
+ ResourcesPlugin.getWorkspace().addSaveParticipant(IMavenConstants.PLUGIN_ID, saveParticipant);
}
private DefaultPlexusContainer newPlexusContainer(ClassLoader cl) throws PlexusContainerException {
@@ -299,7 +325,6 @@ public class MavenPluginActivator extends Plugin {
public void stop(BundleContext context) throws Exception {
super.stop(context);
- this.managerImpl.writeWorkspaceState();
context.removeBundleListener(bundleListener);
this.mavenBackgroundJob.cancel();
@@ -309,6 +334,7 @@ public class MavenPluginActivator extends Plugin {
// ignored
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.removeSaveParticipant(IMavenConstants.PLUGIN_ID);
workspace.removeResourceChangeListener(this.mavenBackgroundJob);
this.mavenBackgroundJob = null;

Back to the top