- // TODO : Improve this methods.
- // For now it is a workaround because we cannot dynamically update context
- // menu to pass the UUID as command parameter
- // public String[] getSelectedResult() {
- // Object obj = ((IStructuredSelection) viewer.getSelection())
- // .getFirstElement();
- //
- // String[] attributes = new String[2];
- //
- // if (obj == null || !(obj instanceof ResultAttributes))
- // return null;
- // else {
- // ResultAttributes ra = (ResultAttributes) obj;
- // attributes[0] = ra.getUuid();
- // attributes[1] = (ra.getAttributes().get("testCase") == null) ? null
- // : ra.getAttributes().get("testCase");
- // return attributes;
- // }
- // }
+ // Manage list of the result
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+ /** Initialize the view **/
+ public void retrieveResults() {
+ try {
+ List<ResultAttributes> lst = testResultCollectionDao
+ .listResultAttributes(null);
+ if (log.isTraceEnabled())
+ log.trace("Result attributes count: " + lst.size());
+
+ // handle removed result from the list locally
+ // Might be optimised.
+ Iterator<ResultAttributes> it = removedResults.iterator();
+ removeResult: while (it.hasNext()) {
+ ResultAttributes curRa = it.next();
+ String curRaId = curRa.getUuid();
+ for (Iterator<ResultAttributes> it2 = lst.iterator(); it2
+ .hasNext();) {
+ ResultAttributes tmpRa = it2.next();
+ if (tmpRa.getUuid().equals(curRaId)) {
+ lst.remove(tmpRa);
+ continue removeResult;
+ }
+ }
+ if (lst.contains(curRa))
+ lst.remove(curRa);
+ }
+ viewer.setInput(lst);
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot refresh the result List", e);
+ }
+ }
+
+ public List<String> getSelectedResultsId() {
+ List<String> resultIds = new ArrayList<String>();
+ IStructuredSelection curSelection = (IStructuredSelection) viewer
+ .getSelection();
+ Iterator it = curSelection.iterator();
+ while (it.hasNext()) {
+ ResultAttributes curResult = (ResultAttributes) it.next();
+ resultIds.add(curResult.getUuid());
+ }
+ return resultIds;
+ }
+
+ /**
+ * Remove selected items from the result list. This process is handled
+ * locally in the UI side : trying to handle that on the server side throws
+ * HibernateLazyInit exception, especially when trying to access
+ * TreeTestResultCollection items.
+ */
+ public void removeSelected() {
+ IStructuredSelection curSelection = (IStructuredSelection) viewer
+ .getSelection();
+ Iterator it = curSelection.iterator();
+ while (it.hasNext()) {
+ ResultAttributes curResult = (ResultAttributes) it.next();
+ if (!removedResults.contains(curResult))
+ removedResults.add(curResult);
+ }
+ retrieveResults();
+ }