]>
git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/argeo-commons/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/Refresh.java
1 package org
.argeo
.cms
.ui
.workbench
.internal
.jcr
.commands
;
3 import java
.util
.Iterator
;
5 import org
.argeo
.cms
.ui
.jcr
.JcrBrowserUtils
;
6 import org
.argeo
.cms
.ui
.workbench
.WorkbenchUiPlugin
;
7 import org
.argeo
.cms
.ui
.workbench
.jcr
.JcrBrowserView
;
8 import org
.argeo
.eclipse
.ui
.TreeParent
;
9 import org
.eclipse
.core
.commands
.AbstractHandler
;
10 import org
.eclipse
.core
.commands
.ExecutionEvent
;
11 import org
.eclipse
.core
.commands
.ExecutionException
;
12 import org
.eclipse
.jface
.viewers
.ISelection
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
16 * Force the selected objects of the active view to be refreshed doing the
19 * <li>The model objects are recomputed</li>
20 * <li>the view is refreshed</li>
23 public class Refresh
extends AbstractHandler
{
25 public final static String ID
= WorkbenchUiPlugin
.PLUGIN_ID
+ ".refresh";
27 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
29 JcrBrowserView view
= (JcrBrowserView
) WorkbenchUiPlugin
.getDefault()
30 .getWorkbench().getActiveWorkbenchWindow().getActivePage()
33 ISelection selection
= WorkbenchUiPlugin
.getDefault().getWorkbench()
34 .getActiveWorkbenchWindow().getActivePage().getSelection();
36 if (selection
!= null && selection
instanceof IStructuredSelection
37 && !selection
.isEmpty()) {
38 Iterator
<?
> it
= ((IStructuredSelection
) selection
).iterator();
39 while (it
.hasNext()) {
40 Object obj
= it
.next();
41 if (obj
instanceof TreeParent
) {
42 TreeParent tp
= (TreeParent
) obj
;
43 JcrBrowserUtils
.forceRefreshIfNeeded(tp
);
47 } else if (view
instanceof JcrBrowserView
)
48 ((JcrBrowserView
) view
).refresh(null); // force full refresh