import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.IWorkbench;
viewer.setContentProvider(new ViewContentProvider());
viewer.setInput(getViewSite());
viewer.addDoubleClickListener(new ViewDoubleClickListener());
+
+ // Context Menu for the end user to choose what kind of display he wants
+ // Problem to dynamically add parameters linked with the current
+ // selected object
+ MenuManager menuManager = new MenuManager();
+ Menu menu = menuManager.createContextMenu(viewer.getControl());
+
+ // unable excel commands if not on windows
+ MenuItem[] items = menu.getItems();
+ String platform = SWT.getPlatform();
+ if (!(platform.equals("win32") || platform.equals("wpf"))) {
+ items[1].setEnabled(false);
+ }
+
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuManager, viewer);
}
protected Table createTable(Composite parent) {
| SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
Table table = new Table(parent, style);
-
+ // table.addMouseListener(new RightClickListener());
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessVerticalSpace = true;
gridData.grabExcessHorizontalSpace = true;
return table;
}
+ // 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;
+ }
+ }
+
// View Specific inner class
protected static class ViewContentProvider implements
IStructuredContentProvider {
}
// Handle Events
+
/**
* The ResultAttributes expose a part of the information contained in the
* TreeTestResult, It has the same UUID as the corresponding treeTestResult.
if (obj instanceof ResultAttributes) {
ResultAttributes ra = (ResultAttributes) obj;
- log.debug("Double-clic on result with UUID" + ra.getUuid());
IWorkbench iw = ClientUiPlugin.getDefault().getWorkbench();
IHandlerService handlerService = (IHandlerService) iw
}
}
- // Ioc
+ // IoC
public void setTestResultCollectionDao(
TreeTestResultCollectionDao testResultCollectionDao) {
this.testResultCollectionDao = testResultCollectionDao;
}
-
}