Custom Console in Eclipse RCP Application

I was working on RCP application and there was a requirement to customize the console view by removing PIN Console, Open Console toolbar buttons.

Let’s learn today how we can do so.

First create a RCP application using Mail Template.

Then create an extension for “org.eclipse.ui.console.consolePageParticipants”.

extension

PageParticipant

This class implements IConsolePageParticipant and override method init()

Now get reference to toolbar manager in console view and remove unwanted buttons.

IPageSite pageSite = page.getSite();

IWorkbenchPage workbenchPage = pageSite.getPage();

IViewPart viewPart =

workbenchPage.findView( IConsoleConstants.ID_CONSOLE_VIEW );

IViewSite viewSite = viewPart.getViewSite();

IActionBars actionBars = viewSite.getActionBars();

IToolBarManager toolBarManager = actionBars.getToolBarManager();

IContributionItem[] contributionItems = toolBarManager.getItems();

contributionItems = toolBarManager.getItems();

toolBarManager.remove( contributionItems[5] );

toolBarManager.remove( contributionItems[6] );

toolBarManager.remove( contributionItems[7] );

 

This will remove Pin Console, Display Selected Console and Open Console buttons from the toolbar in console view.

There could be better way of removing tool bar buttons from console view but this is what I know so far.

Complete source code for this example can be found here.