EclipseとSWTを使用して、私は現在、CommandContributionItem
(CCI)を2つのテキストフィールドを持つButton
に取得しようとしています。ViewPart
ボタンを押すParameterizedCommand
と、テキストフィールドの現在のテキスト値をパラメータとして使用して呼び出されるはずです。
次のように、テキストフィールドの初期値をCCIに渡すことができました。
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(1, false));
text = new Text(parent, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
text_1 = new Text(parent, SWT.BORDER);
text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Map<String, String> params = new HashMap<String, String>();
params.put("myString", text.getText());
params.put("mySecondString", text_1.getText());
CommandContributionItemParameter p = new CommandContributionItemParameter(getSite(),
"commandSyso","com.voo.example.commandparameter.simple.sysoCommand", CommandContributionItem.STYLE_PUSH);
p.label = "My Label";
p.parameters = params;
CommandContributionItem item = new CommandContributionItem(p);
item.fill(parent);
}
ただし、これは静的な1回限りのパスです。CCIが呼び出されるたびにこれを動的に更新する方法はありますか?