Home » Eclipse Projects » Nebula » CTableTree - communicating with custom cell
CTableTree - communicating with custom cell [message #16892] |
Fri, 17 November 2006 09:51  |
Eclipse User |
|
|
|
Originally posted by: boo123.gmail.com
hi group,
i am having some trouble figuring out how i should talk to my custom cell.
since the cells are passed over as class array, i never get to the actual
objects to attach some data (or set them as listeners or something like
that).
i have all the data i need in the class that creates the tabletree. the
custom cell needs access to this data when its created (to display the
data) and when the custom cell is changed (to update the data).
how should i pass the data to the custom cell?
i dont have access to the object directly. usually i'd use the
widget.setData(string, object) method to attach some arbitrary data, which
in this case aint possible either, since createTitleContents() is called
upon object creation, which is before i am able to attach any data to the
CTableTreeItem.
in an older thread (variable CTableTreeCell) which i think discusses a
similar problem, Jeremy Dowdall said that update() should be used to delay
the contentcreation, but neither of the update-methods ever gets called.
or am i supposed to (get them) call(ed) manually ?
Here is a simple example of what i mean:
TableTreeTest contains the data i want to be displayed (and updated) and
TextCell contains the Text-field where it should be displayed. The problem
now is: get the data to TextCell.createTitleContents :)
http://rapidshare.com/files/3723562/TableTreeTest.zip.html (1.2kb, zip)
thanks,
Ulrich.
any help is appreciated.
|
|
|
Re: CTableTree - communicating with custom cell [message #16923 is a reply to message #16892] |
Mon, 20 November 2006 08:04  |
Eclipse User |
|
|
|
Ulrich,
CTableTreeItems extend from widget and therefore you can use the
setData() methods to attach arbitrary data. They also have an update()
method which will call update() on each of their cells. The cell's
update method will grab the item's data (using item.getData() - see
CContainerCell.update()) and then call the cell's update(element,
properties) method - depending on your use case, your custom cell can
override one or both of its update methods to handle changes to the
data. You do have to call update() on the item yourself, because there
is no way of knowing what your cells need to react to (they are, after
all, custom).
createTitleContents should not be setting data, only creating the
contents of the title area - similar to creating any widget in SWT:
Label lbl = new Label(parent, style);
lbl.setText("some text");
it is two separate steps (and it's probably best to have a layout happen
before setting the text as well...).
There are two ways to go from here - 1. force the createTitleContents to
happen at cell creation so that it will be ready whenever update is
called; or 2. have update check to see if the cell is ready and abort if
it is not (this allows lazy creation of heavy weight objects).
That being said, I wasn't clear from your code why CTableTree is being
used - what do you need to do that isn't possible in a standard SWT Tree
w/columns?
cheers,
jeremy
Ulrich Binder wrote:
> hi group,
>
> i am having some trouble figuring out how i should talk to my custom cell.
> since the cells are passed over as class array, i never get to the actual
> objects to attach some data (or set them as listeners or something like
> that).
>
> i have all the data i need in the class that creates the tabletree. the
> custom cell needs access to this data when its created (to display the
> data) and when the custom cell is changed (to update the data).
>
> how should i pass the data to the custom cell?
> i dont have access to the object directly. usually i'd use the
> widget.setData(string, object) method to attach some arbitrary data, which
> in this case aint possible either, since createTitleContents() is called
> upon object creation, which is before i am able to attach any data to the
> CTableTreeItem.
>
> in an older thread (variable CTableTreeCell) which i think discusses a
> similar problem, Jeremy Dowdall said that update() should be used to delay
> the contentcreation, but neither of the update-methods ever gets called.
> or am i supposed to (get them) call(ed) manually ?
>
> Here is a simple example of what i mean:
> TableTreeTest contains the data i want to be displayed (and updated) and
> TextCell contains the Text-field where it should be displayed. The problem
> now is: get the data to TextCell.createTitleContents :)
> http://rapidshare.com/files/3723562/TableTreeTest.zip.html (1.2kb, zip)
>
> thanks,
> Ulrich.
>
> any help is appreciated.
|
|
|
Re: CTableTree - communicating with custom cell [message #568764 is a reply to message #16892] |
Mon, 20 November 2006 08:04  |
Eclipse User |
|
|
|
Ulrich,
CTableTreeItems extend from widget and therefore you can use the
setData() methods to attach arbitrary data. They also have an update()
method which will call update() on each of their cells. The cell's
update method will grab the item's data (using item.getData() - see
CContainerCell.update()) and then call the cell's update(element,
properties) method - depending on your use case, your custom cell can
override one or both of its update methods to handle changes to the
data. You do have to call update() on the item yourself, because there
is no way of knowing what your cells need to react to (they are, after
all, custom).
createTitleContents should not be setting data, only creating the
contents of the title area - similar to creating any widget in SWT:
Label lbl = new Label(parent, style);
lbl.setText("some text");
it is two separate steps (and it's probably best to have a layout happen
before setting the text as well...).
There are two ways to go from here - 1. force the createTitleContents to
happen at cell creation so that it will be ready whenever update is
called; or 2. have update check to see if the cell is ready and abort if
it is not (this allows lazy creation of heavy weight objects).
That being said, I wasn't clear from your code why CTableTree is being
used - what do you need to do that isn't possible in a standard SWT Tree
w/columns?
cheers,
jeremy
Ulrich Binder wrote:
> hi group,
>
> i am having some trouble figuring out how i should talk to my custom cell.
> since the cells are passed over as class array, i never get to the actual
> objects to attach some data (or set them as listeners or something like
> that).
>
> i have all the data i need in the class that creates the tabletree. the
> custom cell needs access to this data when its created (to display the
> data) and when the custom cell is changed (to update the data).
>
> how should i pass the data to the custom cell?
> i dont have access to the object directly. usually i'd use the
> widget.setData(string, object) method to attach some arbitrary data, which
> in this case aint possible either, since createTitleContents() is called
> upon object creation, which is before i am able to attach any data to the
> CTableTreeItem.
>
> in an older thread (variable CTableTreeCell) which i think discusses a
> similar problem, Jeremy Dowdall said that update() should be used to delay
> the contentcreation, but neither of the update-methods ever gets called.
> or am i supposed to (get them) call(ed) manually ?
>
> Here is a simple example of what i mean:
> TableTreeTest contains the data i want to be displayed (and updated) and
> TextCell contains the Text-field where it should be displayed. The problem
> now is: get the data to TextCell.createTitleContents :)
> http://rapidshare.com/files/3723562/TableTreeTest.zip.html (1.2kb, zip)
>
> thanks,
> Ulrich.
>
> any help is appreciated.
|
|
|
Goto Forum:
Current Time: Thu Jul 10 08:05:59 EDT 2025
Powered by FUDForum. Page generated in 0.09375 seconds
|