Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » add combobox to toolbar and change drop-down list programmatically(add combobox to toolbar and change drop-down list programmatically)
add combobox to toolbar and change drop-down list programmatically [message #648194] Tue, 11 January 2011 13:08 Go to next message
fran81 Missing name is currently offline fran81 Missing name
Messages: 27
Registered: November 2010
Junior Member
Hi,

I am trying to add a combobox to a toolbar in an eclipse rcp app. but I'd also like to have the content of the drop-down list changing programmatically (i.e. depending on other events). Right now this combobox works, but it's on a view instead of a toolbar.

Is there a way to achieve this by setting the plugin.xml (it looks like the content of the dropdown needs to be set this way at the beginning, and cannot be changed programmatically)?
Is there another way to do that?

Thanks,
Francesca
Re: add combobox to toolbar and change drop-down list programmatically [message #649333 is a reply to message #648194] Tue, 18 January 2011 14:02 Go to previous messageGo to next message
fran81 Missing name is currently offline fran81 Missing name
Messages: 27
Registered: November 2010
Junior Member
I found out how to do this, so I thought I may as well share.

To show a combobox (or other buttons) on the toolbar one can create a class for example

public class DoThis extends Action implements IWorkbenchAction {
public DoThis() {

}

|

this class should implements the method

public Menu getMenu(Control parent) {

}
to actually show a combobox and the menu should be populated by menuitems.

After that one needs to add this action to the toolbar. To do that I have written this code in the class that display the view that contains the toolbar

DoThis myaction = new DoThis();
getViewSite().getActionBArs().getToolBarManager().add(myacti on);
Re: add combobox to toolbar and change drop-down list programmatically [message #649335 is a reply to message #648194] Tue, 18 January 2011 14:21 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can place a <control/> in a toolbar using the org.eclipse.ui.menus
contribution. You can also create a dropdown toolitem and fill in the
dropdown menu dynamically also use org.eclipse.ui.menus and a <dynamic/>
element.

See some of the examples in my .sig links


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Scrollbar For TextBox
Next Topic:eclipse rcp + spring + eclipselink
Goto Forum:
  


Current Time: Fri Aug 22 15:50:20 EDT 2014

Powered by FUDForum. Page generated in 0.02399 seconds