KickJava   Java API By Example, From Geeks To Geeks.

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


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 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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

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