Reputation: 5792
I cannot find anywhere how to add a button to the top-right corner of the Eclipse form, same as on the screenshot provided.
The button seems to be a part of the form title area, is it part of the form functionality or its just another composite which looks like a form title? Any source code examples (even drafts) highly appreciated.
Edit:
I have managed to add buttons to the section but still not to the form itself, I have used an example found here:
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 though.
Upvotes: 4
Views: 4908
Reputation: 5310
You can get the toolbarmanager like this:
IManagedForm mform = formPage.getManagedForm();
IToolBarManager toolbar = mform.getForm().getToolBarManager();
Now you should be able to add items to the toolbar using the toolbar manager APIs as per usual.
Upvotes: 3