Project: Eclipse_Platform_UI
Bug 265159 [Import/Export] When user double clicks on an item in the Import Wizard 2 calls are made to showPage
Reported: 2009-02-17 09:12:03 | Status: verified fixed

Build ID: I20080617-2000 Steps To Reproduce: 1. Please see More Information for a discussion on how to reproduce - the fix is 1 line. 2. 3. More information: We register a Wizard with the importWizards extension point. When a user double clicks on the item in the import wizard tree 2 calls are made to showPage. This is general not an issue, however in our situation a lengthy calculation is performed before the first wizard page is displayed which we allow the user to cancel, if cancelled we return the user to the import wizard. General to achieve cancellation we would use a IPageChangingListener, however in this case, as it is the first wizard page it is not possible as we do not gain access to the page Container to register the listener with, until it is too late so instead within the pages setVisible method we register a IPageChangedListener if the operation is cancelled. Within its pageChanged method we call: getWizard().getContainer().showPage(getPreviousPage()); The above technique works fine if the user uses the Next button to advance to our wizard however if the user instead double clicks on the item in the tree we find are setVisible method is called twice. I have tracked the reason down to the following code in org.eclipse.ui.internal.dialogs.ImportExportPage.java protected void treeDoubleClicked(DoubleClickEvent event) { 233: ISelection selection = event.getViewer().getSelection(); 234: IStructuredSelection ss = (IStructuredSelection) selection; 235: listSelectionChanged(ss); 236: 237: Object element = ss.getFirstElement(); 238: TreeViewer v = (TreeViewer) event.getViewer(); 239: if (v.isExpandable(element)) { 240: v.setExpandedState(element, !v.getExpandedState(element)); 241: } else if (element instanceof WorkbenchWizardElement) { 242: if (canFlipToNextPage()) { 243: getContainer().showPage(getNextPage()); 244: } 245: } 246: getContainer().showPage(getNextPage()); 247: } It seems line 243 is being invoked and then line 246 both calling showPage The first few lines of showPage are public void showPage(IWizardPage page) { if (page == null || page == currentPage) { return; } Hence in the common case after the first call to showPage currentPage is set and when the second call comes in page == currentPage and no action is taken. However, if the first call to showPage causes the page to reverted to the import wizard page, in the second call page != currentPage. A simple one line fix to the problem would be to add a return statement after line 243.

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ImportExportPage.java