JFace provides ControlContribution which can be added to the toolbar.
public class LabelControlContribution extends ControlContribution
{
protected LabelControlContribution(String id)
{
super(id);
}
@Override
protected Control createControl(Composite parent)
{
final Label b = new Label(parent, SWT.LEFT);
b.setText("Label: <Your User Name>");
return b;
}
}
Add the ControlContribution to the coolbar in the ApplicationActionBarAdvisors fillCoolbar method.
IToolBarManager toolbar1 = new ToolBarManager(SWT.FLAT
| SWT.RIGHT_TO_LEFT);
coolBar.add(new ToolBarContributionItem(toolbar1, "label"));
toolbar1.add(new LabelContribution("Label"));
Now the toolbar with the ControlContribution gets added to the Toolbar.
No comments:
Post a Comment