[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-ui-dev] question about ITreeContentProvider
|
Thank you Nick, you answered my question.
Maybe I should provide a wrapper for the DAG to get all the tree functions to work
jml
----- Original Message -----
From: "Nick Edgar" <Nick_Edgar@xxxxxxx>
To: <platform-ui-dev@xxxxxxxxxxx>
Sent: Thursday, October 17, 2002 9:34 PM
Subject: Re: [platform-ui-dev] question about ITreeContentProvider
> jml,
>
> ITreeContentProvider.getParent(Object) is used to find the parent for the
> given model element. This is used when you ask the viewer to do something
> to the element, but the viewer does not already know the element (tree
> viewers are lazily populated, so there is no corresponding TreeItem yet).
> Methods which use this include: reveal, setExpanded, expandToLevel, and
> setSelection.
>
> For example, in your tree structure below, if A had never been expanded,
> then the viewer would not know about elements B or C.
> If you ask it to reveal(C), then it has to call getParent(C) to determine
> which item(s) to expand and populate to show C. In this case, your
> content provider would return A, so the viewer would populate the children
> of A, then expand A to reveal C.
>
> Since you want to show a DAG, getParent can be one-to-many, so you can't
> always answer this question (i.e. for B, as you point out).
> It's OK to always return null for getParent, as long as you steer clear of
> using the methods above, or only use them on the elements that are known
> to the tree.
>
> Beware that having multiple equal elements in the tree can lead to other
> confusnig behaviour, since the viewers typically assume a 1-1 mapping
> between element and SWT item.
> For example, after expanding A and B if you ask the tree to select C,
> which item should it select? Currently it will select only the first one
> found.
>
> Hope this clarifies,
> Nick
>
>
>
>
>
> "jml" <jml@xxxxxxxx>
> Sent by: platform-ui-dev-admin@xxxxxxxxxxx
> 10/17/02 03:08 AM
> Please respond to platform-ui-dev
>
>
> To: <platform-ui-dev@xxxxxxxxxxx>
> cc:
> Subject: [platform-ui-dev] question about ITreeContentProvider
>
>
> Hi, all
>
> In ITreeContentProvider, there is a function as getParent(), is it
> necessary?
> I have a data structure, which is a directed no-cycle graph.
> For example, it has A,B,C, and A->B, A->C and B->C
>
> Now I want to show it as a tree, as
>
> A
> -B
> -C
> -C
>
> and I want to just write a ITreeContentProvider to do that.
>
> All other thing are very easy and straightforward, but the getParent().
> Since now when the parameter for getParent() is C, I don't know what to
> return.
>
> I tried just return null in getParent(), and the tree can be displayed. So
> come my question, is getParent() necessary? Where does it be used in the
> current system? Also, I would think the underlying TreeItem implementation
> must already remember the parent relationship in it.
>
> Thanks
>
> jml
>
>
> _______________________________________________
> platform-ui-dev mailing list
> platform-ui-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ui-dev