[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] ComboBoxCellEditor not working as expected
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Not the apropiate mailling list for such questions use eclipse.platform
for question concerning jface.
Mike Bennett schrieb:
> Hello
>
> 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
> setters:
>
> 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)) {
> cellValue.setDataItemName((String)value);
> } else if (CellValue.VALUE.equals(property)) {
> cellValue.setValue((String)value);
> } else if (CellValue.TYPE.equals(property)) {
> cellValue.setItemTypeIndex(((Integer)value).intValue());
> } else if (CellValue.SHOW.equals(property)) {
> cellValue.setShowOnSheet(((Boolean)value).booleanValue());
> }
>
> viewer.refresh();
> }
> 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?
>
> Thanks
>
> Mike
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
- --
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
- ------------------------------------------------------------------------
tom schindl leiter softwareentwicklung/CSE mobile ++43 676 3232147
- ------------------------------------------------------------------------
eduard-bodem-gasse 8/3 A-6020 innsbruck fax ++43 512 935833
http://www.bestsolution.at phone ++43 512 935834
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFC28Ma4E2ESUTeSPQRAqAnAJ0c4Vj/MN98P3Sq8V1CGE0O8jgebgCfc5kx
tFGkWyp1kkqMhWNkFzP4VsQ=
=QSxN
-----END PGP SIGNATURE-----