Sometimes you may need to add SWT Controls to the Statusline. SWT Controls like Text; label can be added to the StatusLine in the form of contribution item.

Following is the snapshot of the WorkBench Window with the StatusLine having SWT Controls.

Structure of the StatusLine:

StatusLine of the Workbench have five parts:

  1. FastViews
  2. Icon/Message
  3. Progress
  4. Contributions
  5. Job progress

SWT Controls can be added in the Contribution part of the StatusLine.

These classes extend the org.eclipse.jface.action.ContributionItem class. It has fill(Composite parent) method, which is used for adding SWT Controls. These controls are added to parent Composite.

Example:

Following is the code of one Contribution class Item1 in which one Label, one Text and one Combo are added. This Contribution class is added to the contribution area of the StatusLine.

 public class Item1 extends ContributionItem { 

  public Item1(String id) {
    super(id);
  }

  public void fill(Composite parent) {

    Label label=new Label(parent,SWT.NONE);
    label.setText("LABEL");
    Text text=new Text(parent, SWT.BORDER);
    text.setText("TEXT");
    Combo combo=new Combo(parent,SWT.NONE);
    combo.setText("COMBO");
    }
}

This contribution item (item1) can be added to the StatusLine using the fillStatusLine() method of the ApplicationActionBarAdvisor:

 protected void fillStatusLine(IStatusLineManager statusLine){

  statusLine.add(new IPDCContributionItem1("1"));
  statusLine.update(true);
  
}