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