1 19 20 package org.netbeans.modules.web.debug; 21 22 import org.openide.*; 23 import org.openide.util.NbBundle; 25 26 import java.net.URI ; 27 import javax.swing.*; 28 29 import org.netbeans.spi.debugger.ui.Controller; 30 import org.netbeans.api.debugger.DebuggerManager; 31 32 import org.netbeans.modules.web.debug.util.Utils; 33 import org.netbeans.modules.web.debug.breakpoints.*; 34 35 40 public class JspBreakpointPanel extends JPanel implements Controller { 41 42 static final long serialVersionUID =-8164649328980808272L; 43 44 private ActionsPanel actionsPanel; 45 private JspLineBreakpoint breakpoint; 46 private boolean createBreakpoint = false; 47 48 public JspBreakpointPanel() { 49 this(JspLineBreakpoint.create(Context.getCurrentURL(), Context.getCurrentLineNumber())); 50 createBreakpoint = true; 51 } 52 53 54 public JspBreakpointPanel(JspLineBreakpoint b) { 55 56 breakpoint = b; 57 initComponents (); 58 putClientProperty("HelpID", "jsp_breakpoint"); 60 getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(JspBreakpointPanel.class, "ACSD_LineBreakpointPanel")); 63 String url = b.getURL(); 64 try { 65 URI uri = new URI (url); 66 cboxJspSourcePath.setText(uri.getPath()); 67 } catch (Exception e) { 68 cboxJspSourcePath.setText(url); 69 } 70 71 int lnum = b.getLineNumber(); 72 if (lnum < 1) { 73 tfLineNumber.setText(""); } else { 75 tfLineNumber.setText(Integer.toString(lnum)); 76 } 77 78 actionsPanel = new ActionsPanel(b); 79 pActions.add(actionsPanel, "Center"); 80 } 81 82 87 private void initComponents() { 88 java.awt.GridBagConstraints gridBagConstraints; 89 90 pSettings = new javax.swing.JPanel (); 91 lblJspSourcePath = new javax.swing.JLabel (); 92 cboxJspSourcePath = new javax.swing.JTextField (); 93 lblLineNumber = new javax.swing.JLabel (); 94 tfLineNumber = new javax.swing.JTextField (); 95 pActions = new javax.swing.JPanel (); 96 jPanel1 = new javax.swing.JPanel (); 97 98 setLayout(new java.awt.GridBagLayout ()); 99 100 pSettings.setLayout(new java.awt.GridBagLayout ()); 101 102 pSettings.setBorder(new javax.swing.border.TitledBorder ("Settings")); 103 lblJspSourcePath.setText(NbBundle.getBundle(JspBreakpointPanel.class).getString("CTL_Source_name")); 104 gridBagConstraints = new java.awt.GridBagConstraints (); 105 gridBagConstraints.gridx = 0; 106 gridBagConstraints.gridy = 1; 107 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 108 gridBagConstraints.insets = new java.awt.Insets (2, 4, 2, 2); 109 pSettings.add(lblJspSourcePath, gridBagConstraints); 110 lblJspSourcePath.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(JspBreakpointPanel.class).getString("ACSN_CTL_Source_name")); 111 112 cboxJspSourcePath.setEditable(false); 113 114 gridBagConstraints = new java.awt.GridBagConstraints (); 115 gridBagConstraints.gridx = 1; 116 gridBagConstraints.gridy = 1; 117 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 118 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 119 gridBagConstraints.weightx = 1.0; 120 gridBagConstraints.insets = new java.awt.Insets (2, 6, 2, 2); 121 pSettings.add(cboxJspSourcePath, gridBagConstraints); 122 cboxJspSourcePath.getAccessibleContext().setAccessibleName(NbBundle.getBundle(JspBreakpointPanel.class).getString("ACSN_CTL_Source_name")); 123 cboxJspSourcePath.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(JspBreakpointPanel.class).getString("ACSD_CTL_Source_name")); 124 125 lblLineNumber.setLabelFor(tfLineNumber); 126 lblLineNumber.setText(NbBundle.getBundle(JspBreakpointPanel.class).getString("CTL_Line_number")); 127 lblLineNumber.setDisplayedMnemonic(NbBundle.getBundle(JspBreakpointPanel.class).getString("CTL_Line_number_mnemonic").charAt(0)); 128 gridBagConstraints = new java.awt.GridBagConstraints (); 129 gridBagConstraints.gridx = 0; 130 gridBagConstraints.gridy = 2; 131 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 132 gridBagConstraints.insets = new java.awt.Insets (2, 4, 2, 2); 133 pSettings.add(lblLineNumber, gridBagConstraints); 134 lblLineNumber.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(JspBreakpointPanel.class).getString("ACSD_CTL_Line_number")); 135 136 tfLineNumber.setColumns(7); 137 tfLineNumber.addFocusListener(new java.awt.event.FocusAdapter () { 138 public void focusGained(java.awt.event.FocusEvent evt) { 139 tfLineNumberFocusGained(evt); 140 } 141 public void focusLost(java.awt.event.FocusEvent evt) { 142 tfLineNumberFocusLost(evt); 143 } 144 }); 145 tfLineNumber.addKeyListener(new java.awt.event.KeyAdapter () { 146 public void keyTyped(java.awt.event.KeyEvent evt) { 147 tfLineNumberKeyTyped(evt); 148 } 149 }); 150 151 gridBagConstraints = new java.awt.GridBagConstraints (); 152 gridBagConstraints.gridx = 1; 153 gridBagConstraints.gridy = 2; 154 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 155 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 156 gridBagConstraints.weightx = 1.0; 157 gridBagConstraints.insets = new java.awt.Insets (2, 6, 2, 2); 158 pSettings.add(tfLineNumber, gridBagConstraints); 159 tfLineNumber.getAccessibleContext().setAccessibleName(NbBundle.getBundle(JspBreakpointPanel.class).getString("ACSN_CTL_Line_number")); 160 tfLineNumber.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(JspBreakpointPanel.class).getString("ACSD_CTL_Line_number")); 161 162 gridBagConstraints = new java.awt.GridBagConstraints (); 163 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 164 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 165 gridBagConstraints.weightx = 1.0; 166 add(pSettings, gridBagConstraints); 167 168 pActions.setLayout(new java.awt.BorderLayout ()); 169 170 gridBagConstraints = new java.awt.GridBagConstraints (); 171 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 172 gridBagConstraints.weightx = 1.0; 173 add(pActions, gridBagConstraints); 174 175 gridBagConstraints = new java.awt.GridBagConstraints (); 176 gridBagConstraints.gridx = 0; 177 gridBagConstraints.gridy = 2; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 179 gridBagConstraints.weightx = 1.0; 180 gridBagConstraints.weighty = 1.0; 181 add(jPanel1, gridBagConstraints); 182 183 } 184 185 private void tfLineNumberKeyTyped(java.awt.event.KeyEvent evt) { 186 } 188 189 private void tfLineNumberFocusGained(java.awt.event.FocusEvent evt) { 190 if (!evt.isTemporary()) { 191 ((JTextField) evt.getComponent()).selectAll(); 192 } 193 } 194 195 private void tfLineNumberFocusLost(java.awt.event.FocusEvent evt) { 196 } 221 222 223 224 225 226 public boolean ok() { 228 if (!isValid()) { 229 return false; 230 } 231 232 actionsPanel.ok (); 233 breakpoint.setLineNumber(Integer.parseInt(tfLineNumber.getText().trim())); 234 235 if (createBreakpoint) { 236 DebuggerManager.getDebuggerManager().addBreakpoint(breakpoint); 237 } 238 return true; 239 } 240 241 public boolean cancel() { 243 return true; 244 } 245 246 public boolean isValid() { 248 try { 249 int line = Integer.parseInt(tfLineNumber.getText().trim()); 250 return line > 0; 251 } catch (NumberFormatException e) { 252 return false; 253 } 254 } 255 256 private javax.swing.JTextField cboxJspSourcePath; 258 private javax.swing.JPanel jPanel1; 259 private javax.swing.JLabel lblJspSourcePath; 260 private javax.swing.JLabel lblLineNumber; 261 private javax.swing.JPanel pActions; 262 private javax.swing.JPanel pSettings; 263 private javax.swing.JTextField tfLineNumber; 264 266 } 267 | Popular Tags |