|
Re: [DataBinding]TreeViewer ComboBoxViewerCellEditor validation [message #641695 is a reply to message #640404] |
Fri, 26 November 2010 19:39 |
Ovidio Mallo Messages: 35 Registered: July 2009 |
Member |
|
|
Hi,
how exactly are you displaying your error message (using a
ControlDecoration or so?)? I'm asking since the
ObservableValueEditingSupport class itself does not display the actual
error message so I guess you have implemented something yourself?
In any case, note that once a CellEditor looses the focus, the
underlying control used for editing (in your case a combo box) is
removed so if you're using something like a ControlDecoration, that one
will be gone as well. Also, if there's a validation error when the
CellEditor looses focus, the invalid value is never written to your
model so you probably don't have to display the error any more?
Let me know whether this helps somehow.
Regards,
Ovidio
On 21.11.2010 19:26, ayia wrote:
> Hi,
>
> I have a treeviewer with several columns.
> One of the columns provides ComboBoxViewerCellEditors for the user.
>
> It works fine, but I would like to ensure that all the combos are
> selected instead of null selection.
>
> I did something like this:
>
> treeViewerColumn2.setEditingSupport(new
> ObservableValueEditingSupport(treeViewer, ctx){
> ...
>
> @Override
> protected Binding createBinding(IObservableValue target,
> IObservableValue model) {
> ..
>
> UpdateValueStrategy strategy= new UpdateValueStrategy();
> strategy.setBeforeSetValidator(new CheckSelection());
> ...
>
> }
> ...
> }
>
>
> but the error message is displayed only when I focus the individual cell
> editor, and it disappears if the focus lost.
>
> Can someone give me a hint. Thanks.
>
> -wei
|
|
|
|
Re: [DataBinding]TreeViewer ComboBoxViewerCellEditor validation [message #642654 is a reply to message #641903] |
Thu, 02 December 2010 08:08 |
Ovidio Mallo Messages: 35 Registered: July 2009 |
Member |
|
|
Hi,
if you want to do a validation over multiple objects, you will most
probably have to use the MultiValidator class. A MultiValidator can be
added to a DataBindingContext as follows:
dbc.addValidationStatusProvider(new MultiValidator() {
protected IStatus validate() {
// validate all combobox values here.
}
});
This validation will thereby automatically show up in the message area
of the wizard. The special thing about the MultiValidator class is that
if you access any observables inside the validate() method, the
validate() method will be automatically triggered again when any of
those observables changes (that's a bit of magic :)). If you do not have
observables for all your comboboxes, you would have to manually trigger
the validate() method by calling MultiValidator#revalidate().
Let me know whether the part with the MultiValidator makes sense.
Regards,
Ovidio
On 29.11.2010 09:31, ayia wrote:
> Hi Ovidio,
>
> Thank you for your reply. I have a better understanding.
>
> I added WizardPageSupport.create(this, ctx);
>
> So I would like to display my error message on my wizard page. In the
> ObservableValueEditingSupport, I just overrided the createbinding method
> in order to add my validator.
>
> The goal is to ensure all the combo boxes are selected without any
> undefined ones. Otherwise, I want to issue an error. Since each combo
> box is bound with a validator, the validator works fine as long as the
> combo box is focused. This approach doesn't support the overall
> validation for all the combo boxes.
> Can you give me a proper way to achieve my goal, thank you.
>
> -Wei
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02881 seconds