# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /doma/jarda/netbeans-src/openide/dialogs # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: src/org/openide/WizardDescriptor.java *** /doma/jarda/netbeans-src/openide/dialogs/src/org/openide/WizardDescriptor.java Base (1.46) --- /doma/jarda/netbeans-src/openide/dialogs/src/org/openide/WizardDescriptor.java Locally Modified (Based On 1.46) *************** *** 72,77 **** --- 72,78 ---- import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; + import org.openide.WizardDescriptor.Panel; import org.openide.awt.HtmlBrowser; import org.openide.awt.Mnemonics; import org.openide.util.Exceptions; *************** *** 338,343 **** --- 339,352 ---- this(new SettingsAndIterator(panels, settings)); } + /** Constructor for subclasses. The expected use is to call this + * constructor and then call {@link setPanelsAndSettings} to provide + * the right iterator, panels and data the wizard should use. + */ + protected WizardDescriptor() { + this(SettingsAndIterator.empty()); + } + private WizardDescriptor(SettingsAndIterator data) { super("", "", true, DEFAULT_OPTION, null, CLOSE_PREVENTER); // NOI18N *************** *** 2721,2726 **** --- 2730,2738 ---- public static SettingsAndIterator create(Iterator iterator) { return new SettingsAndIterator(iterator, null, true); } + public static SettingsAndIterator empty() { + return new SettingsAndIterator(new EmptyPanel(), (Void)null); + } public Iterator getIterator(WizardDescriptor caller) { return panels; *************** *** 2736,2742 **** --- 2748,2803 ---- return s; } } + + private static final class EmptyPanel implements Panel, Iterator { + public Component getComponent() { + return new JPanel(); } + + public HelpCtx getHelp() { + return HelpCtx.DEFAULT_HELP; + } + + public void readSettings(Void settings) { + } + + public void storeSettings(Void settings) { + } + + public boolean isValid() { + return true; + } + + public void addChangeListener(ChangeListener l) { + } + + public void removeChangeListener(ChangeListener l) { + } + + public Panel current() { + return this; + } + + public String name() { + return ""; // NORTH + } + + public boolean hasNext() { + return false; + } + + public boolean hasPrevious() { + return false; + } + + public void nextPanel() { + } + + public void previousPanel() { + } + } // end of EmptyPanel + } Index: test/unit/src/org/openide/WizardSetDataAndIteratorTest.java *** /doma/jarda/netbeans-src/openide/dialogs/test/unit/src/org/openide/WizardSetDataAndIteratorTest.java No Base Revision --- /doma/jarda/netbeans-src/openide/dialogs/test/unit/src/org/openide/WizardSetDataAndIteratorTest.java Locally New *************** *** 1,0 **** --- 1,114 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Portions Copyrighted 2007 Sun Microsystems, Inc. + */ + package org.openide; + + import java.awt.Component; + import javax.swing.JPanel; + import javax.swing.event.ChangeListener; + import org.netbeans.junit.NbTestCase; + import org.openide.WizardDescriptor.Panel; + import org.openide.util.HelpCtx; + + /** + * + * @author Jaroslav Tulach + */ + public class WizardSetDataAndIteratorTest extends NbTestCase { + + public WizardSetDataAndIteratorTest(String s) { + super(s); + } + + + public void testSetDataAndIterator() throws Exception { + MyWizard w = new MyWizard(); + assertTrue("Finish enabled", w.isFinishEnabled()); + assertEquals("Right Settings passed", w, MyPanel.set); + } + private static class MyWizard extends WizardDescriptor { + public MyWizard() { + super(); + setPanelsAndSettings(new MyIter(), this); + } + } + + private static class MyIter implements WizardDescriptor.Iterator { + private MyPanel myPanel = new MyPanel(); + + public Panel current() { + return myPanel; + } + + public String name() { + return "OneName"; + } + + public boolean hasNext() { + return false; + } + + public boolean hasPrevious() { + return false; + } + + public void nextPanel() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void previousPanel() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void addChangeListener(ChangeListener l) { + } + + public void removeChangeListener(ChangeListener l) { + } + } + + private static class MyPanel implements WizardDescriptor.Panel { + private static MyWizard set; + + private JPanel cmp = new JPanel(); + + public Component getComponent() { + return cmp; + } + + public HelpCtx getHelp() { + return HelpCtx.DEFAULT_HELP; + } + + public void readSettings(org.openide.WizardSetDataAndIteratorTest.MyWizard settings) { + assertNull("Not yet set", set); + set = settings; + } + + public void storeSettings(org.openide.WizardSetDataAndIteratorTest.MyWizard settings) { + } + + public boolean isValid() { + return true; + } + + public void addChangeListener(ChangeListener l) { + } + + public void removeChangeListener(ChangeListener l) { + } + } + }