Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Dear all,
Dear all, [message #274750] Thu, 28 October 2004 04:50 Go to next message
Eclipse UserFriend
Originally posted by: rsudra.hotmail.com

Dear all,

I am created a (Extended)TableTreeViewer which is initialised in the usual manner. The TableTree is really just a single column tree (but I wanted the option of other column's in the future) and I need to get the Y coord of the rows to align some GEF edit parts against (to simulate an MS Project like editor).

Based on some event, I ask the editor to given me a map of my model objects as supplied by TableTreeViewer.setInput() (remember that it is a single column) to coords (y only). The way I do this is the iterate over the TableItems:

Map objectToYMapping = new HashMap();
int column = 0;
TableItem[] tableItems = getTableTreeViewer().getTableTree().getTable().getItems();
for (int i = 0; i < tableItems.length; i++) {
// FIXME RS how the heck do I get the associated data object from the table item???
Object data = ((ExtendedTableTreeViewer.ExtendedTableTreeItem)tableItems[i ].getData( "TableTreeItemID")).getData();
LOG.debug("putting key=" + data + " , val=" + tableItems[i].getBounds(column).y);
objectToYMapping.put(data, new Integer(tableItems[i].getBounds(column).y));
}

As you can see by comment, I don't really understand how to get the model object out of the TableItem? It seems that the hacky way that I am doing it must be wrong. In particular the use of "TableTreeItemID" which is a package-private constant in TableTree and the use of (ExtendedTableTreeViewer.ExtendedTableTreeItem) which again is implementation knowledge for the type of underlying control used.

Any help would be great as although the above works, I want to understand how to use the API correctly. TIA & Regards,

Raj
Re: Dear all, [message #274848 is a reply to message #274750] Fri, 29 October 2004 11:30 Go to previous message
Eclipse UserFriend
The TreeViewer does not provide API for looking up an element from the item
in thie viewer. We store the element in the data but this is not specified
in the API.

You are best to manage your own model rather than reply on callbacks from
the SWT widget.

Tod Creasey
Platform UI Team
"Rajeev Sudra" <rsudra@hotmail.com> wrote in message
news:clqbrs$s9r$1@eclipse.org...
> Dear all,
>
> I am created a (Extended)TableTreeViewer which is initialised in the usual
manner. The TableTree is really just a single column tree (but I wanted the
option of other column's in the future) and I need to get the Y coord of the
rows to align some GEF edit parts against (to simulate an MS Project like
editor).
>
> Based on some event, I ask the editor to given me a map of my model
objects as supplied by TableTreeViewer.setInput() (remember that it is a
single column) to coords (y only). The way I do this is the iterate over the
TableItems:
>
> Map objectToYMapping = new HashMap();
> int column = 0;
> TableItem[] tableItems =
getTableTreeViewer().getTableTree().getTable().getItems();
> for (int i = 0; i < tableItems.length; i++) {
> // FIXME RS how the heck do I get the associated data object from the
table item???
> Object data =
((ExtendedTableTreeViewer.ExtendedTableTreeItem)tableItems[i ].getData( "Table
TreeItemID")).getData();
> LOG.debug("putting key=" + data + " , val=" +
tableItems[i].getBounds(column).y);
> objectToYMapping.put(data, new
Integer(tableItems[i].getBounds(column).y));
> }
>
> As you can see by comment, I don't really understand how to get the model
object out of the TableItem? It seems that the hacky way that I am doing it
must be wrong. In particular the use of "TableTreeItemID" which is a
package-private constant in TableTree and the use of
(ExtendedTableTreeViewer.ExtendedTableTreeItem) which again is
implementation knowledge for the type of underlying control used.
>
> Any help would be great as although the above works, I want to understand
how to use the API correctly. TIA & Regards,
>
> Raj
>
>
Previous Topic:Why doesn't my markers show in the Resource view?
Next Topic:Plugin platform dependency
Goto Forum:
  


Current Time: Sun May 11 23:32:01 EDT 2025

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

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

Back to the top