Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [Databinding] Master/Detail Validation Error
[Databinding] Master/Detail Validation Error [message #675767] Wed, 01 June 2011 13:02 Go to next message
Matthias F is currently offline Matthias FFriend
Messages: 16
Registered: June 2011
Junior Member
Hi,

I'm having some problems with a master/detail binding.

I have Table with Entries of LAN interfaces (part of a EMF model). When selecting one, the user shall be able to edit it's settings through some Widgets below the table.

The table itself is a detail object too, master is a device (EMF model).
IObservableValue selection = ViewerProperties.singleSelection().observe(availableDevicesList);

availableDevicesList ist a TreeViewer with all devices which should managed.


TableViewer tableViewer = new TableViewer(this, SWT.SINGLE | SWT.BORDER
				| SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
tableViewer.setContentProvider(new ObservableListContentProvider());
tableViewer.setLabelProvider(new MyInterfaceTableLabelProvider());

Table table = tableViewer.getTable();
table.setLayoutData(formdata);
table.setLinesVisible(true);

//sets the columns and headers etc.
createTable(table);

// get the data observable
IObservableList list = EMFProperties.list( RadioPackage.Literals.RADIO__LAN_INTERFACES).observeDetail(selection);

tableViewer.setInput(list);



One widget for example:
Spinner mask = new Spinner(editGroup, SWT.BORDER);
mask.setMaximum(32);
mask.setMinimum(0);

//TODO change to properties, too
dbc.bindValue(SWTObservables.observeDelayedValue(400,
SWTObservables.observeSelection(mask)),
EMFObservables.observeDetailValue(Realm.getDefault(),
tableSelection,						RadioPackage.Literals.LAN_INTERFACE__MASK));


A button to save the settings is enabled/disabled by the AggregateValidationStatus.

The problem is now: When I deselect all table entries (ctrl+space) the AggregateValidationStatus returns some errors and therefor the button is disabled.
The error:
Status ERROR: org.eclipse.core.databinding code=0 An error occurred while setting the value. java.lang.NullPointerException children=[Status ERROR: org.eclipse.core.databinding code=0 An error occurred while setting the value. java.lang.NullPointerException]


The same happens when I select another device.

A possible solution could be to set the tableSelection to the initial state when the app was started and no table entry is clicked yet. Is this possible?

Setting the tableViewer selection to StructuredSelection.EMPTY did not solve the problem.

Thanks for your help,
Mav
Re: [Databinding] Master/Detail Validation Error [message #676987 is a reply to message #675767] Tue, 07 June 2011 08:05 Go to previous message
Matthias F is currently offline Matthias FFriend
Messages: 16
Registered: June 2011
Junior Member
I found the solution by myself. The problem was actually the spinner itself. It threw a nullpointer when the selection was empty and there was no value.

I solved it by giving it a custom converter (from int to int...) where I return a default value if the source is null. Now the validation works fine and my button's enable state is set correct.
Previous Topic:FilteredSelectionDialog - Internal ContentProvider does not see model changes
Next Topic:How do I obtain an Object of a particular ROW in TreeViewer
Goto Forum:
  


Current Time: Mon Dec 22 17:20:18 GMT 2014

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

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