Eclipse RCP - how to add a button to the upper right corner of an eclipse shape

I can not find anywhere how to add a button to the upper right corner of the Eclipse form, as in the screenshot.

eclispe-rcp form with a button

The button seems to be part of the namespace of the form, is it part of the functionality of the form, or is it just another composite that looks like the title of the form? Any source code examples (even drafts) are highly appreciated.

Edit:

I managed to add buttons to the section, but still not in the form itself, I used the example given here:

http://svn.regilo.org/repository/regilo/trunk/org.regilo.menu/src/org/regilo/menu/editor/page/MenuPageMaster.java

private void createSectionToolbar(Section section, FormToolkit toolkit) { ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); ToolBar toolbar = toolBarManager.createControl(section); final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); toolbar.setCursor(handCursor); // Cursor needs to be explicitly disposed toolbar.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if ((handCursor != null) && (handCursor.isDisposed() == false)) { handCursor.dispose(); } } }); // save CommandContributionItemParameter saveContributionParameter = new CommandContributionItemParameter( editor.getSite(), null, "it.wellnet.easysitebox.menu.commands.saveMenu", CommandContributionItem.STYLE_PUSH); saveContributionParameter.icon = RegiloCoreImages.getInstance().DESC_UPDATE; CommandContributionItem saveMenu = new CommandContributionItem( saveContributionParameter); toolBarManager.add(saveMenu); toolBarManager.update(true); section.setTextClient(toolbar); } 

Still no luck with the form itself.

+4
source share
2 answers

You can get the toolbarmanager as follows:

 IManagedForm mform = formPage.getManagedForm(); IToolBarManager toolbar = mform.getForm().getToolBarManager(); 

Now you can add items to the toolbar using the toolbar manager APIs as usual.

+3
source

Try to get the toolbar manager using form.getToolBarManager()

0
source

All Articles