Community
Participate
Working Groups
If a combo box has not the stlye STW-READ_ONLY applied, one can assume, the combo box can be edited, put in custom values. But the implementation of the API does not support this behaviour. It only supports returning -1 (doGetValue)if you type in a custom value. To pass a custom value to the combo box - only integer values are allowed (doSetValue) is not possible (you can only pass -1 for a custom value. If the combo box is not hidden, on can subclass the widget and work with the method's comboBox.getText()/setText() as a hack. I have implemented the method doGetValue() and doSetValue() the following way to get an editable combo box for my purposes: protected Object doGetValue() { return comboBox.getText(); } protected void doSetValue(final Object value) { Assert.isTrue(value instanceof String); int selection = -1; for (int i = 0; i < items.length; i++) { final String currentItem = items[i]; if (currentItem.equals(value.toString())) { selection = i; } } comboBox.select(selection); comboBox.setText(value.toString()); } I the method getValue() of the CellEditor, return the same string as one in the items list or the custom object. A generally valid implementation and clean implementation is welcome! There is also a custom implementation in the EMF Framework with a list of object (not Strings) and a ILabelProvider to represent the objects in the combo box. Why?? There should be one in the JFace Framework which is not as limited as the one existing now!
Should you wish to attach a suggested implementation we could look at it
I will be back next week with code ...
Similar issue is present in ComboBoxViewerCellEditor.