This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 226437
Collapse All | Expand All

(-)a/api.debugger.jpda/apichanges.xml (+19 lines)
Lines 857-862 Link Here
857
        <issue number="228894"/>
857
        <issue number="228894"/>
858
    </change>
858
    </change>
859
859
860
    <change>
861
        <api name="JPDADebuggerAPI"/>
862
        <summary>Association of breakpoints with source files.</summary>
863
        <version major="2" minor="46"/>
864
        <date day="28" month="8" year="2013"/>
865
        <author login="mentlicher"/>
866
        <compatibility addition="yes" source="compatible" binary="compatible"/>
867
        <description>
868
            getURL()/setURL() methods are added to breakpoints so that they can
869
            be associated with their source files. Changes in these source files
870
            can be then reflected in the breakpoint settings.
871
        </description>
872
        <class package="org.netbeans.api.debugger.jpda" name="ClassLoadUnloadBreakpoint" />
873
        <class package="org.netbeans.api.debugger.jpda" name="ExceptionBreakpoint" />
874
        <class package="org.netbeans.api.debugger.jpda" name="FieldBreakpoint" />
875
        <class package="org.netbeans.api.debugger.jpda" name="MethodBreakpoint" />
876
        <issue number="226437"/>
877
    </change>
878
860
879
861
</changes>
880
</changes>
862
881
(-)a/api.debugger.jpda/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.debugger.jpda/2
2
OpenIDE-Module: org.netbeans.api.debugger.jpda/2
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/jpda/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/jpda/Bundle.properties
4
OpenIDE-Module-Specification-Version: 2.45
4
OpenIDE-Module-Specification-Version: 2.46
5
OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager]
5
OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager]
6
6
(-)a/api.debugger.jpda/nbproject/project.xml (-1 / +9 lines)
Lines 55-61 Link Here
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
57
                        <release-version>1</release-version>
58
                        <specification-version>1.35</specification-version>
58
                        <specification-version>1.44</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
Lines 68-73 Link Here
68
                    </run-dependency>
68
                    </run-dependency>
69
                </dependency>
69
                </dependency>
70
                <dependency>
70
                <dependency>
71
                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
72
                    <build-prerequisite/>
73
                    <compile-dependency/>
74
                    <run-dependency>
75
                        <specification-version>8.6</specification-version>
76
                    </run-dependency>
77
                </dependency>
78
                <dependency>
71
                    <code-name-base>org.netbeans.modules.java.source</code-name-base>
79
                    <code-name-base>org.netbeans.modules.java.source</code-name-base>
72
                    <build-prerequisite/>
80
                    <build-prerequisite/>
73
                    <compile-dependency/>
81
                    <compile-dependency/>
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/ClassLoadUnloadBreakpoint.java (-1 / +122 lines)
Lines 51-59 Link Here
51
import java.util.Arrays;
51
import java.util.Arrays;
52
import java.util.List;
52
import java.util.List;
53
import org.netbeans.api.debugger.DebuggerEngine;
53
import org.netbeans.api.debugger.DebuggerEngine;
54
import org.netbeans.api.debugger.DebuggerManager;
55
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeListener;
56
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeTracker;
57
import org.netbeans.api.java.source.CompilationController;
58
import org.netbeans.api.java.source.JavaSource;
59
import org.netbeans.api.java.source.Task;
54
import org.netbeans.api.project.Project;
60
import org.netbeans.api.project.Project;
55
import org.netbeans.api.project.ProjectManager;
61
import org.netbeans.api.project.ProjectManager;
62
import org.netbeans.spi.debugger.BreakpointURLHandler;
63
import org.netbeans.spi.debugger.BreakpointURLHandler.URLBasedBreakpoint;
56
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
65
import org.openide.util.Exceptions;
57
import org.openide.util.NbBundle;
66
import org.openide.util.NbBundle;
58
67
59
68
Lines 81-86 Link Here
81
    public static final String          PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
90
    public static final String          PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
82
    /** Name of property for breakpoint type. */
91
    /** Name of property for breakpoint type. */
83
    public static final String          PROP_BREAKPOINT_TYPE = "breakpointType"; // NOI18N
92
    public static final String          PROP_BREAKPOINT_TYPE = "breakpointType"; // NOI18N
93
    /** Property name constant
94
     * @since 2.46 */
95
    public static final String          PROP_URL = LineBreakpoint.PROP_URL;
84
96
85
    /** Catch type property value constant. */
97
    /** Catch type property value constant. */
86
    public static final int             TYPE_CLASS_LOADED = 1;
98
    public static final int             TYPE_CLASS_LOADED = 1;
Lines 202-207 Link Here
202
    }
214
    }
203
215
204
    /**
216
    /**
217
     * Get URL of the class source file.
218
     * @return The URL or <code>null</code> when there is no association with the source file.
219
     * @since 2.46
220
     */
221
    public String getURL() {
222
        return null;
223
    }
224
    
225
    /**
226
     * Associate this breakpoint with the class source file.
227
     * @param url The URL of the class source file.
228
     * @since 2.46
229
     */
230
    public void setURL(String url) {
231
    }
232
    
233
    /**
205
     * Returns a string representation of this object.
234
     * Returns a string representation of this object.
206
     *
235
     *
207
     * @return  a string representation of the object
236
     * @return  a string representation of the object
Lines 211-218 Link Here
211
        return "ClassLoadUnloadBreakpoint " + Arrays.toString(classFilters);
240
        return "ClassLoadUnloadBreakpoint " + Arrays.toString(classFilters);
212
    }
241
    }
213
242
214
    private static final class ClassLoadUnloadBreakpointImpl extends ClassLoadUnloadBreakpoint implements PropertyChangeListener {
243
    private static final class ClassLoadUnloadBreakpointImpl extends ClassLoadUnloadBreakpoint
244
                                                             implements URLBasedBreakpoint,
245
                                                                        PropertyChangeListener,
246
                                                                        ElementChangeListener{
215
247
248
        private final BreakpointURLHandler urlHandler;
249
        private ElementChangeTracker elementChangeTracker;
250
        private final Object elementChangeTrackerLock = new Object();
251
        
252
        ClassLoadUnloadBreakpointImpl() {
253
            super();
254
            urlHandler = BreakpointURLHandler.create(this);
255
        }
256
        
216
        @Override
257
        @Override
217
        public GroupProperties getGroupProperties() {
258
        public GroupProperties getGroupProperties() {
218
            return new ClassGroupProperties();
259
            return new ClassGroupProperties();
Lines 223-228 Link Here
223
            enginePropertyChange(evt);
264
            enginePropertyChange(evt);
224
        }
265
        }
225
266
267
        @Override
268
        public void setClassFilters(String[] classFilters) {
269
            super.setClassFilters(classFilters);
270
            trackClassElement();
271
        }
272
        
273
        @Override
274
        public String getURL() {
275
            if (urlHandler == null) {
276
                return null;
277
            } else {
278
                return urlHandler.getURL();
279
            }
280
        }
281
282
        @Override
283
        public void setURL(String url) {
284
            String old = urlHandler.setURL(url);
285
            if (old == null || !old.equals(url)) {
286
                firePropertyChange (PROP_URL, old, url);
287
                if (old != null && !old.isEmpty()) {
288
                    DebuggerManager.getDebuggerManager().addBreakpoint(this);
289
                }
290
                firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
291
                trackClassElement();
292
            }
293
        }
294
        
295
        private void trackClassElement() {
296
            synchronized (elementChangeTrackerLock) {
297
                if (elementChangeTracker != null) {
298
                    elementChangeTracker.destroy();
299
                }
300
            }
301
            String[] classFilters = getClassFilters();
302
            FileObject fo = urlHandler.getFileObject();
303
            if (classFilters.length == 1 && fo != null) {
304
                final String clazz = classFilters[0];
305
                final JavaSource js = JavaSource.forFileObject(fo);
306
                if (js == null) {
307
                    return ;
308
                }
309
                try {
310
                    js.runWhenScanFinished(new Task<CompilationController>() {
311
                        @Override
312
                        public void run(CompilationController parameter) throws Exception {
313
                            ElementChangeTracker ect = JavaSourceUtils.createElementChangeTracker(js, clazz, null, null);
314
                            if (ect != null) {
315
                                ect.setElementChangeListener(ClassLoadUnloadBreakpointImpl.this);
316
                                synchronized (elementChangeTrackerLock) {
317
                                    elementChangeTracker = ect;
318
                                }
319
                            }
320
                        }
321
                    }, true);
322
                } catch (IOException ex) {
323
                    Exceptions.printStackTrace(ex);
324
                }
325
            }
326
        }
327
328
        @Override
329
        protected void dispose() {
330
            super.dispose();
331
            synchronized (elementChangeTrackerLock) {
332
                if (elementChangeTracker != null) {
333
                    elementChangeTracker.destroy();
334
                }
335
            }
336
        }
337
        
338
        @Override
339
        public void removed() {
340
            DebuggerManager.getDebuggerManager().removeBreakpoint(this);
341
        }
342
343
        @Override
344
        public void changed(String name) {
345
        }
346
226
347
227
        private final class ClassGroupProperties extends GroupProperties {
348
        private final class ClassGroupProperties extends GroupProperties {
228
349
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/ExceptionBreakpoint.java (-1 / +120 lines)
Lines 50-58 Link Here
50
import java.util.ArrayList;
50
import java.util.ArrayList;
51
import java.util.List;
51
import java.util.List;
52
import org.netbeans.api.debugger.DebuggerEngine;
52
import org.netbeans.api.debugger.DebuggerEngine;
53
import org.netbeans.api.debugger.DebuggerManager;
54
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeListener;
55
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeTracker;
56
import org.netbeans.api.java.source.CompilationController;
57
import org.netbeans.api.java.source.JavaSource;
58
import org.netbeans.api.java.source.Task;
53
import org.netbeans.api.project.Project;
59
import org.netbeans.api.project.Project;
54
import org.netbeans.api.project.ProjectManager;
60
import org.netbeans.api.project.ProjectManager;
61
import org.netbeans.spi.debugger.BreakpointURLHandler;
62
import org.netbeans.spi.debugger.BreakpointURLHandler.URLBasedBreakpoint;
55
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileObject;
64
import org.openide.util.Exceptions;
56
import org.openide.util.NbBundle;
65
import org.openide.util.NbBundle;
57
66
58
67
Lines 78-83 Link Here
78
    public static final String          PROP_CLASS_FILTERS = "classFilters"; // NOI18N
87
    public static final String          PROP_CLASS_FILTERS = "classFilters"; // NOI18N
79
    /** Property name constant */
88
    /** Property name constant */
80
    public static final String          PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
89
    public static final String          PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
90
    /** Property name constant
91
     * @since 2.46 */
92
    public static final String          PROP_URL = LineBreakpoint.PROP_URL;
81
    /** Property name constant. */
93
    /** Property name constant. */
82
    public static final String          PROP_CATCH_TYPE = "catchType"; // NOI18N
94
    public static final String          PROP_CATCH_TYPE = "catchType"; // NOI18N
83
    /** Property name constant. */
95
    /** Property name constant. */
Lines 187-192 Link Here
187
    }
199
    }
188
    
200
    
189
    /**
201
    /**
202
     * Get URL of the exception source file.
203
     * @return The URL or <code>null</code> when there is no association with the source file.
204
     * @since 2.46
205
     */
206
    public String getURL() {
207
        return null;
208
    }
209
    
210
    /**
211
     * Associate this breakpoint with an exception source file.
212
     * @param url The URL of the exception source file.
213
     * @since  2.46
214
     */
215
    public void setURL(String url) {
216
    }
217
    
218
    /**
190
     * Returns condition.
219
     * Returns condition.
191
     *
220
     *
192
     * @return cond a condition
221
     * @return cond a condition
Lines 245-253 Link Here
245
        return "ExceptionBreakpoint" + exceptionClassName;
274
        return "ExceptionBreakpoint" + exceptionClassName;
246
    }
275
    }
247
276
248
    private static final class ExceptionBreakpointImpl extends ExceptionBreakpoint implements PropertyChangeListener {
277
    private static final class ExceptionBreakpointImpl extends ExceptionBreakpoint implements URLBasedBreakpoint,
278
                                                                                              PropertyChangeListener,
279
                                                                                              ElementChangeListener {
280
        private final BreakpointURLHandler urlHandler;
281
        private ElementChangeTracker elementChangeTracker;
282
        private final Object elementChangeTrackerLock = new Object();
283
        
284
        ExceptionBreakpointImpl() {
285
            super();
286
            urlHandler = BreakpointURLHandler.create(this);
287
        }
249
288
250
        @Override
289
        @Override
290
        public String getURL() {
291
            if (urlHandler == null) {
292
                return null;
293
            } else {
294
                return urlHandler.getURL();
295
            }
296
        }
297
298
        @Override
299
        public void setURL(String url) {
300
            String old = urlHandler.setURL(url);
301
            if (old == null || !old.equals(url)) {
302
                firePropertyChange (PROP_URL, old, url);
303
                if (old != null && !old.isEmpty()) {
304
                    DebuggerManager.getDebuggerManager().addBreakpoint(this);
305
                }
306
                firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
307
                trackFieldElement();
308
            }
309
        }
310
311
        @Override
312
        public void setExceptionClassName(String cn) {
313
            super.setExceptionClassName(cn);
314
            trackFieldElement();
315
        }
316
        
317
        private void trackFieldElement() {
318
            synchronized (elementChangeTrackerLock) {
319
                if (elementChangeTracker != null) {
320
                    elementChangeTracker.destroy();
321
                }
322
            }
323
            final String clazz  = getExceptionClassName();
324
            FileObject fo = urlHandler.getFileObject();
325
            if (!clazz.isEmpty() && fo != null) {
326
                final JavaSource js = JavaSource.forFileObject(fo);
327
                if (js == null) {
328
                    return ;
329
                }
330
                try {
331
                    js.runWhenScanFinished(new Task<CompilationController>() {
332
                        @Override
333
                        public void run(CompilationController parameter) throws Exception {
334
                            ElementChangeTracker ect = JavaSourceUtils.createElementChangeTracker(js, clazz, null, null);
335
                            if (ect != null) {
336
                                ect.setElementChangeListener(ExceptionBreakpointImpl.this);
337
                                synchronized (elementChangeTrackerLock) {
338
                                    elementChangeTracker = ect;
339
                                }
340
                            }
341
                        }
342
                    }, true);
343
                } catch (IOException ex) {
344
                    Exceptions.printStackTrace(ex);
345
                }
346
            }
347
        }
348
349
        @Override
350
        protected void dispose() {
351
            super.dispose();
352
            synchronized (elementChangeTrackerLock) {
353
                if (elementChangeTracker != null) {
354
                    elementChangeTracker.destroy();
355
                }
356
            }
357
        }
358
        
359
        @Override
251
        public GroupProperties getGroupProperties() {
360
        public GroupProperties getGroupProperties() {
252
            return new ExceptionGroupProperties();
361
            return new ExceptionGroupProperties();
253
        }
362
        }
Lines 257-262 Link Here
257
            enginePropertyChange(evt);
366
            enginePropertyChange(evt);
258
        }
367
        }
259
368
369
        @Override
370
        public void removed() {
371
            DebuggerManager.getDebuggerManager().removeBreakpoint(this);
372
        }
373
374
        @Override
375
        public void changed(String name) {
376
            setExceptionClassName(name);
377
        }
378
260
        private final class ExceptionGroupProperties extends GroupProperties {
379
        private final class ExceptionGroupProperties extends GroupProperties {
261
380
262
            @Override
381
            @Override
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/FieldBreakpoint.java (-2 / +130 lines)
Lines 54-63 Link Here
54
import javax.swing.event.ChangeEvent;
54
import javax.swing.event.ChangeEvent;
55
import javax.swing.event.ChangeListener;
55
import javax.swing.event.ChangeListener;
56
import org.netbeans.api.debugger.Breakpoint;
56
import org.netbeans.api.debugger.Breakpoint;
57
import static org.netbeans.api.debugger.Breakpoint.PROP_GROUP_PROPERTIES;
57
import org.netbeans.api.debugger.DebuggerEngine;
58
import org.netbeans.api.debugger.DebuggerEngine;
59
import org.netbeans.api.debugger.DebuggerManager;
60
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeListener;
61
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeTracker;
62
import org.netbeans.api.java.source.CompilationController;
63
import org.netbeans.api.java.source.JavaSource;
64
import org.netbeans.api.java.source.Task;
58
import org.netbeans.api.project.Project;
65
import org.netbeans.api.project.Project;
59
import org.netbeans.api.project.ProjectManager;
66
import org.netbeans.api.project.ProjectManager;
67
import org.netbeans.spi.debugger.BreakpointURLHandler;
68
import org.netbeans.spi.debugger.BreakpointURLHandler.URLBasedBreakpoint;
60
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileObject;
70
import org.openide.util.Exceptions;
61
import org.openide.util.NbBundle;
71
import org.openide.util.NbBundle;
62
72
63
/**
73
/**
Lines 81-86 Link Here
81
    public static final String      PROP_FIELD_NAME = "fieldName"; // NOI18N
91
    public static final String      PROP_FIELD_NAME = "fieldName"; // NOI18N
82
    /** Property name constant. */
92
    /** Property name constant. */
83
    public static final String      PROP_CLASS_NAME = "className"; // NOI18N
93
    public static final String      PROP_CLASS_NAME = "className"; // NOI18N
94
    /** Property name constant
95
     * @since 2.46 */
96
    public static final String      PROP_URL = LineBreakpoint.PROP_URL;
84
    /** Property name constant. */
97
    /** Property name constant. */
85
    public static final String      PROP_CONDITION = "condition"; // NOI18N
98
    public static final String      PROP_CONDITION = "condition"; // NOI18N
86
    /** Property name constant. */
99
    /** Property name constant. */
Lines 180-185 Link Here
180
    }
193
    }
181
194
182
    /**
195
    /**
196
     * Get URL of the field source file.
197
     * @return The URL or <code>null</code> when there is no association with the source file.
198
     * @since 2.46
199
     */
200
    public String getURL() {
201
        return null;
202
    }
203
    
204
    /**
205
     * Associate this breakpoint with the field source file.
206
     * @param url The URL of the field source file.
207
     * @since 2.46
208
     */
209
    public void setURL(String url) {
210
    }
211
    
212
    /**
183
     * Get the instance filter for a specific debugger session.
213
     * Get the instance filter for a specific debugger session.
184
     * @return The instances or <code>null</code> when there is no instance restriction.
214
     * @return The instances or <code>null</code> when there is no instance restriction.
185
     */
215
     */
Lines 300-307 Link Here
300
        return "FieldBreakpoint " + className + "." + fieldName;
330
        return "FieldBreakpoint " + className + "." + fieldName;
301
    }
331
    }
302
    
332
    
303
    private static final class FieldBreakpointImpl extends FieldBreakpoint implements ChangeListener,
333
    private static final class FieldBreakpointImpl extends FieldBreakpoint implements URLBasedBreakpoint,
304
                                                                                      PropertyChangeListener {
334
                                                                                      ChangeListener,
335
                                                                                      PropertyChangeListener,
336
                                                                                      ElementChangeListener {
337
        
338
        private final BreakpointURLHandler urlHandler;
339
        private ElementChangeTracker elementChangeTracker;
340
        private final Object elementChangeTrackerLock = new Object();
341
        
342
        FieldBreakpointImpl() {
343
            super();
344
            urlHandler = BreakpointURLHandler.create(this);
345
        }
346
347
        @Override
348
        public String getURL() {
349
            if (urlHandler == null) {
350
                return null;
351
            } else {
352
                return urlHandler.getURL();
353
            }
354
        }
355
356
        @Override
357
        public void setURL(String url) {
358
            String old = urlHandler.setURL(url);
359
            if (old == null || !old.equals(url)) {
360
                firePropertyChange (PROP_URL, old, url);
361
                if (old != null && !old.isEmpty()) {
362
                    DebuggerManager.getDebuggerManager().addBreakpoint(this);
363
                }
364
                firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
365
                trackFieldElement();
366
            }
367
        }
368
369
        @Override
370
        public void setClassName(String className) {
371
            super.setClassName(className);
372
            trackFieldElement();
373
        }
374
375
        @Override
376
        public void setFieldName(String name) {
377
            super.setFieldName(name);
378
            trackFieldElement();
379
        }
380
        
381
        private void trackFieldElement() {
382
            synchronized (elementChangeTrackerLock) {
383
                if (elementChangeTracker != null) {
384
                    elementChangeTracker.destroy();
385
                }
386
            }
387
            final String clazz  = getClassName();
388
            FileObject fo = urlHandler.getFileObject();
389
            if (!clazz.isEmpty() && fo != null) {
390
                final JavaSource js = JavaSource.forFileObject(fo);
391
                if (js == null) {
392
                    return ;
393
                }
394
                final String fieldName = getFieldName();
395
                try {
396
                    js.runWhenScanFinished(new Task<CompilationController>() {
397
                        @Override
398
                        public void run(CompilationController parameter) throws Exception {
399
                            ElementChangeTracker ect = JavaSourceUtils.createElementChangeTracker(js, clazz, fieldName, null);
400
                            if (ect != null) {
401
                                ect.setElementChangeListener(FieldBreakpointImpl.this);
402
                                synchronized (elementChangeTrackerLock) {
403
                                    elementChangeTracker = ect;
404
                                }
405
                            }
406
                        }
407
                    }, true);
408
                } catch (IOException ex) {
409
                    Exceptions.printStackTrace(ex);
410
                }
411
            }
412
        }
413
414
        @Override
415
        protected void dispose() {
416
            super.dispose();
417
            synchronized (elementChangeTrackerLock) {
418
                if (elementChangeTracker != null) {
419
                    elementChangeTracker.destroy();
420
                }
421
            }
422
        }
305
        
423
        
306
        @Override
424
        @Override
307
        public GroupProperties getGroupProperties() {
425
        public GroupProperties getGroupProperties() {
Lines 322-327 Link Here
322
            enginePropertyChange(evt);
440
            enginePropertyChange(evt);
323
        }
441
        }
324
442
443
        @Override
444
        public void removed() {
445
            DebuggerManager.getDebuggerManager().removeBreakpoint(this);
446
        }
447
448
        @Override
449
        public void changed(String name) {
450
            setFieldName(name);
451
        }
452
325
        private final class FieldGroupProperties extends GroupProperties {
453
        private final class FieldGroupProperties extends GroupProperties {
326
454
327
            @Override
455
            @Override
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/JavaSourceUtils.java (+374 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.api.debugger.jpda;
43
44
import java.io.IOException;
45
import java.util.ArrayList;
46
import java.util.Collection;
47
import java.util.Collections;
48
import java.util.LinkedHashSet;
49
import java.util.List;
50
import java.util.Set;
51
import javax.lang.model.element.Element;
52
import javax.lang.model.element.ElementKind;
53
import javax.lang.model.element.ExecutableElement;
54
import javax.lang.model.element.Modifier;
55
import javax.lang.model.element.TypeElement;
56
import javax.lang.model.element.VariableElement;
57
import javax.lang.model.type.ArrayType;
58
import javax.lang.model.type.DeclaredType;
59
import javax.lang.model.type.TypeMirror;
60
import javax.lang.model.util.ElementScanner6;
61
import javax.lang.model.util.Types;
62
import org.netbeans.api.java.source.ClassIndex;
63
import org.netbeans.api.java.source.ClassIndexListener;
64
import org.netbeans.api.java.source.CompilationController;
65
import org.netbeans.api.java.source.ElementHandle;
66
import org.netbeans.api.java.source.ElementUtilities;
67
import org.netbeans.api.java.source.JavaSource;
68
import org.netbeans.api.java.source.RootsEvent;
69
import org.netbeans.api.java.source.Task;
70
import org.netbeans.api.java.source.TypesEvent;
71
import org.openide.filesystems.FileObject;
72
import org.openide.filesystems.FileUtil;
73
import org.openide.util.Exceptions;
74
import org.openide.util.Parameters;
75
76
/**
77
 * Java source utilities.
78
 * The main purpose is to track changes in Java elements.
79
 * 
80
 * @author Martin Entlicher
81
 */
82
final class JavaSourceUtils {
83
    
84
    private JavaSourceUtils() {}
85
    
86
    static Collection<ElementHandle<TypeElement>> getClasses (final FileObject fo) {
87
        Parameters.notNull("fo", fo);   //NOI18N
88
        if (!fo.isValid()) {
89
            throw new IllegalArgumentException ("FileObject : " + FileUtil.getFileDisplayName(fo) + " is not valid.");  //NOI18N
90
        }
91
        if (fo.isVirtual()) {
92
            throw new IllegalArgumentException ("FileObject : " + FileUtil.getFileDisplayName(fo) + " is virtual.");  //NOI18N
93
        }
94
        final JavaSource js = JavaSource.forFileObject(fo);        
95
        if (js == null) {
96
            throw new IllegalArgumentException ();
97
        }
98
        try {
99
            final LinkedHashSet<ElementHandle<TypeElement>> result = new LinkedHashSet<ElementHandle<TypeElement>>();
100
            js.runUserActionTask(new Task<CompilationController>() {            
101
                @Override
102
                public void run(final CompilationController control) throws Exception {
103
                    if (control.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED).compareTo (JavaSource.Phase.ELEMENTS_RESOLVED)>=0) {
104
                        final List<TypeElement>  types = new ArrayList<TypeElement>();
105
                        final ElementScanner6<Void,Void> visitor = new ElementScanner6<Void, Void>() {
106
                            @Override
107
                            public Void visitType(TypeElement e, Void p) {
108
                                if (e.getEnclosingElement().getKind() == ElementKind.PACKAGE
109
                                   || e.getModifiers().contains(Modifier.STATIC)) {
110
                                    types.add(e);
111
                                    return super.visitType(e, p);
112
                                } else {
113
                                    return null;
114
                                }
115
                            }
116
                        };
117
                        visitor.scan(control.getTopLevelElements(), null);
118
                        for (TypeElement type : types) {
119
                            result.add (ElementHandle.create(type));
120
                        }
121
                    }
122
                }                
123
124
            }, true);
125
            return result;
126
        } catch (IOException ioe) {
127
            Exceptions.printStackTrace(ioe);
128
            return Collections.<ElementHandle<TypeElement>>emptySet();
129
        }		
130
    }
131
    
132
    static ElementChangeTracker createElementChangeTracker(JavaSource js, String clazz, String name, String signature) {
133
        ClassIndex classIndex = js.getClasspathInfo().getClassIndex();
134
        String packageName = "";
135
        int pkgIndex = clazz.lastIndexOf('.');
136
        if (pkgIndex > 0) {
137
            packageName = clazz.substring(0, pkgIndex);
138
        }
139
        ClassIndex.SearchScopeType scopeType = new JavaSourceUtils.PackageSearchType(packageName);
140
        String prefix = (pkgIndex > 0) ? clazz.substring(pkgIndex+1) : clazz;
141
        int i = prefix.lastIndexOf('$');
142
        if (i > 0) {
143
            prefix = prefix.substring(i+1);
144
        }
145
        ElementHandle<TypeElement> classElement = null;
146
        Set<ElementHandle<TypeElement>> declaredTypes = classIndex.getDeclaredTypes(prefix, ClassIndex.NameKind.PREFIX, Collections.singleton(scopeType));
147
        //System.err.println("Declared types of "+clazz+" = "+declaredTypes);
148
        for (ElementHandle<TypeElement> dt : declaredTypes) {
149
            if (clazz.equals(dt.getBinaryName())) {
150
                classElement = dt;
151
            }
152
        }
153
        //System.err.println("Class Element of "+clazz+" = "+classElement);
154
        if (classElement == null) {
155
            return null;
156
        }
157
        return new ElementChangeTracker(js, classIndex, classElement, name, signature);
158
    }
159
    
160
    static final class ElementChangeTracker {
161
        
162
        private final Tracker tracker = new Tracker();
163
        private final JavaSource js;
164
        private final ClassIndex classIndex;
165
        private final ElementHandle<TypeElement> classElement;
166
        private String name;
167
        private String signature;
168
        private ElementChangeListener ecl;
169
        
170
        private ElementChangeTracker(JavaSource js, ClassIndex classIndex, ElementHandle<TypeElement> classElement, String name, String signature) {
171
            assert classElement != null;
172
            this.js = js;
173
            this.classIndex = classIndex;
174
            this.classElement = classElement;
175
            this.name = name;
176
            this.signature = signature;
177
            classIndex.addClassIndexListener(tracker);
178
        }
179
        
180
        void setName(String name) {
181
            this.name = name;
182
        }
183
        
184
        void setSignature(String signature) {
185
            this.signature = signature;
186
        }
187
        
188
        void setElementChangeListener(ElementChangeListener ecl) {
189
            this.ecl = ecl;
190
        }
191
        
192
        void destroy() {
193
            classIndex.removeClassIndexListener(tracker);
194
        }
195
        
196
        class Tracker implements ClassIndexListener {
197
198
            @Override
199
            public void typesAdded(TypesEvent event) {
200
                for (ElementHandle<TypeElement> eh : event.getTypes()) {
201
                    String binaryName = eh.getBinaryName();
202
                }
203
            }
204
205
            @Override
206
            public void typesRemoved(TypesEvent event) {
207
                for (ElementHandle<TypeElement> eh : event.getTypes()) {
208
                    //String binaryName = eh.getBinaryName();
209
                    if (classElement.signatureEquals(eh)) {
210
                        ecl.removed();
211
                    }
212
                }
213
            }
214
215
            @Override
216
            public void typesChanged(TypesEvent event) {
217
                for (ElementHandle<TypeElement> eh : event.getTypes()) {
218
                    //String binaryName = eh.getBinaryName();
219
                    if (classElement.signatureEquals(eh)) {
220
                        if (name != null && !name.isEmpty()) {
221
                            if (!doesElementExist(js, eh, name, signature)) {
222
                                ecl.removed();
223
                            }
224
                        }
225
                        //ecl.changed(name);
226
                    }
227
                }
228
            }
229
230
            @Override
231
            public void rootsAdded(RootsEvent event) {
232
                event.toString();
233
            }
234
235
            @Override
236
            public void rootsRemoved(RootsEvent event) {
237
                event.toString();
238
            }
239
        }
240
        
241
    }
242
    
243
    static boolean doesElementExist(final JavaSource js,
244
                                    final ElementHandle<TypeElement> typeHandle,
245
                                    final String name,
246
                                    final String signature) {
247
        final boolean[] exists = new boolean[] { false };
248
        try {
249
            js.runUserActionTask(new Task<CompilationController>() {
250
                @Override
251
                public void run(CompilationController cc) throws Exception {
252
                    if (cc.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED).compareTo (JavaSource.Phase.ELEMENTS_RESOLVED) >= 0) {
253
                        TypeElement type = typeHandle.resolve(cc);
254
                        if (type == null) {
255
                            return ;
256
                        }
257
                        //List<? extends Element> allMembers = cc.getElements().getAllMembers(type);
258
                        List<? extends Element> allMembers = type.getEnclosedElements();
259
                        for (Element member : allMembers) {
260
                            if (!member.getSimpleName().contentEquals(name)) {
261
                                continue;
262
                            }
263
                            if (signature == null) {
264
                                if (!ElementKind.FIELD.equals(member.getKind())) {
265
                                    continue;
266
                                }
267
                                exists[0] = true;
268
                                break;
269
                            } else {
270
                                if (!ElementKind.METHOD.equals(member.getKind())) {
271
                                    continue;
272
                                }
273
                                ExecutableElement method = (ExecutableElement) member;
274
                                if (!signature.isEmpty()) {
275
                                    if (!signature.equals(createSignature(method, cc.getTypes()))) {
276
                                        continue;
277
                                    }
278
                                }
279
                                exists[0] = true;
280
                                break;
281
                            }
282
                        }
283
                    } else {
284
                        exists[0] = true; // Be optimistic
285
                    }
286
                }
287
            }, true);
288
        } catch (IOException ex) {
289
            Exceptions.printStackTrace(ex);
290
        }
291
        return exists[0];
292
    }
293
    
294
    private static String createSignature(ExecutableElement elm, Types types) {
295
        StringBuilder signature = new StringBuilder("(");
296
        for (VariableElement param : elm.getParameters()) {
297
            TypeMirror pt = param.asType();
298
            pt = types.erasure(pt);
299
            String paramType = getTypeBinaryName(pt);
300
            signature.append(getSignature(paramType));
301
        }
302
        signature.append(')');
303
        String returnType = getTypeBinaryName(types.erasure(elm.getReturnType()));
304
        signature.append(getSignature(returnType));
305
        return signature.toString();
306
    }
307
    
308
    private static String getTypeBinaryName(TypeMirror t) {
309
        if (t instanceof ArrayType) {
310
            TypeMirror ct = ((ArrayType) t).getComponentType();
311
            return getTypeBinaryName(ct)+"[]";
312
        }
313
        if (t instanceof DeclaredType) {
314
            return ElementUtilities.getBinaryName((TypeElement) ((DeclaredType) t).asElement());
315
        }
316
        return t.toString();
317
    }
318
319
    private static String getSignature(String javaType) {
320
        if (javaType.equals("boolean")) {
321
            return "Z";
322
        } else if (javaType.equals("byte")) {
323
            return "B";
324
        } else if (javaType.equals("char")) {
325
            return "C";
326
        } else if (javaType.equals("short")) {
327
            return "S";
328
        } else if (javaType.equals("int")) {
329
            return "I";
330
        } else if (javaType.equals("long")) {
331
            return "J";
332
        } else if (javaType.equals("float")) {
333
            return "F";
334
        } else if (javaType.equals("double")) {
335
            return "D";
336
        } else if (javaType.equals("void")) {
337
            return "V";
338
        } else if (javaType.endsWith("[]")) {
339
            return "["+getSignature(javaType.substring(0, javaType.length() - 2));
340
        } else {
341
            return "L"+javaType.replace('.', '/')+";";
342
        }
343
    }
344
345
    static interface ElementChangeListener {
346
        void removed();
347
        void changed(String name);
348
    }
349
    
350
    static final class PackageSearchType implements ClassIndex.SearchScopeType {
351
        
352
        private final Set<? extends String> packages;
353
        
354
        PackageSearchType(String packageName) {
355
            packages = Collections.singleton(packageName);
356
        }
357
358
        @Override
359
        public Set<? extends String> getPackages() {
360
            return packages;
361
        }
362
363
        @Override
364
        public boolean isSources() {
365
            return true;
366
        }
367
368
        @Override
369
        public boolean isDependencies() {
370
            return false;
371
        }
372
    }
373
    
374
}
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java (-97 / +15 lines)
Lines 59-64 Link Here
59
import org.netbeans.api.debugger.DebuggerManager;
59
import org.netbeans.api.debugger.DebuggerManager;
60
import org.netbeans.api.project.Project;
60
import org.netbeans.api.project.Project;
61
import org.netbeans.api.project.ProjectManager;
61
import org.netbeans.api.project.ProjectManager;
62
import org.netbeans.spi.debugger.BreakpointURLHandler;
62
import org.openide.ErrorManager;
63
import org.openide.ErrorManager;
63
import org.openide.filesystems.FileAttributeEvent;
64
import org.openide.filesystems.FileAttributeEvent;
64
import org.openide.filesystems.FileChangeListener;
65
import org.openide.filesystems.FileChangeListener;
Lines 430-492 Link Here
430
    public String toString () {
431
    public String toString () {
431
        String fileName = null;
432
        String fileName = null;
432
        try {
433
        try {
433
            FileObject fo = URLMapper.findFileObject(new URL(url));
434
            FileObject fo = URLMapper.findFileObject(new URL(getURL()));
434
            if (fo != null) {
435
            if (fo != null) {
435
                fileName = fo.getNameExt();
436
                fileName = fo.getNameExt();
436
            }
437
            }
437
        } catch (MalformedURLException ex) {}
438
        } catch (MalformedURLException ex) {}
438
        if (fileName == null) {
439
        if (fileName == null) {
439
            fileName = url;
440
            fileName = getURL();
440
        }
441
        }
441
        return "LineBreakpoint " + fileName + " : " + lineNumber;
442
        return "LineBreakpoint " + fileName + " : " + lineNumber;
442
    }
443
    }
443
    
444
    
444
    private static class LineBreakpointImpl extends LineBreakpoint 
445
    private static class LineBreakpointImpl extends LineBreakpoint 
445
                                            implements Comparable, FileChangeListener,
446
                                            implements BreakpointURLHandler.URLBasedBreakpoint, Comparable,
446
                                                       ChangeListener, PropertyChangeListener {
447
                                                       ChangeListener, PropertyChangeListener {
447
        
448
        
448
        // We need to hold our FileObject so that it's not GC'ed, because we'd loose our listener.
449
        // We need to hold our FileObject so that it's not GC'ed, because we'd loose our listener.
449
        private FileObject fo;
450
        private final BreakpointURLHandler urlHandler;
450
        private ChangeListener registryListener;
451
        private FileChangeListener fileListener;
452
       
451
       
453
        public LineBreakpointImpl(String url) {
452
        public LineBreakpointImpl(String url) {
454
            super(url);
453
            super(url);
455
            if (url.length() > 0) {
454
            urlHandler = BreakpointURLHandler.create(this);
456
                try {
457
                    fo = URLMapper.findFileObject(new URL(url));
458
                    if (fo != null) {
459
                        fileListener = WeakListeners.create(FileChangeListener.class, this, fo);
460
                        fo.addFileChangeListener(fileListener);
461
                        registryListener = WeakListeners.change(this, DataObject.getRegistry());
462
                        DataObject.getRegistry().addChangeListener(registryListener);
463
                    }
464
                } catch (MalformedURLException ex) {
465
                    ErrorManager.getDefault().notify(new IllegalArgumentException("URL = '"+url+"'", ex));
466
                } catch (IllegalArgumentException ex) {
467
                    ErrorManager.getDefault().notify(new IllegalArgumentException("URL = '"+url+"'", ex));
468
                }
469
            }
470
        }
455
        }
471
456
472
        @Override
457
        @Override
473
        public void setURL(String url) {
458
        public void setURL(String url) {
474
            if (fo != null) {
459
            String old = urlHandler.setURL(url);
475
                fo.removeFileChangeListener(fileListener);
460
            if (old == null || !old.equals(url)) {
476
            }
461
                super.setURL(url);
477
            super.setURL(url);
462
                DebuggerManager.getDebuggerManager().addBreakpoint(this);
478
            if (url.length() > 0) {
463
                firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
479
                try {
480
                    fo = URLMapper.findFileObject(new URL(url));
481
                    if (fo != null) {
482
                        fileListener = WeakListeners.create(FileChangeListener.class, this, fo);
483
                        fo.addFileChangeListener(fileListener);
484
                    }
485
                } catch (MalformedURLException ex) {
486
                    ErrorManager.getDefault().notify(new IllegalArgumentException("URL = '"+url+"'", ex));
487
                } catch (IllegalArgumentException ex) {
488
                    ErrorManager.getDefault().notify(new IllegalArgumentException("URL = '"+url+"'", ex));
489
                }
490
            }
464
            }
491
        }
465
        }
492
466
Lines 500-506 Link Here
500
            if (o instanceof LineBreakpointImpl) {
474
            if (o instanceof LineBreakpointImpl) {
501
                LineBreakpoint lbthis = this;
475
                LineBreakpoint lbthis = this;
502
                LineBreakpoint lb = (LineBreakpoint) o;
476
                LineBreakpoint lb = (LineBreakpoint) o;
503
                int uc = lbthis.url.compareTo(lb.url);
477
                int uc = lbthis.getURL().compareTo(lb.getURL());
504
                if (uc != 0) {
478
                if (uc != 0) {
505
                    return uc;
479
                    return uc;
506
                } else {
480
                } else {
Lines 523-577 Link Here
523
        }
497
        }
524
498
525
        @Override
499
        @Override
526
        public void fileFolderCreated(FileEvent fe) {
527
        }
528
529
        @Override
530
        public void fileDataCreated(FileEvent fe) {
531
        }
532
533
        @Override
534
        public void fileChanged(FileEvent fe) {
535
        }
536
537
        @Override
538
        public void fileDeleted(FileEvent fe) {
539
            DebuggerManager.getDebuggerManager().removeBreakpoint(this);
540
            fo = null;
541
        }
542
543
        @Override
544
        public void fileRenamed(FileRenameEvent fe) {
545
                this.setURL(((FileObject) fe.getSource()).toURL().toString());
546
        }
547
548
        @Override
549
        public void fileAttributeChanged(FileAttributeEvent fe) {
550
        }
551
    
552
        @Override
553
        public void stateChanged(ChangeEvent chev) {
500
        public void stateChanged(ChangeEvent chev) {
554
            Object source = chev.getSource();
501
            Object source = chev.getSource();
555
            if (source instanceof Breakpoint.VALIDITY) {
502
            if (source instanceof Breakpoint.VALIDITY) {
556
                setValidity((Breakpoint.VALIDITY) source, chev.toString());
503
                setValidity((Breakpoint.VALIDITY) source, chev.toString());
557
            } else if (source instanceof Collection) {
558
                for (Object obj : ((Collection) source)) {
559
                    DataObject dobj = (DataObject) obj;
560
                    if (registryListener != null) {
561
                        FileObject fileObject = this.fo;
562
                        if (fileObject == null) {
563
                            DataObject.getRegistry().removeChangeListener(registryListener);
564
                            registryListener = null;
565
                            return ;
566
                        }
567
                        FileObject primary = dobj.getPrimaryFile();
568
                        if (fileObject.equals(primary)) {
569
                            dobj.addPropertyChangeListener(WeakListeners.propertyChange(this, dobj));
570
                            DataObject.getRegistry().removeChangeListener(registryListener);
571
                            registryListener = null;
572
                        }
573
                    }
574
                }
575
            } else {
504
            } else {
576
                throw new UnsupportedOperationException(chev.toString());
505
                throw new UnsupportedOperationException(chev.toString());
577
            }
506
            }
Lines 579-596 Link Here
579
508
580
        @Override
509
        @Override
581
        public void propertyChange(PropertyChangeEvent evt) {
510
        public void propertyChange(PropertyChangeEvent evt) {
582
            if (DataObject.PROP_PRIMARY_FILE.equals(evt.getPropertyName())) {
511
            if (DebuggerEngine.class.getName().equals(evt.getPropertyName())) {
583
                if (fo != null) {
584
                    fo.removeFileChangeListener(fileListener);
585
                }
586
                FileObject newFO = ((DataObject) evt.getSource()).getPrimaryFile();
587
                fileListener = WeakListeners.create(FileChangeListener.class, this, newFO);
588
                newFO.addFileChangeListener(fileListener);
589
                    this.setURL(newFO.toURL().toString());
590
                fo = newFO;
591
                DebuggerManager.getDebuggerManager().addBreakpoint(this);
592
                firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
593
            } else if (DebuggerEngine.class.getName().equals(evt.getPropertyName())) {
594
                enginePropertyChange(evt);
512
                enginePropertyChange(evt);
595
            }
513
            }
596
        }
514
        }
Lines 609-620 Link Here
609
527
610
            @Override
528
            @Override
611
            public FileObject[] getFiles() {
529
            public FileObject[] getFiles() {
612
                return new FileObject[] { fo };
530
                return new FileObject[] { urlHandler.getFileObject() };
613
            }
531
            }
614
532
615
            @Override
533
            @Override
616
            public Project[] getProjects() {
534
            public Project[] getProjects() {
617
                FileObject f = fo;
535
                FileObject f = urlHandler.getFileObject();
618
                while (f != null) {
536
                while (f != null) {
619
                    f = f.getParent();
537
                    f = f.getParent();
620
                    if (f != null && ProjectManager.getDefault().isProject(f)) {
538
                    if (f != null && ProjectManager.getDefault().isProject(f)) {
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/MethodBreakpoint.java (-2 / +145 lines)
Lines 55-63 Link Here
55
import javax.swing.event.ChangeListener;
55
import javax.swing.event.ChangeListener;
56
import org.netbeans.api.debugger.Breakpoint;
56
import org.netbeans.api.debugger.Breakpoint;
57
import org.netbeans.api.debugger.DebuggerEngine;
57
import org.netbeans.api.debugger.DebuggerEngine;
58
import org.netbeans.api.debugger.DebuggerManager;
59
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeListener;
60
import org.netbeans.api.debugger.jpda.JavaSourceUtils.ElementChangeTracker;
61
import org.netbeans.api.java.source.CompilationController;
62
import org.netbeans.api.java.source.JavaSource;
63
import org.netbeans.api.java.source.Task;
58
import org.netbeans.api.project.Project;
64
import org.netbeans.api.project.Project;
59
import org.netbeans.api.project.ProjectManager;
65
import org.netbeans.api.project.ProjectManager;
66
import org.netbeans.spi.debugger.BreakpointURLHandler;
67
import org.netbeans.spi.debugger.BreakpointURLHandler.URLBasedBreakpoint;
60
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileObject;
69
import org.openide.util.Exceptions;
61
import org.openide.util.NbBundle;
70
import org.openide.util.NbBundle;
62
71
63
/**
72
/**
Lines 89-94 Link Here
89
    public static final String          PROP_CLASS_FILTERS = "classFilters"; // NOI18N
98
    public static final String          PROP_CLASS_FILTERS = "classFilters"; // NOI18N
90
    /** Property name constant */
99
    /** Property name constant */
91
    public static final String          PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
100
    public static final String          PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
101
    /** Property name constant
102
     * @since 2.46 */
103
    public static final String          PROP_URL = LineBreakpoint.PROP_URL;
92
    /** Property name constant */
104
    /** Property name constant */
93
    public static final String          PROP_INSTANCE_FILTERS = "instanceFilters"; // NOI18N
105
    public static final String          PROP_INSTANCE_FILTERS = "instanceFilters"; // NOI18N
94
    /** Property name constant */
106
    /** Property name constant */
Lines 286-291 Link Here
286
    }
298
    }
287
    
299
    
288
    /**
300
    /**
301
     * Get URL of the method source file.
302
     * @return The URL or <code>null</code> when there is no association with the source file.
303
     * @since 2.46
304
     */
305
    public String getURL() {
306
        return null;
307
    }
308
    
309
    /**
310
     * Associate this breakpoint with the method source file.
311
     * @param url The URL of the method source file.
312
     * @since 2.46
313
     */
314
    public void setURL(String url) {
315
    }
316
    
317
    /**
289
     * Get the instance filter for a specific debugger session.
318
     * Get the instance filter for a specific debugger session.
290
     * @return The instances or <code>null</code> when there is no instance restriction.
319
     * @return The instances or <code>null</code> when there is no instance restriction.
291
     */
320
     */
Lines 360-367 Link Here
360
    }
389
    }
361
    
390
    
362
    
391
    
363
    private static final class MethodBreakpointImpl extends MethodBreakpoint implements ChangeListener,
392
    private static final class MethodBreakpointImpl extends MethodBreakpoint implements URLBasedBreakpoint,
364
                                                                                        PropertyChangeListener {
393
                                                                                        ChangeListener,
394
                                                                                        PropertyChangeListener,
395
                                                                                        ElementChangeListener {
396
        
397
        private final BreakpointURLHandler urlHandler;
398
        private ElementChangeTracker elementChangeTracker;
399
        private final Object elementChangeTrackerLock = new Object();
400
        
401
        MethodBreakpointImpl() {
402
            super();
403
            urlHandler = BreakpointURLHandler.create(this);
404
        }
405
406
        @Override
407
        public String getURL() {
408
            if (urlHandler == null) {
409
                return null;
410
            } else {
411
                return urlHandler.getURL();
412
            }
413
        }
414
415
        @Override
416
        public void setURL(String url) {
417
            String old = urlHandler.setURL(url);
418
            if (old == null || !old.equals(url)) {
419
                firePropertyChange (PROP_URL, old, url);
420
                if (old != null && !old.isEmpty()) {
421
                    DebuggerManager.getDebuggerManager().addBreakpoint(this);
422
                }
423
                firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
424
                trackMethodElement();
425
            }
426
        }
427
428
        @Override
429
        public void setClassFilters(String[] classFilters) {
430
            super.setClassFilters(classFilters);
431
            trackMethodElement();
432
        }
433
434
        @Override
435
        public void setMethodName(String mn) {
436
            super.setMethodName(mn);
437
            synchronized (elementChangeTrackerLock) {
438
                if (elementChangeTracker != null) {
439
                    elementChangeTracker.setName(mn);
440
                }
441
            }
442
        }
443
444
        @Override
445
        public void setMethodSignature(String signature) {
446
            super.setMethodSignature(signature);
447
            synchronized (elementChangeTrackerLock) {
448
                if (elementChangeTracker != null) {
449
                    elementChangeTracker.setSignature(signature);
450
                }
451
            }
452
        }
453
        
454
        private void trackMethodElement() {
455
            synchronized (elementChangeTrackerLock) {
456
                if (elementChangeTracker != null) {
457
                    elementChangeTracker.destroy();
458
                }
459
            }
460
            String[] classFilters = getClassFilters();
461
            FileObject fo = urlHandler.getFileObject();
462
            if (classFilters.length == 1 && fo != null) {
463
                final String clazz = classFilters[0];
464
                final JavaSource js = JavaSource.forFileObject(fo);
465
                if (js == null) {
466
                    return ;
467
                }
468
                final String methodName = getMethodName();
469
                final String methodSignature = getMethodSignature();
470
                try {
471
                    js.runWhenScanFinished(new Task<CompilationController>() {
472
                        @Override
473
                        public void run(CompilationController parameter) throws Exception {
474
                            ElementChangeTracker ect = JavaSourceUtils.createElementChangeTracker(js, clazz, methodName, methodSignature);
475
                            if (ect != null) {
476
                                ect.setElementChangeListener(MethodBreakpointImpl.this);
477
                                synchronized (elementChangeTrackerLock) {
478
                                    elementChangeTracker = ect;
479
                                }
480
                            }
481
                        }
482
                    }, true);
483
                } catch (IOException ex) {
484
                    Exceptions.printStackTrace(ex);
485
                }
486
            }
487
        }
488
489
        @Override
490
        protected void dispose() {
491
            super.dispose();
492
            synchronized (elementChangeTrackerLock) {
493
                if (elementChangeTracker != null) {
494
                    elementChangeTracker.destroy();
495
                }
496
            }
497
        }
365
        
498
        
366
        @Override
499
        @Override
367
        public GroupProperties getGroupProperties() {
500
        public GroupProperties getGroupProperties() {
Lines 382-387 Link Here
382
            enginePropertyChange(evt);
515
            enginePropertyChange(evt);
383
        }
516
        }
384
517
518
        @Override
519
        public void removed() {
520
            DebuggerManager.getDebuggerManager().removeBreakpoint(this);
521
        }
522
523
        @Override
524
        public void changed(String name) {
525
            setMethodName(name);
526
        }
527
385
        
528
        
386
        private final class MethodGroupProperties extends GroupProperties {
529
        private final class MethodGroupProperties extends GroupProperties {
387
530
(-)a/api.debugger/apichanges.xml (+14 lines)
Lines 75-80 Link Here
75
<!-- ACTUAL CHANGES BEGIN HERE: -->
75
<!-- ACTUAL CHANGES BEGIN HERE: -->
76
76
77
<changes>
77
<changes>
78
    <change id="BreakpointURLHandler">
79
        <api name="DebuggerCoreAPI"/>
80
        <summary>Handling of breakpoint's URL updates.</summary>
81
        <version major="1" minor="44"/>
82
        <date day="28" month="8" year="2013"/>
83
        <author login="mentlicher"/>
84
        <compatibility binary="compatible" source="compatible" addition="yes" deletion="no"/>
85
        <description>
86
            A class BreakpointURLHandler is added to automatically update
87
            breakpoint's URL property when the breakpoint's source URL changes.
88
        </description>
89
        <class package="org.netbeans.spi.debugger" name="BreakpointURLHandler"/>
90
        <issue number="226437"/>
91
    </change>
78
    <change id="Watch_disableable">
92
    <change id="Watch_disableable">
79
        <api name="DebuggerCoreAPI"/>
93
        <api name="DebuggerCoreAPI"/>
80
        <summary>API for changing enabled state of a Watch</summary>
94
        <summary>API for changing enabled state of a Watch</summary>
(-)a/api.debugger/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.debugger/1
2
OpenIDE-Module: org.netbeans.api.debugger/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.43
4
OpenIDE-Module-Specification-Version: 1.44
5
OpenIDE-Module-Layer: org/netbeans/api/debugger/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/api/debugger/layer.xml
(-)a/api.debugger/nbproject/project.xml (+16 lines)
Lines 76-81 Link Here
76
                    </run-dependency>
76
                    </run-dependency>
77
                </dependency>
77
                </dependency>
78
                <dependency>
78
                <dependency>
79
                    <code-name-base>org.openide.loaders</code-name-base>
80
                    <build-prerequisite/>
81
                    <compile-dependency/>
82
                    <run-dependency>
83
                        <specification-version>7.50</specification-version>
84
                    </run-dependency>
85
                </dependency>
86
                <dependency>
79
                    <code-name-base>org.openide.modules</code-name-base>
87
                    <code-name-base>org.openide.modules</code-name-base>
80
                    <build-prerequisite/>
88
                    <build-prerequisite/>
81
                    <compile-dependency/>
89
                    <compile-dependency/>
Lines 84-89 Link Here
84
                    </run-dependency>
92
                    </run-dependency>
85
                </dependency>
93
                </dependency>
86
                <dependency>
94
                <dependency>
95
                    <code-name-base>org.openide.nodes</code-name-base>
96
                    <build-prerequisite/>
97
                    <compile-dependency/>
98
                    <run-dependency>
99
                        <specification-version>7.36</specification-version>
100
                    </run-dependency>
101
                </dependency>
102
                <dependency>
87
                    <code-name-base>org.openide.util</code-name-base>
103
                    <code-name-base>org.openide.util</code-name-base>
88
                    <build-prerequisite/>
104
                    <build-prerequisite/>
89
                    <compile-dependency/>
105
                    <compile-dependency/>
(-)a/api.debugger/src/org/netbeans/spi/debugger/BreakpointURLHandler.java (+265 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.debugger;
43
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
46
import java.net.MalformedURLException;
47
import java.net.URL;
48
import java.util.Collection;
49
import javax.swing.event.ChangeEvent;
50
import javax.swing.event.ChangeListener;
51
import org.netbeans.api.debugger.Breakpoint;
52
import org.netbeans.api.debugger.DebuggerManager;
53
import org.openide.ErrorManager;
54
import org.openide.filesystems.FileAttributeEvent;
55
import org.openide.filesystems.FileChangeListener;
56
import org.openide.filesystems.FileEvent;
57
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileRenameEvent;
59
import org.openide.filesystems.URLMapper;
60
import org.openide.loaders.DataObject;
61
import org.openide.util.WeakListeners;
62
63
/**
64
 * A utility class, that keeps an association of the breakpoint with an URL
65
 * and reflects the changes of the URL to the breakpoint.
66
 * 
67
 * @author Martin Entlicher
68
 * @since 1.44
69
 */
70
public final class BreakpointURLHandler {
71
    
72
    private final URLBasedBreakpoint breakpoint;
73
    private String url;
74
    private FileObject fo;
75
    private Listener listener;
76
    
77
    private BreakpointURLHandler(URLBasedBreakpoint breakpoint) {
78
        this.breakpoint = breakpoint;
79
        setURL(breakpoint.getURL());
80
    }
81
    
82
    /**
83
     * Creates a handler from an URL-based breakpoint.
84
     * @param breakpoint The URL-based breakpoint
85
     * @return a new instance of the handler
86
     */
87
    public static BreakpointURLHandler create(URLBasedBreakpoint breakpoint) {
88
        return new BreakpointURLHandler(breakpoint);
89
    }
90
    
91
    /**
92
     * Gets a string representation of URL of the source file,
93
     * which contains the breakpoint.
94
     *
95
     * @return URL of the breakpoint source file.
96
     */
97
    public String getURL() {
98
        return url;
99
    }
100
    
101
    /**
102
     * Set a string representation of URL of the source file containing the breakpoint.
103
     * @param url the URL of the breakpoint source file.
104
     * @return an old URL, or <code>null</code>.
105
     */
106
    public String setURL(String url) {
107
        String old;
108
        synchronized (this) {
109
            if (url == null) {
110
                url = "";
111
            }
112
            if (url.equals(this.url)) {
113
                return this.url;
114
            }
115
            old = this.url;
116
            this.url = url;
117
118
            if (listener != null) {
119
                listener.removeFrom(fo);
120
            }
121
            if (url.length() > 0) {
122
                try {
123
                    fo = URLMapper.findFileObject(new URL(url));
124
                    if (fo != null) {
125
                        if (listener == null) {
126
                            listener = new Listener();
127
                        }
128
                        listener.addTo(fo);
129
                    }
130
                } catch (MalformedURLException ex) {
131
                    ErrorManager.getDefault().notify(new IllegalArgumentException("URL = '"+url+"'", ex));
132
                } catch (IllegalArgumentException ex) {
133
                    ErrorManager.getDefault().notify(new IllegalArgumentException("URL = '"+url+"'", ex));
134
                }
135
            }
136
        }
137
        return old;
138
    }
139
    
140
    /**
141
     * Get the FileObject that corresponds to the current URL.
142
     * @return The FileObject or <code>null</code>.
143
     */
144
    public FileObject getFileObject() {
145
        return fo;
146
    }
147
    
148
    void setFileObject(FileObject newFO) {
149
        synchronized (this) {
150
            if (listener != null) {
151
                if (fo != null) {
152
                    listener.removeFrom(fo);
153
                }
154
                listener.addTo(newFO);
155
            }
156
            fo = newFO;
157
        }
158
        breakpoint.setURL(newFO.toURL().toString());
159
    }
160
    
161
    private class Listener implements FileChangeListener, ChangeListener, PropertyChangeListener {
162
        
163
        private FileChangeListener fileListener;
164
        private ChangeListener registryListener;
165
        
166
        public Listener() {
167
            registryListener = WeakListeners.change(this, DataObject.getRegistry());
168
            DataObject.getRegistry().addChangeListener(registryListener);
169
        }
170
        
171
        void addTo(FileObject fo) {
172
            fileListener = WeakListeners.create(FileChangeListener.class, this, fo);
173
            fo.addFileChangeListener(fileListener);
174
        }
175
        
176
        void removeFrom(FileObject fo) {
177
            fo.removeFileChangeListener(fileListener);
178
        }
179
180
        @Override
181
        public void fileFolderCreated(FileEvent fe) {
182
        }
183
184
        @Override
185
        public void fileDataCreated(FileEvent fe) {
186
        }
187
188
        @Override
189
        public void fileChanged(FileEvent fe) {
190
        }
191
192
        @Override
193
        public void fileDeleted(FileEvent fe) {
194
            if (breakpoint instanceof Breakpoint) {
195
                DebuggerManager.getDebuggerManager().removeBreakpoint((Breakpoint) breakpoint);
196
            }
197
            fo = null;
198
        }
199
200
        @Override
201
        public void fileRenamed(FileRenameEvent fe) {
202
            breakpoint.setURL(((FileObject) fe.getSource()).toURL().toString());
203
        }
204
205
        @Override
206
        public void fileAttributeChanged(FileAttributeEvent fe) {
207
        }
208
209
        @Override
210
        public void stateChanged(ChangeEvent chev) {
211
            Object source = chev.getSource();
212
            if (source instanceof Collection) {
213
                for (Object obj : ((Collection) source)) {
214
                    DataObject dobj = (DataObject) obj;
215
                    if (registryListener != null) {
216
                        FileObject fileObject = fo;
217
                        if (fileObject == null) {
218
                            DataObject.getRegistry().removeChangeListener(registryListener);
219
                            registryListener = null;
220
                            return ;
221
                        }
222
                        FileObject primary = dobj.getPrimaryFile();
223
                        if (fileObject.equals(primary)) {
224
                            dobj.addPropertyChangeListener(WeakListeners.propertyChange(this, dobj));
225
                            DataObject.getRegistry().removeChangeListener(registryListener);
226
                            registryListener = null;
227
                        }
228
                    }
229
                }
230
            }
231
        }
232
233
        @Override
234
        public void propertyChange(PropertyChangeEvent evt) {
235
            if (DataObject.PROP_PRIMARY_FILE.equals(evt.getPropertyName())) {
236
                FileObject newFO = ((DataObject) evt.getSource()).getPrimaryFile();
237
                setFileObject(newFO);
238
                //DebuggerManager.getDebuggerManager().addBreakpoint(this);
239
                //firePropertyChange(PROP_GROUP_PROPERTIES, null, null);
240
            }
241
        }
242
        
243
    }
244
    
245
    /**
246
     * Breakpoints that are associated with an URL should implement this
247
     * interface so that they can be updated as the underlying source file changes.
248
     */
249
    public static interface URLBasedBreakpoint {
250
        
251
        /**
252
         * Get the breakpoint's URL.
253
         * @return The URL.
254
         */
255
        String getURL();
256
    
257
        /**
258
         * Set the breakpoint to a new URL.
259
         * @param url The new URL.
260
         */
261
        void setURL(String url);
262
    
263
    }
264
    
265
}
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/actions/ToggleMethodFieldBreakpointAction.java (-6 / +9 lines)
Lines 255-261 Link Here
255
                        } else if (fn == null && mn == null) {
255
                        } else if (fn == null && mn == null) {
256
                            return ; // line breakpoint only, which was submitted already.
256
                            return ; // line breakpoint only, which was submitted already.
257
                        }
257
                        }
258
                        if (submitFieldOrMethodOrClassBreakpoint(cn, fn, mn, ms, null, ln)) {
258
                        if (submitFieldOrMethodOrClassBreakpoint(cn, fn, mn, ms, url, null, ln)) {
259
                            // We've submitted a field or method breakpoint, so delete the line one:
259
                            // We've submitted a field or method breakpoint, so delete the line one:
260
                            LineBreakpoint lb = ToggleBreakpointActionProvider.findBreakpoint (
260
                            LineBreakpoint lb = ToggleBreakpointActionProvider.findBreakpoint (
261
                                url, ln
261
                                url, ln
Lines 278-288 Link Here
278
            if (classDeclaration[0] != null) {
278
            if (classDeclaration[0] != null) {
279
                return submitFieldOrMethodOrClassBreakpoint(classDeclaration[0], null,
279
                return submitFieldOrMethodOrClassBreakpoint(classDeclaration[0], null,
280
                                                            null, null,
280
                                                            null, null,
281
                                                            url, ln);
281
                                                            null, url, ln);
282
            } else {
282
            } else {
283
                return submitFieldOrMethodOrClassBreakpoint(className[0], fieldName[0],
283
                return submitFieldOrMethodOrClassBreakpoint(className[0], fieldName[0],
284
                                                            methodName, methodSignature,
284
                                                            methodName, methodSignature,
285
                                                            url, ln);
285
                                                            url, url, ln);
286
            }
286
            }
287
        }
287
        }
288
        
288
        
Lines 317-323 Link Here
317
        
317
        
318
    private boolean submitFieldOrMethodOrClassBreakpoint(final String className, final String fieldName,
318
    private boolean submitFieldOrMethodOrClassBreakpoint(final String className, final String fieldName,
319
                                                         final String methodName, final String methodSignature,
319
                                                         final String methodName, final String methodSignature,
320
                                                         String url, int line) {
320
                                                         final String sourceURL, String lineURL, int line) {
321
        if (className == null) {
321
        if (className == null) {
322
            return false;   // Can not do anything without the class name
322
            return false;   // Can not do anything without the class name
323
        }
323
        }
Lines 332-339 Link Here
332
        //} else {
332
        //} else {
333
        //    return false;
333
        //    return false;
334
        }
334
        }
335
        if (b == null && url != null) {
335
        if (b == null && lineURL != null) {
336
            b = ToggleBreakpointActionProvider.findBreakpoint(url, line);
336
            b = ToggleBreakpointActionProvider.findBreakpoint(lineURL, line);
337
        }
337
        }
338
        DebuggerManager d = DebuggerManager.getDebuggerManager();
338
        DebuggerManager d = DebuggerManager.getDebuggerManager();
339
        if (b != null) {
339
        if (b != null) {
Lines 357-369 Link Here
357
                    JPDABreakpoint b;
357
                    JPDABreakpoint b;
358
                    if (fieldName != null) {
358
                    if (fieldName != null) {
359
                        b = FieldBreakpoint.create(className, fieldName, FieldBreakpoint.TYPE_MODIFICATION | FieldBreakpoint.TYPE_ACCESS);
359
                        b = FieldBreakpoint.create(className, fieldName, FieldBreakpoint.TYPE_MODIFICATION | FieldBreakpoint.TYPE_ACCESS);
360
                        ((FieldBreakpoint) b).setURL(sourceURL);
360
                        b.setPrintText(NbBundle.getMessage(FieldBreakpointPanel.class, "CTL_Field_Breakpoint_Print_Text"));
361
                        b.setPrintText(NbBundle.getMessage(FieldBreakpointPanel.class, "CTL_Field_Breakpoint_Print_Text"));
361
                    } else if (methodName != null) {
362
                    } else if (methodName != null) {
362
                        b = MethodBreakpoint.create(className, methodName);
363
                        b = MethodBreakpoint.create(className, methodName);
363
                        ((MethodBreakpoint) b).setMethodSignature(methodSignature);
364
                        ((MethodBreakpoint) b).setMethodSignature(methodSignature);
365
                        ((MethodBreakpoint) b).setURL(sourceURL);
364
                        b.setPrintText(NbBundle.getMessage(MethodBreakpointPanel.class, "CTL_Method_Breakpoint_Print_Text"));
366
                        b.setPrintText(NbBundle.getMessage(MethodBreakpointPanel.class, "CTL_Method_Breakpoint_Print_Text"));
365
                    } else {
367
                    } else {
366
                        b = ClassLoadUnloadBreakpoint.create(className, false, ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED);
368
                        b = ClassLoadUnloadBreakpoint.create(className, false, ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED);
369
                        ((ClassLoadUnloadBreakpoint) b).setURL(sourceURL);
367
                        b.setPrintText (NbBundle.getMessage(ClassBreakpointPanel.class, "CTL_Class_Breakpoint_Print_Text"));
370
                        b.setPrintText (NbBundle.getMessage(ClassBreakpointPanel.class, "CTL_Class_Breakpoint_Print_Text"));
368
                    }
371
                    }
369
                    DebuggerManager d = DebuggerManager.getDebuggerManager();
372
                    DebuggerManager d = DebuggerManager.getDebuggerManager();
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/ClassBreakpointPanel.java (+2 lines)
Lines 57-62 Link Here
57
import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge;
57
import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge;
58
import org.netbeans.modules.debugger.jpda.ui.completion.JavaClassNbDebugEditorKit;
58
import org.netbeans.modules.debugger.jpda.ui.completion.JavaClassNbDebugEditorKit;
59
import org.netbeans.spi.debugger.ui.Controller;
59
import org.netbeans.spi.debugger.ui.Controller;
60
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
60
61
61
import org.openide.DialogDisplayer;
62
import org.openide.DialogDisplayer;
62
import org.openide.NotifyDescriptor;
63
import org.openide.NotifyDescriptor;
Lines 94-99 Link Here
94
            false, 
95
            false, 
95
            ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED
96
            ClassLoadUnloadBreakpoint.TYPE_CLASS_LOADED_UNLOADED
96
        );
97
        );
98
        mb.setURL(EditorContextDispatcher.getDefault().getMostRecentURLAsString());
97
        mb.setPrintText (
99
        mb.setPrintText (
98
            NbBundle.getBundle (ClassBreakpointPanel.class).getString 
100
            NbBundle.getBundle (ClassBreakpointPanel.class).getString 
99
                ("CTL_Class_Breakpoint_Print_Text")
101
                ("CTL_Class_Breakpoint_Print_Text")
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/ExceptionBreakpointPanel.java (+2 lines)
Lines 54-59 Link Here
54
import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge;
54
import org.netbeans.modules.debugger.jpda.ui.EditorContextBridge;
55
import org.netbeans.modules.debugger.jpda.ui.completion.ExceptionClassNbDebugEditorKit;
55
import org.netbeans.modules.debugger.jpda.ui.completion.ExceptionClassNbDebugEditorKit;
56
import org.netbeans.spi.debugger.ui.Controller;
56
import org.netbeans.spi.debugger.ui.Controller;
57
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
57
58
58
import org.openide.DialogDisplayer;
59
import org.openide.DialogDisplayer;
59
import org.openide.NotifyDescriptor;
60
import org.openide.NotifyDescriptor;
Lines 91-96 Link Here
91
            className,
92
            className,
92
            ExceptionBreakpoint.TYPE_EXCEPTION_CATCHED_UNCATCHED
93
            ExceptionBreakpoint.TYPE_EXCEPTION_CATCHED_UNCATCHED
93
        );
94
        );
95
        mb.setURL(EditorContextDispatcher.getDefault().getMostRecentURLAsString());
94
        mb.setPrintText (
96
        mb.setPrintText (
95
            NbBundle.getBundle (ExceptionBreakpointPanel.class).getString 
97
            NbBundle.getBundle (ExceptionBreakpointPanel.class).getString 
96
                ("CTL_Exception_Breakpoint_Print_Text")
98
                ("CTL_Exception_Breakpoint_Print_Text")
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/FieldBreakpointPanel.java (+2 lines)
Lines 57-62 Link Here
57
import org.netbeans.modules.debugger.jpda.ui.completion.JavaClassNbDebugEditorKit;
57
import org.netbeans.modules.debugger.jpda.ui.completion.JavaClassNbDebugEditorKit;
58
import org.netbeans.modules.debugger.jpda.ui.completion.JavaFieldNbDebugEditorKit;
58
import org.netbeans.modules.debugger.jpda.ui.completion.JavaFieldNbDebugEditorKit;
59
import org.netbeans.spi.debugger.ui.Controller;
59
import org.netbeans.spi.debugger.ui.Controller;
60
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
60
61
61
import org.openide.DialogDisplayer;
62
import org.openide.DialogDisplayer;
62
import org.openide.NotifyDescriptor;
63
import org.openide.NotifyDescriptor;
Lines 102-107 Link Here
102
            fieldName,
103
            fieldName,
103
            FieldBreakpoint.TYPE_ACCESS | FieldBreakpoint.TYPE_MODIFICATION
104
            FieldBreakpoint.TYPE_ACCESS | FieldBreakpoint.TYPE_MODIFICATION
104
        );
105
        );
106
        mb.setURL(EditorContextDispatcher.getDefault().getMostRecentURLAsString());
105
        mb.setPrintText (
107
        mb.setPrintText (
106
            NbBundle.getBundle (FieldBreakpointPanel.class).getString 
108
            NbBundle.getBundle (FieldBreakpointPanel.class).getString 
107
                ("CTL_Field_Breakpoint_Print_Text")
109
                ("CTL_Field_Breakpoint_Print_Text")
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/MethodBreakpointPanel.java (+2 lines)
Lines 55-60 Link Here
55
import org.netbeans.modules.debugger.jpda.ui.completion.JavaClassNbDebugEditorKit;
55
import org.netbeans.modules.debugger.jpda.ui.completion.JavaClassNbDebugEditorKit;
56
import org.netbeans.modules.debugger.jpda.ui.completion.JavaMethodNbDebugEditorKit;
56
import org.netbeans.modules.debugger.jpda.ui.completion.JavaMethodNbDebugEditorKit;
57
import org.netbeans.spi.debugger.ui.Controller;
57
import org.netbeans.spi.debugger.ui.Controller;
58
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
58
import org.openide.DialogDisplayer;
59
import org.openide.DialogDisplayer;
59
import org.openide.NotifyDescriptor;
60
import org.openide.NotifyDescriptor;
60
import org.openide.ErrorManager;
61
import org.openide.ErrorManager;
Lines 103-108 Link Here
103
        try {
104
        try {
104
            mb.setMethodSignature(EditorContextBridge.getMostRecentMethodSignature());
105
            mb.setMethodSignature(EditorContextBridge.getMostRecentMethodSignature());
105
        } catch (java.awt.IllegalComponentStateException icsex) {}
106
        } catch (java.awt.IllegalComponentStateException icsex) {}
107
        mb.setURL(EditorContextDispatcher.getDefault().getMostRecentURLAsString());
106
        mb.setPrintText (
108
        mb.setPrintText (
107
            NbBundle.getBundle (MethodBreakpointPanel.class).getString 
109
            NbBundle.getBundle (MethodBreakpointPanel.class).getString 
108
                ("CTL_Method_Breakpoint_Print_Text")
110
                ("CTL_Method_Breakpoint_Print_Text")
(-)a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointsReader.java (+32 lines)
Lines 178-183 Link Here
178
                    MethodBreakpoint.TYPE_METHOD_ENTRY
178
                    MethodBreakpoint.TYPE_METHOD_ENTRY
179
                )
179
                )
180
            );
180
            );
181
            String url = properties.getString(MethodBreakpoint.PROP_URL, null);
182
            if (url != null) {
183
                mb.setURL(url);
184
            }
181
            synchronized (this) {
185
            synchronized (this) {
182
                cachedSourceRoots.put(mb, properties.getString("sourceRoot", null));
186
                cachedSourceRoots.put(mb, properties.getString("sourceRoot", null));
183
            }
187
            }
Lines 203-208 Link Here
203
                    new String [0]
207
                    new String [0]
204
                )
208
                )
205
            );
209
            );
210
            String url = properties.getString(ClassLoadUnloadBreakpoint.PROP_URL, null);
211
            if (url != null) {
212
                cb.setURL(url);
213
            }
206
            synchronized (this) {
214
            synchronized (this) {
207
                cachedSourceRoots.put(cb, properties.getString("sourceRoot", null));
215
                cachedSourceRoots.put(cb, properties.getString("sourceRoot", null));
208
            }
216
            }
Lines 231-236 Link Here
231
            if (classExclusionFilters != null) {
239
            if (classExclusionFilters != null) {
232
                eb.setClassExclusionFilters(classExclusionFilters);
240
                eb.setClassExclusionFilters(classExclusionFilters);
233
            }
241
            }
242
            String url = properties.getString(ExceptionBreakpoint.PROP_URL, null);
243
            if (url != null) {
244
                eb.setURL(url);
245
            }
234
            synchronized (this) {
246
            synchronized (this) {
235
                cachedSourceRoots.put(eb, properties.getString("sourceRoot", null));
247
                cachedSourceRoots.put(eb, properties.getString("sourceRoot", null));
236
            }
248
            }
Lines 249-254 Link Here
249
            fb.setCondition (
261
            fb.setCondition (
250
                properties.getString (FieldBreakpoint.PROP_CONDITION, "")
262
                properties.getString (FieldBreakpoint.PROP_CONDITION, "")
251
            );
263
            );
264
            String url = properties.getString(FieldBreakpoint.PROP_URL, null);
265
            if (url != null) {
266
                fb.setURL(url);
267
            }
252
            synchronized (this) {
268
            synchronized (this) {
253
                cachedSourceRoots.put(fb, properties.getString("sourceRoot", null));
269
                cachedSourceRoots.put(fb, properties.getString("sourceRoot", null));
254
            }
270
            }
Lines 440-445 Link Here
440
                MethodBreakpoint.PROP_BREAKPOINT_TYPE, 
456
                MethodBreakpoint.PROP_BREAKPOINT_TYPE, 
441
                mb.getBreakpointType ()
457
                mb.getBreakpointType ()
442
            );
458
            );
459
            properties.setString(
460
                MethodBreakpoint.PROP_URL,
461
                mb.getURL()
462
            );
443
            properties.setString("sourceRoot", findCachedSourceRoot(mb));
463
            properties.setString("sourceRoot", findCachedSourceRoot(mb));
444
            return;
464
            return;
445
        } else 
465
        } else 
Lines 457-462 Link Here
457
                ClassLoadUnloadBreakpoint.PROP_BREAKPOINT_TYPE, 
477
                ClassLoadUnloadBreakpoint.PROP_BREAKPOINT_TYPE, 
458
                cb.getBreakpointType ()
478
                cb.getBreakpointType ()
459
            );
479
            );
480
            properties.setString(
481
                ClassLoadUnloadBreakpoint.PROP_URL,
482
                cb.getURL()
483
            );
460
            properties.setString("sourceRoot", findCachedSourceRoot(cb));
484
            properties.setString("sourceRoot", findCachedSourceRoot(cb));
461
            return;
485
            return;
462
        } else 
486
        } else 
Lines 480-485 Link Here
480
                ExceptionBreakpoint.PROP_CONDITION, 
504
                ExceptionBreakpoint.PROP_CONDITION, 
481
                eb.getCondition ()
505
                eb.getCondition ()
482
            );
506
            );
507
            properties.setString(
508
                ExceptionBreakpoint.PROP_URL,
509
                eb.getURL()
510
            );
483
            properties.setString("sourceRoot", findCachedSourceRoot(eb));
511
            properties.setString("sourceRoot", findCachedSourceRoot(eb));
484
            return;
512
            return;
485
        } else 
513
        } else 
Lines 501-506 Link Here
501
                FieldBreakpoint.PROP_BREAKPOINT_TYPE, 
529
                FieldBreakpoint.PROP_BREAKPOINT_TYPE, 
502
                fb.getBreakpointType ()
530
                fb.getBreakpointType ()
503
            );
531
            );
532
            properties.setString(
533
                FieldBreakpoint.PROP_URL,
534
                fb.getURL()
535
            );
504
            properties.setString("sourceRoot", findCachedSourceRoot(fb));
536
            properties.setString("sourceRoot", findCachedSourceRoot(fb));
505
            return;
537
            return;
506
        } else 
538
        } else 

Return to bug 226437