Community
Participate
Working Groups
This method of SwtObservableList try to cast every object coming from the model to String. public void add(int index, Object element) { int size = doGetSize(); if (index < 0 || index > size) index = size; String[] newItems = new String[size + 1]; System.arraycopy(getItems(), 0, newItems, 0, index); newItems[index] = (String) element; <------------------------------------------ HERE System.arraycopy(getItems(), index, newItems, index + 1, size - index); setItems(newItems); fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, true, element))); } so, making something like this dbc.bindList( SWTObservables.observeItems(usersList.getListViewer().getList()), users, b); where users is an ObservableList based on an ArrayList<Integer> causes a ClassCastException Even applying a converter in BindSpec has no effects, i think that ListBinding is not caring about it.
ListBinding also does not work across realms, we can probably fix both at the same time.
i think that newItems[index] = (String) element; should be newItems[index] = element.toString; you have to obtain a label from the element... or not?
(In reply to comment #2) > i think that > > newItems[index] = (String) element; > > should be > > newItems[index] = element.toString; I would prefer this not to change. The reason being that the list returned specifies that it's contents are of type String.class. I think the appropriate change is to support conversion in ListBinding as today we do not. I was going to do this over the weekend but didn't get around to it. If Boris doesn't get to it soon I'll try to do it some night this week.
I know that the appropriate way is to support convert. I would like to contribute to the project, can i try do a patch? there is a similar component that can i use as "model" ?
(In reply to comment #4) > I know that the appropriate way is to support convert. > I would like to contribute to the project, can i try do a patch? Feel free. We'd greatly appreciate it. > there is a similar component that can i use as "model" ? WritableList is an observable list that can be bound to the target.
Created attachment 59919 [details] Conversion support for ListBinding Am I correct in understanding that all we want here is for ListBinding to apply the modelToTargetConverter and targetToModelConverter already provided in the BindSpec? If so, perhaps this patch will be sufficient. Can someone test it for me and let me know?
(In reply to comment #6) > Am I correct in understanding that all we want here is for ListBinding to apply > the modelToTargetConverter and targetToModelConverter already provided in the > BindSpec? Correct. > If so, perhaps this patch will be sufficient. Can someone test it > for me and let me know? I'm assuming with the info in bug 124683 comment 5 you will be able to do this on your own. If not hollar and I can help out.
Adding Peter to the CC. Peter, see comment 7.
Created attachment 60231 [details] Patch to apply converter
i moved IConverter conv = bindSpec.getModelToTargetConverter(); outside the for loop. (In reply to comment #7) > (In reply to comment #6) > > Am I correct in understanding that all we want here is for ListBinding to apply > > the modelToTargetConverter and targetToModelConverter already provided in the > > BindSpec? > > Correct. > > > If so, perhaps this patch will be sufficient. Can someone test it > > for me and let me know? > > I'm assuming with the info in bug 124683 comment 5 you will be able to do this > on your own. If not hollar and I can help out. >
This will change when we move away from BindSpec. See bug 172193.
This has been fixed as part of the refactoring to use UpdateListStrategy instead of BindSpec.
Verified on Windows XP using I20070322-1800 by code inspection.
Changing OS from Mac OS to Mac OS X as per bug 185991