我想在装饰条中创建组合框。
所以我开始添加一个文本框。
我创建了 TrimBars->WindowTrim->Toolbar->Tool Control
我还提到了 Class URI
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);
}
}
我也将 Sysout 放入方法中,但该方法永远不会被执行。
我做了与沃盖拉网站中提到的相同的事情
参见第 30.2 节http://www.vogella.com/tutorials/EclipseRCP/article.html#toolbar_advanced_toolcontrols http://www.vogella.com/tutorials/EclipseRCP/article.html#toolbar_advanced_toolcontrols
Edited:-
@格雷格-449
我已经删除了父布局的更改,
下面是应用程序.e4xmi的trimBars部分代码
<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>
运行应用程序后,我可以看到修剪条,但我的文本字段不存在。
“待渲染”和“可见”设置为 true。
是否需要更多条目,还有其他地方,我是否遗漏了一些东西。