我尝试在 Application.e4xmi 中的 Eclipse RCP 应用程序按钮后面的工具栏中添加搜索字段,但它不起作用。我创建了一个带有处理程序的 ToolControl :
@Execute
public void execute(Shell shell)
{
shell.setLayout(new GridLayout());
final Composite comp = new Composite(shell, 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);
}
我应该怎么做?
最佳答案
我假设您将此类指定为 e4xmi 中的 ToolControl
。
ToolControls 不使用@Execute
,并且没有为它们提供Shell
。
而是使用@PostConstruct
并指定Composite
:
@PostConstruct
public void postConstruct(Composite parent)
{
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout());
....
}
注意:不要不要更改父组合的布局。
关于java - 工具栏中的文本框 Eclipse RCP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45137904/