+
+ // Handle Events
+ class SelectionChangedListener implements ISelectionChangedListener {
+ public void selectionChanged(SelectionChangedEvent evt) {
+
+ IStructuredSelection curSelection = (IStructuredSelection) evt
+ .getSelection();
+ Object obj = curSelection.getFirstElement();
+
+ if (obj instanceof ResultAttributes) {
+ selectedRa = (ResultAttributes) obj;
+ }
+ }
+ }
+
+ private void refreshCommand(IMenuManager menuManager,
+ IServiceLocator locator, String cmdId, String label, String iconPath) {
+ IContributionItem ici = menuManager.find(cmdId);
+ if (ici != null)
+ menuManager.remove(ici);
+ CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
+ locator, null, cmdId, SWT.PUSH);
+
+ // Set Params
+ contributionItemParameter.label = label;
+ contributionItemParameter.icon = ClientUiPlugin
+ .getImageDescriptor(iconPath);
+
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(UUID_PARAM_ID, selectedRa.getUuid());
+ params.put(NAME_PARAM_ID,
+ (selectedRa.getAttributes().get("testCase") == null) ? null
+ : selectedRa.getAttributes().get("testCase"));
+ contributionItemParameter.parameters = params;
+
+ CommandContributionItem cci = new CommandContributionItem(
+ contributionItemParameter);
+ cci.setId(cmdId);
+ menuManager.add(cci);
+ }
+
+ private void contextMenuAboutToShow(IMenuManager menuManager) {
+
+ IWorkbenchWindow window = ClientUiPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow();
+
+ refreshCommand(menuManager, window, DISPLAY_CMD_ID,
+ "Display as a tree", "icons/result_details.gif");
+ // We only show this command on windows OS
+ if (PLATFORM.equals("win32") || PLATFORM.equals("wpf")) {
+ refreshCommand(menuManager, window, DISPLAY_AS_XLS_CMD_ID,
+ "Display with Excel", "icons/excel.png");
+ }
+ refreshCommand(menuManager, window, SAVE_AS_XLS_CMD_ID,
+ "Save as Excel file", "icons/excel.png");
+ }
+
+ // Providers
+