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

Bug 482697

Summary: PreferencePage: adding new buttons (contributeButtons()) breaks the layout
Product: [Eclipse Project] Platform Reporter: Andrei Diaconu <andi_dm1>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: bsd
Version: 4.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andrei Diaconu CLA 2015-11-20 09:15:04 EST
Javadoc of contributeButtons(Composite parent) states:

For each button a subclass contributes, it must also increase the parent's grid layout number of columns by one; that is,
((GridLayout) parent.getLayout()).numColumns++);

And it used to work in older versions. Now, in v4.5.1, I see the following code in createControl(Composite parent), after calling contributeButtons(Composite parent):

layout.numColumns = 1 + (createApplyButton && createDefaultButton ? 1 : 0);


So the number of columns will be 0 or 1, no matter how many other buttons have been added, and how many times the GridLayou.numColumn field has been incremented.

A fix would be to replace = with +=.

I marked the severity as major because existing code that used to work well now produces undesired effect.
Comment 1 Brian de Alwis CLA 2015-11-24 10:39:05 EST
This was fixed in master; I'll request a backport to 4.5.2.

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