KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > jpda > ui > breakpoints > ThreadBreakpointPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.debugger.jpda.ui.breakpoints;
21
22 import javax.swing.JPanel JavaDoc;
23 import org.netbeans.api.debugger.DebuggerManager;
24
25 import org.netbeans.api.debugger.jpda.ThreadBreakpoint;
26 import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge;
27 import org.netbeans.spi.debugger.ui.Controller;
28 import org.openide.util.NbBundle;
29
30 /**
31  * @author Jan Jancura
32  */

33 // <RAVE> CR 6207738 - fix debugger help IDs
34
// Implement HelpCtx.Provider interface to provide help ids for help system
35
// public class ThreadBreakpointPanel extends JPanel implements Controller {
36
// ====
37
public class ThreadBreakpointPanel extends JPanel JavaDoc implements Controller, org.openide.util.HelpCtx.Provider {
38 // </RAVE>
39

40     private ActionsPanel actionsPanel;
41     private ThreadBreakpoint breakpoint;
42     private boolean createBreakpoint = false;
43     
44     
45     private static ThreadBreakpoint creteBreakpoint () {
46         ThreadBreakpoint mb = ThreadBreakpoint.create ();
47         mb.setPrintText (
48             NbBundle.getBundle (ThreadBreakpointPanel.class).getString
49                 ("CTL_Thread_Breakpoint_Print_Text")
50         );
51         return mb;
52     }
53     
54     
55     /** Creates new form LineBreakpointPanel */
56     public ThreadBreakpointPanel () {
57         this (creteBreakpoint ());
58         createBreakpoint = true;
59     }
60     
61     /** Creates new form LineBreakpointPanel */
62     public ThreadBreakpointPanel (ThreadBreakpoint b) {
63         breakpoint = b;
64         initComponents ();
65         
66         cbBreakpointType.addItem (java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle").getString("LBL_Thread_Breakpoint_Type_Start"));
67         cbBreakpointType.addItem (java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle").getString("LBL_Thread_Breakpoint_Type_Death"));
68         cbBreakpointType.addItem (java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle").getString("LBL_Thread_Breakpoint_Type_Start_or_Death"));
69         switch (b.getBreakpointType ()) {
70             case ThreadBreakpoint.TYPE_THREAD_STARTED:
71                 cbBreakpointType.setSelectedIndex (0);
72                 break;
73             case ThreadBreakpoint.TYPE_THREAD_DEATH:
74                 cbBreakpointType.setSelectedIndex (1);
75                 break;
76             case ThreadBreakpoint.TYPE_THREAD_STARTED_OR_DEATH:
77                 cbBreakpointType.setSelectedIndex (2);
78                 break;
79         }
80         
81         actionsPanel = new ActionsPanel (b);
82         pActions.add (actionsPanel, "Center");
83         // <RAVE>
84
// The help IDs for the AddBreakpointPanel panels have to be different from the
85
// values returned by getHelpCtx() because they provide different help
86
// in the 'Add Breakpoint' dialog and when invoked in the 'Breakpoints' view
87
putClientProperty("HelpID_AddBreakpointPanel", "debug.add.breakpoint.java.thread"); // NOI18N
88
// </RAVE>
89
}
90     
91     // <RAVE>
92
// Implement getHelpCtx() with the correct helpID
93
public org.openide.util.HelpCtx getHelpCtx() {
94         return new org.openide.util.HelpCtx("NetbeansDebuggerBreakpointThreadJPDA"); // NOI18N
95
}
96     // </RAVE>
97

98     /** This method is called from within the constructor to
99      * initialize the form.
100      * WARNING: Do NOT modify this code. The content of this method is
101      * always regenerated by the Form Editor.
102      */

103     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
104
private void initComponents() {
105         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
106
107         pSettings = new javax.swing.JPanel JavaDoc();
108         jLabel4 = new javax.swing.JLabel JavaDoc();
109         cbBreakpointType = new javax.swing.JComboBox JavaDoc();
110         pActions = new javax.swing.JPanel JavaDoc();
111         jPanel1 = new javax.swing.JPanel JavaDoc();
112
113         setLayout(new java.awt.GridBagLayout JavaDoc());
114
115         pSettings.setLayout(new java.awt.GridBagLayout JavaDoc());
116
117         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle"); // NOI18N
118
pSettings.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("L_Thread_Breakpoint_BorderTitle"))); // NOI18N
119
jLabel4.setLabelFor(cbBreakpointType);
120         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, bundle.getString("L_Thread_Breakpoint_Type")); // NOI18N
121
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
122         gridBagConstraints.gridx = 0;
123         gridBagConstraints.gridy = 3;
124         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
125         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
126         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
127         pSettings.add(jLabel4, gridBagConstraints);
128         jLabel4.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_L_Thread_Breakpoint_Type")); // NOI18N
129

130         cbBreakpointType.setToolTipText(bundle.getString("TTT_CB_Thread_Breakpoint_Type")); // NOI18N
131
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
132         gridBagConstraints.gridx = 1;
133         gridBagConstraints.gridy = 3;
134         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
135         gridBagConstraints.weightx = 1.0;
136         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
137         pSettings.add(cbBreakpointType, gridBagConstraints);
138         cbBreakpointType.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CB_Thread_Breakpoint_Type")); // NOI18N
139

140         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
141         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
142         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
143         gridBagConstraints.weightx = 1.0;
144         add(pSettings, gridBagConstraints);
145
146         pActions.setLayout(new java.awt.BorderLayout JavaDoc());
147
148         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
150         gridBagConstraints.weightx = 1.0;
151         add(pActions, gridBagConstraints);
152
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 0;
155         gridBagConstraints.gridy = 2;
156         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
157         gridBagConstraints.weightx = 1.0;
158         gridBagConstraints.weighty = 1.0;
159         add(jPanel1, gridBagConstraints);
160
161     }// </editor-fold>//GEN-END:initComponents
162

163     
164     // Controller implementation ...............................................
165

166     /**
167      * Called when "Ok" button is pressed.
168      *
169      * @return whether customizer can be closed
170      */

171     public boolean ok () {
172         actionsPanel.ok ();
173         switch (cbBreakpointType.getSelectedIndex ()) {
174             case 0:
175                 breakpoint.setBreakpointType (ThreadBreakpoint.TYPE_THREAD_STARTED);
176                 break;
177             case 1:
178                 breakpoint.setBreakpointType (ThreadBreakpoint.TYPE_THREAD_DEATH);
179                 break;
180             case 2:
181                 breakpoint.setBreakpointType (ThreadBreakpoint.TYPE_THREAD_STARTED_OR_DEATH);
182                 break;
183         }
184         
185         if (createBreakpoint)
186             DebuggerManager.getDebuggerManager ().addBreakpoint (breakpoint);
187         return true;
188     }
189     
190     /**
191      * Called when "Cancel" button is pressed.
192      *
193      * @return whether customizer can be closed
194      */

195     public boolean cancel () {
196         return true;
197     }
198     
199     /**
200      * Return <code>true</code> whether value of this customizer
201      * is valid (and OK button can be enabled).
202      *
203      * @return <code>true</code> whether value of this customizer
204      * is valid
205      */

206     public boolean isValid () {
207         return true;
208     }
209     
210     
211     // Variables declaration - do not modify//GEN-BEGIN:variables
212
private javax.swing.JComboBox JavaDoc cbBreakpointType;
213     private javax.swing.JLabel JavaDoc jLabel4;
214     private javax.swing.JPanel JavaDoc jPanel1;
215     private javax.swing.JPanel JavaDoc pActions;
216     private javax.swing.JPanel JavaDoc pSettings;
217     // End of variables declaration//GEN-END:variables
218

219 }
220
Popular Tags