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.
Marking P2 just because it is an API issue so we should get it right for 6.0. I have always been a bit confused by the generification of WizardDescriptor.{Iterator,Panel} and in fact I have not seen any examples of it being used successfully (i.e. no warnings, no @SuppressWarnings). Today I tried to fix the warning in the ant module, but found that I could not, unless I accepted a pointless cast from WizardDescriptor to ShortcutWizard in CustomizeScriptWizardPanel.storeSettings. The reason is that I would like my Iterator and Panel's to be of type <ShortcutWizard> (that is in fact the wizard I am showing), yet the WizardDescriptor constructor accepts only Iterator<WizardDescriptor>. I am attaching a possible patch which shows a change to accept Iterator<? extends WizardDescriptor>, and its usage in the ant module. But I am not sure if it is correct. Really I would like to express that for a subclass T of WizardDescriptor, the superclass constructor should accept Iterator<T> (I guess - really <? super T extends WizardDescriptor>, if that were legal syntax). But this is probably impossible? The patch compiles without warnings, but you are using @SuppressWarnings("unchecked") in various places so that does not mean much. There is nothing preventing the following mistake: class W1 extends WizardDescriptor { W1() {super(new Iterator<W1>() {...});} } class W2 extends WizardDescriptor { W2() {super(new Iterator<W1>() {...});} } where read/storeSettings on W2's iterator will be passed a W2 although it expects a W1. Is there some way to prevent this from happening?
Created attachment 41512 [details] Possible patch
Created attachment 41741 [details] Using ... instead of []
I guess there is a need for just a cosmetic fix. Jesse, is this ok for you?
I'm not sure what your patch has to do with the problem I reported. You are not even looking at the same constructor. ??
#1 I do not think that your patch with ? extends WizardDescriptor is correct. #2 Somewhere where you instantiate the ShortcutWizard, just call super() and then call setPanelsAndSettings(new ShortcutIterator(), this);
There is no zero-arg supertype constructor. The available constructors are: 1. (Iterator<WizardDescriptor>). Forces unchecked warnings, as described here, since I have an Iterator<ShortcutWizard>. 2. (Panel<WizardDescriptor>[]). Incorrect (I have a nontrivial iterator), and anyway an array of a generic type cannot be constructed without unchecked warnings. (Which makes your proposed [] -> ... replacement useless, since varargs do not avoid this warning.) 3. (Panel<Data>[],Data). Same problems as #2. 4. (Iterator<Data>,Data). Fine as a method, but cannot be used for a constructor, since a this-reference cannot be passed to a super constructor. It would probably suffice for a no-arg protected constructor to be added as then I could call setPanelsAndSettings as you suggest. However then there is nothing preventing someone from forgetting to set an iterator. (There are some places where data.getIterator(this) != null is checked, implying that sometimes it is null, but it is not obvious when.) Or the default constructor could just be @SuppressWarnings("unchecked") /** Initially no panels, call {@link #setPanelsAndSettings} to use. */ protected WizardDescriptor() { this(new Panel<WizardDescriptor>[0]); }
Created attachment 41891 [details] new version of the api for jesse. do you like this?
Yes, I think that can work. Probably a good idea to mention in the Javadoc of the new method that the purpose of calling setPanelsAndSettings separately is to avoid unchecked warnings. Forgot '#' in @link. (Check your imports. Looks like I am not the only one for whom Retouche adds unnecessary imports of nested classes. I need to file a bug about this at some point. I will add you to CC.)
Created attachment 41932 [details] Ok, so I'll integrate on Monday
new revision: 1.14; previous revision: 1.13 done Checking in dialogs/manifest.mf; /cvs/openide/dialogs/manifest.mf,v <-- manifest.mf new revision: 1.12; previous revision: 1.11 done Checking in dialogs/src/org/openide/WizardDescriptor.java; /cvs/openide/dialogs/src/org/openide/WizardDescriptor.java,v <-- WizardDescriptor.java new revision: 1.47; previous revision: 1.46 done RCS file: /cvs/openide/dialogs/test/unit/src/org/openide/WizardSetDataAndIteratorTest.java,v done Checking in dialogs/test/unit/src/org/openide/WizardSetDataAndIteratorTest.java; /cvs/openide/dialogs/test/unit/src/org/openide/WizardSetDataAndIteratorTest.java,v <-- WizardSetDataAndIteratorTest.java initial revision: 1.1
FYI: Checking in IntroPanel.java; /shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/wizards/shortcut/IntroPanel.java,v <-- IntroPanel.java new revision: 1.18; previous revision: 1.17 done Checking in SelectFolderPanel.java; /shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/wizards/shortcut/SelectFolderPanel.java,v <-- SelectFolderPanel.java new revision: 1.16; previous revision: 1.15 done Checking in CustomizeScriptPanel.java; /shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/wizards/shortcut/CustomizeScriptPanel.java,v <-- CustomizeScriptPanel.java new revision: 1.15; previous revision: 1.14 done Checking in ShortcutIterator.java; /shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/wizards/shortcut/ShortcutIterator.java,v <-- ShortcutIterator.java new revision: 1.19; previous revision: 1.18 done Checking in SelectKeyboardShortcutPanel.java; /shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/wizards/shortcut/SelectKeyboardShortcutPanel.java,v <-- SelectKeyboardShortcutPanel.java new revision: 1.15; previous revision: 1.14 done Checking in ShortcutWizard.java; /shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/wizards/shortcut/ShortcutWizard.java,v <-- ShortcutWizard.java new revision: 1.7; previous revision: 1.6 done