|UndoableModelPropertySheetEntry and ComboBoxCellEditor validation problem [message #697981]
||Mon, 18 July 2011 14:36
Registered: July 2011
I got the following issue in Eclipse 3.6 :
I'm using live validation in Eclipse / EMF / GMF. In the property viewer, when I change a combo box value for a wrong one, the validation is correctly triggered a first time, and an error popup is correctly shown. But after this, when I click anywhere in Eclipse, the change of active part launches the validation again. It's not optimal but won't be a problem, except the wrong value is kept and applied a second time, and I got the error message again.
I've traced the problem. When first initialized, the CCombo attached to my UndoableModelPropertySheetEntry has its selection correctly initialized with the correct value (in the PropertySheetEntry.getEditor() method). Then when I change the value for a wrong one (validation speaking), the SelectionListener attached to the ComboBoxCellEditor launches widgetSelected(), and the internal "selection" attribute is set to the new index.
After that the UndoableModelPropertySheetEntry.setValue() method calls the validation, and if the validation status is ok, sets definitely the new value. In my case it does not, which is correct, but the "selection" attribute keeps the same value.
When the main editor is activated by clicking on it, as the same object had the focus in this editor before (which is why I was able to edit the corresponding properties), it sets the same input to the property viewer. That's also fine, except the Property Editor doesn't have the focus in the meantime and it doesn't not reset the "selection" attribute via the getEditor(), that still is referencing the wrong value. So the UndoableModelPropertySheetEntry.setValue() retrieves it indirectly (by asking the combo is current selection), and sets this wrong value again (because it's still different from the value it knows), launching the validation again ...
Does someone have an idea what I can do to prevent this behaviour ? Considering all this code (except the validation class) is generic GMF/EMF code ?
Powered by FUDForum
. Page generated in 0.01562 seconds