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.debugger.gdb.breakpoints;
043:
044: import java.awt.event.ItemEvent;
045: import java.awt.event.ItemListener;
046: import javax.swing.JPanel;
047: import org.netbeans.modules.cnd.debugger.gdb.breakpoints.GdbBreakpoint;
048: import org.openide.util.NbBundle;
049:
050: /**
051: * Panel for customizing breakpoints.
052: * This panel is a part of "New Breakpoint" dialog.
053: *
054: * @author Nik Molchanov (copied and modified from JDPA debugger).
055: */
056: public class ActionsPanel extends JPanel implements ItemListener {
057:
058: private GdbBreakpoint breakpoint;
059:
060: /** Creates new form LineBreakpointPanel */
061: public ActionsPanel(GdbBreakpoint b) {
062: breakpoint = b;
063: initComponents();
064:
065: cbSuspend.addItem(NbBundle.getMessage(ActionsPanel.class,
066: "LBL_CB_Actions_Panel_Suspend_None")); // NOI18N
067: cbSuspend.addItem(NbBundle.getMessage(ActionsPanel.class,
068: "LBL_CB_Actions_Panel_Suspend_Current")); // NOI18N
069: cbSuspend.addItem(NbBundle.getMessage(ActionsPanel.class,
070: "LBL_CB_Actions_Panel_Suspend_All")); // NOI18N
071: tfThreadID.setText(b.getThreadID());
072:
073: switch (b.getSuspend()) {
074: case GdbBreakpoint.SUSPEND_NONE:
075: cbSuspend.setSelectedIndex(0);
076: tfThreadID.setEnabled(false);
077: lThreadID.setEnabled(false);
078: break;
079: case GdbBreakpoint.SUSPEND_THREAD:
080: cbSuspend.setSelectedIndex(1);
081: tfThreadID.setEnabled(true);
082: lThreadID.setEnabled(true);
083: break;
084: case GdbBreakpoint.SUSPEND_ALL:
085: default:
086: cbSuspend.setSelectedIndex(2);
087: tfThreadID.setEnabled(false);
088: lThreadID.setEnabled(false);
089: break;
090: }
091: if (b.getPrintText() != null) {
092: tfPrintText.setText(b.getPrintText());
093: }
094: }
095:
096: /**
097: * Called when "Ok" button is pressed.
098: */
099: public void ok() {
100: String printText = tfPrintText.getText();
101: if (printText.trim().length() > 0) {
102: breakpoint.setPrintText(printText.trim());
103: } else {
104: breakpoint.setPrintText(null);
105: }
106:
107: switch (cbSuspend.getSelectedIndex()) {
108: case 0:
109: breakpoint.setSuspend(GdbBreakpoint.SUSPEND_NONE);
110: break;
111: case 1:
112: breakpoint.setSuspend(GdbBreakpoint.SUSPEND_THREAD,
113: tfThreadID.getText());
114: break;
115: case 2:
116: breakpoint.setSuspend(GdbBreakpoint.SUSPEND_ALL);
117: break;
118: }
119: }
120:
121: public void itemStateChanged(ItemEvent ev) {
122: if (ev.getStateChange() == ItemEvent.SELECTED
123: && ev.getSource() == cbSuspend) {
124: int idx = cbSuspend.getSelectedIndex();
125: tfThreadID.setEnabled(idx == GdbBreakpoint.SUSPEND_THREAD);
126: lThreadID.setEnabled(idx == GdbBreakpoint.SUSPEND_THREAD);
127: }
128: }
129:
130: /** This method is called from within the constructor to
131: * initialize the form.
132: * WARNING: Do NOT modify this code. The content of this method is
133: * always regenerated by the Form Editor.
134: */
135: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
136: private void initComponents() {
137: java.awt.GridBagConstraints gridBagConstraints;
138:
139: lSuspend = new javax.swing.JLabel();
140: cbSuspend = new javax.swing.JComboBox();
141: cbSuspend.addItemListener(this );
142: lThreadID = new javax.swing.JLabel();
143: tfThreadID = new javax.swing.JTextField();
144: tfPrintText = new javax.swing.JTextField();
145: lPrintText = new javax.swing.JLabel();
146:
147: java.util.ResourceBundle bundle = java.util.ResourceBundle
148: .getBundle("org/netbeans/modules/cnd/debugger/gdb/breakpoints/Bundle"); // NOI18N
149: setBorder(javax.swing.BorderFactory.createTitledBorder(bundle
150: .getString("L_Actions_Panel_BorderTitle"))); // NOI18N
151: setLayout(new java.awt.GridBagLayout());
152:
153: lSuspend
154: .setDisplayedMnemonic(java.util.ResourceBundle
155: .getBundle(
156: "org/netbeans/modules/cnd/debugger/gdb/breakpoints/Bundle")
157: .getString("MN_L_Actions_Panel_Suspend")
158: .charAt(0));
159: lSuspend.setLabelFor(cbSuspend);
160: lSuspend.setText(bundle.getString("L_Actions_Panel_Suspend")); // NOI18N
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridx = 0;
163: gridBagConstraints.gridy = 0;
164: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
165: add(lSuspend, gridBagConstraints);
166: lSuspend.getAccessibleContext().setAccessibleName(
167: bundle.getString("ACSD_L_Actions_Panel_Suspend")); // NOI18N
168: lSuspend.getAccessibleContext().setAccessibleDescription(
169: bundle.getString("ACSD_L_Actions_Panel_Suspend")); // NOI18N
170:
171: cbSuspend.setToolTipText(bundle
172: .getString("TTT_CB_Actions_Panel_Suspend")); // NOI18N
173: gridBagConstraints = new java.awt.GridBagConstraints();
174: gridBagConstraints.gridx = 1;
175: gridBagConstraints.gridy = 0;
176: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
177: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
178: gridBagConstraints.weightx = 2.0;
179: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
180: add(cbSuspend, gridBagConstraints);
181: cbSuspend.getAccessibleContext().setAccessibleName(
182: bundle.getString("ACSN_CB_Actions_Panel_Suspend")); // NOI18N
183: cbSuspend.getAccessibleContext().setAccessibleDescription(
184: bundle.getString("ACSD_CB_Actions_Panel_Suspend")); // NOI18N
185:
186: lThreadID
187: .setDisplayedMnemonic(java.util.ResourceBundle
188: .getBundle(
189: "org/netbeans/modules/cnd/debugger/gdb/breakpoints/Bundle")
190: .getString("MN_ThreadID").charAt(0));
191: lThreadID.setLabelFor(tfThreadID);
192: lThreadID.setText(org.openide.util.NbBundle.getMessage(
193: ActionsPanel.class, "L_Actions_Panel_ThreadID")); // NOI18N
194: gridBagConstraints = new java.awt.GridBagConstraints();
195: gridBagConstraints.gridx = 2;
196: gridBagConstraints.gridy = 0;
197: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
198: gridBagConstraints.insets = new java.awt.Insets(3, 6, 3, 3);
199: add(lThreadID, gridBagConstraints);
200:
201: tfThreadID.setColumns(4);
202: tfThreadID.setToolTipText(org.openide.util.NbBundle.getMessage(
203: ActionsPanel.class, "TT_ThreadID")); // NOI18N
204: tfThreadID.setAutoscrolls(false);
205: tfThreadID.setMinimumSize(new java.awt.Dimension(8, 21));
206: gridBagConstraints = new java.awt.GridBagConstraints();
207: gridBagConstraints.gridx = 3;
208: gridBagConstraints.gridy = 0;
209: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
210: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
211: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
212: add(tfThreadID, gridBagConstraints);
213:
214: tfPrintText.setToolTipText(bundle
215: .getString("TTT_TF_Actions_Panel_Print_Text")); // NOI18N
216: gridBagConstraints = new java.awt.GridBagConstraints();
217: gridBagConstraints.gridx = 1;
218: gridBagConstraints.gridy = 1;
219: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
220: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
221: gridBagConstraints.weightx = 1.0;
222: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
223: add(tfPrintText, gridBagConstraints);
224: tfPrintText.getAccessibleContext().setAccessibleName(
225: bundle.getString("ACSN_TF_Actions_Panel_Print_Text")); // NOI18N
226: tfPrintText.getAccessibleContext().setAccessibleDescription(
227: bundle.getString("ACSD_TF_Actions_Panel_Print_Text")); // NOI18N
228:
229: lPrintText
230: .setDisplayedMnemonic(java.util.ResourceBundle
231: .getBundle(
232: "org/netbeans/modules/cnd/debugger/gdb/breakpoints/Bundle")
233: .getString("MN_L_Actions_Panel_Print_Text")
234: .charAt(0));
235: lPrintText.setLabelFor(tfPrintText);
236: lPrintText.setText(bundle
237: .getString("L_Actions_Panel_Print_Text")); // NOI18N
238: gridBagConstraints = new java.awt.GridBagConstraints();
239: gridBagConstraints.gridx = 0;
240: gridBagConstraints.gridy = 1;
241: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
242: add(lPrintText, gridBagConstraints);
243: lPrintText.getAccessibleContext().setAccessibleName(
244: bundle.getString("ACSD_L_Actions_Panel_Print_Text")); // NOI18N
245: lPrintText.getAccessibleContext().setAccessibleDescription(
246: bundle.getString("ACSD_L_Actions_Panel_Print_Text")); // NOI18N
247:
248: getAccessibleContext().setAccessibleName(
249: bundle.getString("ACSN_Actions_Panel")); // NOI18N
250: getAccessibleContext().setAccessibleDescription(
251: bundle.getString("ACSD_Actions_Panel")); // NOI18N
252: }// </editor-fold>//GEN-END:initComponents
253:
254: // Variables declaration - do not modify//GEN-BEGIN:variables
255: private javax.swing.JComboBox cbSuspend;
256: private javax.swing.JLabel lPrintText;
257: private javax.swing.JLabel lSuspend;
258: private javax.swing.JLabel lThreadID;
259: private javax.swing.JTextField tfPrintText;
260: private javax.swing.JTextField tfThreadID;
261: // End of variables declaration//GEN-END:variables
262:
263: }
|