1 19 20 package org.netbeans.modules.web.debug.actions; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Dialog ; 24 import java.awt.Toolkit ; 25 import java.awt.event.ActionEvent ; 26 import java.lang.ref.WeakReference ; 27 import java.util.LinkedList ; 28 import java.util.Iterator ; 29 import java.util.ResourceBundle ; 30 import javax.swing.AbstractAction ; 31 import javax.swing.Action ; 32 import javax.swing.JLabel ; 33 import javax.swing.JPanel ; 34 import javax.swing.JTextField ; 35 import javax.swing.SwingUtilities ; 36 import javax.swing.border.CompoundBorder ; 37 import javax.swing.border.EmptyBorder ; 38 import org.netbeans.api.debugger.DebuggerManager; 39 import org.netbeans.api.debugger.Watch; 40 import org.netbeans.modules.web.debug.util.Utils; 41 42 import org.openide.DialogDisplayer; 43 import org.openide.util.HelpCtx; 44 import org.openide.util.NbBundle; 45 import org.openide.util.actions.CallableSystemAction; 46 47 48 53 public class AddJspWatchAction extends CallableSystemAction { 54 55 private static String watchHistory = ""; 57 73 protected boolean asynchronous () { 74 return false; 75 } 76 77 public String getName () { 78 return NbBundle.getMessage ( 79 AddJspWatchAction.class, "CTL_New_Watch" 80 ); 81 } 82 83 public HelpCtx getHelpCtx () { 84 return new HelpCtx (AddJspWatchAction.class); 85 86 } 87 88 91 protected String iconResource () { 92 return "org/netbeans/modules/debugger/resources/actions/NewWatch.gif"; } 94 95 96 public void performAction () { 97 ResourceBundle bundle = NbBundle.getBundle (AddJspWatchAction.class); 98 99 JPanel panel = new JPanel (); 100 panel.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_WatchPanel")); JTextField textField; 102 JLabel textLabel = new JLabel (bundle.getString ("CTL_Watch_Name")); textLabel.setBorder (new EmptyBorder (0, 0, 0, 10)); 104 panel.setLayout (new BorderLayout ()); 105 panel.setBorder (new EmptyBorder (11, 12, 1, 11)); 106 panel.add ("West", textLabel); panel.add ("Center", textField = new JTextField (25)); textField.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_CTL_Watch_Name")); textField.setBorder ( 110 new CompoundBorder (textField.getBorder (), 111 new EmptyBorder (2, 0, 2, 0)) 112 ); 113 textLabel.setDisplayedMnemonic ( 114 bundle.getString ("CTL_Watch_Name_Mnemonic").charAt (0) ); 116 117 118 String t = null; 121 boolean isScriptlet = Utils.isScriptlet(); 122 Utils.getEM().log("Watch: isScriptlet: " + isScriptlet); 123 124 if ((t == null) && (isScriptlet)) { 125 t = Utils.getJavaIdentifier(); 126 Utils.getEM().log("Watch: javaIdentifier = " + t); 127 } 128 129 if (t != null) { 130 textField.setText(t); 131 } else { 132 textField.setText(watchHistory); 133 } 134 textField.selectAll (); 135 textLabel.setLabelFor (textField); 136 textField.requestFocus (); 137 138 org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor ( 139 panel, 140 bundle.getString ("CTL_Watch_Title") ); 142 dd.setHelpCtx (new HelpCtx ("debug.add.watch")); 143 Dialog dialog = DialogDisplayer.getDefault ().createDialog (dd); 144 dialog.setVisible(true); 145 dialog.dispose (); 146 147 if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION) return; 148 String watch = textField.getText(); 149 if ((watch == null) || (watch.trim ().length () == 0)) { 150 return; 151 } 152 153 String s = watch; 154 int i = s.indexOf (';'); 155 while (i > 0) { 156 String ss = s.substring (0, i).trim (); 157 if (ss.length () > 0) 158 DebuggerManager.getDebuggerManager ().createWatch (ss); 159 s = s.substring (i + 1); 160 i = s.indexOf (';'); 161 } 162 s = s.trim (); 163 if (s.length () > 0) 164 DebuggerManager.getDebuggerManager ().createWatch (s); 165 166 watchHistory = watch; 167 168 } 171 } 172 173 | Popular Tags |