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: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 2004-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.junit.wizards;
043:
044: import java.awt.Component;
045: import javax.swing.Box;
046: import javax.swing.BoxLayout;
047: import javax.swing.JCheckBox;
048: import javax.swing.JComponent;
049: import javax.swing.event.ChangeListener;
050: import org.netbeans.modules.junit.GuiUtils;
051: import org.netbeans.modules.junit.SelfResizingPanel;
052: import org.openide.WizardDescriptor;
053: import org.openide.util.HelpCtx;
054: import org.openide.util.NbBundle;
055:
056: /**
057: *
058: * @author Marian Petras
059: */
060: class EmptyTestStepLocation implements
061: WizardDescriptor.Panel<WizardDescriptor> {
062:
063: private Component visualComp;
064: private JCheckBox chkSetUp;
065: private JCheckBox chkTearDown;
066: private JCheckBox chkCodeHints;
067:
068: EmptyTestStepLocation() {
069: super ();
070: visualComp = createVisualComp();
071: }
072:
073: private Component createVisualComp() {
074: JCheckBox[] chkBoxes;
075:
076: JComponent optCode = GuiUtils.createChkBoxGroup(NbBundle
077: .getMessage(GuiUtils.class,
078: "JUnitCfgOfCreate.groupOptCode"), //NOI18N
079: chkBoxes = GuiUtils.createCheckBoxes(new String[] {
080: GuiUtils.CHK_SETUP, GuiUtils.CHK_TEARDOWN }));
081: chkSetUp = chkBoxes[0];
082: chkTearDown = chkBoxes[1];
083:
084: JComponent optComments = GuiUtils
085: .createChkBoxGroup(
086: NbBundle.getMessage(GuiUtils.class,
087: "JUnitCfgOfCreate.groupOptComments"), //NOI18N
088: chkBoxes = GuiUtils
089: .createCheckBoxes(new String[] { GuiUtils.CHK_HINTS }));
090: chkCodeHints = chkBoxes[0];
091:
092: JComponent box = new SelfResizingPanel();
093: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
094: box.add(optCode);
095: box.add(Box.createHorizontalStrut(18));
096: box.add(optComments);
097:
098: /* tune layout of the components within the box: */
099: optCode.setAlignmentY(0.0f);
100: optComments.setAlignmentY(0.0f);
101:
102: return box;
103: }
104:
105: public void addChangeListener(ChangeListener l) {
106: // no listeners needed - the panel is always valid
107: }
108:
109: public void removeChangeListener(ChangeListener l) {
110: // no listeners needed - the panel is always valid
111: }
112:
113: public Component getComponent() {
114: return visualComp;
115: }
116:
117: public HelpCtx getHelp() {
118: //PENDING
119: return null;
120: }
121:
122: public boolean isValid() {
123: return true;
124: }
125:
126: public void readSettings(WizardDescriptor settings) {
127: chkSetUp.setSelected(Boolean.TRUE.equals(settings
128: .getProperty(GuiUtils.CHK_SETUP)));
129: chkTearDown.setSelected(Boolean.TRUE.equals(settings
130: .getProperty(GuiUtils.CHK_TEARDOWN)));
131: chkCodeHints.setSelected(Boolean.TRUE.equals(settings
132: .getProperty(GuiUtils.CHK_HINTS)));
133: }
134:
135: public void storeSettings(WizardDescriptor settings) {
136: settings.putProperty(GuiUtils.CHK_SETUP, Boolean
137: .valueOf(chkSetUp.isSelected()));
138: settings.putProperty(GuiUtils.CHK_TEARDOWN, Boolean
139: .valueOf(chkTearDown.isSelected()));
140: settings.putProperty(GuiUtils.CHK_HINTS, Boolean
141: .valueOf(chkCodeHints.isSelected()));
142: }
143:
144: }
|