0

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);  
}
gamo
  • 1,549
  • 7
  • 24
  • 36

2 Answers2

1

Please add the below line of code to your View->createPartControl() method:

getViewSite().getActionBars().getToolBarManager().add(openViewAction);
canolucas
  • 1,482
  • 1
  • 15
  • 32
Binu VM
  • 11
  • 1
0

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.

gamo
  • 1,549
  • 7
  • 24
  • 36