Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » ComboBoxViewerCellEditor problem
ComboBoxViewerCellEditor problem [message #19552] Wed, 08 July 2009 20:15 Go to next message
Peter Moogk is currently offline Peter MoogkFriend
Messages: 15
Registered: July 2009
Junior Member
I'm trying to use a cell editor within a table. My requirement is that
I would like the user to be able to select from a list of predefined
labels in the cell editor. The user should also be able to type in their
own value if the values in the list aren't what they want.

Initially, I tried to use a ComboBoxCellEditor cell editor. This class
returns an Integer value to the cell modifier, so there doesn't seem to be
a way to get a value that is typed in by the user.

I then tried using the ComboBoxViewerCellEditor cell editor. This
class returns a String value. When a predefined string in the combo is
selected the expected string value is returned in the modify method of the
cell modifier. However, when the user types some different value into the
combo box(ie. other than the ones in the combo list) a null value is
passed to the modify method of the cell modifer. I would have expected
the value to be the user specified string and not null. This null value
passed to the cell modifier causes the user entered value to get blanked
out in the table cell. So there does seem to be a way to capture the user
enter value. Am I doing something wrong in my code that creates this
ComboBoxViewerCellEditor class. Here is the code that I'm using to create
this cell editor. Alternative can someone point me to an example that
shows how to get user enter values from a combo cell editor. All of the
examples that I have come across only show the READ-ONLY combo box
scenario. Thanks!

Peter Moogk

public CellEditor[] createCellEditors(Composite parent)
CellEditor[] cellEditors = new CellEditor[3];
ComboBoxViewerCellEditor comboEditor = new ComboBoxViewerCellEditor(
parent );

cellEditors[0] = new TextCellEditor( parent );
cellEditors[1] = comboEditor;
cellEditors[2] = new TextCellEditor( parent );
comboEditor.setLabelProvider( new LabelProvider() );
comboEditor.setContenProvider( new ComboContentProvider() );
comboEditor.setInput( new String[]{ "item1", "item2"} );
return cellEditors;

private class ComboContentProvider implements IStructuredContentProvider
public Object[] getElements(Object inputElement)
Object[] result = null;
if( inputElement instanceof String[] )
result = (String[])inputElement; }
return result;

public void dispose()

public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
Re: ComboBoxViewerCellEditor problem [message #723296 is a reply to message #19552] Thu, 08 September 2011 09:18 Go to previous messageGo to next message
Bhuvan Mehta is currently offline Bhuvan MehtaFriend
Messages: 58
Registered: July 2009

I am also facing the same issue, did you get any solution for the same?

Thanks and Regards,
Re: ComboBoxViewerCellEditor problem [message #740734 is a reply to message #723296] Tue, 18 October 2011 20:55 Go to previous messageGo to next message
Peter Mising name is currently offline Peter Mising nameFriend
Messages: 1
Registered: October 2011
Junior Member
I just came across the same issue.

My EditingSupport class's setValue method is receiving null when the user types in their own value in a ComboBoxViewerCellEditor.

Can anyone acknowledge we are not doing something wrong?


Re: ComboBoxViewerCellEditor problem [message #811824 is a reply to message #740734] Fri, 02 March 2012 21:46 Go to previous message
Samantha Chan is currently offline Samantha ChanFriend
Messages: 60
Registered: July 2009
I got around this by doing this in the setValue(...) method:

protected void setValue(Object element, Object value) {

if (value == null)
value = ((CCombo)fCellEditor.getControl()).getText();

// continue the rest of setValue...
Previous Topic:How to implement a on-the-fly compiler?
Next Topic:TextCellEditor variant supporting different fonts/colors?
Goto Forum:

Current Time: Tue Apr 24 01:15:29 GMT 2018

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

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