Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Validation of Tables with Databinding(ControlDecorationSupport for TableCells?)
Validation of Tables with Databinding [message #991323] Tue, 18 December 2012 14:21 Go to next message
Simon Scholz is currently offline Simon Scholz
Messages: 73
Registered: April 2012
Location: Germany
Member
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 #998118 is a reply to message #991323] Wed, 09 January 2013 12:05 Go to previous messageGo to next message
Timur Achmetow is currently offline Timur Achmetow
Messages: 38
Registered: April 2012
Member
I'm not sure, but I think that's not possible with the framework solutions.

I have solved this problem like this:
Collect each cell validator result in a list and show this list results over the table with an icon and error message. It's a little more work.
Re: Validation of Tables with Databinding [message #1000732 is a reply to message #991323] Tue, 15 January 2013 10:50 Go to previous message
Simon Scholz is currently offline Simon Scholz
Messages: 73
Registered: April 2012
Location: Germany
Member
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
Previous Topic:using Treeviewer (lazy) showing database content with filtering
Next Topic:ICelleditor: show error and do not allow to loose focus until valid data is inserted
Goto Forum:
  


Current Time: Sun Oct 26 03:00:19 GMT 2014

Powered by FUDForum. Page generated in 0.03050 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software