简体   繁体   中英

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);  
}

请将以下代码行添加到您的View-> createPartControl()方法中:

getViewSite().getActionBars().getToolBarManager().add(openViewAction);

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM