Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Dynamic combobox in tableviewer(Live modification of a ComboBoxViewerCellEditor model based on table selection)
Dynamic combobox in tableviewer [message #1060383] Fri, 24 May 2013 11:23
Don Smyth is currently offline Don SmythFriend
Messages: 35
Registered: April 2013
Member
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:

cellEditor.setInput(newArrayList);

[Updated on: Fri, 24 May 2013 14:16]

Report message to a moderator

Previous Topic:Re: Detecting keys while showing a context menu
Next Topic:jface 3.9 release notes
Goto Forum:
  


Current Time: Fri Apr 26 14:02:42 GMT 2024

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

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

Back to the top