Michael
Michael

Reputation: 5062

Eclipse RCP: Height of a search text in the toolbar in Eclipse 4.6

I have an Eclipse 3.8 RCP application that runs on the Eclipse 4.4 platform using the compatibility layer. In the toolbar there is a search text which looks like this:

toolbar 4.4

But when I run the application on Eclipse 4.6 it looks like this:

toolbar 4.6

The search text is added via the following extension point in the plugin.xml:

<extension point="org.eclipse.ui.menus">
<menuContribution
    locationURI="toolbar:org.eclipse.ui.trim.command2">
    <toolbar id="search.toolbar">
    <control 
        class="app.SearchText"
        id="app.SearchText">
    </control>
    </toolbar>
</menuContribution>
</extension>

The SearchText class looks like this:

public class SearchText extends WorkbenchWindowControlContribution {

// ...

@Override
protected Control createControl(Composite parent) {
    parent.setLayout(new FillLayout());
    log.trace("create search text control");
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = 5;
    layout.marginHeight = 0;
    layout.marginWidth = 5;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);
    text = new Text(composite, SWT.BORDER | SWT.SEARCH);
    // ...
    return composite;
}

// ...

I played with the layout parameters but with no success and I have no idea how this could be fixed. Thanks for any help on this!

Upvotes: 2

Views: 1012

Answers (2)

Michael
Michael

Reputation: 5062

For Eclipse Oxygen (4.7) the following workaround posted on this issue worked for me:

public class MyWorkbenchWindowControlContribution extends
    WorkbenchWindowControlContribution {

  @Override
  protected Control createControl(Composite parent) {
    parent.getParent().setRedraw(true);
    ....
  }

  @Override
  public boolean isDynamic() {
    return true;
  }
  ...

Upvotes: 2

flavio.donze
flavio.donze

Reputation: 8100

I reported a bug a while ago: main toolbar control contributions is cut off

Here is a workaround:

The class should extend ControlContribution instead of WorkbenchWindowControlContribution.

In the YourApplicationNameActionBarAdvisor.fillCoolBar() (replace the YourApplicationName) add: toolbar.add(new SearchText());



Here the print screens of the reported bug, must be the same issue.

Test with Eclipse Luna (4.4.2) Test with Eclipse Luna (4.4.2)

Test with Eclipse Mars (4.5.0) Test with Eclipse Mars (4.5.0)

Upvotes: 1

Related Questions