private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener( new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { ResultsView.this.fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
private void hookDoubleClickAction() { viewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { doubleClickAction.run(); } }); }
/** This is a callback that will allow us to create the viewer and initialize it. */ public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); drillDownAdapter = new DrillDownAdapter(viewer); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); // Create the help context id for the viewer's control PlatformUI.getWorkbench() .getHelpSystem() .setHelp(viewer.getControl(), "cyrilqc-eclipse.viewer"); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); }
/** Passing the focus request to the viewer's control. */ public void setFocus() { viewer.getControl().setFocus(); }
private void showMessage(String message) { MessageDialog.openInformation(viewer.getControl().getShell(), "Results View", message); }