1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.client.ui.commands;
17
18 import java.util.Iterator;
19
20 import org.argeo.slc.client.ui.ClientUiPlugin;
21 import org.argeo.slc.client.ui.model.ResultParent;
22 import org.argeo.slc.client.ui.views.JcrResultTreeView;
23 import org.eclipse.core.commands.AbstractHandler;
24 import org.eclipse.core.commands.ExecutionEvent;
25 import org.eclipse.core.commands.ExecutionException;
26 import org.eclipse.jface.resource.ImageDescriptor;
27 import org.eclipse.jface.viewers.IStructuredSelection;
28 import org.eclipse.ui.handlers.HandlerUtil;
29
30
31
32
33
34
35 public class RefreshJcrResultTreeView extends AbstractHandler {
36 public final static String ID = ClientUiPlugin.ID
37 + ".refreshJcrResultTreeView";
38 public final static String PARAM_REFRESH_TYPE = ClientUiPlugin.ID
39 + ".param.refreshType";
40 public final static String PARAM_REFRESH_TYPE_FULL = "fullRefresh";
41 public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
42 .getImageDescriptor("icons/refresh.png");
43 public final static String DEFAULT_LABEL = "Refresh selected";
44
45 public Object execute(final ExecutionEvent event) throws ExecutionException {
46 String refreshType = event.getParameter(PARAM_REFRESH_TYPE);
47 JcrResultTreeView view = (JcrResultTreeView) HandlerUtil
48 .getActiveWorkbenchWindow(event).getActivePage()
49 .getActivePart();
50
51
52 if (PARAM_REFRESH_TYPE_FULL.equals(refreshType))
53 view.refresh(null);
54 else {
55 IStructuredSelection selection = (IStructuredSelection) HandlerUtil
56 .getActiveWorkbenchWindow(event).getActivePage()
57 .getSelection();
58 @SuppressWarnings("rawtypes")
59 Iterator it = selection.iterator();
60 while (it.hasNext()) {
61 Object obj = it.next();
62 if (obj instanceof ResultParent) {
63 view.refresh((ResultParent) obj);
64 }
65 }
66 }
67 return null;
68 }
69 }