Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ComboBoxCellEditor not working as expected
ComboBoxCellEditor not working as expected [message #458650] Mon, 18 July 2005 13:40
Eclipse UserFriend
Originally posted by:


I am trying to use the ComboBoxCellEditor for a column in a table.

When the table first populates, the cells display the values as expected,
however if the combo box is used to change the value of a cell, the new
value is always that associated with index 0 in the list of possible values.

I have an object called CellValue, this has the following getters and

public String getItemType() {
return (itemType==null?"":itemType);
public int getItemTypeIndex() {
if (itemType == null) return 0;
if (itemType.equals("text")) return 0;
else if (itemType.equals("integer")) return 1;
else if (itemType.equals("double")) return 2;
return 0;
public void setItemType(String itemType) {
System.out.println("CellValue.setItemType: itemType " + itemType);
this.itemType = itemType.trim().toLowerCase();
public void setItemTypeIndex(int itemType) {
System.out.println("CellValue.setItemTypeIndex: itemType " + itemType);
switch (itemType) {
case 0: setItemType("text");
case 1: setItemType("integer");
case 2: setItemType("double");
default: setItemType("text");

The methods in my modifier are:

public Object getValue(Object rowData, String property) {
System.out.println("getValue: property " + property);
CellValue cellValue = (CellValue)rowData;
if (CellValue.NAME.equals(property)) {
return cellValue.getDataItemName();
} else if (CellValue.VALUE.equals(property)) {
return cellValue.getValue();
} else if (CellValue.TYPE.equals(property)) {
System.out.println("Type is " + cellValue.getItemTypeIndex());
return new Integer(cellValue.getItemTypeIndex());
} else if (CellValue.SHOW.equals(property)) {
return (new Boolean(cellValue.isShowOnSheet()));
return null;

public void modify(Object rowData, String property, Object value) {
System.out.println("CellValueModifier.modify: rowData " +
rowData.getClass().toString() +
" value " + value.getClass().toString());
if (rowData instanceof Item) rowData = ((Item)rowData).getData();

CellValue cellValue = (CellValue)rowData;
if (CellValue.NAME.equals(property)) {
} else if (CellValue.VALUE.equals(property)) {
} else if (CellValue.TYPE.equals(property)) {
} else if (CellValue.SHOW.equals(property)) {


As you can see I have added a number of debug lines. The results I get are:

CellValueModifier.modify: rowData class org.eclipse.swt.widgets.TableItem
value class java.lang.Integer

CellValue.setItemTypeIndex: itemType 2

CellValue.setItemType: itemType double

CellValue.setItemType: itemType text

CellValueModifier.modify: before refresh

CellValueModifier.modify: after refresh

The problem seams to be caused by the second setItemType method call. This
is very strange as the only place I call this is in the setItemTypeIndex
method and the trace shows that this is only called once.

I am doing something daft that I can't see or is there a problem here?


Previous Topic:Any tutorials on SWT?
Next Topic:Proper use of ColumnWeightData
Goto Forum:

Current Time: Wed Oct 28 00:02:19 GMT 2020

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

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

Back to the top