KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > wizards > EmptyTestStepLocation


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 2004-2005 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.junit.wizards;
21
22 import java.awt.Component JavaDoc;
23 import javax.swing.Box JavaDoc;
24 import javax.swing.BoxLayout JavaDoc;
25 import javax.swing.JCheckBox JavaDoc;
26 import javax.swing.JComponent JavaDoc;
27 import javax.swing.event.ChangeListener JavaDoc;
28 import org.netbeans.modules.junit.GuiUtils;
29 import org.netbeans.modules.junit.SelfResizingPanel;
30 import org.openide.WizardDescriptor;
31 import org.openide.loaders.TemplateWizard;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34
35 /**
36  *
37  * @author Marian Petras
38  */

39 class EmptyTestStepLocation implements WizardDescriptor.Panel {
40
41     private Component JavaDoc visualComp;
42     private JCheckBox JavaDoc chkSetUp;
43     private JCheckBox JavaDoc chkTearDown;
44     private JCheckBox JavaDoc chkCodeHints;
45
46     EmptyTestStepLocation() {
47         super();
48         visualComp = createVisualComp();
49     }
50
51     private Component JavaDoc createVisualComp() {
52         JCheckBox JavaDoc[] chkBoxes;
53         
54         JComponent JavaDoc optCode = GuiUtils.createChkBoxGroup(
55                 NbBundle.getMessage(
56                         GuiUtils.class,
57                         "JUnitCfgOfCreate.groupOptCode"), //NOI18N
58
chkBoxes = GuiUtils.createCheckBoxes(new String JavaDoc[] {
59                         GuiUtils.CHK_SETUP,
60                         GuiUtils.CHK_TEARDOWN}));
61         chkSetUp = chkBoxes[0];
62         chkTearDown = chkBoxes[1];
63         
64         JComponent JavaDoc optComments = GuiUtils.createChkBoxGroup(
65                 NbBundle.getMessage(
66                         GuiUtils.class,
67                         "JUnitCfgOfCreate.groupOptComments"), //NOI18N
68
chkBoxes = GuiUtils.createCheckBoxes(new String JavaDoc[] {
69                         GuiUtils.CHK_HINTS}));
70         chkCodeHints = chkBoxes[0];
71
72         JComponent JavaDoc box = new SelfResizingPanel();
73         box.setLayout(new BoxLayout JavaDoc(box, BoxLayout.Y_AXIS));
74         box.add(optCode);
75         box.add(Box.createVerticalStrut(11));
76         box.add(optComments);
77
78         /* tune layout of the components within the box: */
79         optCode.setAlignmentX(0.0f);
80         optComments.setAlignmentX(0.0f);
81
82         return box;
83     }
84
85     public void addChangeListener(ChangeListener JavaDoc l) {
86          // no listeners needed - the panel is always valid
87
}
88
89     public void removeChangeListener(ChangeListener JavaDoc l) {
90          // no listeners needed - the panel is always valid
91
}
92
93     public Component JavaDoc getComponent() {
94         return visualComp;
95     }
96
97     public HelpCtx getHelp() {
98         //PENDING
99
return null;
100     }
101
102     public boolean isValid() {
103         return true;
104     }
105
106     public void readSettings(Object JavaDoc settings) {
107         TemplateWizard wizard = (TemplateWizard) settings;
108         
109         chkSetUp.setSelected(
110                 Boolean.TRUE.equals(wizard.getProperty(GuiUtils.CHK_SETUP)));
111         chkTearDown.setSelected(
112                 Boolean.TRUE.equals(wizard.getProperty(GuiUtils.CHK_TEARDOWN)));
113         chkCodeHints.setSelected(
114                 Boolean.TRUE.equals(wizard.getProperty(GuiUtils.CHK_HINTS)));
115     }
116
117     public void storeSettings(Object JavaDoc settings) {
118         TemplateWizard wizard = (TemplateWizard) settings;
119         
120         wizard.putProperty(GuiUtils.CHK_SETUP,
121                            Boolean.valueOf(chkSetUp.isSelected()));
122         wizard.putProperty(GuiUtils.CHK_TEARDOWN,
123                            Boolean.valueOf(chkTearDown.isSelected()));
124         wizard.putProperty(GuiUtils.CHK_HINTS,
125                            Boolean.valueOf(chkCodeHints.isSelected()));
126     }
127
128 }
129
Popular Tags