Community
Participate
Working Groups
The problem is in this method. See line marked with "@ERROR" below. private void applyEditorValueAndDeactivate() { selection = comboBox.getSelectionIndex(); Object newValue = doGetValue(); markDirty(); boolean isValid = isCorrect(newValue); setValueValid(isValid); if (!isValid) { //@ERROR //THIS LINE CAUSES AN ERROR. IT ASSUMES SOMETHING IS SELECTED. IN EDIT //MODE, THIS IS NOT TRUE IF I JUST TYPE SOMETHING INTO THE CELL EDITOR. //IN THIS CASE, selection IS AN INVALID INDEX. setErrorMessage( MessageFormat.format(getErrorMessage(), new Object[] {items[selection]})); } fireApplyEditorValue(); deactivate(); }
The problem appears to lie in that the populateComboBoxItems() routine sets the selection in the ComboBoxCellEditor, but not in the contained CCombo. Therefore, the CCombo remains with a selection of -1. If some code happens to cause a deactivation (usually because of lost focus) before a call to doSetValue (), then CCombo still returns a -1 which causes many problems, not just the one reported above. For example, if the ComboBoxCellEditor is being used by an EMF editor (ExtendedComboboxCellEditor) and the EMF model is a boolean, then when the code attempts to store the value (because of focus lost) you end up with a NullPointerException. It would seem to me that the simplest solution would be to add a comboBox.select (selection) call into populateComboBoxItems().
Hi Tod, Since there was no activity in this bug since May 2004, I am assuming there is some plausible workaround which would enable one to use the ComboBoxCellEditor without throwing an exception. But I can't figure out how to do it (maybe there is an alternative CellEditor somewhere?) Could you please point out how to work around this bug? Thank you!
We haven't had the resources to invetigate your case. The workaround is to only return false for isValid when you want the error. If you have a suggested patch we could look at it.
*** Bug 39826 has been marked as a duplicate of this bug. ***
Eric is in this area at the moment. The fix should be simple.
Created attachment 25045 [details] Use the text from the edit control if the 'selection' index == -1 JUnit tests should come as part of fixing Bug 83559
Patch released to HEAD with Bug number removed.
*** Bug 107930 has been marked as a duplicate of this bug. ***
Test in M2...
M3...
Verified in >I20051101-0010.
*** Bug 67698 has been marked as a duplicate of this bug. ***