From: Hannu Niemistö Date: Wed, 24 May 2017 17:28:07 +0000 (+0300) Subject: (refs #7242) Refresh button to SCL Module browser X-Git-Tag: v1.29.0~23^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F548%2F1;p=simantics%2Fplatform.git (refs #7242) Refresh button to SCL Module browser Change-Id: I51a7441fc6fe702b6f7fc4410b67e24e6d788ae4 --- diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleBrowser.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleBrowser.java index 379a446f9..5e08a55a4 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleBrowser.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleBrowser.java @@ -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 diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleTree.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleTree.java index 43e6781d4..6ce186f2f 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleTree.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/modulebrowser/SCLModuleTree.java @@ -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 names) { @@ -65,4 +65,8 @@ public class SCLModuleTree extends TreeViewer { return root; } + public void recalculateInput() { + setInput(repository.getSourceRepository().getModuleNames()); + } + }