2

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.

Aman
  • 51
  • 2
  • 5
  • You should not be changing the layout of `parent` - remove the `parent.setLayout(new GridLayout());` line. Other than that it looks OK. Show us the declaration in the Application.e4xmi. – greg-449 Mar 23 '15 at 13:09
  • @greg-449 :- I have shared Application.e4xmi above. – Aman Mar 24 '15 at 08:21
  • Is 'com.gide.sasm.cardprofile.model.viewmodel' the id of the plugin containing your code? – greg-449 Mar 24 '15 at 08:33
  • @greg-449 Yes, its a (.viewModel) generated by using EMF, Class "SearchToolItem" lies in that module. – Aman Mar 24 '15 at 08:38
  • Are you specifying '-clearPersistedState' when you run the app? Without this new items are not picked up – greg-449 Mar 24 '15 at 08:45
  • @greg-449 Yes I have specified "clearPersistedState" to "true" in pulgin.xml – Aman Mar 24 '15 at 09:45
  • Try '-clearPersistedState' in program arguments in the Run Configuration – greg-449 Mar 24 '15 at 09:46
  • @greg-449 Can you please give me a working example for this, because I am trying everything but somehow its not working. :( – Aman Mar 24 '15 at 11:37
  • I tried your code and it works for me so I don't know what to suggest – greg-449 Mar 24 '15 at 11:50
  • greg-449 Thanks I got it running somehow, But now the problem is that text box height is too small in trimbars, how shall I increase it. – Aman Mar 25 '15 at 05:46
  • Can you ask a new question about that so that any answer we come up with will help other people as well – greg-449 Mar 25 '15 at 08:00

2 Answers2

1

Your ToolControl have to be in the Window Trim, not in the ToolBar. enter image description here

Matthias H
  • 1,300
  • 13
  • 19
  • If I have only TrimBars->WindowTrim->Tool Control now I am not even seeing trimBars in the window. :( – Aman Mar 24 '15 at 08:01
  • There is no problem with having Tool Control objects in the Toolbar, I have apps with lots of these. – greg-449 Mar 24 '15 at 08:27
  • Did you checked if the toolcontrols are in the model on Runtime with a ApplicationModelSpy ? Are there exceptions on Application Startup ? Is bundleclass://com.gide.sasm.cardprofile.model.viewmodel/com.gide.sasm.toolbar.handler.SearchToolItem 100% right ? – Matthias H Mar 24 '15 at 14:09
0

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

  1. Application.e4xmi: enter image description here

  2. PerspectiveComboControl enter image description here

  3. And here is how it lookalikes enter image description here

I hope, this would help you.

Lycone
  • 650
  • 9
  • 18