@Override public void menuShown(MenuEvent e) { oldListener.menuShown(e); // now lets see if we have a rascal menu IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection(); if (selection.size() != 1) { return; } final TestElement testElement = (TestElement) selection.getFirstElement(); if (TestNameTranslator.isRascalTestElement(testElement)) { MenuItem gotoFile = ((Menu) e.getSource()).getItem(0); Listener oldListener = gotoFile.getListeners(SWT.Selection)[0]; gotoFile.removeListener(SWT.Selection, oldListener); gotoFile.addListener( SWT.Selection, new TypedListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TestNameTranslator.tryOpenRascalTest(testElement); } })); } else if (TestNameTranslator.isRascalSuiteElement(testElement)) { MenuItem gotoFile = ((Menu) e.getSource()).getItem(0); gotoFile.setEnabled(false); } }
public void menuHidden(final MenuEvent e) { if (e.getSource() == menu && !toolItem.isDisposed()) { toolItem.setSelection(false); } }