Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » ComboBoxViewerCellEditor problem
ComboBoxViewerCellEditor problem [message #336846] Tue, 07 July 2009 19:14
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)
Previous Topic:Reacting on page changes in a multi-page editor from a separate view
Next Topic:Display an XML file in an XML editor, not in the default text editor
Goto Forum:

Current Time: Sun May 20 16:03:09 GMT 2018

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

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

Back to the top