Bug 270174 - [Wizards] Wizard's 'Finish' button is misaligned if there are multiple pages and it cannot be finished early
Summary: [Wizards] Wizard's 'Finish' button is misaligned if there are multiple pages ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Remy Suen CLA
QA Contact: Boris Bokowski CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-26 15:56 EDT by Remy Suen CLA
Modified: 2009-04-28 10:30 EDT (History)
1 user (show)

See Also:


Attachments
Patch to modify createButtonsForButtonBar and test additions (8.57 KB, patch)
2009-03-27 09:13 EDT, Remy Suen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2009-03-26 15:56:14 EDT
Build id: I20090325-1135

1. File > New > Other...
2. See that the 'Finish' button is at the end of the button bar.
3. Window > Preferences > Java > Installed JREs
4. Click the 'Add...' button.
5. See that the 'Finish' button is not the last button.
6. Close the dialog.
7. Select an existing JRE.
8. Click 'Edit...'.
9. See that the 'Finish' button is at the end of the button bar.

I snooped around the code but couldn't quite figure out what was wrong. :o
Comment 1 Remy Suen CLA 2009-03-26 23:15:05 EDT
It seems that the 'Next' button being enabled right off the bat is the cause behind this bug. The button is disabled when using wizards the "usual way" because we expect the user to choose a wizard before letting them select a page (or some other action such as filling in a project name).

I presume this is a problem on Macs as well?

Thread [main] (Suspended)	
	Shell(Decorations).setDefaultButton(Button) line: 534	
	WizardDialog.updateButtons() line: 1256	
	WizardDialog.update() line: 1234	
	WizardDialog.showStartingPage() line: 1191	
	WizardDialog.createContents(Composite) line: 545	
	WizardDialog(Window).create() line: 431	
	WizardDialog(Dialog).create() line: 1088	
	WizardDialog(Window).open() line: 790	
	InstalledJREsBlock.addVM() line: 568	
	InstalledJREsBlock.access$10(InstalledJREsBlock) line: 565	
	InstalledJREsBlock$8.handleEvent(Event) line: 324	
	EventTable.sendEvent(Event) line: 84	
	Button(Widget).sendEvent(Event) line: 1161	
	Display.runDeferredEvents() line: 3480	
	Display.readAndDispatch() line: 3099	
	WorkbenchPreferenceDialog(Window).runEventLoop(Shell) line: 825	
	WorkbenchPreferenceDialog(Window).open() line: 801	
	OpenPreferencesAction.run() line: 65	
	OpenPreferencesAction(Action).runWithEvent(Event) line: 498	
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 584	
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 501	
	ActionContributionItem$5.handleEvent(Event) line: 411	
Comment 2 Remy Suen CLA 2009-03-26 23:33:27 EDT
Pure JFace code to reproduce the problem.

public static void main(String[] args) {
	Display display = new Display();
	IWizard wizard = new Wizard() {
		public void addPages() {
			addPage(new WizardPageImpl());
			addPage(new WizardPageImpl());
		}

		public boolean performFinish() {
			return false;
		}

		public boolean canFinish() {
			return false;
		}
	};
	new WizardDialog(null, wizard).open();
	display.dispose();
}

static class WizardPageImpl extends WizardPage {

	WizardPageImpl() {
		super(WizardPageImpl.class.getName());
	}

	public void createControl(Composite parent) {
		setControl(parent);
	}

}
Comment 3 Remy Suen CLA 2009-03-26 23:57:32 EDT
I'm not sure how to get around this off-hand outside of doing something like attachment 108401 [details].
Comment 4 Markus Keller CLA 2009-03-27 06:58:25 EDT
> I'm not sure how to get around this off-hand outside of doing something like
> attachment 108401 [details].

That approach looks good to me. Since WizardDialog#createPreviousAndNextButtons(..) creates an additional Composite for the '< Back' and 'Next >' buttons, the special code for Mac and GTK in Dialog#initializeBounds() effectively becomes a no-op in this scenario.

To avoid duplicating the button creation code, you could also do it like in OpenResourceDialog, i.e. add this to the end of WizardDialog#createButtonsForButtonBar(Composite):

	if (finishButton.getDisplay().getDismissalAlignment() == SWT.RIGHT) {
		// Make the default button the right-most button.
		// See also special code in org.eclipse.jface.dialogs.Dialog#initializeBounds()
		finishButton.moveBelow(null);
	}

To solve this more generally, JFace would need to introduce another concept of a default button, which would only be used to determine the button to be moved to the right, regardless of the Shell's default button.

But since the current approach of moving the Shell's default button works fine in most cases, I think it's OK to just fix problems like this where they show up.
Comment 5 Remy Suen CLA 2009-03-27 09:13:03 EDT
Created attachment 130102 [details]
Patch to modify createButtonsForButtonBar and test additions

(In reply to comment #4)
> To avoid duplicating the button creation code, you could also do it like in
> OpenResourceDialog, i.e. add this to the end of
> WizardDialog#createButtonsForButtonBar(Composite):

Yes, I was planning to do that (if it came down to fixing it this way anyway).
Comment 6 Boris Bokowski CLA 2009-03-30 14:10:57 EDT
Do you need more feedback on your patch, Remy?
Comment 7 Remy Suen CLA 2009-03-30 14:28:04 EDT
(In reply to comment #6)
> Do you need more feedback on your patch, Remy?

No, I think we are good here. I will look into getting this in for M7.
Comment 8 Remy Suen CLA 2009-04-17 09:09:44 EDT
Fix released to >20090414.
Comment 9 Remy Suen CLA 2009-04-17 10:36:21 EDT
(In reply to comment #8)
> Fix released to >20090414.

Er...that should be >20090417. :O
Comment 10 Remy Suen CLA 2009-04-28 10:30:31 EDT
Verified on I20090428-0100. Tests appear to have been added properly and being run also.