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.
TemplateWizard should return the value returned by InstantiatingIterator.instantiate ().
I think a method with this flavor should be added ASAP to avoid to publish unfinished API in promoD.
The attached patch changes WizardDescriptor, added the new method Set/*<FileObject>*/ getInstantiatedObjects. This method returns set of newly instantiated objects if the wizard has been correctly finished. The empty set as default, if the wizard uses the InstantiatingIterator then returns a set of FileObject as same as InstantiatingIterator.instantiate(). The method throws the exception IllegalStateException if this method is called on the unfinished wizard. The patch also contains the tests which covered new funcionality. Reviews, please could you review the attached patch before merge to maintrunk? Thanks
Created attachment 15994 [details] proposed API change
Request from me: WizardDescriptor cannot return Set<FileObject> as it does not depend on filesystem API. My suggestions. Imho you have to choice something else: 1. return just Object to represent "a value" 2. return Lookup 3. say that when one uses InstantiatingIterator and it finishes successfully the value of already existing WizardDescriptor.getValue() will be the one returned from the iterator. 4. talk about the Set as a set of Objects I like #3, but I am unsure of the implications. #1 means yet another method that returns object, which is a bit ugly. #2 is partially nice as it allows multiple returned value types, but such usage of lookup is a bit pioneering. #4 is probably how Jesse wanted it when he helped to introduce InstantiatingIterator. My summary and suggested solution: On the other hand - the InstantiatingIterator is SPI so it is fine to return the Set. The WizardDescriptor's getter is however plain API - for that Lookup was found right. So the only change which would make the system independent on the actual returned type and provide a bit of type safety is: public Lookup WizardDescriptor.getInstantiatedObjects () { return Lookups.fixed (newObjects.toArray ()); } Take most of this issue as suggestions, the requests that blocks the integration is only the reference to FileObject.
Jardo, thank you for your comments. I tend to use your suggestion #4, i.e. return set of indeterminate objects (in place of FileObject). Let's wait for opinions of others before do the finally decision. Thanks
Re. "#4 is probably how Jesse wanted it when he helped to introduce InstantiatingIterator." - for the record, I never suggested or encouraged *any* use of InstantiatingIterator in WizardDescriptor. All we ever needed from it was for the interface to be defined in openide.jar. There was never any use case in the project system for the interface to be referenced from anywhere else inside openide.jar. In fact the only reason to put it in openide.jar at all was because it seemed undesirable to copy the same interface into the SPIs of several different modules that could use it. However since TemplateWizard was changed to use WD.II (which was not strictly necessary, but apparently convenient?) then we are forced to have TW at least (in openide-loaders.jar) be changed to refer to it in its API. I hope that one day openide-loaders.jar will die and TemplateWizard will be replaced by something simpler and more testable. Re. Lookup WizardDescriptor.getInstantiatedObjects() - ugly and unnecessary, IMHO. Why can't we just return Set<Object>??
Thanks for comments, I'm going to integrate it, I'll followed your recommendations.
Checking in openide-spec-vers.properties; /cvs/openide/openide-spec-vers.properties,v <-- openide-spec-vers.properties new revision: 1.151; previous revision: 1.150 done Processing log script arguments... Mailing the commit message to cvs@openide.netbeans.org (from jrechtacek@netbeans.org) Checking in api/doc/changes/apichanges.xml; /cvs/openide/api/doc/changes/apichanges.xml,v <-- apichanges.xml new revision: 1.210; previous revision: 1.209 done Processing log script arguments... Mailing the commit message to cvs@openide.netbeans.org (from jrechtacek@netbeans.org) Checking in src/org/openide/WizardDescriptor.java; /cvs/openide/src/org/openide/WizardDescriptor.java,v <-- WizardDescriptor.java new revision: 1.105; previous revision: 1.104 done Processing log script arguments... Mailing the commit message to cvs@openide.netbeans.org (from jrechtacek@netbeans.org) Checking in test/unit/src/org/openide/InstantiatingIteratorTest.java; /cvs/openide/test/unit/src/org/openide/InstantiatingIteratorTest.java,v <-- InstantiatingIteratorTest.java new revision: 1.6; previous revision: 1.5 done Checking in test/unit/src/org/openide/WizardDescTest.java; /cvs/openide/test/unit/src/org/openide/WizardDescTest.java,v <-- WizardDescTest.java new revision: 1.5; previous revision: 1.4 done
Can you verify it Tomas??
OK
Thanx
Verified