This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The TemplateWizard, which is launched from the File/New menu, exits when the Finish button is pressed even if an IOException has been thrown from a DataObject handleCreateFromTemplate(). The TemplateWizard should stay open to allow the user to correct the problem, which may be an illegal name. An example of this is Templates/Beans/Bean. If you enter an illegal name on the "New From Template - Target Location" dialog (screen 2 of the wizard), then click Finish, you get an IOException message, but the wizard closes. To correct the name you must launch the wizard again.
I think you can do something with IllegalArgumentException here instead? ...but not sure.
Please read this: http://www.netbeans.org/www-nbdev/msg03185.html IOException should happen only when e.g. you run the wizard and you add the file with same name from outside the ide, or someone unmount your disk or similar strange error. The wizard author is responsible for checking the name and can throw IllegalArgumentException. Marking this as invalid, if you don't agree please comment and reopen. Thanks.
The solution described will require implementing an Iterator. I have a situation in which I am using the default iterator. It seems to me like overkill to have to implement an Iterator for a simple wizard that has only the one name panel just to do a simple validation. My suggestion is to modify the default iterator to validate basic types, namely, valid Java identifiers. The default iterator would need to know which basic type to validate for. Please look at the wizards for Java classes and Beans. In both cases, if the user presses Finish after entering a bad name (a name that is not a valid Java identifier), they get an IOException thrown from handleCreateFromTemplate(), and the wizard exits before they can correct the name. There are dozens of other similar examples: AWT Forms (Applet, Dialog, Frame, Panel), Beans (Bean, BeanInfo, BeanInfoNoIcon, Customizer, PropertyEditor), CORBA (POA-Adapter Activate, POA-ServantActivate, POA-ServantLocate, Client Main, Server Main), Classes (Applet, Class, Empty, Exception, Interface, JApplet, Main), Sample Form (Application, MDI Application, OK/Cancel Dialog)....and many more.
Also note, that if an IOException is thrown from instantiate() of the iterator (or createFromTemplate of a DataObject), some garbage may be left in the target directory.
Svata has a point, undoing the effects after IOException is thrown is not reasonable, it should be caught before then. The Java module provides a default iterator for all JavaDataObject's, I believe, so why can't it throw IllegalArgumentException if the name is invalid? Agreed it is unreasonable for every *.java template to do this specially, but java module should I think. Cf. also an older RFE for a DataObject to be able to declare an iterator type without using file attributes.
I have marked this as duplicate of #8858 because 1. we agreed that IOException is not the main problem 2. there should be a way how to validate the name without the need to write /specify the iterator (and this is described in 8858). So again - if you think that solving 8858 does not solve this issue please reopen this one. I think (as Jesse pointed out) the problem is not in IOException -- it is in not being able to create a "default" iterator. *** This issue has been marked as a duplicate of 8858 ***
Resolved for 3.4.x or earlier, no new info since then -> verified
Resolved for 3.4.x or earlier, no new info since then -> closing.