Search code examples
javaeclipseeclipse-rcptoolbareclipse-juno

How to get the toolbar elements in RCP application, in the default location in eclipse 4?


There are two ways of adding toolbar in RCP:

  1. Using org.eclipse.ui.menu

  2. Using ActionBarAdvisor fillCoolBar(){..}

Now I am using the 1st method to implement the MenuBar and Toolbar, when I try to add the toolbar item its getting displayed but on the Right end of the screen after Quick Access textbox (which I beleive has been hard coded in Juno and till now there is no option to hide it). Anyways my question here is "How do I get those menu items in the left side (which generally is the default place for toolbar items in Eclipse)?"

Using the 2nd method does places the toolbar items as expected, but I don't want to use it since they are not encouraged for use in eclipse4, and even juno help, does not give a description for this method.


Solution

  • Try adding the following in your ActionBarAdvisor of the RCP.

    @Override
    protected void fillCoolBar(ICoolBarManager coolBar) {
        coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    }
    

    This will allow you to use org.eclipse.ui.menu and also keep the toolbar on the correct side. Reference: http://www.eclipse.org/forums/index.php/t/351345/

    Alternatively, you can also remove the Quick Access box by adding the following in your css.xml file

    #SearchField { visibility: hidden; }