GritcoAndreea
GritcoAndreea

Reputation: 85

TextBox in Toolbar Eclipse RCP Application

I am trying to add a search field in the toolbar after my buttons of my Eclipse RCP Application from the Application.e4xmi , but it doesn't work. I created a ToolControl with a handler :

@Execute
public void execute(Shell shell) 
{

     shell.setLayout(new GridLayout());
        final Composite comp = new Composite(shell, SWT.NONE);
        comp.setLayout(new GridLayout());
        Text text = new Text(comp, SWT.BORDER);
        text.setMessage("Search");
        text.setToolTipText("search");
        System.out.println("i am in SearchToolItem ");


        GridData lGridData = new GridData(GridData.FILL, GridData.FILL, true, true);
        lGridData.widthHint = 200;
        text.setLayoutData(lGridData);
}

How should I do this?

enter image description here

enter image description here

Upvotes: 0

Views: 551

Answers (1)

greg-449
greg-449

Reputation: 111142

I assume you are specifying this class as a ToolControl in the e4xmi.

ToolControls don't use @Execute and they aren't given a Shell.

Instead use @PostConstruct and specify a Composite:

@PostConstruct
public void postConstruct(Composite parent)
{
   Composite comp = new Composite(parent, SWT.NONE);
   comp.setLayout(new GridLayout());

  ....
}

Note: Do not change the layout for the parent composite.

Upvotes: 1

Related Questions