Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to implement get/setGrayed method with TreeViewer and ContentProviders
How to implement get/setGrayed method with TreeViewer and ContentProviders [message #268568] Wed, 25 August 2004 04:25 Go to next message
Eclipse UserFriend
Originally posted by: thomas.hollfelder.XXXX.de

Hi,

I have a view with a tree (TreeViewer) and added a ViewContentProvider
which returns my
Objects and a LabelProvider which returns the labels for the objects.
As I work with a CheckBoxTreeViewer I want also implement the "checked" and
"grayed" things, but I don't know how? I see that I can implement a
ICheckable interface, but there is no IGrayable.
Who must provide the grayed and checked information? I think the
ViewContentProvider, but how? or must I return my Objects wrapped in
TreeItems?

Help Appreciated.

Thanks
Thomas
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #268728 is a reply to message #268568] Wed, 25 August 2004 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tod_creasey.oti.com

> Who must provide the grayed and checked information? I think the
> ViewContentProvider, but how? or must I return my Objects wrapped in
> TreeItems?

The interface already handles setGrayed - I'm not sure what you need. The
grayed elements are already kep by this viewer so that you do not need to
manage them. If you need to manage them yourself for some reason this viewer
may not be for you.

Tod Creasey
Platform UI Team
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #269011 is a reply to message #268728] Fri, 27 August 2004 10:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thomas.hollfelder.XXXX.de

"Tod Creasey" <tod_creasey@oti.com> wrote in
news:cgip98$m87$1@eclipse.org:

>
>> Who must provide the grayed and checked information? I think the
>> ViewContentProvider, but how? or must I return my Objects wrapped in
>> TreeItems?
>
> The interface already handles setGrayed - I'm not sure what you need.
> The grayed elements are already kep by this viewer so that you do not
> need to manage them. If you need to manage them yourself for some
> reason this viewer may not be for you.
>
> Tod Creasey
> Platform UI Team
>
>
>

My Idea was, the viewer knows from the object (from the ContentProvider) if
it needs to be gray or checked and if a TreeItem is grayed or checked , the
object sets its Properties according. The Application should work similar
to the include-to-build-editor in the plugin-manifest-editor and I had a
look in the sources how that was done.

Thanks,

Thomas
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #269510 is a reply to message #268728] Tue, 31 August 2004 10:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michael.simons.uniopt.net

Am Wed, 25 Aug 2004 15:31:45 -0400 schrieb Tod Creasey
<tod_creasey@oti.com>:

>
>> Who must provide the grayed and checked information? I think the
>> ViewContentProvider, but how? or must I return my Objects wrapped in
>> TreeItems?
>
> The interface already handles setGrayed - I'm not sure what you need. The
> grayed elements are already kep by this viewer so that you do not need to
> manage them. If you need to manage them yourself for some reason this
> viewer
> may not be for you.
>
> Tod Creasey
> Platform UI Team
>
>

Hello Tod,

please, can You tell me how to achieve this handling of grayed/checked?
I have a CkeckboxTreeViewer based on a Tree (SWT.CHECK). When the tree is
displayed and I check an item no sub-/parent-item is checked/grayed.
Do I have to handle that by an ICheckboxStateListener?
I have to set some of the items checked according to the status of the
underlying element. I thought
ITreeViewerListener.treeExpanded(TreeExpansionEvent) to be a good place to
handle this, but this method is not called when the tree is constructed
(according to the value of setAutoExpandLevel(int).
Can You tell me, where's the best place to handle this? In the method
where the TreeViewer is created and its input is set, I don't know
anything of the model except the input.

You see, I'm absolutely confused and appreciate any help,
Michael
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #269545 is a reply to message #269510] Tue, 31 August 2004 11:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thomas.hollfelder.XXXX.de

michael <michael.simons@uniopt.net> wrote in
news:opsdlordzy1t3rh7@news.eclipse.org:

> Hello Tod,
>
> please, can You tell me how to achieve this handling of
> grayed/checked? I have a CkeckboxTreeViewer based on a Tree
> (SWT.CHECK). When the tree is displayed and I check an item no
> sub-/parent-item is checked/grayed. Do I have to handle that by an
> ICheckboxStateListener? I have to set some of the items checked
> according to the status of the underlying element. I thought
> ITreeViewerListener.treeExpanded(TreeExpansionEvent) to be a good
> place to handle this, but this method is not called when the tree is
> constructed (according to the value of setAutoExpandLevel(int).
> Can You tell me, where's the best place to handle this? In the method
> where the TreeViewer is created and its input is set, I don't know
> anything of the model except the input.
>
> You see, I'm absolutely confused and appreciate any help,
> Michael
>

Hi Michael,

this is exact what I needed. I solved it that way:

I added a ITreeViewerListener to the viewer and in treeExpanded() I
initialized the tree based on the state of the elements. And I added a
CheckStateListener to the viewer that sets the state of my elements and
synchronized the state of the treeitems with the state of the elements.
Its tricky but it works. It's some kind of back and forth between the
treeitems and the underlying objects.

Thomas
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #269551 is a reply to message #269545] Tue, 31 August 2004 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michael.simons.uniopt.net

Am Tue, 31 Aug 2004 15:30:48 +0000 (UTC) schrieb Hollfelder
<thomas.hollfelder@XXXX.de>:

> michael <michael.simons@uniopt.net> wrote in
> news:opsdlordzy1t3rh7@news.eclipse.org:
>
>> Hello Tod,
>>
>> please, can You tell me how to achieve this handling of
>> grayed/checked? I have a CkeckboxTreeViewer based on a Tree
>> (SWT.CHECK). When the tree is displayed and I check an item no
>> sub-/parent-item is checked/grayed. Do I have to handle that by an
>> ICheckboxStateListener? I have to set some of the items checked
>> according to the status of the underlying element. I thought
>> ITreeViewerListener.treeExpanded(TreeExpansionEvent) to be a good
>> place to handle this, but this method is not called when the tree is
>> constructed (according to the value of setAutoExpandLevel(int).
>> Can You tell me, where's the best place to handle this? In the method
>> where the TreeViewer is created and its input is set, I don't know
>> anything of the model except the input.
>>
>> You see, I'm absolutely confused and appreciate any help,
>> Michael
>>
>
> Hi Michael,
>
> this is exact what I needed. I solved it that way:
>
> I added a ITreeViewerListener to the viewer and in treeExpanded() I
> initialized the tree based on the state of the elements. And I added a
> CheckStateListener to the viewer that sets the state of my elements and
> synchronized the state of the treeitems with the state of the elements.
> Its tricky but it works. It's some kind of back and forth between the
> treeitems and the underlying objects.
>
> Thomas
>

Hi Thomas,

first of all thanks a lot for replying that fast. I almost believed that I
completely misunderstood the whole thing.

I also tried to initialize the checkboxes in the treeExpanded() method but
that seems not sufficient because treeExpanded() is not called when the
tree is constructed (on the setInput() call). How did you solve that?

Do You agree with me when I say it would be much easier when the
CheckboxTreeViewer had it's own extended ILabelProvider (extended by a
method like "int getCheckedState (Object element)" returning 0,1,2 or 3
for normal, checked, grayed, checked+grayed)?

After all it seems like I'm not completely off the track.

Michael
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #269644 is a reply to message #269551] Wed, 01 September 2004 03:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thomas.hollfelder.XXXX.de

michael <michael.simons@uniopt.net> wrote in
news:opsdls7wji1t3rh7@news.eclipse.org:
> Hi Thomas,
>
> first of all thanks a lot for replying that fast. I almost believed
> that I completely misunderstood the whole thing.
>
> I also tried to initialize the checkboxes in the treeExpanded() method
> but that seems not sufficient because treeExpanded() is not called
> when the tree is constructed (on the setInput() call). How did you
> solve that?

I have a method initializeTree() which sets the checks and greys in the
tree based on the underlying objects. I call this method in
createPartControl() after setInput() and again every time in the
treeExpanded().

>
> Do You agree with me when I say it would be much easier when the
> CheckboxTreeViewer had it's own extended ILabelProvider (extended by a
> method like "int getCheckedState (Object element)" returning 0,1,2 or
> 3 for normal, checked, grayed, checked+grayed)?

I was looking for that the whole time because I saw, content is coming
so easy to the tree, labels too, so there must be a way to connect the
state of the objects with the tree items state.

>
> After all it seems like I'm not completely off the track.

No I don't think so. But I think you are like myself still at the
beginning, and it's not always fun to get into new complex matter.

Cheers

Thomas
Re: How to implement get/setGrayed method with TreeViewer and ContentProviders [message #269654 is a reply to message #269644] Wed, 01 September 2004 06:22 Go to previous message
Eclipse UserFriend
Originally posted by: michael.simons.uniopt.net

Am Wed, 1 Sep 2004 07:13:31 +0000 (UTC) schrieb Hollfelder
<thomas.hollfelder@XXXX.de>:

> michael <michael.simons@uniopt.net> wrote in
> news:opsdls7wji1t3rh7@news.eclipse.org:
>> Hi Thomas,
>>
>> first of all thanks a lot for replying that fast. I almost believed
>> that I completely misunderstood the whole thing.
>>
>> I also tried to initialize the checkboxes in the treeExpanded() method
>> but that seems not sufficient because treeExpanded() is not called
>> when the tree is constructed (on the setInput() call). How did you
>> solve that?
>
> I have a method initializeTree() which sets the checks and greys in the
> tree based on the underlying objects. I call this method in
> createPartControl() after setInput() and again every time in the
> treeExpanded().
>
>>
>> Do You agree with me when I say it would be much easier when the
>> CheckboxTreeViewer had it's own extended ILabelProvider (extended by a
>> method like "int getCheckedState (Object element)" returning 0,1,2 or
>> 3 for normal, checked, grayed, checked+grayed)?
>
> I was looking for that the whole time because I saw, content is coming
> so easy to the tree, labels too, so there must be a way to connect the
> state of the objects with the tree items state.
>
>>
>> After all it seems like I'm not completely off the track.
>
> No I don't think so. But I think you are like myself still at the
> beginning, and it's not always fun to get into new complex matter.
>
> Cheers
>
> Thomas


I get it up and running now in the same way that you mentioned.
Thanks a lot for your help,
Michael
Previous Topic:[RCP] Bug in splash screen support?
Next Topic:Dynamic workbench menu
Goto Forum:
  


Current Time: Thu Jul 10 02:08:22 EDT 2025

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

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

Back to the top