]> git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/ResultDetailsDisplayHandler.java
Add commands and tha ability to manage more than one item at a time in the result...
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / commands / ResultDetailsDisplayHandler.java
1 package org.argeo.slc.client.ui.commands;
2
3 import java.util.Iterator;
4 import java.util.List;
5
6 import org.argeo.slc.client.ui.views.ResultDetailView;
7 import org.argeo.slc.client.ui.views.ResultListView;
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.ui.handlers.HandlerUtil;
12
13 /**
14 * Command handler to set visible or create a ResultDetailView. UUID of the
15 * testResult is passed via command parameters.
16 *
17 * @author bsinou
18 *
19 */
20
21 public class ResultDetailsDisplayHandler extends AbstractHandler {
22 // private static final Log log = LogFactory
23 // .getLog(ResultDetailsDisplayHandler.class);
24
25 public final static String ID = "org.argeo.slc.client.ui.displayResultDetails";
26
27 public Object execute(ExecutionEvent event) throws ExecutionException {
28
29 // We rather directly retrieve the corresponding view than use command
30 // parameters.
31
32 // We pass the UUID of the test result we want to display via command
33 // parameters.
34 // String uuid = event
35 // .getParameter("org.argeo.slc.client.commands.resultUuid");
36
37 // TODO : remove this.
38 // if (uuid == null || "".equals(uuid)) {
39 // try {
40 // } catch (PartInitException e) {
41 // // TODO Auto-generated catch block
42 // e.printStackTrace();
43 // }
44 //
45 // }
46
47 // mode = 2 : VIEW_VISIBLE, Show view mode that indicates the view
48 // should be created or made visible if already created .
49 // mode = 1 : VIEW_ACTIVATE, Show view mode that indicates the view
50 // should be made visible and activated. Use of this mode has the same
51 // effect as calling
52 try {
53 ResultListView rlv = (ResultListView) HandlerUtil
54 .getActiveWorkbenchWindow(event).getActivePage()
55 .findView(ResultListView.ID);
56 List<String> ids = rlv.getSelectedResultsId();
57
58 ResultDetailView rView;
59 Iterator<String> it = ids.iterator();
60 while (it.hasNext()) {
61 String uuid = it.next();
62 rView = (ResultDetailView) HandlerUtil
63 .getActiveWorkbenchWindow(event).getActivePage()
64 .showView(ResultDetailView.ID, "UUID-" + uuid, 1);
65 rView.setUuid(uuid);
66 rView.retrieveResults();
67 }
68 } catch (Exception e) {
69 e.printStackTrace();
70 }
71 return null;
72 }
73 }