2017-07-17 123 views
0

我想從Application.e4xmi的Eclipse RCP應用程序的按鈕之後在工具欄中添加搜索字段,但它不起作用。我使用處理程序創建了一個ToolControl:工具欄中的TextBox Eclipse RCP應用程序

@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

回答

1

我假設你指定這個類作爲一個e4xmi ToolControl

ToolControls不使用@Execute而且他們沒有給出Shell

而是使用@PostConstruct,並指定一個Composite

@PostConstruct 
public void postConstruct(Composite parent) 
{ 
    Composite comp = new Composite(parent, SWT.NONE); 
    comp.setLayout(new GridLayout()); 

    .... 
} 

注意:不要改變佈局中的父複合。

+0

現在工具欄出現了,但它給了我一個例外:無法處理「GoToLinkHandler#postConstruct()」:沒有找到實際值的參數「複合」。 – GritcoAndreea

+0

這是e4xmi中的ToolControl還是命令處理程序?此代碼僅適用於ToolControl。編輯你的問題,並把你正在嘗試使用。 –

+0

這是一個ToolControl – GritcoAndreea