Bug 562374

Summary: "Generate Getter and Setter" dialog does display grayed​ state incorrectly
Product: [Eclipse Project] Platform Reporter: Dieter Mai <maidieter>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: loskutov, michael.keppler
Version: 4.15Keywords: regression
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=539724
Whiteboard:
Attachments:
Description Flags
Observed O3
none
Expected E3
none
PossibleFix
none
PossibleFix2 none

Description Dieter Mai CLA 2020-04-21 16:01:43 EDT
Created attachment 282527 [details]
Observed O3

The Dialog "Generate Getter and Setter" displays a tree with the fields of a class as root elements it the getter and setter as leafs. If only one of the methods of a field has its checked, the checkbox of the field should be in its intermediate/grayed​ state. This does not always work.

How to reproduce

[Preconditions]
[P1] Have an java file open with fields that don't have any getters and setters.

[Actions]
[A1] Select the menu Source -> "Generate Getters and Setters..."
[A2] Press the button "Select All"
[A3] Press the button "Select Getters"

[Observed]
[O1] Dialog "Generate Getters and Setters" opens.
[O2] All entries for the fields and their methods are displayed as fully checked.
[O3a] All entries for the getters are displayed as fully checked.
[O3b] All entries for the setters are displayed as un-checked.
[O3c] [NOK] All entries for the fields are displayed as un-checked.

[Expected]
[O3c] All entries for the fields are displayed as grayed​.
Comment 1 Dieter Mai CLA 2020-04-21 16:02:56 EDT
Created attachment 282528 [details]
Expected E3
Comment 2 Dieter Mai CLA 2020-04-21 16:04:44 EDT
Tested on
Version: 2020-03 (4.15.0)
Build id: 20200313-1211
Windows 10

did not test any other versions/systems.
Comment 3 Dieter Mai CLA 2020-04-29 16:59:11 EDT
I had a look at the source code and determined that this is not a JDT issue but an issue with the class ContainerCheckedTreeViewer in org.eclipse.ui.workbench. Due to that i moved it to Product: Platform.

It seems like the issue was introduced with the performance improvements for ticket 539724. 
The changes in ContainerCheckedTreeViewer#setCheckedElements assumed that the method super.setCheckedElements(elements) would only check elements but in fact it also un-checks some.
Comment 4 Andrey Loskutov CLA 2020-04-29 17:02:38 EDT
Michael, could you please check this?
Comment 5 Dieter Mai CLA 2020-04-30 14:24:03 EDT
Created attachment 282638 [details]
PossibleFix

I testes some changes and come up with this
Comment 6 Dieter Mai CLA 2020-05-01 09:01:55 EDT
Created attachment 282649 [details]
PossibleFix2

some small small improvements