2017-07-17 6 views
0

Eclipse RCPアプリケーションのボタンをApplication.e4xmiから削除した後、ツールバーに検索フィールドを追加しようとしていますが、機能しません。ツールバーのテキストボックス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()」を処理できませんでした。引数「Composite」に実際の値が見つかりませんでした。 – GritcoAndreea

+0

これはe4xmiのToolControlですか、それともコマンドハンドラですか?このコードは、ToolControlでのみ機能します。あなたの質問を編集し、あなたが使っているものを正確に入れてください。 –

+0

これはToolControlです – GritcoAndreea

関連する問題