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

Bug 552514

Summary: [10.15] Some categories in tree not displaying in PreferenceDialog on MacOS 10.15
Product: [Eclipse Project] Platform Reporter: Phil Beauvoir <p.beauvoir>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED DUPLICATE QA Contact: Sravan Kumar Lakkimsetti <sravankumarl>
Severity: normal    
Priority: P3 CC: a.nesheret, Lars.Vogel, lshanmug, peter, ts-swt
Version: 4.13   
Target Milestone: 4.15 M3   
Hardware: Macintosh   
OS: Mac OS X   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=558584
Whiteboard:
Bug Depends on:    
Bug Blocks: 553808    

Description Phil Beauvoir CLA 2019-10-29 07:34:32 EDT
Eclipse 4.13
MacOS 10.15

Steps to reproduce:

1. Open Preferences dialog
2. Select the "Java" category on the left.
3. Close Preferences dialog
4. Re-open Preferences dialog

All categories above "Java" are no longer visible.

Workaround: type something in the search box and then clear it.
Comment 1 Lars Vogel CLA 2019-10-29 07:40:50 EDT
Could you provide a Gerrit?
Comment 2 Phil Beauvoir CLA 2019-10-29 07:43:02 EDT
(In reply to Lars Vogel from comment #1)
> Could you provide a Gerrit?

Lars, I can certainly take a look into the issue but I won't be able to look at it for a couple of weeks.
Comment 3 Phil Beauvoir CLA 2019-10-29 08:04:03 EDT
The workaround is, in fact, simpler:

- Resize the dialog window

This gives us a clue. Perhaps PreferenceDialog#layoutTreeAreaControl() is the culprit?

(Will investigate further and provide a Gerrit if I can)
Comment 4 Phil Beauvoir CLA 2019-10-29 12:28:28 EDT
After some time investigating I've found a workaround or fix in org.eclipse.jface.preference.PreferenceDialog:

protected void layoutTreeAreaControl(Control control) {
    GridDataFactory.fillDefaults().hint(getLastRightWidth(), convertVerticalDLUsToPixels(120)).grab(false, true)
				.applyTo(control);

    // Workaround for 552514
    control.getParent().layout(true);
}

But these are the issues I'm facing:

1. I don't know if this is a proper fix or a workaround. The root cause may lie elsewhere.

2. I want to surround that line of code with a call to Platform.getOS() and to check that we're on Mac OS and that the OS version number >= 10.15 but the bundle doesn't import org.eclipse.core.runtime so I can't do that.
Comment 5 Lars Vogel CLA 2019-10-29 12:48:54 EDT
Layout calls are bad. Does requestLayout() also work?
Comment 6 Phil Beauvoir CLA 2019-10-29 13:10:56 EDT
(In reply to Lars Vogel from comment #5)
> Layout calls are bad. Does requestLayout() also work?

No.

The problem also occurs in org.eclipse.ui.internal.dialogs.PropertyDialog so I now need to look in org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog
Comment 7 Phil Beauvoir CLA 2019-10-29 13:26:57 EDT
(In reply to Phil Beauvoir from comment #6)
> The problem also occurs in org.eclipse.ui.internal.dialogs.PropertyDialog so
> I now need to look in
> org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog

Actually the workaround also works for org.eclipse.ui.internal.dialogs.PropertyDialog so nothing to do with FilteredPreferenceDialog
Comment 8 Phil Beauvoir CLA 2019-10-29 13:59:27 EDT
I think the underlying issue is when a tree node is selected when opening the dialog.

Mac seems to differ on the order of UI events in some cases.

When the dialog is opened and the last selected tree node is reselected this is called in PreferenceDialog#selectSavedItem():


getTreeViewer().setSelection(new StructuredSelection(node), true);
getTreeViewer().getControl().setFocus();

If we call these two lines in a Display.asyncExec() runnable block then the tree nodes are all correctly displayed. However, this breaks other code that puts the focus on the search text box in FilteredPreferenceDialog#selectSavedItem()

I don't have a solution to this other than the workaround above.
Comment 9 Phil Beauvoir CLA 2019-10-30 05:38:10 EDT
(In reply to Lars Vogel from comment #5)
> Layout calls are bad. Does requestLayout() also work?

This also works:

control.getParent().pack();

pack() eventually calls this:

setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, true));
Comment 10 Lars Vogel CLA 2019-10-30 05:49:14 EDT
(In reply to Phil Beauvoir from comment #0)
> Eclipse 4.13
> MacOS 10.15
> 
> Steps to reproduce:
> 
> 1. Open Preferences dialog
> 2. Select the "Java" category on the left.
> 3. Close Preferences dialog
> 4. Re-open Preferences dialog
> 
> All categories above "Java" are no longer visible.

Can't reproduce under Linux therefore it looks like an SWT Mac problem. 
Moving to SWT. 

Phil, are you able to reproduce this with a SWT snippet?
Comment 11 Phil Beauvoir CLA 2019-10-30 05:53:36 EDT
Lars, I don't think this is an SWT issue. It's to do with the order of selecting a tree node and then laying out the tree and parent composite. This is only occurring in the Preferences dialog.

(You won't be able to reproduce it under Windows, either.)

In my experience, these types of issues are caused by the order of some events being different on Mac.
Comment 12 Phil Beauvoir CLA 2019-10-30 06:09:52 EDT
I tested with a modified snippet (https://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet002TreeViewer.java) that simply selects the nth node in the SWT Tree and could not reproduce this issue.

Therefore, I think this issue is unique to PreferencesDialog and the order of creating the Tree, laying out and selecting a node in MacOS 10.15.

Another example of this type of Mac issue can be found here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=545279
Comment 13 Lakshmi P Shanmugam CLA 2020-02-03 01:24:09 EST
Fix for Bug 558584 fixes the Preferences dialog as well.

*** This bug has been marked as a duplicate of bug 558584 ***