]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7242) Refresh button to SCL Module browser 48/548/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 24 May 2017 17:28:07 +0000 (20:28 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 24 May 2017 17:28:07 +0000 (20:28 +0300)
Change-Id: I51a7441fc6fe702b6f7fc4410b67e24e6d788ae4

bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleBrowser.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleTree.java

index 379a446f99614bc349c1564e79d2ee93af5b83d5..5e08a55a407958d12c0b1b542307074e018559c2 100644 (file)
@@ -1,5 +1,7 @@
 package org.simantics.scl.ui.modulebrowser;
 
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelection;
@@ -8,6 +10,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.part.ViewPart;
 import org.simantics.scl.osgi.SCLOsgi;
+import org.simantics.scl.ui.Activator;
 import org.simantics.scl.ui.editor2.OpenSCLModule;
 
 public class SCLModuleBrowser extends ViewPart {
@@ -29,6 +32,16 @@ public class SCLModuleBrowser extends ViewPart {
                     OpenSCLModule.openModule(entry.fullName);
             }
         });
+        
+        IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
+        toolBarManager.add(new Action("Refresh modules",
+                Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png")) {
+            @Override
+            public void run() {
+                SCLOsgi.MODULE_REPOSITORY.getSourceRepository().checkUpdates();
+                content.recalculateInput();
+            }
+        });
     }
 
     @Override
index 43e6781d406e5d2942b83e0db7f798770d4e00a3..6ce186f2f76b58cf591a9085406206dc3f2750bb 100644 (file)
@@ -55,7 +55,7 @@ public class SCLModuleTree extends TreeViewer {
         setLabelProvider(labelProvider);
         setContentProvider(contentProvider);
         setAutoExpandLevel(1);
-        setInput(repository.getSourceRepository().getModuleNames());
+        recalculateInput();
     }
 
     private static ModuleNameTreeEntry createModuleTreeEntry(Collection<String> names) {
@@ -65,4 +65,8 @@ public class SCLModuleTree extends TreeViewer {
         return root;
     }
 
+    public void recalculateInput() {
+        setInput(repository.getSourceRepository().getModuleNames());
+    }
+
 }