use action to show progress during repository update FELIX-2564


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@991128 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
index 677e019..5e241e5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
@@ -20,6 +20,8 @@
 package org.apache.felix.sigil.eclipse.ui.actions;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.felix.sigil.common.repository.IBundleRepository;
@@ -34,12 +36,27 @@
 
 public class RefreshRepositoryAction extends DisplayAction
 {
-    private final IRepositoryModel[] model;
+    private final List<IBundleRepository> repositories;
 
+    public RefreshRepositoryAction(IBundleRepository...repositories) {
+        this.repositories = Arrays.asList(repositories);
+        
+    }
     public RefreshRepositoryAction(IRepositoryModel... model)
     {
         super("Refresh repository");
-        this.model = model;
+        ArrayList<IBundleRepository> reps = new ArrayList<IBundleRepository>(model.length);
+        for (IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories())
+        {
+            for (IRepositoryModel m : model)
+            {
+                if (b.getId().equals(m.getId()))
+                {
+                    reps.add(b);
+                }
+            }
+        }
+        this.repositories = reps;
     }
 
     @Override
@@ -47,27 +64,15 @@
     {
         WorkspaceModifyOperation op = new WorkspaceModifyOperation()
         {
-
             @Override
             protected void execute(IProgressMonitor monitor) throws CoreException,
                 InvocationTargetException, InterruptedException
             {
-                boolean changed = false;
-
-                for (IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories())
-                {
-                    for (IRepositoryModel m : model)
-                    {
-                        if (b.getId().equals(m.getId()))
-                        {
-                            b.refresh();
-                            changed = true;
-                        }
+                if ( !repositories.isEmpty() ) {
+                    for (IBundleRepository rep : repositories ) {
+                        rep.refresh();                        
                     }
-                }
-
-                if (changed)
-                {
+                    
                     List<ISigilProjectModel> projects = SigilCore.getRoot().getProjects();
                     SubMonitor sub = SubMonitor.convert(monitor, projects.size() * 10);
                     for (ISigilProjectModel p : projects)
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
index 755f146..1a85949 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
@@ -34,6 +34,7 @@
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 import org.apache.felix.sigil.eclipse.model.util.ModelHelper;
 import org.apache.felix.sigil.eclipse.ui.SigilUI;
+import org.apache.felix.sigil.eclipse.ui.actions.RefreshRepositoryAction;
 import org.apache.felix.sigil.eclipse.ui.util.DefaultTreeContentProvider;
 import org.apache.felix.sigil.eclipse.ui.util.ModelLabelProvider;
 import org.eclipse.jface.action.Action;
@@ -180,8 +181,7 @@
             IBundleRepository rep = (IBundleRepository) treeViewer.getInput();
             if (rep != null)
             {
-                rep.refresh();
-                treeViewer.refresh();
+                new RefreshRepositoryAction(rep).run();
             }
         }