I've created a table with an table viewer (content provider, ...). I have a fix number of 3 rows and 5 columns.
Now I need to enable cell editing in one column for each row. Therefore I added a TextCellEditor to the column.
Editing works fine, but I want to access the cells with databinding.
The TextCellEditor is the target, the model is a bean.
Then I created the CellModifier and added the ContentProvider, LableProvider and set the Input (A list of TableModel objects).
My table has exactly 3 rows. Each row is mapped to a TableModel object.
To be able to save the content of the table we use BusinessEntities. One BusinessEntity for each row. So we have also 3 BusinessEntities. A BusinessEntity has the fields "genehmigt" (corresponds to the "geneh" field in the TableModel, column 3) and "datum" (corresponds to the "datum" field in the TableModel, column 4)
Now I have the problem: How can I access the value of one cell? I found out that I can get the control of the TextCellEditors by calling the getControl() method.
So I tried: this (Adding Databinding to the 3rd column)
If I enter a Text in one cell of the 3rd column which is not valid (for my validator) every cell in this column is marked as invalid. If it is correct every cell is marked as correct.
I think the problem is that the TextCellEditor uses one Text object for every cell in the row. So I always get the String of the last cell I edited. Therefore it's not possible use the Text control for Databinding as I do. I didn't find another way to access CellEditor cells..
Take a look at the EditingSupport integration in JFace-Databinding.
Am 25.06.10 16:31, schrieb Roberto:
> I've created a table with an table viewer (content provider, ...). I
> have a fix number of 3 rows and 5 columns.
> Now I need to enable cell editing in one column for each row. Therefore
> I added a TextCellEditor to the column. Editing works fine, but I want
> to access the cells with databinding.
> The TextCellEditor is the target, the model is a bean.
> So I've to get all the TextCellEditors:
> CellEditor zelleditoren = tblviewer.getCellEditors();
> Then I create an ObservableValue for row 3 which is my TextCellEditor:
> IObservableValue obs = SWTObservables.observeText((Text)
> zelleditoren.getControl(), SWT.Modify);
> Then I added this value to my DatabindingContext.
> But here is my problem: I can only specify one bean property for this
> So the text of the last cell I edit is written into my model. But I need
> one property for one cell!
> Is this possibly with CellEditors?
> Thanks in advance