Validation error while data binding [message #1760527] |
Fri, 28 April 2017 02:16  |
Eclipse User |
|
|
|
I am developing an rcp application where I bind my UI widgets in the editor to the model objects. Whenever I modify the text box value in my UI, the bound model object's attribute is updated properly but it however shows a validation error message called "An error occurred while setting the value" in my control decorator. No idea why this validation error message is shown every time a character is entered into the text box.
My data binding code is as follows:
public void initDataBinding(EObject selectedObjectDef, EObject selectedObject, Widget widget) {
EMFDataBindingContext bindingContext = new EMFDataBindingContext();
IObservableValue modelObservableVal = EMFObservables.observeValue(selectedObject, selectedObject.eClass()
.getEStructuralFeature(EcucdescriptionPackage.ECUC_TEXTUAL_PARAM_VALUE__VALUE));
ISWTObservableValue targetObservableVal = WidgetProperties.text(SWT.Modify).observe(widget);
Binding bindValue = bindingContext.bindValue(targetObservableVal, modelObservableVal);
ControlDecorationSupport.create(bindValue, SWT.TOP | SWT.LEFT);
}
On further debugging I found this error is thrown by one of the super classes called BasicNotifierImpl#eNotify()
1 public void eNotify(Notification notification)
2 {
3 Adapter[] eAdapters = eBasicAdapterArray();
4 if (eAdapters != null && eDeliver())
5 {
6 for (int i = 0, size = eAdapters.length; i < size; ++i)
7 {
8 eAdapters[i].notifyChanged(notification);
9 }
10 }
11 }
at line no.8 when i == 1, giving java.lang.IllegalStateException: Cannot modify resource set without a write transaction. I tried using an editing domain but still I get the same exception. But in the UI, validation msg shown is "An error occurred while setting the value" even before I use an UpdateValueStrategy validator.
Any help is greatly appreciated. Thanks in anticipation.
|
|
|
|
|
|
|
|
|
Re: Validation error while data binding [message #1760958 is a reply to message #1760865] |
Thu, 04 May 2017 10:58   |
Eclipse User |
|
|
|
Hi Mr Ed Merks, the Model design is not in my control actually. I am just binding my UI widgets to the existing model attributes provided by the artop. The user in my application enters numerical values(Integer or float), I am binding this value in the widget to the existing model object(EcucNumericalParamValue provided by artop)'s attribute called value. After realising that, this value attribute's EDataType is NumericalValueVariationPoint which is not serializable I changed my binding code as follows :
1 public void initDataBinding(EObject selectedObjectDef, EObject selectedObject, Widget widget) {
2 EMFDataBindingContext bindingContext = new EMFDataBindingContext();
3
4 NumericalValueVariationPoint numValueVP = ((EcucNumericalParamValue) selectedObject).getValue();
5 FeatureMap mixedFeatureMap = numValueVP.getMixed();
6 Entry entry = mixedFeatureMap.get(0);
7 EStructuralFeature feature = entry.getEStructuralFeature();
8 ISWTObservableValue modelObservableVal = EMFEditObservables.observeValue(editingDomain, entry, feature);
9
10 ISWTObservableValue targetObservableVal = WidgetProperties.text(SWT.Modify).observe(widget);
11 Binding bindValue = bindingContext.bindValue(targetObservableVal, modelObservableVal);
12 ControlDecorationSupport.create(bindValue, SWT.TOP | SWT.LEFT);
13 }
Now the EDataType of 'feature' is String which should support data binding. But in the above code, I get a compile time error at line no.8 saying "The method observeValue(EditingDomain, EObject, EStructuralFeature) in the type EMFEditObservables is not applicable for the arguments (TransactionalEditingDomain, FeatureMap.Entry, EStructuralFeature)". I am not getting the EObject to pass as the 2nd argument to EMFEditObservables.observeValue() method. I have attached the EcucNumericalParamValueImpl.class file which has the model Object attributes I am binding, for your reference(autosar40.ecucdescription.impl.EcucNumericalParamValueImpl). Or is there a way to bind the Object(NumericalValueVariationPoint) itself? It was difficult for me to implement as per your suggestion in the previous reply, So I did this way. Kindly help me in resolving this problem. Thank you.
|
|
|
Re: Validation error while data binding [message #1761002 is a reply to message #1760958] |
Fri, 05 May 2017 04:27  |
Eclipse User |
|
|
|
I can't do anything with a .class file. You can't observe an entry; an entry's value can never change. What features does NumericalValueVariationPoint have, other than the mixed feature? It might be the case that EMFEditObservables.observeValue(editingDomain, numValueVP , feature) works, but I don't know what kind of feature 'feature" is...
|
|
|
Powered by
FUDForum. Page generated in 0.04258 seconds