Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Databinding with CellEditor
Databinding with CellEditor [message #542653] Fri, 25 June 2010 14:31 Go to next message
Roberto  is currently offline Roberto
Messages: 6
Registered: June 2010
Junior Member
Hi.

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[2].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 value.
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

Roberto
Re: Databinding with CellEditor [message #542769 is a reply to message #542653] Fri, 25 June 2010 23:45 Go to previous messageGo to next message
chengdong is currently offline chengdong
Messages: 17
Registered: July 2009
Junior Member
Hi,

Your problem is unclear to me. Can you post some code snippet to demonstrate your problem?

[Updated on: Fri, 25 June 2010 23:48]

Report message to a moderator

Re: Databinding with CellEditor [message #542811 is a reply to message #542653] Sat, 26 June 2010 10:21 Go to previous messageGo to next message
Roberto  is currently offline Roberto
Messages: 6
Registered: June 2010
Junior Member
Hi. Ok, I give it a try Wink

First I created a model, a ContentProvider and a LableProvider for my TableViewer.

Then I created the Table and the TableViewer.
My table has 5 columns:

Quote:
1. An Image of a lock. A CheckBoxCellEditor changes the "geschlossen" boolean. Depending on the value the LableProvider shows the open or closed lock.

2. A Lable (No CellEditor)

3. A TextCellEditor. In the TableModel it's the "geneh" field. Later this String must be written into a bean with Databinding.

4. Same as 3, but "datum" field

5. An image of a calendar. By clicking this image a calendar modal dialog opens (I used a CheckBoxCellEditor to handle the selection event).


In the next step I created the CellEditors by calling my zellEditoren-method.

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..
Sad
Re: Databinding with CellEditor [message #542824 is a reply to message #542653] Sat, 26 June 2010 13:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5350
Registered: July 2009
Senior Member
Take a look at the EditingSupport integration in JFace-Databinding.

Tom

Am 25.06.10 16:31, schrieb Roberto:
> Hi.
>
> 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[2].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
> value.
> 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
>
> Roberto
Re: Databinding with CellEditor [message #543056 is a reply to message #542653] Mon, 28 June 2010 10:12 Go to previous message
Roberto  is currently offline Roberto
Messages: 6
Registered: June 2010
Junior Member
Thanks for your reply. I implemented the EditingSupport as described in this tutorial:
http://www.vogella.de/articles/EclipseJFaceTable/article.htm l

But how can I access the cells via databinding? tableviewer.getCellEditors() returns null... Sad

[Updated on: Mon, 28 June 2010 10:19]

Report message to a moderator

Previous Topic:Disable hiding celleditor controls
Next Topic:Closing a view programmatically before shutdown
Goto Forum:
  


Current Time: Wed Oct 01 14:34:25 GMT 2014

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

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