Bug 288830 - Exporting project Ant build file behaves strangely
Summary: Exporting project Ant build file behaves strangely
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Richard . CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-09-08 10:31 EDT by Michael Rennie CLA
Modified: 2011-10-28 11:49 EDT (History)
1 user (show)

See Also:


Attachments
Fixed sources: AntBuildfileExportPage.java, ExportUtil.java (10.17 KB, application/zip)
2011-10-13 13:37 EDT, Richard . CLA
no flags Details
Fixed sources: AntBuildfileExportPage.java, ExportUtil.java, DataTransferMessages.properties (11.61 KB, application/zip)
2011-10-18 07:46 EDT, Richard . CLA
no flags Details
patch (6.81 KB, patch)
2011-10-19 12:13 EDT, Michael Rennie CLA
Michael_Rennie: iplog+
Michael_Rennie: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2009-09-08 10:31:51 EDT
I20090901-0800

Testing the patch for bug 203522 I found:

1. that if you select a project in the wizard that already has a build file (build.xml) in it, the prompt you get does not have a question mark as part of its punctuation.

2. once you press the finish button you get the same prompt as in 1. - even though you saw it when you selected the project.

Steps:

1. create a build.xml file in a project
2. open the wizard to generate the buildfile for the project - you get the prompt mentioned when you check it
3. press the finish button - you get prompted again

if you happen to press cancel on the second prompt (when you have pressed finish) you get the following error:

java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:477)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:944)
	at org.eclipse.ant.internal.ui.datatransfer.AntBuildfileExportPage.generateBuildfiles(AntBuildfileExportPage.java:339)
	at org.eclipse.ant.internal.ui.datatransfer.AntBuildfileExportWizard.performFinish(AntBuildfileExportWizard.java:36)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:752)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3885)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3478)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ui.internal.handlers.WizardHandler$Export.executeHandler(WizardHandler.java:97)
	at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:273)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
	at org.eclipse.ui.internal.actions.CommandAction.run(CommandAction.java:171)
	at org.eclipse.ui.actions.ExportResourcesAction.run(ExportResourcesAction.java:116)
	at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3885)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3478)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:367)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:610)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:565)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1362)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1338)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:546)
	at java.util.ArrayList.get(ArrayList.java:321)
	at org.eclipse.ant.internal.ui.datatransfer.ExportUtil.validateEdit(ExportUtil.java:638)
	at org.eclipse.ant.internal.ui.datatransfer.BuildFileCreator.createBuildFilesLoop(BuildFileCreator.java:157)
	at org.eclipse.ant.internal.ui.datatransfer.BuildFileCreator.createBuildFiles(BuildFileCreator.java:133)
	at org.eclipse.ant.internal.ui.datatransfer.AntBuildfileExportPage$6.run(AntBuildfileExportPage.java:316)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
	... 53 more
Comment 1 Richard . CLA 2011-10-13 13:37:21 EDT
Created attachment 205146 [details]
Fixed sources: AntBuildfileExportPage.java, ExportUtil.java

You are right:
1. The confirmation dialog opens twice.
2. Pressing cancel results in an IndexOutOfBoundsException for an empty list.

The attachment fixes both. Thanks for finding this bug.
Comment 2 Michael Rennie CLA 2011-10-17 15:32:25 EDT
(In reply to comment #1)
> Created attachment 205146 [details]
> Fixed sources: AntBuildfileExportPage.java, ExportUtil.java
> 
> You are right:
> 1. The confirmation dialog opens twice.
> 2. Pressing cancel results in an IndexOutOfBoundsException for an empty list.
> 
> The attachment fixes both. Thanks for finding this bug.

Still no question mark in the confirmation dialog and the wording is a bit awkward - I would suggest something like:

"Overwrite Buildfiles?" for the title, and
"Are you sure you want to overwrite the build.xml buildfiles for the selected projects?" (or similar) for the dialog message.

I would also expect the dialog to be Yes/No since it asks you a question, with 'No' letting me go back to the wizard and make a different selection.
Comment 3 Richard . CLA 2011-10-18 07:46:42 EDT
Created attachment 205415 [details]
Fixed sources: AntBuildfileExportPage.java, ExportUtil.java, DataTransferMessages.properties

> Still no question mark in the confirmation dialog and the wording is a bit
> awkward - I would suggest something like:
>
> "Overwrite Buildfiles?" for the title, and
> "Are you sure you want to overwrite the build.xml buildfiles for the selected
> projects?" (or similar) for the dialog message.

OK, but:
1. The filename 'build.xml' is configurable.
2. 'selected projects' is not always correct. It could be a file of a project dependency. Therefore the dialog box shows a project list.

Conclusion:
AntBuildfileExportPage_3=Are you sure you want to overwrite the buildfiles for these projects?
AntBuildfileExportPage_4=Overwrite Buildfiles?

I hope this is not against the Eclipse standards.

> I would also expect the dialog to be Yes/No since it asks you a question, with
> 'No' letting me go back to the wizard and make a different selection.

I changed it from openConfirm() to openQuestion().
NOTE: 'Cancel' triggered an exception, therefore the export wizard was not closed. To preserve this behavior without an exception I had to add an if statement.
Comment 4 Michael Rennie CLA 2011-10-19 12:13:10 EDT
Created attachment 205546 [details]
patch

patch from the attached source files.
Comment 5 Michael Rennie CLA 2011-10-19 12:15:46 EDT
The changes look good - pushed to master.

Thanks Richard.
Comment 6 Michael Rennie CLA 2011-10-28 11:49:11 EDT
verified in I20111027-1800