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 java.awt.event.ItemEvent;
047: import java.awt.event.ItemListener;
048: import javax.swing.ButtonGroup;
049: import javax.swing.JLabel;
050: import javax.swing.JPanel;
051: import javax.swing.JRadioButton;
052: import javax.swing.JTextArea;
053:
054: public class PlatformTypePanel extends MakefileWizardPanel {
055:
056: /** Serial version number */
057: static final long serialVersionUID = -8937832625633215976L;
058:
059: // the fields in the first panel...
060: private boolean initialized;
061: private JPanel panel2;
062: private JTextArea message1;
063: private JTextArea message2;
064: private JLabel makefileTypeLabel;
065: private ButtonGroup compilerButtonGroup;
066: private JRadioButton sunCollectionRadioButton;
067: private JRadioButton gnuCollectionRadioButton;
068: private JLabel makefilePlatformLabel;
069: private ButtonGroup platformButtonGroup;
070: private JRadioButton solarisRadioButton;
071: private JRadioButton linuxRadioButton;
072: private JRadioButton windowsRadioButton;
073: private JRadioButton macosxRadioButton;
074:
075: /**
076: * Constructor for the Makefile name panel. Remember, most of the panel is
077: * inherited from WizardDescriptor.
078: */
079: PlatformTypePanel(MakefileWizard wd) {
080: super (wd);
081: String subtitle = getString("LBL_PlatformTypePanel"); // NOI18N
082: setSubTitle(subtitle);
083: this .getAccessibleContext().setAccessibleDescription(subtitle);
084: initialized = false;
085: }
086:
087: /** Defer widget creation until the panel needs to be displayed */
088: private void create() {
089: setLayout(new GridBagLayout());
090: GridBagConstraints gridBagConstraints;
091: JPanel panel = new JPanel(new GridBagLayout());
092:
093: gridBagConstraints = new java.awt.GridBagConstraints();
094: gridBagConstraints.gridx = 0;
095: gridBagConstraints.gridy = 0;
096: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
097: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
098: gridBagConstraints.weightx = 1.0;
099: gridBagConstraints.weighty = 1.0;
100: add(panel, gridBagConstraints);
101:
102: panel2 = new JPanel();
103: message1 = new JTextArea();
104: makefileTypeLabel = new JLabel();
105: compilerButtonGroup = new ButtonGroup();
106: sunCollectionRadioButton = new JRadioButton();
107: gnuCollectionRadioButton = new JRadioButton();
108: message2 = new JTextArea();
109: makefilePlatformLabel = new JLabel();
110: platformButtonGroup = new ButtonGroup();
111: solarisRadioButton = new JRadioButton();
112: linuxRadioButton = new JRadioButton();
113: windowsRadioButton = new JRadioButton();
114: macosxRadioButton = new JRadioButton();
115: panel2.setLayout(new java.awt.GridBagLayout());
116:
117: makefileTypeLabel.setText(getString("LBL_CompilerType")); // NOI18N
118: gridBagConstraints = new java.awt.GridBagConstraints();
119: gridBagConstraints.gridx = 0;
120: gridBagConstraints.gridy = 0;
121: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
122: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
123: panel2.add(makefileTypeLabel, gridBagConstraints);
124:
125: sunCollectionRadioButton
126: .setText(getString("RB_CompilerTypeSun")); // NOI18N
127: sunCollectionRadioButton.setMnemonic(getString(
128: "MNEM_CompilerTypeSun").charAt(0)); // NOI18N
129: gridBagConstraints = new java.awt.GridBagConstraints();
130: gridBagConstraints.gridx = 0;
131: gridBagConstraints.gridy = 1;
132: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
133: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
134: panel2.add(sunCollectionRadioButton, gridBagConstraints);
135:
136: gnuCollectionRadioButton
137: .setText(getString("RB_CompilerTypeGNU")); // NOI18N
138: gnuCollectionRadioButton.setMnemonic(getString(
139: "MNEM_CompilerTypeGNU").charAt(0)); // NOI18N
140: gridBagConstraints = new java.awt.GridBagConstraints();
141: gridBagConstraints.gridx = 0;
142: gridBagConstraints.gridy = 2;
143: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
144: panel2.add(gnuCollectionRadioButton, gridBagConstraints);
145:
146: message1.setBackground(panel.getBackground());
147: message1.setEditable(false);
148: message1.setLineWrap(true);
149: message1.setWrapStyleWord(true);
150: message1.setFocusable(false);
151: message1.setText(getString("TXT_PlatformTypeMsg1")); // NOI18N
152: message1.setFocusable(false);
153: gridBagConstraints = new java.awt.GridBagConstraints();
154: gridBagConstraints.gridx = 0;
155: gridBagConstraints.gridy = 3;
156: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
157: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
158: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
159: gridBagConstraints.weightx = 1.0;
160: gridBagConstraints.weighty = 1.0;
161: panel2.add(message1, gridBagConstraints);
162:
163: makefilePlatformLabel.setText(getString("LBL_PlatformType")); // NOI18N
164: gridBagConstraints = new java.awt.GridBagConstraints();
165: gridBagConstraints.gridx = 0;
166: gridBagConstraints.gridy = 4;
167: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
168: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
169: panel2.add(makefilePlatformLabel, gridBagConstraints);
170:
171: solarisRadioButton.setText(getString("RB_PlatformTypeSolaric")); // NOI18N
172: solarisRadioButton.setMnemonic(getString(
173: "MNEM_PlatformTypeSolaric").charAt(0)); // NOI18N
174: gridBagConstraints = new java.awt.GridBagConstraints();
175: gridBagConstraints.gridx = 0;
176: gridBagConstraints.gridy = 5;
177: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
178: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
179: panel2.add(solarisRadioButton, gridBagConstraints);
180:
181: linuxRadioButton.setText(getString("RB_PlatformTypeLinux")); // NOI18N
182: linuxRadioButton
183: .setMnemonic(getString("MNEM_PlatformTypeLinux")
184: .charAt(0)); // NOI18N
185: gridBagConstraints = new java.awt.GridBagConstraints();
186: gridBagConstraints.gridx = 0;
187: gridBagConstraints.gridy = 6;
188: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
189: panel2.add(linuxRadioButton, gridBagConstraints);
190:
191: windowsRadioButton.setText(getString("RB_PlatformTypeWindows")); // NOI18N
192: windowsRadioButton.setMnemonic(getString(
193: "MNEM_PlatformTypeWindows").charAt(0)); // NOI18N
194: windowsRadioButton.addItemListener(new ItemListener() {
195: public void itemStateChanged(ItemEvent event) {
196: if (event.getStateChange() == ItemEvent.SELECTED) {
197: if (sunCollectionRadioButton.isSelected()) {
198: gnuCollectionRadioButton.setSelected(true);
199: }
200: sunCollectionRadioButton.setEnabled(false);
201: } else {
202: sunCollectionRadioButton.setEnabled(true);
203: }
204: }
205: });
206: gridBagConstraints = new java.awt.GridBagConstraints();
207: gridBagConstraints.gridx = 0;
208: gridBagConstraints.gridy = 7;
209: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
210: panel2.add(windowsRadioButton, gridBagConstraints);
211:
212: macosxRadioButton.setText(getString("RB_PlatformTypeMasOSX")); // NOI18N
213: macosxRadioButton.setMnemonic(getString(
214: "MNEM_PlatformTypeMasOSX").charAt(0)); // NOI18N
215: macosxRadioButton.addItemListener(new ItemListener() {
216: public void itemStateChanged(ItemEvent event) {
217: if (event.getStateChange() == ItemEvent.SELECTED) {
218: if (sunCollectionRadioButton.isSelected()) {
219: gnuCollectionRadioButton.setSelected(true);
220: }
221: sunCollectionRadioButton.setEnabled(false);
222: } else {
223: sunCollectionRadioButton.setEnabled(true);
224: }
225: }
226: });
227: gridBagConstraints = new java.awt.GridBagConstraints();
228: gridBagConstraints.gridx = 0;
229: gridBagConstraints.gridy = 8;
230: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
231: panel2.add(macosxRadioButton, gridBagConstraints);
232:
233: message2.setBackground(panel.getBackground());
234: message2.setEditable(false);
235: message2.setLineWrap(true);
236: message2.setWrapStyleWord(true);
237: message2.setFocusable(false);
238: message2.setText(getString("TXT_PlatformTypeMsg2")); // NOI18N
239: message2.setFocusable(false);
240: gridBagConstraints = new java.awt.GridBagConstraints();
241: gridBagConstraints.gridx = 0;
242: gridBagConstraints.gridy = 9;
243: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
244: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
245: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
246: gridBagConstraints.weightx = 1.0;
247: gridBagConstraints.weighty = 1.0;
248: panel2.add(message2, gridBagConstraints);
249:
250: gridBagConstraints = new java.awt.GridBagConstraints();
251: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
252: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
253: gridBagConstraints.weightx = 1.0;
254: gridBagConstraints.weighty = 1.0;
255: panel.add(panel2, gridBagConstraints);
256:
257: // Create button groups and the buttons ...
258: compilerButtonGroup.add(sunCollectionRadioButton);
259: compilerButtonGroup.add(gnuCollectionRadioButton);
260:
261: platformButtonGroup.add(solarisRadioButton);
262: platformButtonGroup.add(linuxRadioButton);
263: platformButtonGroup.add(windowsRadioButton);
264: platformButtonGroup.add(macosxRadioButton);
265: }
266:
267: /** Create the widgets if not initialized. Also set the RadioButtons */
268: public void addNotify() {
269: if (!initialized) {
270: create();
271: initialized = true;
272:
273: // Check OS. If Solaris, choose Sun as default platform....
274: String osname = System.getProperty("os.name"); // NOI18N
275: osname = osname.toLowerCase();
276: if (osname.indexOf("sunos") >= 0) { // NOI18N
277: getMakefileData().setToolset(
278: MakefileData.SUN_TOOLSET_TYPE);
279: getMakefileData().setMakefileOS(
280: MakefileData.SOLARIS_OS_TYPE);
281: } else if (osname.indexOf("linux") >= 0) { // NOI18N
282: getMakefileData().setToolset(
283: MakefileData.GNU_TOOLSET_TYPE);
284: getMakefileData().setMakefileOS(
285: MakefileData.LINUX_OS_TYPE);
286: } else if (osname.startsWith("windows")) { // NOI18N
287: getMakefileData().setToolset(
288: MakefileData.GNU_TOOLSET_TYPE);
289: getMakefileData().setMakefileOS(
290: MakefileData.WINDOWS_OS_TYPE);
291: } else if (osname.startsWith("mac")) { // NOI18N
292: getMakefileData().setToolset(
293: MakefileData.GNU_TOOLSET_TYPE);
294: getMakefileData().setMakefileOS(
295: MakefileData.MACOSX_OS_TYPE);
296: } else {
297: getMakefileData().setToolset(
298: MakefileData.GNU_TOOLSET_TYPE);
299: getMakefileData().setMakefileOS(
300: MakefileData.LINUX_OS_TYPE);
301: }
302: }
303:
304: if (getMakefileData().getToolset() == MakefileData.SUN_TOOLSET_TYPE) {
305: sunCollectionRadioButton.setSelected(true);
306: } else if (getMakefileData().getToolset() == MakefileData.GNU_TOOLSET_TYPE) {
307: gnuCollectionRadioButton.setSelected(true);
308: }
309:
310: if (getMakefileData().getMakefileOS() == MakefileData.SOLARIS_OS_TYPE) {
311: solarisRadioButton.setSelected(true);
312: } else if (getMakefileData().getMakefileOS() == MakefileData.LINUX_OS_TYPE) {
313: linuxRadioButton.setSelected(true);
314: } else if (getMakefileData().getMakefileOS() == MakefileData.WINDOWS_OS_TYPE) {
315: windowsRadioButton.setSelected(true);
316: } else if (getMakefileData().getMakefileOS() == MakefileData.MACOSX_OS_TYPE) {
317: macosxRadioButton.setSelected(true);
318: }
319:
320: super .addNotify();
321: sunCollectionRadioButton.requestFocus();
322: }
323:
324: public void removeNotify() {
325: super.removeNotify();
326: if (sunCollectionRadioButton.isSelected()) {
327: getMakefileData().setToolset(MakefileData.SUN_TOOLSET_TYPE);
328: } else if (gnuCollectionRadioButton.isSelected()) {
329: getMakefileData().setToolset(MakefileData.GNU_TOOLSET_TYPE);
330: }
331:
332: if (solarisRadioButton.isSelected()) {
333: getMakefileData().setMakefileOS(
334: MakefileData.SOLARIS_OS_TYPE);
335: } else if (linuxRadioButton.isSelected()) {
336: getMakefileData().setMakefileOS(MakefileData.LINUX_OS_TYPE);
337: } else if (windowsRadioButton.isSelected()) {
338: getMakefileData().setMakefileOS(
339: MakefileData.WINDOWS_OS_TYPE);
340: } else if (macosxRadioButton.isSelected()) {
341: getMakefileData()
342: .setMakefileOS(MakefileData.MACOSX_OS_TYPE);
343: }
344: }
345:
346: }
|