Sunday, August 24, 2014

Eclipse RCP: How to Hide or Remove a Contribution Item from a toolbar or Menubar

Using the following code we can hide or remove a Contribution item from a toolbar or menubar



private void hidePinbuttonFromPropertySheet() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = page.findView(IPageLayout.ID_PROP_SHEET);   String id = "";
if(view!=null)
{
for ( IContributionItem item : view.getViewSite().getActionBars().getToolBarManager().getItems()) {
if (item.getId().indexOf("PinPropertySheetAction")!=-1) { id = item.getId();
break;
}
}
view.getViewSite().getActionBars().getToolBarManager().remove(id);
view.getViewSite().getActionBars().getToolBarManager().update(false); } }


No comments:

Post a Comment

5 Strategies for Getting More Work Done in Less Time

Summary.    You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...