|Dynamic combobox in tableviewer [message #1060383]
||Fri, 24 May 2013 11:23
| Don Smyth
Registered: April 2013
I have a TableViewer with 3 columns.|
<String> name, <ComboBoxViewerCellEditor> cellEdit1, <ComboBoxViewerCellEditor> cellEdit2.
I am using EditingSupport and the E4 IEventBroker for cell editing and messaging.
The table is populated from a file.
Based on the user selection in cellEdit1 I would like to change the data model in cellEdit2. (eg user selects 'fish' in cellEdit1, then cellEdit2's model becomes 'gills','scales','fins'; if user selects 'cats' in cellEdit1, cellEdit2's model becomes 'fur', 'tail', 'paws'. etc...
Note that the user can select different animal types on each row of column 2, and the models in column 3 will should different for each row.
I tried implementing a map copy of the data model for cellEdit1, and registered the class containing the map with IEventBroker. I can receive an event that the model for cellEdit1 has changed but I cannot work out a way to know which row in the second table column was changed.- the Object that is sent to the setValue(Object element, Object value) method in the EditingSupport class has little information.
Has anyone else come accross this issue? is there some other way to monitor cells in a TableViewer or get cell row number information?
I just found a way to do this:
Pass the TableViewer object into the column3 EditingSupport class and keep a copy.
Then on the getValue(Object element) method do
int indx = tViewer.getTable().getSelectionIndex();
TableItem ti = tViewer.getTable().getItem(indx);
MyDataModel dataModel = (MyDataModel) ti.getData();
check the dataModel for the animal type and put a new model
if needed in the ComboBoxViewerCellEditor with:
[Updated on: Fri, 24 May 2013 14:16]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.07941 seconds