I am developing an Eclipse plug in and try to put a JComboBox
on an IToolBarManager
and add ActionListener
to it, so I can handle the JComboBox
selection.
我正在开发Eclipse插件并尝试将JComboBox放在IToolBarManager上并向其添加ActionListener,因此我可以处理JComboBox选择。
Can anyone please help me with that?
谁能帮助我呢?
1 个解决方案
#1
4
There may be a better solution, but I have used the following method:
可能有更好的解决方案,但我使用了以下方法:
IToolBarManager mgr = this.getViewSite().getActionBars().getToolBarManager();
IContributionItem comboCI = new ControlContribution("test") {
protected Control createControl(Composite parent) {
final Combo c = new Combo(parent, SWT.READ_ONLY);
c.add("one");
c.add("two");
c.add("three");
c.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
c.add("four");
}
});
return c;
}
};
mgr.add(comboCI);
}
#1
4
There may be a better solution, but I have used the following method:
可能有更好的解决方案,但我使用了以下方法:
IToolBarManager mgr = this.getViewSite().getActionBars().getToolBarManager();
IContributionItem comboCI = new ControlContribution("test") {
protected Control createControl(Composite parent) {
final Combo c = new Combo(parent, SWT.READ_ONLY);
c.add("one");
c.add("two");
c.add("three");
c.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
c.add("four");
}
});
return c;
}
};
mgr.add(comboCI);
}