title: Multilevel Master/Detail Databinding with EMF and RCP
body: <p>I made a model with EMF, representing the settings of a device, and a RCP GUI. In the GUI I have a list to select different devices of the type of the model (Master).</p>
  
  <p>The model has a List of Objects of a small class which should be displayed in a table (Detail).</p>
  
  <p>The tableItems itself need to be edited so I have a small GUI part with checkboxes etc. to change the settings. Here the tableitem is master and all fields shown in the GUI are details.</p>
  
  <p>Observable for the List of devices:</p>
  
  <pre class="lang-java prettyprint-override"><code>IObservableValue selection = ViewersObservables.observeSingleSelection(availableDevicesList);
  </code></pre>
  
  <p>Table:</p>
  
  <pre class="lang-java prettyprint-override"><code>IObservableList list = EMFObservables.observeDetailList(Realm.getDefault(), selection,DevicePackage.Literals.LIST);
  
  TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION);
  tableViewer.setInput(list);
  
  IObservableValue tableSelection = ViewersObservables.observeSingleSelection(tableViewer);
  </code></pre>
  
  <p>Editing:</p>
  
  <pre class="lang-java prettyprint-override"><code>Spinner field1 = new Spinner(parent, SWT.BORDER);
  
  dbc.bindValue(SWTObservables.observeSelection(field1), EMFObservables.observeDetailValue(Realm.getDefault(), tableSelection, DevicePackage.Literals.Value1));
  </code></pre>
  
  <p>When changing the device selection the tableitems get replaced. But the tableSelection seems to have a problem with this. Sometimes it still contains values of a a tableitem from a different device and sometimes it just contains null.
  I also have a button which gets enabled/disabled according the validation status of all fields. When the tableSelection puts null into these fields the validation does not work and the button is disabled until a entry in the table is selected.</p>
  
  <p>I tried to manually set the selection empty with a listener on the list and:</p>
  
  <pre class="lang-java prettyprint-override"><code>tableViewer.setSelection(StructuredSelection.EMPTY, true);
  </code></pre>
  
  <p>but this does not do the full job. At least all "old" values are replaced but the null problem still occurs.</p>
  
  <p>All I need is to set the tableSelection to an empty state as after the launch of the application, when no tableitem was selected yet.</p>