-->

Eclipse e4 tool Control in trimbars

2019-07-20 12:32发布

问题:

I want to create combobox in trimbars. So I started with adding a text box.

I created TrimBars->WindowTrim->Toolbar->Tool Control

I mentioned Class URI also

public class SearchToolItem {

  @PostConstruct
  public void createControls(Composite parent) {
    parent.setLayout(new GridLayout());
    final Composite comp = new Composite(parent, 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);

  }
}

I also put Sysout in method, but this method never gets executed.

I did same as mentioned in vogella site

see section 30.2 http://www.vogella.com/tutorials/EclipseRCP/article.html#toolbar_advanced_toolcontrols


Edited:-

@greg-449 I have removed changing of parent layout, below is the trimBars portion code of Application .e4xmi

<trimBars xmi:id="_MWSIoJgaEeKJoJcmiy2C6w" elementId="org.eclipse.emf.ecp.e4.application.trimbar.0">
  <children xsi:type="menu:ToolBar" xmi:id="_np7_0NHfEeSckszzmbNB_g" elementId="com.gide.sasm.application.toolbar.0">
    <children xsi:type="menu:ToolControl" xmi:id="_eGZ0ENHfEeSckszzmbNB_g" elementId="com.gide.sasm.application.toolcontrol.searchTool" accessibilityPhrase="" contributionURI="bundleclass://com.gide.sasm.cardprofile.model.viewmodel/com.gide.sasm.toolbar.handler.SearchToolItem"/>
  </children>
</trimBars>

After runnig application I can see trimBars but my text field is not present. "To Be Rendered" and "visible" are set to true. Is there some more entry needed, some where else also, am I missing something.

回答1:

Your ToolControl have to be in the Window Trim, not in the ToolBar.



回答2:

In my example, i implement a ComboBox to switch between perspectives. Here are the steps to follow.

  1. Application.e4xmi:

  2. PerspectiveComboControl

  3. And here is how it lookalikes

I hope, this would help you.