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.JLabel;
047: import javax.swing.JPanel;
048: import org.netbeans.modules.cnd.api.utils.IpeUtils;
049:
050: /**
051: * Create the third panel in the Makefile wizard.
052: */
053:
054: public class SelectPreferencesPanel extends MakefileWizardPanel {
055:
056: /** Serial version number */
057: static final long serialVersionUID = -8883172608978315976L;
058:
059: // the fields in the first panel...
060: private JLabel compilerMsg;
061: private boolean initialized;
062: private javax.swing.JPanel panel2;
063: private javax.swing.JTextArea compilerMsg2;
064: private javax.swing.JCheckBox debugCheckBox;
065: private javax.swing.JCheckBox optimizeCheckBox;
066:
067: /**
068: * Constructor for the Makefile name panel. Remember, most of the panel is
069: * inherited from WizardDescriptor.
070: */
071: SelectPreferencesPanel(MakefileWizard wd) {
072: super (wd);
073: String subtitle = getString("LBL_SelectPreferencesPanel"); // NOI18N
074: setSubTitle(subtitle);
075: this .getAccessibleContext().setAccessibleDescription(subtitle);
076: initialized = false;
077: }
078:
079: /** Defer widget creation until the panel needs to be displayed */
080: private void create() {
081:
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: compilerMsg = new JLabel();
097: debugCheckBox = new javax.swing.JCheckBox();
098: optimizeCheckBox = new javax.swing.JCheckBox();
099: compilerMsg2 = new javax.swing.JTextArea();
100:
101: gridBagConstraints.weightx = 1.0;
102: gridBagConstraints.weighty = 1.0;
103: gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
104: gridBagConstraints.gridheight = GridBagConstraints.REMAINDER;
105: gridBagConstraints.fill = GridBagConstraints.BOTH;
106: add(new JLabel(""), gridBagConstraints); // NOI18N
107:
108: panel2.setLayout(new java.awt.GridBagLayout());
109:
110: compilerMsg.setText(getString("LBL_CompilerFlagsMsg")); // NOI18N
111: gridBagConstraints = new java.awt.GridBagConstraints();
112: gridBagConstraints.gridx = 0;
113: gridBagConstraints.gridy = 0;
114: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
115: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
116: panel2.add(compilerMsg, gridBagConstraints);
117:
118: debugCheckBox.setText(getString("RB_DebugMsg")); // NOI18N
119: debugCheckBox.setMnemonic(getString("MNEM_DebugMsg").charAt(0)); // NOI18N
120: gridBagConstraints = new java.awt.GridBagConstraints();
121: gridBagConstraints.gridx = 0;
122: gridBagConstraints.gridy = 1;
123: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
124: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
125: gridBagConstraints.weightx = 1.0;
126: panel2.add(debugCheckBox, gridBagConstraints);
127:
128: optimizeCheckBox.setText(getString("RB_OptMsg")); // NOI18N
129: optimizeCheckBox
130: .setMnemonic(getString("MNEM_OptMsg").charAt(0)); // NOI18N
131: gridBagConstraints = new java.awt.GridBagConstraints();
132: gridBagConstraints.gridx = 0;
133: gridBagConstraints.gridy = 2;
134: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
135: panel2.add(optimizeCheckBox, gridBagConstraints);
136:
137: compilerMsg2.setBackground(panel.getBackground());
138: compilerMsg2.setEditable(false);
139: compilerMsg2.setLineWrap(true);
140: compilerMsg2.setWrapStyleWord(true);
141: compilerMsg2.setFocusable(false);
142: compilerMsg2.setText(getString("LBL_CompilerFlagsMsg2")); // NOI18N
143: gridBagConstraints = new java.awt.GridBagConstraints();
144: gridBagConstraints.gridx = 0;
145: gridBagConstraints.gridy = 3;
146: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
147: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
148: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
149: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
150: gridBagConstraints.weightx = 1.0;
151: panel2.add(compilerMsg2, gridBagConstraints);
152:
153: gridBagConstraints = new java.awt.GridBagConstraints();
154: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
155: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
156: gridBagConstraints.weightx = 1.0;
157: gridBagConstraints.weighty = 1.0;
158: panel.add(panel2, gridBagConstraints);
159: }
160:
161: /** Create the widgets if not initialized. Also set the RadioButtons */
162: public void addNotify() {
163: CompilerFlags copts = getMakefileData().getCompilerFlags();
164:
165: if (!initialized) {
166: create();
167: copts.setOptionSource(OptionSource.SIMPLE);
168: copts.setSimpleDebug(true);
169: initialized = true;
170: }
171:
172: super .addNotify();
173: debugCheckBox.setSelected(copts.isSimpleDebug());
174: optimizeCheckBox.setSelected(copts.isSimpleOptimize());
175: // Try to get focus (two different methods ...)
176: debugCheckBox.requestFocus();
177: IpeUtils.requestFocus(debugCheckBox);
178: }
179:
180: public void removeNotify() {
181: super .removeNotify();
182:
183: CompilerFlags copts = getMakefileData().getCompilerFlags();
184:
185: copts.setSimpleDebug(debugCheckBox.isSelected());
186: copts.setSimpleOptimize(optimizeCheckBox.isSelected());
187: }
188:
189: }
|