Binding details table to validation [message #1060967] |
Wed, 29 May 2013 06:53  |
Eclipse User |
|
|
|
Hi,
I've got a straight-forward Master-Details set-up which validates the details of the selected item in the Master table using the EMF model.
This is all working fine apart from one thing - I have a table in the Details section and the contents of this table are not validated when they are changed.
I've got the following code which makes sure that changes to this table are reflected in the model:-
ViewerSupport.bind(
detailsTableViewer,
EMFProperties.list(detailsTableFeature).observeDetail(sel),
EMFProperties.values(columnFeatures.keySet().toArray(
new EStructuralFeature[0])));
but it doesn't validate the changes until I save the model.
Any ideas?
Thanks,
Simon
|
|
|
|
|
|
Re: Binding details table to validation [message #1061190 is a reply to message #1061052] |
Thu, 30 May 2013 09:14   |
Eclipse User |
|
|
|
Ah, you're right.
The validation is actually initiated by a validation status provider which has been added to the binding context, as follows:-
bindingCtxt.addValidationStatusProvider(new ValidationStatusProvider() {
@Override
public IObservableValue getValidationStatus() {
/* validate the model */
return new ComputedValue() {
@Override
protected Object calculate() {
return BasicDiagnostic.toIStatus(Diagnostician.INSTANCE.validate((Impl) (editingDomain.getResourceSet().getResources().get(0).getContents().get(0))));
}
};
}
@Override
public IObservableList getTargets() {
return null;
}
@Override
public IObservableList getModels() {
return null;
};
});
When I add a text field to the details part of the form, I use the following code:-
bindingCtxt.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(400, text),
EMFEditProperties.value(domain, feature).observeDetail(sel));
but when I add a table, I use:-
ViewerSupport.bind(
detailsTableViewer,
EMFProperties.list(detailsTableFeature).observeDetail(sel),
EMFProperties.values(columnFeatures.keySet().toArray(
new EStructuralFeature[0])));
As the table version has no connection to the binding context, my guess would be that changes to it don't invoke the validation through the validation status provider.
Does that sound sensible? And if so, how would I fix that?
|
|
|
Re: Binding details table to validation [message #1061194 is a reply to message #1061190] |
Thu, 30 May 2013 09:22  |
Eclipse User |
|
|
|
Simon,
That's beyond skills in data binding. Perhaps is a general data binding
(JFace) question or perhaps someone with more knowledge will chime in
here...
On 30/05/2013 3:14 PM, Simon Barnett wrote:
> Ah, you're right.
>
> The validation is actually initiated by a validation status provider
> which has been added to the binding context, as follows:-
>
>
> bindingCtxt.addValidationStatusProvider(new ValidationStatusProvider() {
>
> @Override
> public IObservableValue getValidationStatus() {
> /* validate the model */
> return new ComputedValue() {
>
> @Override
> protected Object calculate() {
> return
> BasicDiagnostic.toIStatus(Diagnostician.INSTANCE.validate((Impl)
> (editingDomain.getResourceSet().getResources().get(0).getContents().get(0))));
> }
> };
> }
>
> @Override
> public IObservableList getTargets() {
> return null;
> }
>
> @Override
> public IObservableList getModels() {
> return null;
> };
> });
>
>
> When I add a text field to the details part of the form, I use the
> following code:-
>
>
> bindingCtxt.bindValue(
> WidgetProperties.text(SWT.Modify).observeDelayed(400, text),
> EMFEditProperties.value(domain, feature).observeDetail(sel));
>
>
> but when I add a table, I use:-
>
>
> ViewerSupport.bind(
> detailsTableViewer,
> EMFProperties.list(detailsTableFeature).observeDetail(sel),
> EMFProperties.values(columnFeatures.keySet().toArray(
> new EStructuralFeature[0])));
>
>
> As the table version has no connection to the binding context, my
> guess would be that changes to it don't invoke the validation through
> the validation status provider.
>
> Does that sound sensible? And if so, how would I fix that?
|
|
|
Powered by
FUDForum. Page generated in 0.09985 seconds