Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Add a menucontribuion to Toolbar dynamically(Is it possible to dynamically add a new "button" to the Eclipse toolbar)
Add a menucontribuion to Toolbar dynamically [message #1736327] Tue, 28 June 2016 12:42
André Ramos is currently offline André RamosFriend
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

Previous Topic:org.apache.commons.io
Next Topic:Product export error when using shared license for a feature
Goto Forum:
  


Current Time: Thu Apr 18 01:28:57 GMT 2024

Powered by FUDForum. Page generated in 0.01798 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top