Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 17907

Summary: [Viewers] ContainerCheckedTreeViewer: incorrect preservingSelection
Product: [Eclipse Project] Platform Reporter: Martin Aeschlimann <martinae>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: mirek.begier, n.a.edgar, philippe_mulet, wuppiwuppi, wuut
Version: 2.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug
Attachments:
Description Flags
updated ContainerCheckedTreeViewer none

Description Martin Aeschlimann CLA 2002-05-27 05:43:11 EDT
20020521

1. Open the override methods dialog. Uncheck 'Group methods by types'
2. Select a method. Uncheck 'Group methods by types'
3. The type containing the selected method should be check & grayed.

I think ContainerCheckedTreeViewer should override 'preservingSelection' and 
update the parent items of all checked items. (updateParentItems)

It's also possible that the client code does this when doing a refresh.
If you prefer this solution please move PR to me.
Comment 1 Nick Edgar CLA 2002-05-27 20:55:26 EDT
Martin, would you mind either doing this in client code, or attaching a 
revised ContainerCheckedTreeViewer?

Thanks
Comment 2 Martin Aeschlimann CLA 2002-05-28 04:56:08 EDT
Created attachment 1083 [details]
updated ContainerCheckedTreeViewer
Comment 3 Martin Aeschlimann CLA 2002-09-18 07:30:27 EDT
*** Bug 22033 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Irvine CLA 2002-09-24 10:38:19 EDT
The attached code does not appear to work as expected.
On ContainerCheckedTreeViewer I did the steps as reported:

1/  Open Override Methods
2/  Unchecked the Group methods by type checkbox
3/  Select addHelpListener
4/  Check the Group methods by type checkbox

No entries appear greyed, nor is there a checkbox beside the viewer class.  The 
selection is not checked in the viewer class when I expand, nor is it selected 
whn I uncheck the methods by type checkbox a second time (the original 
configuration when I checked the box).

If I perform the same test with addTreeListener (public) checked then I believe 
I get the expected behaviour.  Checking both addTreeListener entries displays 
the behaviour I mentioned above.
Comment 5 Nick Edgar CLA 2003-02-09 23:01:09 EST
Not for 2.1.
Comment 6 Mirek Begier CLA 2006-04-17 17:12:43 EDT
I find this bug in ContainerCheckedTreeViewer class 
in method "updateParentItems(TreeItem item)" there is

item.setChecked(containsChecked);
item.setGrayed(containsChecked && containsUnchecked);

but should be:

if (containsChecked) {
    item.setChecked(true);
}
item.setGrayed(containsUnchecked);
Comment 7 Nick Edgar CLA 2006-04-17 17:32:56 EDT
Thanks for the suggestion, Mirek, but I think there are a couple of issues with it:
1. items are reused across different elements, so the checked state needs to be assigned each time
2. the invariants we want to maintain are:
  a) a container node should be white-checked if-and-only-if all children are checked
  b) a container node should be gray-checked if-and-only-if some but not all children are checked
  c) a container node should be unchecked if-and-only-if no children are checked
but
  item.setGrayed(containsUnchecked)
would incorrectly result in case c being gray.
Comment 8 Mirek Begier CLA 2006-04-17 17:46:53 EDT
I'm sory I have Eclipse 3.2 M6 but here is 2.0
And there(3.2M6) when I have a tree
vA-|
  vB-|
    vC
where "v" - means check option
and I want eg. unchecked C, now in (Eclipse 3.2 M6) I get
A-|
  B-|
    C
but result should be
gvA-|
   gvB-|
        C
where "gv" is grayed and chacked
 
Comment 9 Nick Edgar CLA 2006-04-18 09:53:24 EDT
That's correct if C has siblings.  If C is the only child of B, then B should be unchecked (and not gray), and likewise up the chain.
Comment 10 Mirek Begier CLA 2006-04-18 11:10:55 EDT
> That's correct if C has siblings.  If C is the only child of B, then B should
> be unchecked (and not gray), and likewise up the chain.
Ok,That's correct if tree show some options, but I want show eg. some directories, and don't want check sub directories.
Comment 11 Boris Bokowski CLA 2007-06-20 11:54:07 EDT
Is this still a problem?
Comment 12 Martin Aeschlimann CLA 2007-06-21 05:05:28 EDT
Yes, this is still no fixed.

In the override dialog, we added a workaround, by setting the checked elements again after refreshing.
Comment 13 Boris Bokowski CLA 2009-11-26 09:51:39 EST
Hitesh is now responsible for watching bugs in the [Viewers] component area.
Comment 14 Eclipse Genie CLA 2020-07-09 17:40:49 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.