JFace ComboViewer with a header entry?
I'm interested in populating a ComboViewer with a list of objects.
I know JFace has some nice features that support that,开发者_Python百科 but what if I want to make the first entry in the ComboViewer something like
<Select Connection>
or some other dummy entry that doesn't have an object associated to it? Is there any simple generic solution to it?
You could do this with the TableCombo widget from the Nebula project. You can a create TableComboViewer with input, selection listeners etc. but also set the text of the combo independently from the current selection.
TableComboViewer viewer = ...
...
viewer.getTableCombo().setText("...");
I use this in a current project. However the TableCombo is in alpha state, but in my application it works quite fine.
AFAIK you can't do it out of the box. You can write you own LabelProvider to do this, or you may want to switch to something like a ListViewer in a popup window, and use the List's headers to display your special first element.
精彩评论