1 19 20 package org.netbeans.modules.debugger.jpda.ui.breakpoints; 21 22 import javax.swing.JPanel ; 23 import javax.swing.JOptionPane ; 24 import org.netbeans.api.debugger.DebuggerManager; 25 26 import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint; 27 import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge; 28 import org.netbeans.spi.debugger.ui.Controller; 29 import org.openide.util.NbBundle; 30 31 34 public class ClassBreakpointPanel extends JPanel implements Controller, org.openide.util.HelpCtx.Provider { 39 41 private ActionsPanel actionsPanel; 42 private ClassLoadUnloadBreakpoint breakpoint; 43 private boolean createBreakpoint = false; 44 45 46 private static ClassLoadUnloadBreakpoint creteBreakpoint () { 47 ClassLoadUnloadBreakpoint mb = ClassLoadUnloadBreakpoint.create ( 48 EditorContextBridge.getCurrentClassName (), 49 false, 50 ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED 51 ); 52 mb.setPrintText ( 53 NbBundle.getBundle (ClassBreakpointPanel.class).getString 54 ("CTL_Class_Breakpoint_Print_Text") 55 ); 56 return mb; 57 } 58 59 60 61 public ClassBreakpointPanel () { 62 this (creteBreakpoint ()); 63 createBreakpoint = true; 64 } 65 66 67 public ClassBreakpointPanel (ClassLoadUnloadBreakpoint b) { 68 breakpoint = b; 69 initComponents (); 70 71 String [] cf = b.getClassExclusionFilters (); 72 String className = ""; 73 if (cf.length > 0) { 74 cbExclusionFilter.setSelected (true); 75 className = cf [0]; 76 } else { 77 cbExclusionFilter.setSelected (false); 78 cf = b.getClassFilters (); 79 if (cf.length > 0) 80 className = cf [0]; 81 } 82 int i = className.lastIndexOf ('.'); 83 if (i < 0) { 84 tfPackageName.setText (""); 85 tfClassName.setText (className); 86 } else { 87 tfPackageName.setText (className.substring (0, i)); 88 tfClassName.setText (className.substring (i + 1, className.length ())); 89 } 90 cbBreakpointType.addItem (java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle").getString("LBL_Class_Breakpoint_Type_Prepare")); 91 cbBreakpointType.addItem (java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle").getString("LBL_Class_Breakpoint_Type_Unload")); 92 cbBreakpointType.addItem (java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle").getString("LBL_Class_Breakpoint_Type_Prepare_or_Unload")); 93 switch (b.getBreakpointType ()) { 94 case ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED: 95 cbBreakpointType.setSelectedIndex (0); 96 break; 97 case ClassLoadUnloadBreakpoint.TYPE_CLASS_UNLOADED: 98 cbBreakpointType.setSelectedIndex (1); 99 break; 100 case ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED: 101 cbBreakpointType.setSelectedIndex (2); 102 break; 103 } 104 105 actionsPanel = new ActionsPanel (b); 106 pActions.add (actionsPanel, "Center"); 107 putClientProperty("HelpID_AddBreakpointPanel", "debug.add.breakpoint.java.class"); } 114 115 public org.openide.util.HelpCtx getHelpCtx() { 118 return new org.openide.util.HelpCtx("NetbeansDebuggerBreakpointClassJPDA"); } 120 122 127 private void initComponents() { 129 java.awt.GridBagConstraints gridBagConstraints; 130 131 pSettings = new javax.swing.JPanel (); 132 jLabel1 = new javax.swing.JLabel (); 133 jLabel2 = new javax.swing.JLabel (); 134 tfPackageName = new javax.swing.JTextField (); 135 jLabel3 = new javax.swing.JLabel (); 136 tfClassName = new javax.swing.JTextField (); 137 cbExclusionFilter = new javax.swing.JCheckBox (); 138 jLabel4 = new javax.swing.JLabel (); 139 cbBreakpointType = new javax.swing.JComboBox (); 140 pActions = new javax.swing.JPanel (); 141 jPanel1 = new javax.swing.JPanel (); 142 143 setLayout(new java.awt.GridBagLayout ()); 144 145 pSettings.setLayout(new java.awt.GridBagLayout ()); 146 147 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle"); pSettings.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("L_Class_Breakpoint_BorderTitle"))); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, bundle.getString("L_Class_Breakpoint_filter_hint")); gridBagConstraints = new java.awt.GridBagConstraints (); 151 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 152 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 153 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 154 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 155 pSettings.add(jLabel1, gridBagConstraints); 156 jLabel1.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_L_Class_Breakpoint_filter_hint")); 158 jLabel2.setLabelFor(tfPackageName); 159 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, bundle.getString("L_Class_Breakpoint_Package_Name")); gridBagConstraints = new java.awt.GridBagConstraints (); 161 gridBagConstraints.gridx = 0; 162 gridBagConstraints.gridy = 1; 163 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 164 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 165 pSettings.add(jLabel2, gridBagConstraints); 166 jLabel2.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_L_Class_Breakpoint_Package_Name")); 168 tfPackageName.setToolTipText(bundle.getString("TTT_TF_Class_Breakpoint_Package_Name")); gridBagConstraints = new java.awt.GridBagConstraints (); 170 gridBagConstraints.gridx = 1; 171 gridBagConstraints.gridy = 1; 172 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 173 gridBagConstraints.weightx = 1.0; 174 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 175 pSettings.add(tfPackageName, gridBagConstraints); 176 tfPackageName.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TF_Class_Breakpoint_Package_Name")); 178 jLabel3.setLabelFor(tfClassName); 179 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, bundle.getString("L_Class_Breakpoint_Class_Name")); gridBagConstraints = new java.awt.GridBagConstraints (); 181 gridBagConstraints.gridx = 0; 182 gridBagConstraints.gridy = 2; 183 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 184 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 185 pSettings.add(jLabel3, gridBagConstraints); 186 jLabel3.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_L_Class_Breakpoint_Class_Name")); 188 tfClassName.setToolTipText(bundle.getString("TTT_TF_Class_Breakpoint_Class_Name")); gridBagConstraints = new java.awt.GridBagConstraints (); 190 gridBagConstraints.gridx = 1; 191 gridBagConstraints.gridy = 2; 192 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 193 gridBagConstraints.weightx = 1.0; 194 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 195 pSettings.add(tfClassName, gridBagConstraints); 196 tfClassName.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TF_Class_Breakpoint_Class_Name")); 198 org.openide.awt.Mnemonics.setLocalizedText(cbExclusionFilter, bundle.getString("CB_Class_Breakpoint_Exclusion_Filter")); cbExclusionFilter.setToolTipText(bundle.getString("TTT_CB_Class_Breakpoint_Exclusion_Filter")); gridBagConstraints = new java.awt.GridBagConstraints (); 201 gridBagConstraints.gridx = 0; 202 gridBagConstraints.gridy = 3; 203 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 204 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 205 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 206 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 207 pSettings.add(cbExclusionFilter, gridBagConstraints); 208 cbExclusionFilter.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CB_Class_Breakpoint_Exclusion_Filter")); 210 jLabel4.setLabelFor(cbBreakpointType); 211 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, bundle.getString("L_Class_Breakpoint_Type")); gridBagConstraints = new java.awt.GridBagConstraints (); 213 gridBagConstraints.gridx = 0; 214 gridBagConstraints.gridy = 4; 215 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 216 pSettings.add(jLabel4, gridBagConstraints); 217 jLabel4.getAccessibleContext().setAccessibleDescription(bundle.getString("ASCD_L_Class_Breakpoint_Type")); 219 cbBreakpointType.setToolTipText(bundle.getString("TTT_CB_Class_Breakpoint_Type")); gridBagConstraints = new java.awt.GridBagConstraints (); 221 gridBagConstraints.gridx = 1; 222 gridBagConstraints.gridy = 4; 223 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 224 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 225 pSettings.add(cbBreakpointType, gridBagConstraints); 226 cbBreakpointType.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CB_Class_Breakpoint_Type")); 228 gridBagConstraints = new java.awt.GridBagConstraints (); 229 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 230 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 231 gridBagConstraints.weightx = 1.0; 232 add(pSettings, gridBagConstraints); 233 234 pActions.setLayout(new java.awt.BorderLayout ()); 235 236 gridBagConstraints = new java.awt.GridBagConstraints (); 237 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 238 gridBagConstraints.weightx = 1.0; 239 add(pActions, gridBagConstraints); 240 241 gridBagConstraints = new java.awt.GridBagConstraints (); 242 gridBagConstraints.gridx = 0; 243 gridBagConstraints.gridy = 2; 244 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 245 gridBagConstraints.weightx = 1.0; 246 gridBagConstraints.weighty = 1.0; 247 add(jPanel1, gridBagConstraints); 248 249 } 251 252 254 259 public boolean ok () { 260 if (! isFilled()) { 261 JOptionPane.showMessageDialog(this, 262 java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle") 263 .getString("MSG_No_Class_Name_Spec")); 264 return false; 265 } 266 actionsPanel.ok (); 267 String className = tfPackageName.getText ().trim (); 268 if (className.length () > 0) 269 className += '.'; 270 className += tfClassName.getText ().trim (); 271 if (cbExclusionFilter.isSelected ()) { 272 breakpoint.setClassFilters (new String [0]); 273 breakpoint.setClassExclusionFilters (new String [] {className}); 274 } else { 275 breakpoint.setClassFilters (new String [] {className}); 276 breakpoint.setClassExclusionFilters (new String [0]); 277 } 278 279 switch (cbBreakpointType.getSelectedIndex ()) { 280 case 0: 281 breakpoint.setBreakpointType (ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED); 282 break; 283 case 1: 284 breakpoint.setBreakpointType (ClassLoadUnloadBreakpoint.TYPE_CLASS_UNLOADED); 285 break; 286 case 2: 287 breakpoint.setBreakpointType (ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED); 288 break; 289 } 290 if (createBreakpoint) 291 DebuggerManager.getDebuggerManager ().addBreakpoint (breakpoint); 292 return true; 293 } 294 295 300 public boolean cancel () { 301 return true; 302 } 303 304 311 public boolean isValid () { 312 return true; 313 } 314 315 boolean isFilled () { 316 if (tfClassName.getText().trim ().length() > 0) 317 return true; 318 return false; 319 } 320 321 private javax.swing.JComboBox cbBreakpointType; 323 private javax.swing.JCheckBox cbExclusionFilter; 324 private javax.swing.JLabel jLabel1; 325 private javax.swing.JLabel jLabel2; 326 private javax.swing.JLabel jLabel3; 327 private javax.swing.JLabel jLabel4; 328 private javax.swing.JPanel jPanel1; 329 private javax.swing.JPanel pActions; 330 private javax.swing.JPanel pSettings; 331 private javax.swing.JTextField tfClassName; 332 private javax.swing.JTextField tfPackageName; 333 335 } 336 | Popular Tags |