How do I tell AdapterFactoryObservableList which feature of the root object to use? [message #1740387] |
Fri, 12 August 2016 13:32 |
Andreas Werner Messages: 1 Registered: July 2009 |
Junior Member |
|
|
Hi,
I'm trying to use a TableView as a viewer for my EMF data. I successfully managed to get this tutorial running and working: http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/demos/org.eclipse.fx.demo.contacts.app?h=2.4.0
Now, I have a problem when I try to reuse the ContactsTableView approach in my project:
public class MyTableViewController {
@FXML private TableColumn<TestObject, Boolean> colValid;
...
public void initTable(ModelService modelService) {
tableView.setItems(new AdapterFactoryObservableList<TestObject>(adapterFactory, modelService.getModel()));
...
colValid.setCellValueFactory(features -> BooleanProperty.booleanProperty(
EMFEditFXProperties.value(editingDomain, features.getValue(), MyTestPackage.eINSTANCE.getTestObject_Valid())); // <-------------------------- Exception
colValid.setCellFactory(CheckBoxTableCell.forTableColumn(colValid));
...
As stated in the above code an exception is being thrown:
...
Caused by: java.lang.NullPointerException
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate(BasicEObjectImpl.java:1565)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1027)
??? at org.dummy.model.impl.TestLevelImpl.eGet(TestLevelImpl.java:146)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:998)
at org.eclipse.fx.emf.databinding.edit.EMFEditFXProperties$EObjectProperty.getValue(EMFEditFXProperties.java:120)
at com.sun.javafx.binding.BidirectionalBinding.bind(BidirectionalBinding.java:64)
at javafx.beans.property.BooleanProperty$1.<init>(BooleanProperty.java:141)
at javafx.beans.property.BooleanProperty.booleanProperty(BooleanProperty.java:139)
...
I guess the NPE is thrown, because the TestLevel class has no "valid" feature. But, I don't want to have TestLevel objects in my table - I only want TestObject objects in my table!!!
So, I guess there might be a problem with the AdapterFactoryObservableList and my model object, because it contains two containment references and all objects of both of these references are used as table items. My question is:
How can I control, that only those objects from the right containment reference are being used as items in the table?
Cheers,
Andreas
|
|
|
Powered by
FUDForum. Page generated in 0.04496 seconds