Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Empty Combo when EMF databinding to a combo in a table viewer
Empty Combo when EMF databinding to a combo in a table viewer [message #1009134] Thu, 14 February 2013 09:14 Go to previous message
Eclipse User
Hello guys,
I have an EMF model and a table viewer to display it. The point is that
one column should display a combo box which is a cell editor. This
means, the selected value then should be set into my EMF model. The
problem is that the input of the combo box should be EMF data bound. I
have the following code:

TableViewer tableViewer = new TableViewer(composite, SWT.BORDER |
SWT.FULL_SELECTION);
Table table = tableViewer.getTable();
ComboBoxViewerCellEditor comboBoxCellEditor = new
ComboBoxViewerCellEditor(table, SWT.READ_ONLY);
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer,
SWT.NONE);
tableViewerColumn.setEditingSupport(new EditingSupport(tableViewer){
@Override
protected CellEditor getCellEditor(Object element) {
return comboBoxCellEditor;
}
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected Object getValue(Object element) {
return element.toString();
}
@Override
protected void setValue(Object element, Object value) {
if(element instanceof MyObject1 && value instanceof MyObject2){
((MyObject1) element).setObject((MyObject2) value);
}
}
});

The binding then is realised as follows:

ObservableListContentProvider listContentProvider_2 = new
ObservableListContentProvider();
IObservableSet knownElements = listContentProvider_2.getKnownElements();
IObservableMap[] observeMaps_2 =
EMFObservables.observeMaps(knownElements, new
EStructuralFeature[]{Literals.MYOBJECT2__NAME});
comboBoxCellEditor.setLabelProvider(new
ObservableMapLabelProvider(observeMaps_2));
comboBoxCellEditor.setContentProvider(listContentProvider_2);

My problem is now that a combo box is displayed but it remains empty.
What am I doing wrong?

best regards,
Gilbert
 
Read Message
Read Message
Read Message
Previous Topic:[EMF Edit] Accessing attributes of children containment references
Next Topic:Xcore - derived features and reflective feature delegation
Goto Forum:
  


Current Time: Thu May 23 16:02:47 EDT 2013

Powered by FUDForum. Page generated in 0.12472 seconds