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 14:14 Go to next message
Eclipse UserFriend
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 |
Table table = tableViewer.getTable();
ComboBoxViewerCellEditor comboBoxCellEditor = new
ComboBoxViewerCellEditor(table, SWT.READ_ONLY);
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer,
tableViewerColumn.setEditingSupport(new EditingSupport(tableViewer){
protected CellEditor getCellEditor(Object element) {
return comboBoxCellEditor;
protected boolean canEdit(Object element) {
return true;
protected Object getValue(Object element) {
return element.toString();
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
IObservableSet knownElements = listContentProvider_2.getKnownElements();
IObservableMap[] observeMaps_2 =
EMFObservables.observeMaps(knownElements, new

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

best regards,
Re: Empty Combo when EMF databinding to a combo in a table viewer [message #1009168 is a reply to message #1009134] Thu, 14 February 2013 15:25 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
this is how I use combos with DataBinding:
The features are often enums. Not sure this would work for you?

cmbLevelViewer.setContentProvider(new ArrayContentProvider());
		cmbLevelViewer.setLabelProvider(new LabelProvider());

		IEMFValueProperty toleranceLevelProperty = EMFEditProperties
				.value(editingService.getEditingDomain(), LibraryPackage.Literals.TOLERANCE__LEVEL);
		IValueProperty selectionProperty = ViewerProperties.singleSelection();
				toleranceLevelProperty.observe(tolerance), null, null);
Re: Empty Combo when EMF databinding to a combo in a table viewer [message #1009532 is a reply to message #1009134] Fri, 15 February 2013 09:28 Go to previous message
Eclipse UserFriend
I found out that not only a content provider is needed but the input
must be set. Why is that?
But ,after I set the input (setInput(..)) I gout an exception that the
given input must be of type IObservableList and it was only an
IObservableSet. I solved this problem not with EMF databinding but with
"normal" databinding like this:

ObservableListContentProvider listContentProvider_2 = new
IObservableMap observeMap =
MyObject2.class, "name");
IObservableList selfList =

This does exactly what I want. But one strange thing left is that
implementing a label provider for the specific column is ignored. So I
had to implement an anonymous lable provider for the table viewer in
which I have to determine distinguish between the different columns.
That's not so good because when columns are added or removed this label
provider must be adapted. Better, each column has its own label provider.

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

Current Time: Fri Feb 24 00:12:09 GMT 2017

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

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