// hookDoubleClickAction();
// contributeToActionBars();
}
private void hookContextMenu() {
final MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
Control lControl = null;
ISelectionProvider lProvider = null;
if (mMediaView.getCurrentView() == MediaView.MEDIA_VIEW) {
lControl = mMediaView.getMediaViewer().mTableViewer.getControl();
lProvider = mMediaView.getMediaViewer().mTableViewer;
} else {
lControl = mMediaView.getItemViewer().mTreeViewer.getControl();
lProvider = mMediaView.getItemViewer().mTreeViewer;
}
final IStructuredSelection selection = (IStructuredSelection) lProvider
.getSelection();
if (selection.isEmpty()) {
// CB TODO decide what to do on an empty selection.
}
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(new Separator("control"));
menuMgr
.appendToGroup("control",
new MediaOpenAction(selection));
menuMgr.appendToGroup("control", new SyncPlayAction(selection));
MediaViewPart.this.fillContextMenu(manager);
}
});
if (lControl != null && lProvider != null) {
Menu menu = menuMgr.createContextMenu(lControl);
lControl.setMenu(menu);
// Register to the workbench.
getSite().registerContextMenu(menuMgr, lProvider);
}
}