添加工具栏到部分

Ido*_*Ido 4 java eclipse swt eclipse-plugin

我想在SWT中的一个部分添加一个工具栏.我在PDE清单编辑器中看到了一个例子.

如何添加此工具栏或按钮?也许我需要使用不同的控件?

谢谢,Ido

Sim*_*mon 6

由于发布的解决方案没有生成透明背景图标,因此我对如何获得与Plug-In Manifest Editor的Extension Page相同的结果进行了一些研究.

Plug-In Manifest Editor  -  Extensions页面

以下是他们创建工具栏的方式:

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolbar = toolBarManager.createControl(section);
    toolbar.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND));

    // Add sort action to the tool bar
    fSortAction = new SortAction(fExtensionTree, PDEUIMessages.ExtensionsPage_sortAlpha, null, null, this);
    toolBarManager.add(fSortAction);
    // Add collapse action to the tool bar
    fCollapseAction = new CollapseAction(fExtensionTree, PDEUIMessages.ExtensionsPage_collapseAll);
    toolBarManager.add(fCollapseAction);

    toolBarManager.update(true);

    section.setTextClient(toolbar);
Run Code Online (Sandbox Code Playgroud)

编辑:

这似乎也很有效:

ToolBar toolbar = new ToolBar(section, SWT.NONE);
//add the toolitems here
//...
section.setTextClient(toolbar);
Run Code Online (Sandbox Code Playgroud)

不要让Window Builder Tool适应工具栏FormToolkit,否则您将获得绘制的白色背景.