001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028: package org.openide;
029:
030: import java.awt.Component;
031: import javax.swing.JPanel;
032: import javax.swing.event.ChangeListener;
033: import org.netbeans.junit.NbTestCase;
034: import org.openide.WizardDescriptor.Panel;
035: import org.openide.util.HelpCtx;
036:
037: /**
038: *
039: * @author Jaroslav Tulach
040: */
041: public class WizardSetDataAndIteratorTest extends NbTestCase {
042:
043: public WizardSetDataAndIteratorTest(String s) {
044: super (s);
045: }
046:
047: public void testSetDataAndIterator() throws Exception {
048: MyWizard w = new MyWizard();
049: assertTrue("Finish enabled", w.isFinishEnabled());
050: assertEquals("Right Settings passed", w, MyPanel.set);
051: }
052:
053: private static class MyWizard extends WizardDescriptor {
054: public MyWizard() {
055: super ();
056: setPanelsAndSettings(new MyIter(), this );
057: }
058: }
059:
060: private static class MyIter implements
061: WizardDescriptor.Iterator<MyWizard> {
062: private MyPanel myPanel = new MyPanel();
063:
064: public Panel<org.openide.WizardSetDataAndIteratorTest.MyWizard> current() {
065: return myPanel;
066: }
067:
068: public String name() {
069: return "OneName";
070: }
071:
072: public boolean hasNext() {
073: return false;
074: }
075:
076: public boolean hasPrevious() {
077: return false;
078: }
079:
080: public void nextPanel() {
081: throw new UnsupportedOperationException(
082: "Not supported yet.");
083: }
084:
085: public void previousPanel() {
086: throw new UnsupportedOperationException(
087: "Not supported yet.");
088: }
089:
090: public void addChangeListener(ChangeListener l) {
091: }
092:
093: public void removeChangeListener(ChangeListener l) {
094: }
095: }
096:
097: private static class MyPanel implements
098: WizardDescriptor.Panel<MyWizard> {
099: private static MyWizard set;
100:
101: private JPanel cmp = new JPanel();
102:
103: public Component getComponent() {
104: return cmp;
105: }
106:
107: public HelpCtx getHelp() {
108: return HelpCtx.DEFAULT_HELP;
109: }
110:
111: public void readSettings(
112: org.openide.WizardSetDataAndIteratorTest.MyWizard settings) {
113: assertNull("Not yet set", set);
114: set = settings;
115: }
116:
117: public void storeSettings(
118: org.openide.WizardSetDataAndIteratorTest.MyWizard settings) {
119: }
120:
121: public boolean isValid() {
122: return true;
123: }
124:
125: public void addChangeListener(ChangeListener l) {
126: }
127:
128: public void removeChangeListener(ChangeListener l) {
129: }
130: }
131: }
|