How do I add a fixed widget to an Eclipse RCP top trimbar?

35 views Asked by At

We want to display an image to the left of the toolbars of our Eclipse RCP application, like this:

Eclipse RCP application with an imagem to the left of the toolbars

Our app has a setting that allows the user to change the size of the toolbars:

Eclipse RCP application with different toolbar size

We tried the following approaches:

  1. Create a model fragment and add a new Trim Contribution with a Tool Control. This Tool Control has the image. The problem here is that the Tool Control is always aligned on the right side of the trim.

  2. Via plugin.xml, use the org.eclipse.ui.menus extension, add a new menuContribution > toolbar > control, and then add a widget on it. This widget has the image. The problem here is that the widget has a fixed height. It's always with the height of a small toolbar.

  3. Create a custom TrimBarRenderer and create a Composite inside the main trim Composite. This inner Composite has the image. The problem here is that when the user changes the toolbar style, this widget is placed on the right. We managed to position it correctly, but it's an ugly solution.

  4. Create a custom TrimBarRenderer, adjust its layout's left margin to add some space and add a paintListener to its Composite. The paintListener draws the image on the space created by the extra margin. This is the best solution so far, albeit too cumbersome.

It seems the first or second approaches are the best ones, but we couldn't find how to deal with the positioning or sizing.

Which is the correct way to do this?

0

There are 0 answers