Search code examples
javaeclipse-plugineclipse-rap

How to add toolbar in a single view in RAP?


I have a View class extend ViewPart and I want to add a toolbar in that view. I think the best way is use Action. But I'm a beginner for eclipse RAP and don't know how to make it. Need help.

I also tried this code below but it doesn't work.

public void createPartControl(Composite parent) {

    IWorkbenchWindow iWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    openViewAction = new OpenViewAction(iWorkbenchWindow, "Open Another Message View", View.ID);

    ICoolBarManager coolBar = new CoolBarManager();

    IToolBarManager toolbar1 = new ToolBarManager(SWT.FLAT);  
        coolBar.add(new ToolBarContributionItem(toolbar1, "label"));  
        toolbar1.add(openViewAction);  
}

Solution

  • I found out a way by use extensions. This is what I did

    plugin.xml > Extensions > org.eclipse.ui.menus > right-click > New > menuContribution > locationURI = toolbar:view_id > right-click > New > command > commandId > Browse

    You guy can find more in this link.