Validation of Tables with Databinding [message #991323] |
Tue, 18 December 2012 14:21 |
|
Hello,
I am using a TableViewer with org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport
To this EditingSupport a DatabindingContext is passed via constructor and when the user clicks on a cell in the table a binding between the model and the CellEditor is created.
In order to have validation with that CellEditor I have overridden the org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport.createBinding(IObservableValue, IObservableValue) method and pass my own UpdateValueStrategy to to binding.
After creating the binding I use the org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport to show the validation:
@Override
protected Binding createBinding(IObservableValue target,
IObservableValue model) {
UpdateValueStrategy targetToModelStrategy = attributeUpdateValueStrategyFactory
.getSingleTargetToModelStrategy(
UpdateValueStrategy.POLICY_CONVERT, attributeName,
isRequired);
Binding binding = databindingContext.bindValue(target, model,
targetToModelStrategy, null);
ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT);
return binding;
}
Actually this works really well and if the validation fails a ControlDecoration is attached to the CellEditor.
The Problem is that I want to have this validation also for the usual table cells and not only when the user is currently editing the table with a CellEditor.
Is it possible to access these usual table cell in order to decorate then always, if table´s content validation fails.
Maybe in a similar why how the celleditor does?
Best regards,
Simon
|
|
|
|
Re: Validation of Tables with Databinding [message #1000732 is a reply to message #991323] |
Tue, 15 January 2013 10:50 |
|
Hello Tim,
thanks for your replay.
In my solution I do pass the IValidator of the UpdateStrategy to the ColumnLabelProvider.
Inside this labelprovider override the getImage method and return a suitable image according to the validation status.
This makes it possible for the user to identify the malformed cell directly.
Nevertheless I dislike this solution and would prefere a better solution offered by the framework.
Best regards,
Simon
|
|
|
Powered by
FUDForum. Page generated in 0.01501 seconds