Search code examples
eclipse-rcpscalinge4

Toolbar does not scale correctly in E4


I have a E4 application with some custom toolbar widgets. When the application ran in WIndows 10 without DPI scaling, everything looks fine. After chaning the DPI settings the application toolbar is not fully viewed.

Correct view:

enter image description here

With scaling enabled:

enter image description here

The application.e4xmi looks like: enter image description here

The class that is responsible for creating the widget looks like:

public class OpenOrderDropDown {

  @Inject
  private IEclipseContext context;

  private Combo combo;

  private static final String[] ITEMS = {"Default", "Planning", "Open JobOrders", "Stock Units", "To Schedule"};

  @PostConstruct
  public void createControls(final Composite parent) {

    RowLayout layout = new RowLayout();
    parent.setLayout(layout);

    Label label = new Label(parent, SWT.LEFT);
    label.setText("View: ");

    combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    combo.setItems(ITEMS);

    combo.select(0);

    combo.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {

        IEventBroker eventBroker = context.get(IEventBroker.class);
        eventBroker.post("openOrdersView", combo.getText());

      }
    });
  }

  @Inject
  @Optional
  public void changeSelection(@UIEventTopic("changeOpenOrdersView") String selection) {
    if (selection == null || selection.isEmpty()) {
      selection = "Default";
    }

    if (combo != null && !combo.isDisposed()) {
      combo.select(combo.indexOf(selection));
    }

  }

}

Is there some way to change the heigt of the widgets in the toolbar? I know how to calculate the DPI change but cannot set any heigt/width values on any of the components.


Solution

  • Move the ToolControl items to be outside of the ToolBar. Controls inside a ToolBar don't resize the bar but when outside of the ToolBar they should resize the TrimBar ok.