//fvMgr.restoreToPresentation(getId());
}
public void initToolBarManager(final ToolBarManager mgr) {
// Set up the ToolBar with a restore button
IContributionItem restoreContrib = new ContributionItem() {
public void fill(ToolBar parent, int index) {
ToolItem restoreItem = new ToolItem(mgr.getControl(), SWT.PUSH, index);
Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART);
restoreItem.setImage(tbImage);
String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore;
restoreItem.setToolTipText(menuTip);
restoreItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
restoreToPresentation();
}
public void widgetSelected(SelectionEvent e) {
restoreToPresentation();
}
});
}
};
mgr.add(restoreContrib);
ShowFastViewContribution sfvc = new ShowFastViewContribution(wbw, getId());
mgr.add(sfvc);
// Add context menu items
mgr.setContextMenuManager(new MenuManager());
MenuManager menuMgr = mgr.getContextMenuManager();
final IContributionItem closeContrib = new ContributionItem() {
public void fill(Menu parent, int index) {
MenuItem closeItem = new MenuItem(parent, SWT.NONE, index++);
closeItem.setText(WorkbenchMessages.WorkbenchWindow_close);
closeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IViewReference selectedView = null;
if (contextToolItem != null) {
selectedView = (IViewReference) contextToolItem.getData(ShowFastViewContribution.FAST_VIEW);
}
if (selectedView != null) {
WorkbenchPage page = wbw.getActiveWorkbenchPage();
if (page != null) {
page.hideView(selectedView);
}
}
}
});
}
};
// We have to manage the visiblity this way...?
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IViewReference selectedView = null;
if (contextToolItem != null) {
selectedView = (IViewReference) contextToolItem.getData(ShowFastViewContribution.FAST_VIEW);
}
// Only show the 'close' item if we've clicked on a view
Perspective persp = wbw.getActiveWorkbenchPage().getActivePerspective();
closeContrib.setVisible(selectedView != null && persp.isCloseable(selectedView));
manager.update(true);
}
});
menuMgr.add(closeContrib);