1 19 20 package org.netbeans.modules.debugger.jpda.ui.actions; 21 22 import java.net.MalformedURLException ; 23 import java.net.URL ; 24 import org.netbeans.api.debugger.Breakpoint; 25 import org.netbeans.api.debugger.DebuggerManager; 26 import org.netbeans.api.debugger.jpda.LineBreakpoint; 27 import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge; 28 import org.netbeans.modules.debugger.jpda.ui.models.BreakpointsActionsProvider; 29 import org.openide.util.HelpCtx; 30 import org.openide.util.NbBundle; 31 import org.openide.util.actions.NodeAction; 32 33 38 public class LineBreakpointCustomizeAction extends NodeAction { 39 40 41 public LineBreakpointCustomizeAction() { 42 } 43 44 static LineBreakpoint getCurrentBreakpoint() { 45 String currentURLStr = EditorContextBridge.getCurrentURL(); 46 if (currentURLStr == null) return null; 47 URL currentURL; 48 try { 49 currentURL = new URL (currentURLStr); 50 } catch (MalformedURLException muex) { 51 return null; 52 } 53 int lineNumber = EditorContextBridge.getCurrentLineNumber(); 54 if (lineNumber < 0) return null; 55 Breakpoint[] bs = DebuggerManager.getDebuggerManager (). 56 getBreakpoints (); 57 for (int i = 0; i < bs.length; i++) { 58 if (bs[i] instanceof LineBreakpoint) { 59 LineBreakpoint lb = (LineBreakpoint) bs[i]; 60 URL url; 61 try { 62 url = new URL (lb.getURL()); 63 } catch (MalformedURLException muex) { 64 continue; 65 } 66 if (currentURL.equals(url)) { 67 if (lineNumber == lb.getLineNumber()) { 68 return lb; 69 } 70 } 71 } 72 } 73 return null; 74 } 75 76 public boolean isEnabled() { return enable(null); 78 } 79 80 protected boolean enable(org.openide.nodes.Node[] activatedNodes) { 81 LineBreakpoint lb = getCurrentBreakpoint(); 82 return lb != null; 83 } 84 85 public String getName() { 86 return NbBundle.getMessage(LineBreakpointCustomizeAction.class, "CTL_customize"); 87 } 88 89 protected void performAction(org.openide.nodes.Node[] activatedNodes) { 90 LineBreakpoint lb = getCurrentBreakpoint(); 91 if (lb == null) return ; 92 BreakpointsActionsProvider.customize(lb); 93 } 94 95 protected boolean asynchronous() { 96 return false; } 98 99 public HelpCtx getHelpCtx() { 100 return null; 101 } 102 103 } 104 | Popular Tags |