Add a menucontribuion to Toolbar dynamically [message #1736327] |
Tue, 28 June 2016 12:42 |
André Ramos Messages: 11 Registered: April 2014 |
Junior Member |
|
|
Is it possible to add menucontribution, basically a new button, to the toolbar:org.eclipse.ui.main.toolbar dynamically?
I tried with AbstractContributionFactory but it seems to be bugged. Since the createContributionItems is never called. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=411765).
My code so far tries to add a new button to the Eclipse toolbar after pressing another button, the thing is that createContributionItem is never called, so i never even see "HallelujAH"":
//If a certain button is pressed run will be executed
public void run(IAction action) {
MessageDialog.openInformation(
window.getShell(),
"Runtimecommands",
"Hello, Eclipse world");
IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
AbstractContributionFactory factory = new AbstractContributionFactory("toolbar:org.eclipse.ui.main.toolbar", null)
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
System.out.println("HALELLUJAHHH!");
}
};
menuService.addContributionFactory(factory);
}
Tks for your attention.
[Updated on: Tue, 28 June 2016 16:41] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01798 seconds