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 1997-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.cnd.makewizard;
043:
044: import java.awt.GridBagConstraints;
045: import java.awt.GridBagLayout;
046: import javax.swing.ButtonGroup;
047: import javax.swing.JLabel;
048: import javax.swing.JPanel;
049: import javax.swing.JRadioButton;
050: import javax.swing.JTextArea;
051:
052: public class CompilerTypePanel extends MakefileWizardPanel {
053:
054: /** Serial version number */
055: static final long serialVersionUID = -8802837465543215976L;
056:
057: // the fields in the first panel...
058: private boolean initialized;
059: private JPanel panel2;
060: private JTextArea message1;
061: private JLabel makefileTypeLabel;
062: private ButtonGroup buttonGroup;
063: private JRadioButton sunCollectionRadioButton;
064: private JRadioButton gnuCollectionRadioButton;
065: private JRadioButton bothCollectionRadioButton;
066: private JTextArea message2;
067:
068: /**
069: * Constructor for the Makefile name panel. Remember, most of the panel is
070: * inherited from WizardDescriptor.
071: */
072: CompilerTypePanel(MakefileWizard wd) {
073: super (wd);
074: String subtitle = getString("LBL_CompilerTypePanel"); // NOI18N
075: setSubTitle(subtitle);
076: this .getAccessibleContext().setAccessibleDescription(subtitle);
077: initialized = false;
078: }
079:
080: /** Defer widget creation until the panel needs to be displayed */
081: private void create() {
082: setLayout(new GridBagLayout());
083: GridBagConstraints gridBagConstraints;
084: JPanel panel = new JPanel(new GridBagLayout());
085:
086: gridBagConstraints = new java.awt.GridBagConstraints();
087: gridBagConstraints.gridx = 0;
088: gridBagConstraints.gridy = 0;
089: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
090: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
091: gridBagConstraints.weightx = 1.0;
092: gridBagConstraints.weighty = 1.0;
093: add(panel, gridBagConstraints);
094:
095: panel2 = new JPanel();
096: message1 = new JTextArea();
097: makefileTypeLabel = new JLabel();
098: sunCollectionRadioButton = new JRadioButton();
099: gnuCollectionRadioButton = new JRadioButton();
100: bothCollectionRadioButton = new JRadioButton();
101: message2 = new JTextArea();
102: panel2.setLayout(new java.awt.GridBagLayout());
103:
104: makefileTypeLabel.setText(getString("LBL_CompilerType")); // NOI18N
105: gridBagConstraints = new java.awt.GridBagConstraints();
106: gridBagConstraints.gridx = 0;
107: gridBagConstraints.gridy = 0;
108: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
109: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
110: panel2.add(makefileTypeLabel, gridBagConstraints);
111:
112: sunCollectionRadioButton
113: .setText(getString("RB_CompilerTypeSun")); // NOI18N
114: sunCollectionRadioButton.setMnemonic(getString(
115: "MNEM_CompilerTypeSun").charAt(0)); // NOI18N
116: gridBagConstraints = new java.awt.GridBagConstraints();
117: gridBagConstraints.gridx = 0;
118: gridBagConstraints.gridy = 1;
119: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
120: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
121: panel2.add(sunCollectionRadioButton, gridBagConstraints);
122:
123: gnuCollectionRadioButton
124: .setText(getString("RB_CompilerTypeGNU")); // NOI18N
125: gnuCollectionRadioButton.setMnemonic(getString(
126: "MNEM_CompilerTypeGNU").charAt(0)); // NOI18N
127: gridBagConstraints = new java.awt.GridBagConstraints();
128: gridBagConstraints.gridx = 0;
129: gridBagConstraints.gridy = 2;
130: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
131: panel2.add(gnuCollectionRadioButton, gridBagConstraints);
132:
133: bothCollectionRadioButton
134: .setText(getString("RB_CompilerTypeBoth")); // NOI18N
135: bothCollectionRadioButton.setMnemonic(getString(
136: "MNEM_CompilerTypeBoth").charAt(0)); // NOI18N
137: bothCollectionRadioButton.setSelected(true);
138: gridBagConstraints = new java.awt.GridBagConstraints();
139: gridBagConstraints.gridx = 0;
140: gridBagConstraints.gridy = 3;
141: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
142: panel2.add(bothCollectionRadioButton, gridBagConstraints);
143:
144: message1.setEditable(false);
145: message1.setLineWrap(true);
146: message1.setWrapStyleWord(true);
147: message1.setFocusable(false);
148: message1.setText(getString("TXT_CompilerTypeMsg1")); // NOI18N
149: message1.setFocusable(false);
150: message1.setBackground(panel.getBackground());
151: gridBagConstraints = new java.awt.GridBagConstraints();
152: gridBagConstraints.gridx = 0;
153: gridBagConstraints.gridy = 4;
154: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
155: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
156: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
157: gridBagConstraints.weightx = 1.0;
158: gridBagConstraints.weighty = 1.0;
159: panel2.add(message1, gridBagConstraints);
160:
161: message2.setEditable(false);
162: message2.setLineWrap(true);
163: message2.setWrapStyleWord(true);
164: message2.setFocusable(false);
165: message2.setText(getString("TXT_CompilerTypeMsg2")); // NOI18N
166: message2.setFocusable(false);
167: message2.setBackground(panel.getBackground());
168: gridBagConstraints = new java.awt.GridBagConstraints();
169: gridBagConstraints.gridx = 0;
170: gridBagConstraints.gridy = 5;
171: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
173: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
174: panel2.add(message2, gridBagConstraints);
175:
176: gridBagConstraints = new java.awt.GridBagConstraints();
177: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
179: gridBagConstraints.weightx = 1.0;
180: gridBagConstraints.weighty = 1.0;
181: panel.add(panel2, gridBagConstraints);
182:
183: // Create button group and add the three radio buttons ...
184: buttonGroup = new ButtonGroup();
185: buttonGroup.add(sunCollectionRadioButton);
186: buttonGroup.add(gnuCollectionRadioButton);
187: buttonGroup.add(bothCollectionRadioButton);
188: }
189:
190: /** Create the widgets if not initialized. Also set the RadioButtons */
191: public void addNotify() {
192: if (!initialized) {
193: create();
194: initialized = true;
195: getMakefileData().setToolset(
196: MakefileData.SUNGNU_TOOLSET_TYPE);
197: getMakefileData().setMakefileOS(MakefileData.UNIX_OS_TYPE);
198: }
199:
200: if (getMakefileData().getToolset() == MakefileData.SUN_TOOLSET_TYPE) {
201: sunCollectionRadioButton.setSelected(true);
202: } else if (getMakefileData().getToolset() == MakefileData.GNU_TOOLSET_TYPE) {
203: gnuCollectionRadioButton.setSelected(true);
204: } else if (getMakefileData().getToolset() == MakefileData.SUNGNU_TOOLSET_TYPE) {
205: bothCollectionRadioButton.setSelected(true);
206: } else {
207: ; // FIXUP - error
208: }
209:
210: super .addNotify();
211: sunCollectionRadioButton.requestFocus();
212: }
213:
214: public void removeNotify() {
215: super .removeNotify();
216: if (sunCollectionRadioButton.isSelected()) {
217: getMakefileData().setToolset(MakefileData.SUN_TOOLSET_TYPE);
218: } else if (gnuCollectionRadioButton.isSelected()) {
219: getMakefileData().setToolset(MakefileData.GNU_TOOLSET_TYPE);
220: } else if (bothCollectionRadioButton.isSelected()) {
221: getMakefileData().setToolset(
222: MakefileData.SUNGNU_TOOLSET_TYPE);
223: } else {
224: ; // FIXUP - error
225: }
226: }
227:
228: }
|