1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.cms.ui.workbench.internal.jcr.commands;
17
18 import java.util.Iterator;
19
20 import org.argeo.cms.ui.jcr.JcrBrowserUtils;
21 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
22 import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
23 import org.argeo.eclipse.ui.TreeParent;
24 import org.eclipse.core.commands.AbstractHandler;
25 import org.eclipse.core.commands.ExecutionEvent;
26 import org.eclipse.core.commands.ExecutionException;
27 import org.eclipse.jface.viewers.ISelection;
28 import org.eclipse.jface.viewers.IStructuredSelection;
29
30
31
32
33
34
35
36
37
38 public class Refresh extends AbstractHandler {
39
40 public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".refresh";
41
42 public Object execute(ExecutionEvent event) throws ExecutionException {
43
44 JcrBrowserView view = (JcrBrowserView) WorkbenchUiPlugin.getDefault()
45 .getWorkbench().getActiveWorkbenchWindow().getActivePage()
46 .getActivePart();
47
48 ISelection selection = WorkbenchUiPlugin.getDefault().getWorkbench()
49 .getActiveWorkbenchWindow().getActivePage().getSelection();
50
51 if (selection != null && selection instanceof IStructuredSelection
52 && !selection.isEmpty()) {
53 Iterator<?> it = ((IStructuredSelection) selection).iterator();
54 while (it.hasNext()) {
55 Object obj = it.next();
56 if (obj instanceof TreeParent) {
57 TreeParent tp = (TreeParent) obj;
58 JcrBrowserUtils.forceRefreshIfNeeded(tp);
59 view.refresh(obj);
60 }
61 }
62 } else if (view instanceof JcrBrowserView)
63 ((JcrBrowserView) view).refresh(null);
64
65 return null;
66 }
67 }