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.

View | Details | Raw Unified | Return to bug 92762
Collapse All | Expand All

(-)openide/dialogs/src/org/openide/DialogDisplayer.java (-1 / +1 lines)
Lines 286-292 Link Here
286
            }
286
            }
287
287
288
            public void updateOptions() {
288
            public void updateOptions() {
289
                Set addedOptions = new HashSet(5);
289
                Set<Object> addedOptions = new HashSet<Object>(5);
290
                Object[] options = nd.getOptions();
290
                Object[] options = nd.getOptions();
291
291
292
                if (options == null) {
292
                if (options == null) {
(-)openide/dialogs/src/org/openide/WizardDescriptor.java (-81 / +129 lines)
Lines 253-260 Link Here
253
    /** 'North' or 'South' */
253
    /** 'North' or 'South' */
254
    private String imageAlignment = "North"; // NOI18N
254
    private String imageAlignment = "North"; // NOI18N
255
255
256
    /** Iterator between panels in the wizard */
256
    /** Iterator between panels in the wizard and its settings */
257
    private Iterator panels;
257
    private SettingsAndIterator<?> data;
258
258
259
    /** Change listener that invokes method update state */
259
    /** Change listener that invokes method update state */
260
    private ChangeListener weakChangeListener;
260
    private ChangeListener weakChangeListener;
Lines 267-278 Link Here
267
    // base listener which won't be directly attached, will only wrapped by WeakListener
267
    // base listener which won't be directly attached, will only wrapped by WeakListener
268
    private Listener baseListener;
268
    private Listener baseListener;
269
269
270
    /** current panel */
271
    private Panel current;
272
273
    /** settings to be used for the panels */
274
    private Object settings;
275
276
    /** message format to create title of the document */
270
    /** message format to create title of the document */
277
    private MessageFormat titleFormat;
271
    private MessageFormat titleFormat;
278
272
Lines 320-338 Link Here
320
    * @param settings the settings to pass to panels, or <code>null</code>
314
    * @param settings the settings to pass to panels, or <code>null</code>
321
    * @see #WizardDescriptor(WizardDescriptor.Iterator, Object)
315
    * @see #WizardDescriptor(WizardDescriptor.Iterator, Object)
322
    */
316
    */
323
    public WizardDescriptor(Panel[] wizardPanels, Object settings) {
317
    public <Data> WizardDescriptor(Panel<Data>[] wizardPanels, Data settings) {
324
        this(new ArrayIterator(wizardPanels), settings);
318
        this(new SettingsAndIterator<Data>(new ArrayIterator<Data>(wizardPanels), settings));
325
    }
319
    }
326
320
    
327
    /** Create a new wizard from a fixed list of panels with settings
321
    /** Create a new wizard from a fixed list of panels with settings
328
    * defaulted to <CODE>this</CODE>.
322
    * defaulted to <CODE>this</CODE>.
329
    *
323
    *
330
    * @param wizardPanels the panels to use
324
    * @param wizardPanels the panels to use
331
    * @see #WizardDescriptor(WizardDescriptor.Iterator, Object)
325
    * @see #WizardDescriptor(WizardDescriptor.Iterator, Object)
332
    */
326
    */
333
    public WizardDescriptor(Panel[] wizardPanels) {
327
    public WizardDescriptor(Panel<WizardDescriptor>[] wizardPanels) {
334
        // passing CLOSE_PREVENTER which is treated especially
328
        this(SettingsAndIterator.create(new ArrayIterator<WizardDescriptor>(wizardPanels)));
335
        this(wizardPanels, CLOSE_PREVENTER);
336
    }
329
    }
337
330
338
    /** Create wizard for a sequence of panels, passing some settings to the panels.
331
    /** Create wizard for a sequence of panels, passing some settings to the panels.
Lines 341-350 Link Here
341
    * @see WizardDescriptor.Panel#readSettings
334
    * @see WizardDescriptor.Panel#readSettings
342
    * @see WizardDescriptor.Panel#storeSettings
335
    * @see WizardDescriptor.Panel#storeSettings
343
    */
336
    */
344
    public WizardDescriptor(Iterator panels, Object settings) {
337
    public <Data>WizardDescriptor(Iterator<Data> panels, Data settings) {
338
        this(new SettingsAndIterator<Data>(panels, settings));
339
    }
340
    
341
    private <Data> WizardDescriptor(SettingsAndIterator<Data> data) {
345
        super("", "", true, DEFAULT_OPTION, null, CLOSE_PREVENTER); // NOI18N
342
        super("", "", true, DEFAULT_OPTION, null, CLOSE_PREVENTER); // NOI18N
346
343
347
        this.settings = (settings == CLOSE_PREVENTER) ? this : settings;
344
        this.data = data;
348
345
349
        baseListener = new Listener();
346
        baseListener = new Listener();
350
347
Lines 371-381 Link Here
371
        super.setOptions(new Object[] { previousButton, nextButton, finishButton, cancelButton });
368
        super.setOptions(new Object[] { previousButton, nextButton, finishButton, cancelButton });
372
        super.setClosingOptions(new Object[] { finishOption, cancelButton });
369
        super.setClosingOptions(new Object[] { finishOption, cancelButton });
373
370
374
        this.panels = panels;
375
376
        // attach the change listener to iterator
371
        // attach the change listener to iterator
377
        weakChangeListener = WeakListeners.change(baseListener, panels);
372
        weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this));
378
        panels.addChangeListener(weakChangeListener);
373
        data.getIterator(this).addChangeListener(weakChangeListener);
379
374
380
        callInitialize();
375
        callInitialize();
381
    }
376
    }
Lines 385-393 Link Here
385
    *
380
    *
386
    * @param panels iterator over all {@link WizardDescriptor.Panel}s that can appear in the wizard
381
    * @param panels iterator over all {@link WizardDescriptor.Panel}s that can appear in the wizard
387
    */
382
    */
388
    public WizardDescriptor(Iterator panels) {
383
    public WizardDescriptor(Iterator<WizardDescriptor> panels) {
389
        // passing CLOSE_PREVENTER which is treated especially
384
        this(SettingsAndIterator.create(panels));
390
        this(panels, CLOSE_PREVENTER);
391
    }
385
    }
392
386
393
    /** Initializes settings.
387
    /** Initializes settings.
Lines 431-444 Link Here
431
    * Correctly updates the buttons.
425
    * Correctly updates the buttons.
432
    * @param panels the new list of {@link WizardDescriptor.Panel}s
426
    * @param panels the new list of {@link WizardDescriptor.Panel}s
433
    */
427
    */
428
    @SuppressWarnings("unchecked")
434
    public final synchronized void setPanels(Iterator panels) {
429
    public final synchronized void setPanels(Iterator panels) {
435
        if (this.panels != null) {
430
        if (data.getIterator(this) != null) {
436
            this.panels.removeChangeListener(weakChangeListener);
431
            data.getIterator(this).removeChangeListener(weakChangeListener);
437
        }
432
        }
438
433
439
        this.panels = panels;
434
        data = data.clone(panels);
440
        weakChangeListener = WeakListeners.change(baseListener, panels);
435
        weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this));
441
        panels.addChangeListener(weakChangeListener);
436
        data.getIterator(this).addChangeListener(weakChangeListener);
442
        init = false;
437
        init = false;
443
438
444
        updateState();
439
        updateState();
Lines 657-689 Link Here
657
    * </PRE></code>
652
    * </PRE></code>
658
    */
653
    */
659
    protected synchronized void updateState() {
654
    protected synchronized void updateState() {
660
        Panel p = panels.current();
655
        updateStateOpen(data);
656
    }
657
    private <A> void updateStateOpen(SettingsAndIterator<A> data) {
658
        Panel<A> p = data.getIterator(this).current();
661
659
662
        // listeners on the panel
660
        // listeners on the panel
663
        if (current != p) {
661
        if (data.current != p) {
664
            if (current != null) {
662
            if (data.current != null) {
665
                // remove
663
                // remove
666
                current.removeChangeListener(weakChangeListener);
664
                data.current.removeChangeListener(weakChangeListener);
667
                current.storeSettings(settings);
665
                data.current.storeSettings(data.getSettings(this));
668
            }
666
            }
669
667
670
            // Hack - obtain current panel again
668
            // Hack - obtain current panel again
671
            // It's here to allow dynamic change of panels in wizard
669
            // It's here to allow dynamic change of panels in wizard
672
            // (which can be done in storeSettings method)
670
            // (which can be done in storeSettings method)
673
            p = panels.current();
671
            p = data.getIterator(this).current();
674
672
675
            // add to new, detach old change listener and attach new one
673
            // add to new, detach old change listener and attach new one
676
            panels.removeChangeListener(weakChangeListener);
674
            data.getIterator(this).removeChangeListener(weakChangeListener);
677
            weakChangeListener = WeakListeners.change(baseListener, p);
675
            weakChangeListener = WeakListeners.change(baseListener, p);
678
            panels.addChangeListener(weakChangeListener);
676
            data.getIterator(this).addChangeListener(weakChangeListener);
679
            p.addChangeListener(weakChangeListener);
677
            p.addChangeListener(weakChangeListener);
680
678
681
            current = p;
679
            data.current = p;
682
            current.readSettings(settings);
680
            p.readSettings(data.getSettings(this));
683
        }
681
        }
684
682
685
        boolean next = panels.hasNext();
683
        boolean next = data.getIterator(this).hasNext();
686
        boolean prev = panels.hasPrevious();
684
        boolean prev = data.getIterator(this).hasPrevious();
687
        boolean valid = p.isValid();
685
        boolean valid = p.isValid();
688
686
689
        // AWT sensitive code
687
        // AWT sensitive code
Lines 778-784 Link Here
778
            panelName = ""; // NOI18N
776
            panelName = ""; // NOI18N
779
        }
777
        }
780
778
781
        Object[] args = { panelName, panels.name() };
779
        Object[] args = { panelName, data.getIterator(this).name() };
782
        MessageFormat mf = getTitleFormat();
780
        MessageFormat mf = getTitleFormat();
783
781
784
        if (autoWizardStyle) {
782
        if (autoWizardStyle) {
Lines 796-817 Link Here
796
    
794
    
797
    // for xtesting usage only
795
    // for xtesting usage only
798
    boolean isForwardEnabled () {
796
    boolean isForwardEnabled () {
799
        return panels.current ().isValid () && !validationRuns;
797
        return data.getIterator(this).current ().isValid () && !validationRuns;
800
    }
798
    }
801
799
802
    private void updateStateInAWT () {
800
    private void updateStateInAWT () {
803
        Panel p = panels.current ();        
801
        Panel<?> p = data.getIterator(this).current ();        
804
        boolean next = panels.hasNext ();
802
        boolean next = data.getIterator(this).hasNext ();
805
        boolean prev = panels.hasPrevious ();
803
        boolean prev = data.getIterator(this).hasPrevious ();
806
        boolean valid = p.isValid () && !validationRuns;
804
        boolean valid = p.isValid () && !validationRuns;
807
805
808
        nextButton.setEnabled (next && valid);
806
        nextButton.setEnabled (next && valid);
809
        previousButton.setEnabled (prev);
807
        previousButton.setEnabled (prev);
810
        cancelButton.setEnabled (true);
808
        cancelButton.setEnabled (true);
811
        
809
        
812
        if (current instanceof FinishablePanel) {
810
        if (data.current instanceof FinishablePanel) {
813
            // check if isFinishPanel
811
            // check if isFinishPanel
814
            if (((FinishablePanel)current).isFinishPanel ()) {
812
            if (((FinishablePanel)data.current).isFinishPanel ()) {
815
                finishButton.setEnabled (valid);
813
                finishButton.setEnabled (valid);
816
            } else {
814
            } else {
817
                // XXX What if the last panel is not FinishPanel ??? enable ?
815
                // XXX What if the last panel is not FinishPanel ??? enable ?
Lines 821-827 Link Here
821
            // original way
819
            // original way
822
            finishButton.setEnabled (
820
            finishButton.setEnabled (
823
                valid &&
821
                valid &&
824
                (!next || (current instanceof FinishPanel))
822
                (!next || (data.current instanceof FinishPanel))
825
            );
823
            );
826
        }
824
        }
827
    }
825
    }
Lines 881-887 Link Here
881
     * wizard window exceeds screen bounds after resize.
879
     * wizard window exceeds screen bounds after resize.
882
     */
880
     */
883
    private void resizeWizard(Window parentWindow, Dimension prevSize) {
881
    private void resizeWizard(Window parentWindow, Dimension prevSize) {
884
        Dimension curSize = panels.current().getComponent().getPreferredSize();
882
        Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize();
885
883
886
        // only enlarge if needed, don't shrink
884
        // only enlarge if needed, don't shrink
887
        if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) {
885
        if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) {
Lines 1117-1124 Link Here
1117
    /** Overrides superclass method. Adds reseting of wizard
1115
    /** Overrides superclass method. Adds reseting of wizard
1118
     * for <code>CLOSED_OPTION</code>. */
1116
     * for <code>CLOSED_OPTION</code>. */
1119
    public void setValue(Object value) {
1117
    public void setValue(Object value) {
1118
        setValueOpen(value, data);
1119
    }
1120
    
1121
    private <A> void setValueOpen(Object value, SettingsAndIterator<A> data) {
1120
        Object convertedValue = backConvertOption(value);
1122
        Object convertedValue = backConvertOption(value);
1121
1122
        // set new value w/o fire PROP_VALUE change
1123
        // set new value w/o fire PROP_VALUE change
1123
        Object oldValue = getValue();
1124
        Object oldValue = getValue();
1124
        setValueWithoutPCH(convertedValue);
1125
        setValueWithoutPCH(convertedValue);
Lines 1129-1136 Link Here
1129
        } else if (FINISH_OPTION.equals(convertedValue) || NEXT_OPTION.equals(convertedValue)) {
1130
        } else if (FINISH_OPTION.equals(convertedValue) || NEXT_OPTION.equals(convertedValue)) {
1130
            //Bugfix #25820: make sure that storeSettings
1131
            //Bugfix #25820: make sure that storeSettings
1131
            //is called before propertyChange.
1132
            //is called before propertyChange.
1132
            if (current != null) {
1133
            if (data.current != null) {
1133
                current.storeSettings(settings);
1134
                data.current.storeSettings(data.getSettings(this));
1134
            }
1135
            }
1135
        }
1136
        }
1136
1137
Lines 1140-1149 Link Here
1140
1141
1141
    /** Resets wizard when after closed/cancelled/finished the wizard dialog. */
1142
    /** Resets wizard when after closed/cancelled/finished the wizard dialog. */
1142
    private void resetWizard() {
1143
    private void resetWizard() {
1143
        if (current != null) {
1144
        resetWizardOpen(data);
1144
            current.storeSettings(settings);
1145
    }
1145
            current.removeChangeListener(weakChangeListener);
1146
    
1146
            current = null;
1147
    private <A> void resetWizardOpen(SettingsAndIterator<A> data) {
1148
        if (data.current != null) {
1149
            data.current.storeSettings(data.getSettings(this));
1150
            data.current.removeChangeListener(weakChangeListener);
1151
            data.current = null;
1147
1152
1148
            if (wizardPanel != null) {
1153
            if (wizardPanel != null) {
1149
                wizardPanel.resetPreferredSize();
1154
                wizardPanel.resetPreferredSize();
Lines 1153-1159 Link Here
1153
        callUninitialize();
1158
        callUninitialize();
1154
1159
1155
        // detach the change listener at the end of wizard
1160
        // detach the change listener at the end of wizard
1156
        panels.removeChangeListener(weakChangeListener);
1161
        data.getIterator(this).removeChangeListener(weakChangeListener);
1157
    }
1162
    }
1158
1163
1159
    private int getIntFromBundle(String key) {
1164
    private int getIntFromBundle(String key) {
Lines 1243-1266 Link Here
1243
1248
1244
    // helper methods which call to InstantiatingIterator
1249
    // helper methods which call to InstantiatingIterator
1245
    private void callInitialize() {
1250
    private void callInitialize() {
1246
        assert panels != null;
1251
        assert data.getIterator(this) != null;
1247
1252
1248
        if (panels instanceof InstantiatingIterator) {
1253
        if (data.getIterator(this) instanceof InstantiatingIterator) {
1249
            ((InstantiatingIterator) panels).initialize(this);
1254
            ((InstantiatingIterator) data.getIterator(this)).initialize(this);
1250
        }
1255
        }
1251
1256
1252
        newObjects = Collections.EMPTY_SET;
1257
        newObjects = Collections.EMPTY_SET;
1253
    }
1258
    }
1254
1259
1255
    private void callUninitialize() {
1260
    private void callUninitialize() {
1256
        assert panels != null;
1261
        assert data.getIterator(this) != null;
1257
1262
1258
        if (panels instanceof InstantiatingIterator) {
1263
        if (data.getIterator(this) instanceof InstantiatingIterator) {
1259
            ((InstantiatingIterator) panels).uninitialize(this);
1264
            ((InstantiatingIterator) data.getIterator(this)).uninitialize(this);
1260
        }
1265
        }
1261
    }
1266
    }
1262
1267
1263
    private void callInstantiate() throws IOException {
1268
    private void callInstantiate() throws IOException {
1269
        callInstantiateOpen(data);
1270
    }
1271
    
1272
    private <A> void callInstantiateOpen(SettingsAndIterator<A> data) throws IOException {
1273
        Iterator<A> panels = data.getIterator(this);
1274
        
1264
        assert panels != null;
1275
        assert panels != null;
1265
        
1276
        
1266
        err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator));
1277
        err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator));
Lines 1287-1293 Link Here
1287
        }
1298
        }
1288
         
1299
         
1289
        // bugfix #44444, force store settings before do instantiate new objects
1300
        // bugfix #44444, force store settings before do instantiate new objects
1290
        panels.current().storeSettings(settings);
1301
        panels.current().storeSettings(data.getSettings(this));
1291
1302
1292
        if (panels instanceof InstantiatingIterator) {
1303
        if (panels instanceof InstantiatingIterator) {
1293
            showWaitCursor();
1304
            showWaitCursor();
Lines 1361-1371 Link Here
1361
    /** Iterator on the sequence of panels.
1372
    /** Iterator on the sequence of panels.
1362
    * @see WizardDescriptor.Panel
1373
    * @see WizardDescriptor.Panel
1363
    */
1374
    */
1364
    public interface Iterator {
1375
    public interface Iterator<Data> {
1365
        /** Get the current panel.
1376
        /** Get the current panel.
1366
        * @return the panel
1377
        * @return the panel
1367
        */
1378
        */
1368
        public Panel current();
1379
        public Panel<Data> current();
1369
1380
1370
        /** Get the name of the current panel.
1381
        /** Get the name of the current panel.
1371
        * @return the name
1382
        * @return the name
Lines 1414-1420 Link Here
1414
     *
1425
     *
1415
     * Please see complete guide at http://performance.netbeans.org/howto/dialogs/wizard-panels.html
1426
     * Please see complete guide at http://performance.netbeans.org/howto/dialogs/wizard-panels.html
1416
     */
1427
     */
1417
    public interface Panel {
1428
    public interface Panel<Data> {
1418
        /** Get the component displayed in this panel.
1429
        /** Get the component displayed in this panel.
1419
         *
1430
         *
1420
         * Note; method can be called from any thread, but not concurrently
1431
         * Note; method can be called from any thread, but not concurrently
Lines 1442-1448 Link Here
1442
        * @exception IllegalStateException if the the data provided
1453
        * @exception IllegalStateException if the the data provided
1443
        * by the wizard are not valid.
1454
        * by the wizard are not valid.
1444
        */
1455
        */
1445
        public void readSettings(Object settings);
1456
        public void readSettings(Data settings);
1446
1457
1447
        /** Provides the wizard panel with the opportunity to update the
1458
        /** Provides the wizard panel with the opportunity to update the
1448
        * settings with its current customized state.
1459
        * settings with its current customized state.
Lines 1457-1463 Link Here
1457
        * in fact the <code>TemplateWizard</code>.
1468
        * in fact the <code>TemplateWizard</code>.
1458
        * @param settings the object representing wizard panel state
1469
        * @param settings the object representing wizard panel state
1459
        */
1470
        */
1460
        public void storeSettings(Object settings);
1471
        public void storeSettings(Data settings);
1461
1472
1462
        /** Test whether the panel is finished and it is safe to proceed to the next one.
1473
        /** Test whether the panel is finished and it is safe to proceed to the next one.
1463
        * If the panel is valid, the "Next" (or "Finish") button will be enabled.
1474
        * If the panel is valid, the "Next" (or "Finish") button will be enabled.
Lines 1487-1500 Link Here
1487
    * implementing this interface.
1498
    * implementing this interface.
1488
    * @deprecated 4.28 Use FinishablePanel instead.
1499
    * @deprecated 4.28 Use FinishablePanel instead.
1489
    */
1500
    */
1490
    public interface FinishPanel extends Panel {
1501
    public interface FinishPanel<Data> extends Panel<Data> {
1491
    }
1502
    }
1492
1503
1493
    /** A special interface for panels that need to do additional
1504
    /** A special interface for panels that need to do additional
1494
     * validation when Next or Finish button is clicked.
1505
     * validation when Next or Finish button is clicked.
1495
     * @since 4.28
1506
     * @since 4.28
1496
     */
1507
     */
1497
    public interface ValidatingPanel extends Panel {
1508
    public interface ValidatingPanel<Data> extends Panel<Data> {
1498
        /**
1509
        /**
1499
         * Is called when Next of Finish buttons are clicked and
1510
         * Is called when Next of Finish buttons are clicked and
1500
         * allows deeper check to find out that panel is in valid
1511
         * allows deeper check to find out that panel is in valid
Lines 1520-1526 Link Here
1520
     *
1531
     *
1521
     * @since 6.2 (16 May 2005)
1532
     * @since 6.2 (16 May 2005)
1522
     */
1533
     */
1523
    public interface AsynchronousValidatingPanel extends ValidatingPanel {
1534
    public interface AsynchronousValidatingPanel<Data> extends ValidatingPanel<Data> {
1524
1535
1525
        /**
1536
        /**
1526
         * Called synchronously from UI thread when Next
1537
         * Called synchronously from UI thread when Next
Lines 1544-1550 Link Here
1544
     * Finish button.
1555
     * Finish button.
1545
     * @since 4.28
1556
     * @since 4.28
1546
     */
1557
     */
1547
    public interface FinishablePanel extends Panel {
1558
    public interface FinishablePanel<Data> extends Panel<Data> {
1548
        /** Specify if this panel would enable Finish button. Finish button is
1559
        /** Specify if this panel would enable Finish button. Finish button is
1549
         * enabled if and only if isValid() returns true and isFinishPanel()
1560
         * enabled if and only if isValid() returns true and isFinishPanel()
1550
         * returns true.
1561
         * returns true.
Lines 1562-1568 Link Here
1562
     * in a template's declaration.)
1573
     * in a template's declaration.)
1563
     * @since org.openide/1 4.33
1574
     * @since org.openide/1 4.33
1564
     */
1575
     */
1565
    public interface InstantiatingIterator extends Iterator {
1576
    public interface InstantiatingIterator<Data> extends Iterator<Data> {
1566
        /** Returns set of instantiated objects. If instantiation fails then wizard remains open to enable correct values.
1577
        /** Returns set of instantiated objects. If instantiation fails then wizard remains open to enable correct values.
1567
         *
1578
         *
1568
         * @throws IOException
1579
         * @throws IOException
Lines 1591-1597 Link Here
1591
     * in a template's declaration.)
1602
     * in a template's declaration.)
1592
     * @since org.openide/1 6.5
1603
     * @since org.openide/1 6.5
1593
     */
1604
     */
1594
    public interface AsynchronousInstantiatingIterator extends InstantiatingIterator {
1605
    public interface AsynchronousInstantiatingIterator<Data> extends InstantiatingIterator<Data> {
1595
1606
1596
        /**
1607
        /**
1597
         * Is called in separate thread when the Finish button
1608
         * Is called in separate thread when the Finish button
Lines 1613-1619 Link Here
1613
     * in a template's declaration.)
1624
     * in a template's declaration.)
1614
     * @since org.openide.dialogs 7.1
1625
     * @since org.openide.dialogs 7.1
1615
     */
1626
     */
1616
    public interface ProgressInstantiatingIterator extends AsynchronousInstantiatingIterator {
1627
    public interface ProgressInstantiatingIterator<Data> extends AsynchronousInstantiatingIterator<Data> {
1617
1628
1618
        /**
1629
        /**
1619
         * Is called in separate thread when the Finish button
1630
         * Is called in separate thread when the Finish button
Lines 1633-1642 Link Here
1633
1644
1634
    /** Special iterator that works on an array of <code>Panel</code>s.
1645
    /** Special iterator that works on an array of <code>Panel</code>s.
1635
    */
1646
    */
1636
    public static class ArrayIterator extends Object implements Iterator {
1647
    public static class ArrayIterator<Data> extends Object implements Iterator<Data> {
1637
        /** Array of items.
1648
        /** Array of items.
1638
        */
1649
        */
1639
        private Panel[] panels;
1650
        private Panel<Data>[] panels;
1640
1651
1641
        /** Index into the array
1652
        /** Index into the array
1642
        */
1653
        */
Lines 1653-1659 Link Here
1653
        /** Construct an iterator.
1664
        /** Construct an iterator.
1654
        * @param array the list of panels to use
1665
        * @param array the list of panels to use
1655
        */
1666
        */
1656
        public ArrayIterator(Panel[] array) {
1667
        public ArrayIterator(Panel<Data>[] array) {
1657
            panels = array;
1668
            panels = array;
1658
            index = 0;
1669
            index = 0;
1659
        }
1670
        }
Lines 1662-1674 Link Here
1662
        * constructed using default constructor.
1673
        * constructed using default constructor.
1663
        * (for example during deserialization.
1674
        * (for example during deserialization.
1664
        * Default implementation returns empty array. */
1675
        * Default implementation returns empty array. */
1665
        protected Panel[] initializePanels() {
1676
        @SuppressWarnings("unchecked")
1677
        protected Panel<Data>[] initializePanels() {
1666
            return new Panel[0];
1678
            return new Panel[0];
1667
        }
1679
        }
1668
1680
1669
        /* The current panel.
1681
        /* The current panel.
1670
        */
1682
        */
1671
        public Panel current() {
1683
        public Panel<Data> current() {
1672
            return panels[index];
1684
            return panels[index];
1673
        }
1685
        }
1674
1686
Lines 1746-1751 Link Here
1746
1758
1747
        /** Action listener */
1759
        /** Action listener */
1748
        public void actionPerformed(ActionEvent ev) {
1760
        public void actionPerformed(ActionEvent ev) {
1761
            final Iterator<?> panels = data.getIterator(WizardDescriptor.this);
1749
            if (wizardPanel != null) {
1762
            if (wizardPanel != null) {
1750
                wizardPanel.setErrorMessage(" ", null); //NOI18N
1763
                wizardPanel.setErrorMessage(" ", null); //NOI18N
1751
            }
1764
            }
Lines 2638-2643 Link Here
2638
            assert ESTIMATED_HEIGHT == Utilities.loadImage ("org/netbeans/modules/dialogs/warning.gif").getHeight (null) : "Use only 16px icon.";
2651
            assert ESTIMATED_HEIGHT == Utilities.loadImage ("org/netbeans/modules/dialogs/warning.gif").getHeight (null) : "Use only 16px icon.";
2639
            preferredSize.height = Math.max (ESTIMATED_HEIGHT, preferredSize.height);
2652
            preferredSize.height = Math.max (ESTIMATED_HEIGHT, preferredSize.height);
2640
            return preferredSize;
2653
            return preferredSize;
2654
        }
2655
    }
2656
    
2657
    private static final class SettingsAndIterator<Data> {
2658
        private final Iterator<Data> panels;
2659
        private final Data settings;
2660
        private final boolean useThis;
2661
        /** current panel */
2662
        private Panel<Data> current;
2663
2664
        
2665
        public SettingsAndIterator(Iterator<Data> iterator, Data settings) {
2666
            this(iterator, settings, false);
2667
        }
2668
        public SettingsAndIterator(Iterator<Data> iterator, Data settings, boolean useThis) {
2669
            this.panels = iterator;
2670
            this.settings = settings;
2671
            this.useThis = useThis;
2672
        }
2673
        public static SettingsAndIterator<WizardDescriptor> create(Iterator<WizardDescriptor> iterator) {
2674
            return new SettingsAndIterator<WizardDescriptor>(iterator, null, true);
2675
        }
2676
2677
        public Iterator<Data> getIterator(WizardDescriptor caller) {
2678
            return panels;
2679
        }
2680
        
2681
        @SuppressWarnings("unchecked")
2682
        public Data getSettings(WizardDescriptor caller) {
2683
            return useThis ? (Data)caller : settings;
2684
        }
2685
        
2686
        public SettingsAndIterator<Data> clone(Iterator<Data> it) {
2687
            SettingsAndIterator<Data> s = new SettingsAndIterator<Data>(it, settings, useThis);
2688
            return s;
2641
        }
2689
        }
2642
    }
2690
    }
2643
}
2691
}
(-)openide/loaders/src/org/openide/loaders/NewObjectWizardPanel.java (-3 / +3 lines)
Lines 30-36 Link Here
30
 *
30
 *
31
 * @author Jiri Rechtacek
31
 * @author Jiri Rechtacek
32
 */
32
 */
33
final class NewObjectWizardPanel implements WizardDescriptor.FinishablePanel {
33
final class NewObjectWizardPanel implements WizardDescriptor.FinishablePanel<WizardDescriptor> {
34
    private NewObjectPanel newObjectPanelUI;
34
    private NewObjectPanel newObjectPanelUI;
35
    /** listener to changes in the wizard */
35
    /** listener to changes in the wizard */
36
    private ChangeListener listener;
36
    private ChangeListener listener;
Lines 135-141 Link Here
135
     * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
135
     * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
136
     * @param settings the object representing wizard panel state, as originally supplied to {@link WizardDescriptor#WizardDescriptor(WizardDescriptor.Iterator,Object)}
136
     * @param settings the object representing wizard panel state, as originally supplied to {@link WizardDescriptor#WizardDescriptor(WizardDescriptor.Iterator,Object)}
137
     */
137
     */
138
    public void readSettings(Object settings) {
138
    public void readSettings(WizardDescriptor settings) {
139
        this.wizard = (TemplateWizard)settings;
139
        this.wizard = (TemplateWizard)settings;
140
        DataObject template = wizard.getTemplate ();
140
        DataObject template = wizard.getTemplate ();
141
        if (template != null) {
141
        if (template != null) {
Lines 159-165 Link Here
159
     * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
159
     * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
160
     * @param settings the object representing a settings of the wizard
160
     * @param settings the object representing a settings of the wizard
161
     */
161
     */
162
    public void storeSettings(Object settings) {
162
    public void storeSettings(WizardDescriptor settings) {
163
        String name = getPanelUI ().getNewObjectName ();
163
        String name = getPanelUI ().getNewObjectName ();
164
        if (name.equals (NewObjectPanel.defaultNewObjectName ())) {
164
        if (name.equals (NewObjectPanel.defaultNewObjectName ())) {
165
            name = null;
165
            name = null;
(-)openide/loaders/src/org/openide/loaders/TemplateWizard.java (-13 / +18 lines)
Lines 68-76 Link Here
68
    static java.awt.Dimension PREF_DIM = new java.awt.Dimension (560, 350);
68
    static java.awt.Dimension PREF_DIM = new java.awt.Dimension (560, 350);
69
69
70
    /** panel */
70
    /** panel */
71
    private Panel templateChooser;
71
    private Panel<WizardDescriptor> templateChooser;
72
    /** panel */
72
    /** panel */
73
    private Panel targetChooser;
73
    private Panel<WizardDescriptor> targetChooser;
74
    /** whether to show target chooser */
74
    /** whether to show target chooser */
75
    private boolean showTargetChooser = true;
75
    private boolean showTargetChooser = true;
76
    
76
    
Lines 271-277 Link Here
271
    /** Returns wizard panel that is used to choose a template.
271
    /** Returns wizard panel that is used to choose a template.
272
     * @return wizard panel
272
     * @return wizard panel
273
     */
273
     */
274
    public Panel templateChooser () {
274
    public Panel<WizardDescriptor> templateChooser () {
275
        synchronized (this) {
275
        synchronized (this) {
276
            if (templateChooser == null) {
276
            if (templateChooser == null) {
277
                templateChooser = createTemplateChooser ();
277
                templateChooser = createTemplateChooser ();
Lines 284-290 Link Here
284
     * name of the template.
284
     * name of the template.
285
     * @return wizard panel
285
     * @return wizard panel
286
     */
286
     */
287
    public Panel targetChooser () {
287
    public Panel<WizardDescriptor> targetChooser () {
288
        synchronized (this) {
288
        synchronized (this) {
289
            if (targetChooser == null) {
289
            if (targetChooser == null) {
290
                targetChooser = createTargetChooser ();
290
                targetChooser = createTargetChooser ();
Lines 307-313 Link Here
307
     * 
307
     * 
308
     * @return the panel
308
     * @return the panel
309
     */
309
     */
310
    protected Panel createTemplateChooser () {
310
    protected Panel<WizardDescriptor> createTemplateChooser () {
311
        return new TemplateWizardPanel1 ();
311
        return new TemplateWizardPanel1 ();
312
    }
312
    }
313
313
Lines 315-322 Link Here
315
     * 
315
     * 
316
     * @return the panel
316
     * @return the panel
317
     */
317
     */
318
    protected Panel createTargetChooser () {
318
    protected Panel<WizardDescriptor> createTargetChooser () {
319
        return showTargetChooser ? (Panel)new TemplateWizardPanel2 () : (Panel)new NewObjectWizardPanel ();
319
        if (showTargetChooser) {
320
            return new TemplateWizardPanel2 ();
321
        } else {
322
            return new NewObjectWizardPanel ();
323
        }
320
    }
324
    }
321
    
325
    
322
    /** Allows subclasses to provide their own default iterator
326
    /** Allows subclasses to provide their own default iterator
Lines 661-666 Link Here
661
    * @param obj the data object
665
    * @param obj the data object
662
    * @return custom iterator or null
666
    * @return custom iterator or null
663
    */
667
    */
668
    @SuppressWarnings("unchecked")
664
    public static Iterator getIterator (DataObject obj) {
669
    public static Iterator getIterator (DataObject obj) {
665
        Object unknownIterator = obj.getPrimaryFile ().getAttribute(CUSTOM_ITERATOR);
670
        Object unknownIterator = obj.getPrimaryFile ().getAttribute(CUSTOM_ITERATOR);
666
        if (unknownIterator == null) {
671
        if (unknownIterator == null) {
Lines 672-678 Link Here
672
            it = (Iterator)unknownIterator;
677
            it = (Iterator)unknownIterator;
673
        // own brigde for each one iterator type
678
        // own brigde for each one iterator type
674
        } if (unknownIterator instanceof WizardDescriptor.InstantiatingIterator) {
679
        } if (unknownIterator instanceof WizardDescriptor.InstantiatingIterator) {
675
            it = new InstantiatingIteratorBridge((WizardDescriptor.InstantiatingIterator) unknownIterator);
680
            it = new InstantiatingIteratorBridge((WizardDescriptor.InstantiatingIterator<WizardDescriptor>) unknownIterator);
676
        }
681
        }
677
        if (it != null) {
682
        if (it != null) {
678
            return it;
683
            return it;
Lines 808-814 Link Here
808
    * <P>
813
    * <P>
809
    * Implements <code>Node.Cookie</code> since version 2.13
814
    * Implements <code>Node.Cookie</code> since version 2.13
810
    */
815
    */
811
    public interface Iterator extends WizardDescriptor.Iterator,
816
    public interface Iterator extends WizardDescriptor.Iterator<WizardDescriptor>,
812
    java.io.Serializable, org.openide.nodes.Node.Cookie {
817
    java.io.Serializable, org.openide.nodes.Node.Cookie {
813
        /** Instantiates the template using information provided by
818
        /** Instantiates the template using information provided by
814
         * the wizard. If instantiation fails then wizard remains open to enable correct values.
819
         * the wizard. If instantiation fails then wizard remains open to enable correct values.
Lines 887-893 Link Here
887
        /** Get the current panel.
892
        /** Get the current panel.
888
        * @return the panel
893
        * @return the panel
889
        */
894
        */
890
        public Panel current() {
895
        public Panel<WizardDescriptor> current() {
891
            return targetChooser ();
896
            return targetChooser ();
892
        }
897
        }
893
        
898
        
Lines 936-943 Link Here
936
    }
941
    }
937
    
942
    
938
    private static class InstantiatingIteratorBridge implements TemplateWizard.Iterator {
943
    private static class InstantiatingIteratorBridge implements TemplateWizard.Iterator {
939
        private WizardDescriptor.InstantiatingIterator instantiatingIterator;
944
        private WizardDescriptor.InstantiatingIterator<WizardDescriptor> instantiatingIterator;
940
        public InstantiatingIteratorBridge (WizardDescriptor.InstantiatingIterator it) {
945
        public InstantiatingIteratorBridge (WizardDescriptor.InstantiatingIterator<WizardDescriptor> it) {
941
            instantiatingIterator = it;
946
            instantiatingIterator = it;
942
        }
947
        }
943
        
948
        
Lines 949-955 Link Here
949
            instantiatingIterator.addChangeListener (l);
954
            instantiatingIterator.addChangeListener (l);
950
        }
955
        }
951
        
956
        
952
        public org.openide.WizardDescriptor.Panel current () {
957
        public org.openide.WizardDescriptor.Panel<WizardDescriptor> current () {
953
            return instantiatingIterator.current ();
958
            return instantiatingIterator.current ();
954
        }
959
        }
955
        
960
        
(-)openide/loaders/src/org/openide/loaders/TemplateWizardIterImpl.java (-2 / +2 lines)
Lines 57-63 Link Here
57
    /** Getter for the first panel.
57
    /** Getter for the first panel.
58
     * @return the first and default panel
58
     * @return the first and default panel
59
     */
59
     */
60
    private WizardDescriptor.Panel firstPanel () {
60
    private WizardDescriptor.Panel<WizardDescriptor> firstPanel () {
61
        return wizardInstance.templateChooser();
61
        return wizardInstance.templateChooser();
62
    }
62
    }
63
63
Lines 114-120 Link Here
114
    /** Get the current panel.
114
    /** Get the current panel.
115
     * @return the panel
115
     * @return the panel
116
     */
116
     */
117
    public WizardDescriptor.Panel current() {
117
    public WizardDescriptor.Panel<WizardDescriptor> current() {
118
        return showingPanel ? firstPanel () : getIterator ().current ();
118
        return showingPanel ? firstPanel () : getIterator ().current ();
119
    }
119
    }
120
120
(-)openide/loaders/src/org/openide/loaders/TemplateWizardIteratorWrapper.java (-5 / +5 lines)
Lines 29-35 Link Here
29
 *
29
 *
30
 * @author Jiri Rechtacek
30
 * @author Jiri Rechtacek
31
 */
31
 */
32
class TemplateWizardIteratorWrapper implements WizardDescriptor.Iterator, ChangeListener {
32
class TemplateWizardIteratorWrapper implements WizardDescriptor.Iterator<WizardDescriptor>, ChangeListener {
33
33
34
    private TemplateWizardIterImpl iterImpl;
34
    private TemplateWizardIterImpl iterImpl;
35
    
35
    
Lines 63-69 Link Here
63
    /** Get the current panel.
63
    /** Get the current panel.
64
     * @return the panel
64
     * @return the panel
65
     */
65
     */
66
    public WizardDescriptor.Panel current() {
66
    public WizardDescriptor.Panel<WizardDescriptor> current() {
67
        return iterImpl.current ();
67
        return iterImpl.current ();
68
    }
68
    }
69
69
Lines 143-161 Link Here
143
        return iterImpl.instantiate (handle);
143
        return iterImpl.instantiate (handle);
144
    }
144
    }
145
    
145
    
146
    static class InstantiatingIterator extends TemplateWizardIteratorWrapper implements WizardDescriptor.InstantiatingIterator {
146
    static class InstantiatingIterator extends TemplateWizardIteratorWrapper implements WizardDescriptor.InstantiatingIterator<WizardDescriptor> {
147
        public InstantiatingIterator (TemplateWizardIterImpl it) {
147
        public InstantiatingIterator (TemplateWizardIterImpl it) {
148
            super (it);
148
            super (it);
149
        }
149
        }
150
    }
150
    }
151
    
151
    
152
    static class AsynchronousInstantiatingIterator extends InstantiatingIterator implements WizardDescriptor.AsynchronousInstantiatingIterator {
152
    static class AsynchronousInstantiatingIterator extends InstantiatingIterator implements WizardDescriptor.AsynchronousInstantiatingIterator<WizardDescriptor> {
153
        public AsynchronousInstantiatingIterator (TemplateWizardIterImpl it) {
153
        public AsynchronousInstantiatingIterator (TemplateWizardIterImpl it) {
154
            super (it);
154
            super (it);
155
        }
155
        }
156
    }
156
    }
157
    
157
    
158
    static class ProgressInstantiatingIterator extends InstantiatingIterator implements WizardDescriptor.ProgressInstantiatingIterator {
158
    static class ProgressInstantiatingIterator extends InstantiatingIterator implements WizardDescriptor.ProgressInstantiatingIterator<WizardDescriptor> {
159
        private TemplateWizardIterImpl itImpl;
159
        private TemplateWizardIterImpl itImpl;
160
        public ProgressInstantiatingIterator (TemplateWizardIterImpl it) {
160
        public ProgressInstantiatingIterator (TemplateWizardIterImpl it) {
161
            super (it);
161
            super (it);
(-)openide/loaders/src/org/openide/loaders/TemplateWizardPanel1.java (-3 / +3 lines)
Lines 28-34 Link Here
28
 *
28
 *
29
 * @author Jiri Rechtacek
29
 * @author Jiri Rechtacek
30
 */
30
 */
31
final class TemplateWizardPanel1 implements WizardDescriptor.Panel {
31
final class TemplateWizardPanel1 implements WizardDescriptor.Panel<WizardDescriptor> {
32
    private TemplateWizard1 templateWizard1UI;
32
    private TemplateWizard1 templateWizard1UI;
33
    /** listener to changes in the wizard */
33
    /** listener to changes in the wizard */
34
    private ChangeListener listener;
34
    private ChangeListener listener;
Lines 101-107 Link Here
101
    * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
101
    * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
102
    * @param settings the object representing wizard panel state, as originally supplied to {@link WizardDescriptor#WizardDescriptor(WizardDescriptor.Iterator,Object)}
102
    * @param settings the object representing wizard panel state, as originally supplied to {@link WizardDescriptor#WizardDescriptor(WizardDescriptor.Iterator,Object)}
103
    */
103
    */
104
    public void readSettings(Object settings) {
104
    public void readSettings(WizardDescriptor settings) {
105
        getPanelUI ().implReadSettings (settings);
105
        getPanelUI ().implReadSettings (settings);
106
    }
106
    }
107
    
107
    
Lines 114-120 Link Here
114
    * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
114
    * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
115
    * @param settings the object representing a settings of the wizard
115
    * @param settings the object representing a settings of the wizard
116
    */
116
    */
117
    public void storeSettings(Object settings) {
117
    public void storeSettings(WizardDescriptor settings) {
118
        getPanelUI ().implStoreSettings (settings);
118
        getPanelUI ().implStoreSettings (settings);
119
    }
119
    }
120
    
120
    
(-)openide/loaders/src/org/openide/loaders/TemplateWizardPanel2.java (-3 / +3 lines)
Lines 27-33 Link Here
27
 *
27
 *
28
 * @author Jiri Rechtacek
28
 * @author Jiri Rechtacek
29
 */
29
 */
30
final class TemplateWizardPanel2 implements WizardDescriptor.FinishablePanel {
30
final class TemplateWizardPanel2 implements WizardDescriptor.FinishablePanel<WizardDescriptor> {
31
    private TemplateWizard2 templateWizard2UI;
31
    private TemplateWizard2 templateWizard2UI;
32
    /** listener to changes in the wizard */
32
    /** listener to changes in the wizard */
33
    private ChangeListener listener;
33
    private ChangeListener listener;
Lines 111-117 Link Here
111
     * by the wizard are not valid.
111
     * by the wizard are not valid.
112
     *
112
     *
113
     */
113
     */
114
    public void readSettings(Object settings) {
114
    public void readSettings(WizardDescriptor settings) {
115
        this.settings = (WizardDescriptor)settings;
115
        this.settings = (WizardDescriptor)settings;
116
        getPanelUI ().implReadSettings (settings);
116
        getPanelUI ().implReadSettings (settings);
117
    }
117
    }
Lines 130-136 Link Here
130
     * @param settings the object representing wizard panel state
130
     * @param settings the object representing wizard panel state
131
     *
131
     *
132
     */
132
     */
133
    public void storeSettings(Object settings) {
133
    public void storeSettings(WizardDescriptor settings) {
134
        getPanelUI ().implStoreSettings (settings);
134
        getPanelUI ().implStoreSettings (settings);
135
        this.settings = null;
135
        this.settings = null;
136
    }
136
    }

Return to bug 92762