Project: Eclipse_Platform_UI
Bug 99840 [Preferences] PreferencePage not repainted when dialog container size equals page container size
Reported: 2005-06-13 17:33:36 | Status: verified fixed

I have a PreferenceDialog which creates 3 PreferencePage objects. When the PreferenceDialog is first displayed, the PreferencePage which is selected by default is displayed correctly. However, when I select the 3rd PreferencePage in the PreferenceDialog, the title changes, but the body is not shown. If I resize it, it is then displayed. I've also noticed that when I instead select the 2nd PreferencePage after the default PreferencePage is first shown, it is displayed correctly. Note that this is a regression from Eclipse 3.0 behavior of this PreferenceDialog I have stepped through PrefencePage.showPage() and have observed that the following code seems to be where the problem lies: Point contentSize = size[0]; // Do we need resizing. Computation not needed if the // first page is inserted since computing the dialog's // size is done by calling dialog.open(). // Also prevent auto resize if the user has manually resized Shell shell = getShell(); Point shellSize = shell.getSize(); if (oldPage != null) { Rectangle rect = pageContainer.getClientArea(); Point containerSize = new Point(rect.width, rect.height); int hdiff = contentSize.x - containerSize.x; int vdiff = contentSize.y - containerSize.y; if (hdiff > 0 || vdiff > 0) { if (shellSize.equals(lastShellSize)) { hdiff = Math.max(0, hdiff); vdiff = Math.max(0, vdiff); setShellSize(shellSize.x + hdiff, shellSize.y + vdiff); lastShellSize = shell.getSize(); if (currentPage.getControl().getSize().x == 0) currentPage.getControl().setSize(containerSize); } else { currentPage.setSize(containerSize); } } else if (hdiff < 0 || vdiff < 0) { currentPage.setSize(containerSize); } } The reason I believe this to be the problem area is because it is only when either a Control.setSize() or PreferencePage.setSize() is executed that the PreferencePage gets repainted. In my case, the PreferenceDialog container size and client area of the PreferencePage for both the 1st and 3rd pages are identical, such that setSize() does not get called. However, currentPage.getControl().setSize(containerSize) does get called when my 2nd PreferencePage is selected, since it has a slightly different container size than the other 2 pages.

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/preference/PreferenceDialog.java