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.Insets;
046: import java.awt.event.ItemEvent;
047: import java.awt.event.ItemListener;
048: import javax.swing.ButtonGroup;
049: import javax.swing.JCheckBox;
050: import javax.swing.JLabel;
051: import javax.swing.JRadioButton;
052: import org.netbeans.modules.cnd.api.utils.IpeUtils;
053:
054: /**
055: * Create the basic compiler flags panel in the Makefile wizard.
056: */
057:
058: public class BasicFlagsPanel extends MakefileWizardPanel {
059:
060: /** Serial version number */
061: static final long serialVersionUID = -2105207605584107631L;
062:
063: /** Code Development flags are active */
064: private JRadioButton develBuildRB;
065:
066: /** Code Development subflag: Just compile with optimization */
067: private JRadioButton develDebugCodeRB;
068:
069: /** Code Development subflag: Compile with optimization and debugging */
070: private JRadioButton develOptDebugCodeRB;
071:
072: ///** Code Development subflag: Compile with SourceBrowser information */
073: //private JCheckBox sbrowseTB;
074:
075: /** Final Code flags are active */
076: private JRadioButton finalBuildRB;
077:
078: /** Final Code subflag: Build optimized code */
079: private JCheckBox finalOptTB;
080:
081: /** Final Code subflag: Strip symbolic information */
082: private JCheckBox finalStripTB;
083:
084: /** The application should be compiled as a 64 bit binary */
085: private JCheckBox create64BitTB;
086:
087: /** Do f90 module reordering in generated Makefile if set */
088: private JCheckBox moduleSupportTB;
089:
090: /** The gui has been initialized */
091: private boolean initialized;
092:
093: /**
094: * Constructor for the Standard Libraries panel.
095: */
096: public BasicFlagsPanel(MakefileWizard wd) {
097: super (wd);
098: String subtitle = getString("LBL_BasicFlagsPanel"); // NOI18N
099: setSubTitle(subtitle);
100: this .getAccessibleContext().setAccessibleDescription(subtitle);
101: initialized = false;
102: }
103:
104: /** Defer widget creation until the panel needs to be displayed */
105: private void create() {
106:
107: setLayout(new java.awt.GridBagLayout());
108: GridBagConstraints grid = new GridBagConstraints();
109: grid.anchor = GridBagConstraints.NORTHWEST;
110: grid.fill = GridBagConstraints.HORIZONTAL;
111: grid.gridx = 0;
112: grid.gridy = GridBagConstraints.RELATIVE;
113: grid.gridwidth = GridBagConstraints.REMAINDER;
114: grid.weightx = 1.0;
115:
116: // Create the Development/Final code build section
117: add(new JLabel(getString("LBL_BuildMode")), grid); // NOI18N
118:
119: develBuildRB = new JRadioButton(getString("RB_DevelBuild")); // NOI18N
120: develBuildRB.setSelected(true);
121: develBuildRB
122: .setMnemonic(getString("MNEM_DevelBuild").charAt(0)); // NOI18N
123: add(develBuildRB, grid);
124:
125: develDebugCodeRB = new JRadioButton(getString("RB_DebugFlag")); // NOI18N
126: develDebugCodeRB.setSelected(true);
127: develDebugCodeRB.setMnemonic(getString("MNEM_DebugFlag")
128: .charAt(0)); // NOI18N
129: grid.insets = new Insets(0, 17, 0, 0);
130: add(develDebugCodeRB, grid);
131:
132: develOptDebugCodeRB = new JRadioButton(
133: getString("RB_OptDebugFlag")); // NOI18N
134: develOptDebugCodeRB.setMnemonic(getString("MNEM_OptDebugFlag")
135: .charAt(0)); // NOI18N
136: add(develOptDebugCodeRB, grid);
137:
138: ButtonGroup develGroup = new ButtonGroup();
139: develGroup.add(develDebugCodeRB);
140: develGroup.add(develOptDebugCodeRB);
141:
142: /* Not currently part of Krakatoa. I'm leaving the code here in case
143: * it gets added later (grp - 4/01).
144: sbrowseTB = new JCheckBox(getString("TB_SourceBrowseFlag")); // NOI18N
145: sbrowseTB.setMnemonic(
146: getString("MNEM_SourceBrowseFlag").charAt(0)); // NOI18N
147: add(sbrowseTB, grid);
148: */
149:
150: finalBuildRB = new JRadioButton(getString("RB_FinalBuild")); // NOI18N
151: finalBuildRB
152: .setMnemonic(getString("MNEM_FinalBuild").charAt(0)); // NOI18N
153: grid.insets.top = 5;
154: grid.insets.left = 0;
155: add(finalBuildRB, grid);
156:
157: finalOptTB = new JCheckBox(getString("TB_OptimizeFlag")); // NOI18N
158: finalOptTB
159: .setMnemonic(getString("MNEM_OptimizeFlag").charAt(0)); // NOI18N
160: finalOptTB.setEnabled(false);
161: grid.insets.top = 0;
162: grid.insets.left = 17;
163: add(finalOptTB, grid);
164:
165: finalStripTB = new JCheckBox(getString("TB_StripFlag")); // NOI18N
166: finalStripTB.setMnemonic(getString("MNEM_StripFlag").charAt(0));// NOI18N
167: finalStripTB.setEnabled(false);
168: add(finalStripTB, grid);
169:
170: // Group the Code Development and Final Code RadioButtons
171: ButtonGroup buildGroup = new ButtonGroup();
172: buildGroup.add(develBuildRB);
173: buildGroup.add(finalBuildRB);
174:
175: create64BitTB = new JCheckBox(getString("TB_64BitFlag")); // NOI18N
176: create64BitTB
177: .setMnemonic(getString("MNEM_64BitFlag").charAt(0)); // NOI18N
178: grid.insets.top = 11;
179: grid.insets.left = 0;
180: add(create64BitTB, grid);
181:
182: moduleSupportTB = new JCheckBox(
183: getString("TB_EnableModuleSupport")); // NOI18N
184: moduleSupportTB.setMnemonic(getString(
185: "MNEM_EnableModuleSupport").charAt(0)); // NOI18N
186: grid.insets.top = 5;
187: add(moduleSupportTB, grid);
188:
189: //xxx
190: /*
191: grid.insets.top = 11;
192: grid.insets.left = 0;
193: JLabel conformanceLabel = new JLabel("Compiler Conformance Level:");
194: add(conformanceLabel, grid);
195:
196: JLabel cLabel = new JLabel(getString("LBL_C"));
197: cLabel.setDisplayedMnemonic(getString("MNEM_C").charAt(0));
198: grid = new GridBagConstraints();
199: grid.anchor = GridBagConstraints.NORTHWEST;
200: grid.fill = GridBagConstraints.NONE;
201: grid.insets.top = 6;
202: grid.insets.left = 0;
203: grid.gridx = 0;
204: grid.gridy = 10;
205: add(cLabel, grid);
206:
207: JComboBox cComboBox = new JComboBox(new String[] {"ISO C (-Xc)", "ISO C Plus K&R C (-Xa)"});
208: grid.anchor = GridBagConstraints.NORTHWEST;
209: grid.fill = GridBagConstraints.NONE;
210: grid.insets.top = 0;
211: grid.insets.left = 0;
212: grid.gridx = 1;
213: grid.gridy = 10;
214: add(cComboBox, grid);
215:
216: JLabel cppLabel = new JLabel(getString("LBL_Cpp"));
217: cppLabel.setDisplayedMnemonic(getString("MNEM_Cpp").charAt(0));
218: grid = new GridBagConstraints();
219: grid.anchor = GridBagConstraints.NORTHWEST;
220: grid.fill = GridBagConstraints.NONE;
221: grid.insets.top = 6;
222: grid.insets.left = 0;
223: grid.gridx = 0;
224: grid.gridy = 11;
225: add(cppLabel, grid);
226:
227: JComboBox cppComboBox = new JComboBox(new String[] {"ISO C (-Xc)", "ISO C Plus K&R C (-Xa)"});
228: grid.anchor = GridBagConstraints.NORTHWEST;
229: grid.fill = GridBagConstraints.NONE;
230: grid.insets.top = 0;
231: grid.insets.left = 0;
232: grid.gridx = 1;
233: grid.gridy = 11;
234: add(cppComboBox, grid);
235: */
236:
237: grid.gridwidth = GridBagConstraints.REMAINDER;
238: grid.gridheight = GridBagConstraints.REMAINDER;
239: grid.weightx = 1.0;
240: grid.weighty = 1.0;
241: add(new JLabel(""), grid); // NOI18N
242:
243: develBuildRB.addItemListener(new ItemListener() {
244: public void itemStateChanged(ItemEvent event) {
245: if (develBuildRB.isSelected()) {
246: develDebugCodeRB.setEnabled(true);
247: develOptDebugCodeRB.setEnabled(true);
248: //sbrowseTB.setEnabled(true);
249: } else {
250: develDebugCodeRB.setEnabled(false);
251: develOptDebugCodeRB.setEnabled(false);
252: //sbrowseTB.setEnabled(false);
253: }
254: }
255: });
256:
257: finalBuildRB.addItemListener(new ItemListener() {
258: public void itemStateChanged(ItemEvent event) {
259: if (finalBuildRB.isSelected()) {
260: finalOptTB.setEnabled(true);
261: finalStripTB.setEnabled(true);
262: } else {
263: finalOptTB.setEnabled(false);
264: finalStripTB.setEnabled(false);
265: }
266: }
267: });
268: }
269:
270: /** Create the widgets if not initialized */
271: public void addNotify() {
272: CompilerFlags copts = getMakefileData().getCompilerFlags();
273:
274: if (!initialized) {
275: create();
276: initialized = true;
277: }
278:
279: // Initialize data from the current CompilerFlags
280: if (copts.getOptionSource() == OptionSource.DEVELOPMENT) {
281: develBuildRB.setSelected(true);
282: } else {
283: finalBuildRB.setSelected(true);
284: }
285: finalOptTB.setSelected(copts.isFinalOptimize());
286: finalStripTB.setSelected(copts.isFinalStrip());
287: develDebugCodeRB.setSelected(copts.isDevelDebug());
288:
289: // 64 bit compilation flag
290: create64BitTB.setSelected(copts.is64Bit());
291:
292: // Fortran module support
293: moduleSupportTB
294: .setSelected(getMakefileData().isModuleEnabled());
295:
296: // Disable fortran module support for GNU compiler
297: if (getMakefileData().getToolset() == MakefileData.GNU_TOOLSET_TYPE) {
298: getMakefileData().setModuleEnabled(false);
299: moduleSupportTB.setEnabled(false);
300: }
301:
302: IpeUtils.requestFocus(develBuildRB);
303: super .addNotify();
304: }
305:
306: /** Get the data from the panel and update the target */
307: public void removeNotify() {
308: super .removeNotify();
309:
310: CompilerFlags copts = getMakefileData().getCompilerFlags();
311:
312: // Build flags
313: if (develBuildRB.isSelected()) {
314: copts.setOptionSource(OptionSource.DEVELOPMENT);
315: } else {
316: copts.setOptionSource(OptionSource.FINAL);
317: }
318:
319: copts.setFinalOptimize(finalOptTB.isSelected());
320: copts.setFinalStrip(finalStripTB.isSelected());
321: copts.setDevelDebug(develDebugCodeRB.isSelected());
322:
323: // 64 bit flag
324: copts.set64Bit(create64BitTB.isSelected());
325:
326: // Fortran module support
327: getMakefileData()
328: .setModuleEnabled(moduleSupportTB.isSelected());
329: }
330: }
|