-->

How to add menu Items to toolbar in Eclipse E4

2019-08-20 04:21发布

问题:

I have an Eclipse RCP application and have added a tollbar via TrimBar->Window Trim->Toolbar->Tool Control. I have tried to add menu/ menu items using SWT Menu but it is not visible in the toolbar. Other components like buttons,labels,combo boxes are added without any problem. Is it possible to add Menu Items to toolbar?

File Edit View Tools Window Help Here-The-Combobox-To-Be-Added

File/Edit/View/Tools/Window/Help are the menu items in the toolbar. And after that a combobox is to be added.

Thanks

回答1:

One solution might be to add a combo box to the trimbar.

I have tried out a progress indicator in the trim bar: Use a ToolControl element in the UI specification WindowTrim->Toolbar->ToolControl. The class given with the tool control is a POJO. Here is the beginning of my progress bindicator:

public class ProgressIndicator implements IProgressMonitor {

    private ProgressBar progressBar;

    @PostConstruct
    public void createControls(final Composite parent) {
        final Group g = new Group(parent, SWT.SHADOW_ETCHED_IN | SWT.FILL);
        g.setLayout(new FillLayout());
        g.setToolTipText(Nls.INSTANCE.getString("Progressbar.tooltip"));
        this.progressBar = new ProgressBar(g, SWT.NONE );
        this.progressBar.setVisible(false);
    }
...
}