/** * Creates a new breakpoint for the given parameters. * * @param url a url * @param lineNumber a line number * @return a new breakpoint for given parameters */ @Messages("CTL_Default_Print_Text=Breakpoint reached at line {lineNumber} in {groovyName} by thread {threadName}.") public static LineBreakpoint create(String url, int lineNumber) { String pt = CTL_Default_Print_Text(); String printText = pt.replace("{groovyName}", getGroovyName(url)); LineBreakpoint groovyBreakpoint = LineBreakpoint.create(url, lineNumber); groovyBreakpoint.setStratum("Groovy"); // NOI18N groovyBreakpoint.setSourceName(getGroovyName(url)); groovyBreakpoint.setSourcePath(getGroovyPath(url)); groovyBreakpoint.setPreferredClassName(getClassFilter(url)); groovyBreakpoint.setPrintText(printText); groovyBreakpoint.setHidden(false); return groovyBreakpoint; }
private synchronized void update() { updatingLine = true; try { lb.setLineNumber(line.getLineNumber() + 1); } finally { updatingLine = false; } }
originalBreakpointLines.put(timeStamp, bpLines); int line = getOriginalLineNumber(lb.getURL(), lb.getLineNumber(), timeStamp); bpLines.put(lb, line); PropertyChangeListener lineNumberListener = new PropertyChangeListener() { lb.addPropertyChangeListener(WeakListeners.propertyChange(lineNumberListener, lb)); return line;
public static boolean showSource(LineBreakpoint b) { if (b.getLineNumber() < 1) { return Context.showSource(b.getURL(), 1, null); } return Context.showSource(b.getURL(), b.getLineNumber(), null); }
/** * Adds annotation to url:line where the given breakpoint is set. * * @param b breakpoint to annotate * * @return annotation or <code>null</code>, when the annotation can not be * created at the url:line where the given breakpoint is set. */ public static Object annotate(LineBreakpoint b) { String url = b.getURL(); int lineNumber = b.getLineNumber(); if (lineNumber < 1) { return null; } String condition = b.getCondition(); boolean isConditional = (condition != null) && !condition.trim().equals(""); // NOI18N String annotationType = b.isEnabled() ? (isConditional ? EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE : EditorContext.BREAKPOINT_ANNOTATION_TYPE) : (isConditional ? EditorContext.DISABLED_CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE : EditorContext.DISABLED_BREAKPOINT_ANNOTATION_TYPE); return annotate(url, lineNumber, annotationType, b); } }
Utils.log("filter: " + filter); javalb = LineBreakpoint.create(url, lineNumber); javalb.setStratum("JSP"); // NOI18N javalb.setSourceName(Utils.getJspName(url)); javalb.setSourcePath(Utils.getJspPath(url)); javalb.setPreferredClassName(filter); javalb.setHidden(true); javalb.setPrintText(printText); javalb.setCondition(condition); Utils.log("condition: " + condition); javalb.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { javalb.addJPDABreakpointListener(new JPDABreakpointListener() { @Override public void breakpointReached(JPDABreakpointEvent event) {
private LineBreakpoint createLineBreakpoint() { int lineNo = jslb.getLineNumber(); lineNo += source.getContentLineShift(); LineBreakpoint lb = LineBreakpoint.create("", lineNo); lb.setHidden(true); //lb.setPreferredClassType(source.getClassType()); setPreferredClassType(lb, source.getClassType()); if (LOG.isLoggable(Level.FINE)) { LOG.fine("LineBreakpointHandler.createLineBreakpoint() classtype = "+source.getClassType().getName()); } lb.setSuspend(JPDABreakpoint.SUSPEND_EVENT_THREAD); lb.setSession(debugger); if (!jslb.isEnabled()) { lb.disable(); } return lb; }
/** Creates new form LineBreakpointPanel */ public LineBreakpointPanel (LineBreakpoint b) { breakpoint = b; initComponents (); String url = b.getURL(); try { URI uri = new URI(url); tfFileName.setText(uri.getPath()); } catch (Exception e) { tfFileName.setText(url); } tfFileName.setPreferredSize(new Dimension( 30*tfFileName.getFontMetrics(tfFileName.getFont()).charWidth('W'), tfFileName.getPreferredSize().height)); tfLineNumber.setText(Integer.toString(b.getLineNumber())); conditionsPanel = new ConditionsPanel(); setupConditionPane(); conditionsPanel.showClassFilter(false); conditionsPanel.setCondition(b.getCondition()); conditionsPanel.setHitCountFilteringStyle(b.getHitCountFilteringStyle()); conditionsPanel.setHitCount(b.getHitCountFilter()); cPanel.add(conditionsPanel, "Center"); actionsPanel = new ActionsPanel (b); pActions.add (actionsPanel, "Center"); }
public synchronized void attach() throws IOException { this.lc = dataObject.getCookie (LineCookie.class); if (lc == null) return ; lb.addPropertyChangeListener(this); try { this.line = lc.getLineSet().getCurrent(lb.getLineNumber() - 1); line.addPropertyChangeListener(this); } catch (IndexOutOfBoundsException ioobex) { // ignore document changes for BP with bad line number } }
@Override public void postAction(Object action, final Runnable actionPerformedNotifier) { final LineBreakpoint newBreakpoint = LineBreakpoint.create ( editorContext.getCurrentURLAsString(), editorContext.getCurrentLineNumber () ); RP.post(new Runnable() { @Override public void run() { // 1) set breakpoint removeBreakpoint (); createBreakpoint (newBreakpoint); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { invokeAction(); } }); } catch (InterruptedException iex) { // Procceed } catch (java.lang.reflect.InvocationTargetException itex) { ErrorManager.getDefault().notify(itex); } finally { actionPerformedNotifier.run(); } } }); }
String condition; if (b instanceof LineBreakpoint) { URLs = new String[] { ((LineBreakpoint) b).getURL () }; lineNumbers = new int[] { ((LineBreakpoint) b).getLineNumber() }; condition = ((LineBreakpoint) b).getCondition(); } else if (b instanceof FieldBreakpoint) { String className = ((FieldBreakpoint) b).getClassName();
public static String getFileName (LineBreakpoint b) { try { return new File (new URL (b.getURL ()).getFile ()).getName (); } catch (MalformedURLException e) { return null; } }
private static LineBreakpoint createBreakpoint () { LineBreakpoint mb = LineBreakpoint.create ( EditorContextBridge.getContext().getCurrentURL (), EditorContextBridge.getContext().getCurrentLineNumber () ); mb.setPrintText ( NbBundle.getBundle (LineBreakpointPanel.class).getString ("CTL_Line_Breakpoint_Print_Text") ); return mb; }
/** * Called when "Ok" button is pressed. * * @return whether customizer can be closed */ public boolean ok () { String msg = valiadateMsg(); if (msg == null) { msg = conditionsPanel.valiadateMsg(); } if (msg != null) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg)); return false; } actionsPanel.ok (); breakpoint.setLineNumber(Integer.parseInt(tfLineNumber.getText().trim())); breakpoint.setCondition (conditionsPanel.getCondition()); breakpoint.setHitCountFilter(conditionsPanel.getHitCount(), conditionsPanel.getHitCountFilteringStyle()); if (createBreakpoint) DebuggerManager.getDebuggerManager ().addBreakpoint (breakpoint); return true; }
private void createBreakpoint (LineBreakpoint breakpoint) { breakpoint.setHidden (true); DebuggerManager.getDebuggerManager ().addBreakpoint (breakpoint); this.breakpoint = breakpoint; }
/** * Gets the condition of a breakpoint. * @param b The breakpoint * @return The condition or empty {@link String} if no condition is supported. */ static String getCondition(Breakpoint b) { if (!(b instanceof JPDABreakpoint)) { return ""; // e.g. JSP breakpoints } if (b instanceof LineBreakpoint) { return ((LineBreakpoint) b).getCondition(); } else if (b instanceof FieldBreakpoint) { return ((FieldBreakpoint) b).getCondition(); } else if (b instanceof MethodBreakpoint) { return ((MethodBreakpoint) b).getCondition(); } else if (b instanceof ClassLoadUnloadBreakpoint) { return ""; } else { throw new IllegalStateException(b.toString()); } }
@Override public void breakpointRemoved (Breakpoint b) { if (b instanceof LineBreakpoint) { ((LineBreakpoint) b).removePropertyChangeListener (this); removeAnnotation ((LineBreakpoint) b); } }
@Override public void breakpointAdded (Breakpoint b) { if (b instanceof LineBreakpoint) { ((LineBreakpoint) b).addPropertyChangeListener (this); annotate ((LineBreakpoint) b); } }
/** * Sets value of print text property. * * @param printText a new value of print text property */ public void setPrintText (String printText) { if (this.printText == printText) return; String old = this.printText; this.printText = printText; if (javalb != null) { javalb.setPrintText(printText); } firePropertyChange(PROP_PRINT_TEXT, old, printText); }
private void setPreferredClassType(LineBreakpoint lb, JPDAClassType classType) { try { Method setPreferredClassTypeMethod = lb.getClass().getMethod("setPreferredClassType", JPDAClassType.class); setPreferredClassTypeMethod.setAccessible(true); setPreferredClassTypeMethod.invoke(lb, classType); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { Exceptions.printStackTrace(ex); lb.setPreferredClassName(source.getClassType().getName()); } }