Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to add a combo to a view's action bar?
How to add a combo to a view's action bar? [message #494377] Fri, 30 October 2009 13:33 Go to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: October 2009
Junior Member
I'm trying to add a combo to a view's action bar. I can successfully add the combo by extending the ControlContribution class which looks something like this:

public class ToolbarCombo extends ControlContribution
{	
	private Combo combo;
	
	public ToolbarCombo(String str)
	{
		super(str);	
	}
	
	@Override
	protected Control createControl(Composite parent)
	{
		combo = new Combo(parent, SWT.DROP_DOWN);

		combo.add("01/01/2009");
		combo.add("01/02/2009");
		combo.add("01/03/2009");
		combo.add("01/04/2009");
		combo.add("01/05/2009");
		combo.setTextLimit(10);
		combo.select(0);

                .....

		return combo;
	}
	
        // TRY to set the width I want... not working!
	protected int computeWidth(Control control)
        {
		return control.computeSize(500, SWT.DEFAULT, true).x;
	}
}

	
private void initializeToolBar()
{
		IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
		ToolbarCombo tc = new ToolbarCombo("dateCombo");
		toolbarManager.add(tc);
}


The problem I am having is that the width is always the size of an action button. The combo works and I can see the items in there if I expand it. Does anyone know of a way to force it to be wider than an action button?

Thanks in advance!

[Updated on: Fri, 30 October 2009 13:33]

Report message to a moderator

Re: How to add a combo to a view's action bar? [message #494598 is a reply to message #494377] Sat, 31 October 2009 21:27 Go to previous message
Vuk  is currently offline Vuk Friend
Messages: 5
Registered: July 2009
Junior Member
No Real Name,

Sorry I really can't help you, but maybe you can help me, how are you calling your ControlContribution. Is it getting loaded programmaticly from ApplicationActionBarAdvisor? I'm looking at not loading it programmaticly but some how through an extension.
Previous Topic:Commands, Actions, Handlers, and buttons
Next Topic:Eclipse Training Series
Goto Forum:
  


Current Time: Thu Dec 18 23:11:00 GMT 2014

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

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