]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java
Remove unused.
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui / src / org / argeo / slc / client / ui / commands / RefreshJcrResultTreeView.java
1 package org.argeo.slc.client.ui.commands;
2
3 import java.util.Iterator;
4
5 import org.argeo.slc.client.ui.ClientUiPlugin;
6 import org.argeo.slc.client.ui.model.ResultParent;
7 import org.argeo.slc.client.ui.views.JcrResultTreeView;
8 import org.eclipse.core.commands.AbstractHandler;
9 import org.eclipse.core.commands.ExecutionEvent;
10 import org.eclipse.core.commands.ExecutionException;
11 import org.eclipse.jface.resource.ImageDescriptor;
12 import org.eclipse.jface.viewers.IStructuredSelection;
13 import org.eclipse.ui.handlers.HandlerUtil;
14
15 /**
16 * Force refresh the ResultTreeView. This command is only intended to be called
17 * by either the toolbar menu of the view or by the popup menu. Refresh due to
18 * data changes must be triggered by Observers
19 */
20 public class RefreshJcrResultTreeView extends AbstractHandler {
21 public final static String ID = ClientUiPlugin.ID
22 + ".refreshJcrResultTreeView";
23 public final static String PARAM_REFRESH_TYPE = ClientUiPlugin.ID
24 + ".param.refreshType";
25 public final static String PARAM_REFRESH_TYPE_FULL = "fullRefresh";
26 public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
27 .getImageDescriptor("icons/refresh.png");
28 public final static String DEFAULT_LABEL = "Refresh selected";
29
30 public Object execute(final ExecutionEvent event) throws ExecutionException {
31 String refreshType = event.getParameter(PARAM_REFRESH_TYPE);
32 JcrResultTreeView view = (JcrResultTreeView) HandlerUtil
33 .getActiveWorkbenchWindow(event).getActivePage()
34 .getActivePart();
35
36 // force full refresh without preserving selection from the tool bar
37 if (PARAM_REFRESH_TYPE_FULL.equals(refreshType))
38 view.refresh(null);
39 else {
40 IStructuredSelection selection = (IStructuredSelection) HandlerUtil
41 .getActiveWorkbenchWindow(event).getActivePage()
42 .getSelection();
43 @SuppressWarnings("rawtypes")
44 Iterator it = selection.iterator();
45 while (it.hasNext()) {
46 Object obj = it.next();
47 if (obj instanceof ResultParent) {
48 view.refresh((ResultParent) obj);
49 }
50 }
51 }
52 return null;
53 }
54 }