1 19 20 package org.netbeans.modules.debugger.ui.actions; 21 22 import java.awt.Dialog ; 23 import java.util.ResourceBundle ; 24 import javax.swing.*; 25 import org.netbeans.api.debugger.DebuggerManager; 26 import org.netbeans.modules.debugger.ui.WatchPanel; 27 import org.netbeans.modules.debugger.ui.views.View; 28 29 import org.openide.DialogDisplayer; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 import org.openide.util.actions.CallableSystemAction; 33 34 35 40 public class AddWatchAction extends CallableSystemAction { 41 42 private static String watchHistory = ""; 44 45 61 protected boolean asynchronous () { 62 return false; 63 } 64 65 public String getName () { 66 return NbBundle.getMessage ( 67 AddWatchAction.class, 68 "CTL_New_Watch" 69 ); 70 } 71 72 public HelpCtx getHelpCtx () { 73 return new HelpCtx (AddWatchAction.class); 74 75 } 76 77 80 protected String iconResource () { 81 return "org/netbeans/modules/debugger/resources/actions/NewWatch.gif"; } 83 84 85 public void performAction () { 86 ResourceBundle bundle = NbBundle.getBundle (AddWatchAction.class); 87 88 WatchPanel wp = new WatchPanel (watchHistory); 89 JComponent panel = wp.getPanel (); 90 91 org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor ( 99 panel, 100 bundle.getString ("CTL_WatchDialog_Title"), true, 102 org.openide.DialogDescriptor.OK_CANCEL_OPTION, 103 null, 104 org.openide.DialogDescriptor.DEFAULT_ALIGN, 105 new org.openide.util.HelpCtx("debug.add.watch"), 106 null 107 ); 108 Dialog dialog = DialogDisplayer.getDefault ().createDialog (dd); 110 dialog.setVisible (true); 111 dialog.dispose (); 112 113 if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION) return; 114 String watch = wp.getExpression (); 115 if ( (watch == null) || 116 (watch.trim ().length () == 0) 117 ) return; 118 119 String s = watch; 120 int i = s.indexOf (';'); 121 while (i > 0) { 122 String ss = s.substring (0, i).trim (); 123 if (ss.length () > 0) 124 DebuggerManager.getDebuggerManager ().createWatch (ss); 125 s = s.substring (i + 1); 126 i = s.indexOf (';'); 127 } 128 s = s.trim (); 129 if (s.length () > 0) 130 DebuggerManager.getDebuggerManager ().createWatch (s); 131 132 watchHistory = watch; 133 134 ViewActions.openComponent ("watchesView", false).requestVisible(); 136 } 137 } 138 | Popular Tags |