java - 工具栏中的文本框 Eclipse RCP 应用程序

标签 java eclipse rcp e4

我尝试在 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);
}

我应该怎么做?

enter image description here

enter image description here

最佳答案

我假设您将此类指定为 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/

相关文章:

java - 当登录失败时,在 spring 中保留用户名

java - 如何找到占用特定端口的神秘服务?

java - 创建一个在 RCP 应用程序启动时运行任意代码的插件

java - 无法让 SWT.UNDERLINE_LINK 与 StyledText 和 TextStyle 结合使用

java - Mockito: "Invalid use of argument matchers!",但我已经一直在使用匹配器

java - 如何在 Java 中发出原始 HTTP 请求?

java - 在没有 Oracle 依赖的 Java 中使用 Oracle ref cursor

java - Gradle 构建成功但失败

android - 如何修复 The method startActivity(Intent) is undefined for the type new View.OnClickListener() 语法错误

eclipse - OSGI(Eclipse RCP)下的Log4j