ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r819287 - in /ant/ivy/ivyde/trunk: CHANGES.txt org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CleanCacheAction.java
Date Sun, 27 Sep 2009 11:47:20 GMT
Author: hibou
Date: Sun Sep 27 11:47:19 2009
New Revision: 819287

URL: http://svn.apache.org/viewvc?rev=819287&view=rev
Log:
Wrap cache cleaning in a job so that it does not block the workspace (IVYDE-207) (thanks to
Jon Schneider)

Modified:
    ant/ivy/ivyde/trunk/CHANGES.txt
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CleanCacheAction.java

Modified: ant/ivy/ivyde/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/CHANGES.txt?rev=819287&r1=819286&r2=819287&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/CHANGES.txt Sun Sep 27 11:47:19 2009
@@ -11,6 +11,8 @@
 - NEW: "Reverse Dependency Explorer" View for synchronizing revisions across multiple projects
in a workspace (IVYDE-195) (thanks to Jon Schneider)
 - NEW: Make the Ivy console filter on the logging level (IVYDE-205)
 
+- IMPROVE: Wrap cache cleaning in a job so that it does not block the workspace (IVYDE-207)
(thanks to Jon Schneider)
+
 - FIX: "Ivy Settings Path" Browse button results in an incorrectly formatted URL (IVYDE-191)
(thanks to Jon Schneider)
 - FIX: Workspace Resolver Prevents Source Download (IVYDE-188) (thanks to Phillip Webb)
 - FIX: Resolve in Workspace fails to find projects under certain conditions (IVYDE-186) (thanks
to Adam Karl)

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CleanCacheAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CleanCacheAction.java?rev=819287&r1=819286&r2=819287&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CleanCacheAction.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CleanCacheAction.java
Sun Sep 27 11:47:19 2009
@@ -20,45 +20,61 @@
 import org.apache.ivy.core.cache.RepositoryCacheManager;
 import org.apache.ivy.core.cache.ResolutionCacheManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.action.Action;
 
 public class CleanCacheAction extends Action {
 
     private final Cleanable[] cleanables;
 
-    public static interface Cleanable {
-        public void clean();
-        public String getName();
+    public static abstract class Cleanable {
+        public void launchClean() {
+            Job cleanJob = new Job("Cleaning cache " + getName()) {
+                protected IStatus run(IProgressMonitor monitor) {
+                    clean();
+                    return Status.OK_STATUS;
+                }
+            };
+
+            cleanJob.setUser(true);
+            cleanJob.schedule();
+        }
+
+        protected abstract void clean();
+
+        public abstract String getName();
     }
 
-    public static class ResolutionCacheCleanable implements Cleanable {
+    public static class ResolutionCacheCleanable extends Cleanable {
         private final ResolutionCacheManager manager;
 
         public ResolutionCacheCleanable(ResolutionCacheManager manager) {
             this.manager = manager;
         }
 
-        public void clean() {
+        protected void clean() {
             manager.clean();
         }
-        
+
         public String getName() {
             return "resolution";
         }
     }
 
-    public static class RepositoryCacheCleanable implements Cleanable {
+    public static class RepositoryCacheCleanable extends Cleanable {
         private final RepositoryCacheManager manager;
 
         public RepositoryCacheCleanable(RepositoryCacheManager manager) {
             this.manager = manager;
         }
 
-        public void clean() {
+        protected void clean() {
             manager.clean();
         }
-        
+
         public String getName() {
             return manager.getName();
         }
@@ -75,7 +91,7 @@
     public void run() {
         StringBuffer builder = new StringBuffer("Ivy cache cleaned: ");
         for (int i = 0; i < cleanables.length; i++) {
-            cleanables[i].clean();
+            cleanables[i].launchClean();
             builder.append(cleanables[i].getName());
             if (i < cleanables.length - 1) {
                 builder.append(", ");



Mime
View raw message