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 79027
Collapse All | Expand All

(-)a/api.debugger.jpda/apichanges.xml (+19 lines)
Lines 816-821 Link Here
816
        <issue number="226029"/>
816
        <issue number="226029"/>
817
    </change>
817
    </change>
818
818
819
    <change>
820
        <api name="JPDADebuggerAPI"/>
821
        <summary>Breakpoints can deactivated.</summary>
822
        <version major="2" minor="42"/>
823
        <date day="27" month="2" year="2013"/>
824
        <author login="mentlicher"/>
825
        <compatibility addition="yes" source="compatible" binary="compatible"/>
826
        <description>
827
            Two methods are added to JPDADebugger class: getBreakpointsActive()
828
            and setBreakpointsActive(boolean). The set method fires PROP_BREAKPOINTS_ACTIVE
829
            event. <br/>
830
            These methods are used to activate/deactivate all breakpoints in the
831
            debugger session.
832
            Initially, the breakpoints are active in the debugger session.
833
        </description>
834
        <class package="org.netbeans.api.debugger.jpda" name="JPDADebugger" />
835
        <issue number="79027"/>
836
    </change>
837
819
838
820
</changes>
839
</changes>
821
840
(-)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.41
4
OpenIDE-Module-Specification-Version: 2.42
5
OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager]
5
OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager]
6
6
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/JPDADebugger.java (+27 lines)
Lines 107-112 Link Here
107
    /** Property name constant.
107
    /** Property name constant.
108
     * @since 2.25     */
108
     * @since 2.25     */
109
    public static final String          PROP_CLASSES_FIXED = "classesFixed";  // NOI18N
109
    public static final String          PROP_CLASSES_FIXED = "classesFixed";  // NOI18N
110
    /** Property name constant. Fired when breakpoints are activated / deactivated.
111
     * @since 2.42     */
112
    public static final String          PROP_BREAKPOINTS_ACTIVE = "breakpointsActive"; // NOI18N
110
    
113
    
111
    /** Suspend property value constant. */
114
    /** Suspend property value constant. */
112
    public static final int             SUSPEND_ALL = EventRequest.SUSPEND_ALL;
115
    public static final int             SUSPEND_ALL = EventRequest.SUSPEND_ALL;
Lines 488-493 Link Here
488
    }
491
    }
489
    
492
    
490
    /**
493
    /**
494
     * Test, if breakpoints are active.
495
     * @return <code>true</code> when breakpoints are active, <code>false</code>
496
     * otherwise. The default implementation returns <code>true</code>, to be overridden
497
     * when needed.
498
     * @since 2.42
499
     */
500
    public boolean getBreakpointsActive() {
501
        return true;
502
    }
503
    
504
    /**
505
     * Set all breakpoints to be active / inactive.
506
     * Activation or deactivation of breakpoints should not alter the enabled/disabled
507
     * state of individual breakpoints.
508
     * The default implementation does nothing, override
509
     * together with {@link #getBreakpointsActive()} when needed.
510
     * @param active <code>true</code> to make all breakpoints active,
511
     *               <code>false</code> to make all breakpoints inactive.
512
     * @since 2.42
513
     */
514
    public void setBreakpointsActive(boolean active) {
515
    }
516
    
517
    /**
491
     * Adds property change listener.
518
     * Adds property change listener.
492
     *
519
     *
493
     * @param l new listener.
520
     * @param l new listener.
(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/BreakpointAnnotationProvider.java (-17 / +80 lines)
Lines 63-76 Link Here
63
import org.netbeans.api.debugger.Breakpoint.VALIDITY;
63
import org.netbeans.api.debugger.Breakpoint.VALIDITY;
64
import org.netbeans.api.debugger.DebuggerEngine;
64
import org.netbeans.api.debugger.DebuggerEngine;
65
import org.netbeans.api.debugger.DebuggerManager;
65
import org.netbeans.api.debugger.DebuggerManager;
66
import org.netbeans.api.debugger.DebuggerManagerAdapter;
66
import org.netbeans.api.debugger.DebuggerManagerListener;
67
import org.netbeans.api.debugger.DebuggerManagerListener;
68
import org.netbeans.api.debugger.LazyDebuggerManagerListener;
67
import org.netbeans.api.debugger.Session;
69
import org.netbeans.api.debugger.Session;
68
import org.netbeans.api.debugger.Watch;
70
import org.netbeans.api.debugger.Watch;
69
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint;
71
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint;
70
import org.netbeans.api.debugger.jpda.FieldBreakpoint;
72
import org.netbeans.api.debugger.jpda.FieldBreakpoint;
71
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
73
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
74
import org.netbeans.api.debugger.jpda.JPDADebugger;
72
import org.netbeans.api.debugger.jpda.LineBreakpoint;
75
import org.netbeans.api.debugger.jpda.LineBreakpoint;
73
import org.netbeans.api.debugger.jpda.MethodBreakpoint;
76
import org.netbeans.api.debugger.jpda.MethodBreakpoint;
77
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
74
import org.netbeans.spi.debugger.jpda.EditorContext;
78
import org.netbeans.spi.debugger.jpda.EditorContext;
75
79
76
import org.openide.cookies.LineCookie;
80
import org.openide.cookies.LineCookie;
Lines 94-107 Link Here
94
 * @author Jan Jancura, Martin Entlicher
98
 * @author Jan Jancura, Martin Entlicher
95
 */
99
 */
96
@org.openide.util.lookup.ServiceProvider(service=org.openide.text.AnnotationProvider.class)
100
@org.openide.util.lookup.ServiceProvider(service=org.openide.text.AnnotationProvider.class)
97
public class BreakpointAnnotationProvider implements AnnotationProvider,
101
@DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
98
                                                     DebuggerManagerListener {
102
public class BreakpointAnnotationProvider extends DebuggerManagerAdapter
103
                                          implements AnnotationProvider/*,
104
                                                     DebuggerManagerListener*/ {
99
105
100
    private final Map<JPDABreakpoint, Set<Annotation>> breakpointToAnnotations =
106
    private final Map<JPDABreakpoint, Set<Annotation>> breakpointToAnnotations =
101
            new IdentityHashMap<JPDABreakpoint, Set<Annotation>>();
107
            new IdentityHashMap<JPDABreakpoint, Set<Annotation>>();
102
    private final Set<FileObject> annotatedFiles = new WeakSet<FileObject>();
108
    private final Set<FileObject> annotatedFiles = new WeakSet<FileObject>();
103
    private Set<PropertyChangeListener> dataObjectListeners;
109
    private Set<PropertyChangeListener> dataObjectListeners;
104
    private boolean attachManagerListener = true;
110
    private boolean attachManagerListener = true;
111
    private volatile JPDADebugger currentDebugger = null;
112
    private volatile boolean breakpointsActive = true;
105
    private RequestProcessor annotationProcessor = new RequestProcessor("Annotation Refresh", 1);
113
    private RequestProcessor annotationProcessor = new RequestProcessor("Annotation Refresh", 1);
106
    private RequestProcessor contextWaitingProcessor = new RequestProcessor("Annotation Refresh Context Waiting", 1);
114
    private RequestProcessor contextWaitingProcessor = new RequestProcessor("Annotation Refresh Context Waiting", 1);
107
115
Lines 168-173 Link Here
168
        }
176
        }
169
        if (attachManagerListener) {
177
        if (attachManagerListener) {
170
            attachManagerListener = false;
178
            attachManagerListener = false;
179
            setCurrentDebugger(DebuggerManager.getDebuggerManager().getCurrentEngine());
171
            DebuggerManager.getDebuggerManager().addDebuggerListener(
180
            DebuggerManager.getDebuggerManager().addDebuggerListener(
172
                    WeakListeners.create(DebuggerManagerListener.class,
181
                    WeakListeners.create(DebuggerManagerListener.class,
173
                                         this,
182
                                         this,
Lines 176-181 Link Here
176
    }
185
    }
177
186
178
    @Override
187
    @Override
188
    public String[] getProperties() {
189
        return new String[] { DebuggerManager.PROP_BREAKPOINTS, DebuggerManager.PROP_DEBUGGER_ENGINES }; 
190
    }
191
192
    @Override
179
    public void breakpointAdded(Breakpoint breakpoint) {
193
    public void breakpointAdded(Breakpoint breakpoint) {
180
        if (isAnnotatable(breakpoint)) {
194
        if (isAnnotatable(breakpoint)) {
181
            JPDABreakpoint b = (JPDABreakpoint) breakpoint;
195
            JPDABreakpoint b = (JPDABreakpoint) breakpoint;
Lines 207-212 Link Here
207
        if (propertyName == null) {
221
        if (propertyName == null) {
208
            return;
222
            return;
209
        }
223
        }
224
        if (DebuggerManager.PROP_CURRENT_ENGINE.equals(propertyName)) {
225
            setCurrentDebugger(DebuggerManager.getDebuggerManager().getCurrentEngine());
226
        }
227
        if (JPDADebugger.PROP_BREAKPOINTS_ACTIVE.equals(propertyName)) {
228
            JPDADebugger debugger = currentDebugger;
229
            if (debugger != null) {
230
                setBreakpointsActive(debugger.getBreakpointsActive());
231
            }
232
        }
210
        if ( (!JPDABreakpoint.PROP_ENABLED.equals (propertyName)) &&
233
        if ( (!JPDABreakpoint.PROP_ENABLED.equals (propertyName)) &&
211
             (!JPDABreakpoint.PROP_VALIDITY.equals (propertyName)) &&
234
             (!JPDABreakpoint.PROP_VALIDITY.equals (propertyName)) &&
212
             (!LineBreakpoint.PROP_CONDITION.equals (propertyName)) &&
235
             (!LineBreakpoint.PROP_CONDITION.equals (propertyName)) &&
Lines 238-243 Link Here
238
        annotationProcessor.post(new AnnotationRefresh(b, true, true));
261
        annotationProcessor.post(new AnnotationRefresh(b, true, true));
239
    }
262
    }
240
    
263
    
264
    private void setCurrentDebugger(DebuggerEngine engine) {
265
        JPDADebugger oldDebugger = currentDebugger;
266
        if (oldDebugger != null) {
267
            oldDebugger.removePropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, this);
268
        }
269
        boolean active = true;
270
        JPDADebugger debugger = null;
271
        if (engine != null) {
272
            debugger = engine.lookupFirst(null, JPDADebugger.class);
273
            if (debugger != null) {
274
                debugger.addPropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, this);
275
                active = debugger.getBreakpointsActive();
276
            }
277
        }
278
        currentDebugger = debugger;
279
        setBreakpointsActive(active);
280
    }
281
    
282
    private void setBreakpointsActive(boolean active) {
283
        if (breakpointsActive == active) {
284
            return ;
285
        }
286
        breakpointsActive = active;
287
        annotationProcessor.post(new AnnotationRefresh(null, true, true));
288
    }
289
    
241
    private final class AnnotationRefresh implements Runnable {
290
    private final class AnnotationRefresh implements Runnable {
242
        
291
        
243
        private JPDABreakpoint b;
292
        private JPDABreakpoint b;
Lines 252-268 Link Here
252
        @Override
301
        @Override
253
        public void run() {
302
        public void run() {
254
            synchronized (breakpointToAnnotations) {
303
            synchronized (breakpointToAnnotations) {
255
                if (remove) {
304
                if (b != null) {
256
                    removeAnnotations(b);
305
                    refreshAnnotation(b);
257
                    if (!add) {
306
                } else {
258
                        breakpointToAnnotations.remove(b);
307
                    List<JPDABreakpoint> bpts = new ArrayList<JPDABreakpoint>(breakpointToAnnotations.keySet());
308
                    for (JPDABreakpoint bp : bpts) {
309
                        refreshAnnotation(bp);
259
                    }
310
                    }
260
                }
311
                }
261
                if (add) {
312
            }
262
                    breakpointToAnnotations.put(b, new WeakSet<Annotation>());
313
        }
263
                    for (FileObject fo : annotatedFiles) {
314
        
264
                        addAnnotationTo(b, fo);
315
        private void refreshAnnotation(JPDABreakpoint b) {
265
                    }
316
            if (remove) {
317
                removeAnnotations(b);
318
                if (!add) {
319
                    breakpointToAnnotations.remove(b);
320
                }
321
            }
322
            if (add) {
323
                breakpointToAnnotations.put(b, new WeakSet<Annotation>());
324
                for (FileObject fo : annotatedFiles) {
325
                    addAnnotationTo(b, fo);
266
                }
326
                }
267
            }
327
            }
268
        }
328
        }
Lines 277-283 Link Here
277
               !((JPDABreakpoint) b).isHidden();
337
               !((JPDABreakpoint) b).isHidden();
278
    }
338
    }
279
    
339
    
280
    private static String getAnnotationType(JPDABreakpoint b, boolean isConditional) {
340
    private static String getAnnotationType(JPDABreakpoint b, boolean isConditional,
341
                                            boolean active) {
281
        boolean isInvalid = b.getValidity() == VALIDITY.INVALID;
342
        boolean isInvalid = b.getValidity() == VALIDITY.INVALID;
282
        String annotationType;
343
        String annotationType;
283
        if (b instanceof LineBreakpoint) {
344
        if (b instanceof LineBreakpoint) {
Lines 301-308 Link Here
301
        } else {
362
        } else {
302
            throw new IllegalStateException(b.toString());
363
            throw new IllegalStateException(b.toString());
303
        }
364
        }
304
        if (isInvalid && b.isEnabled ()) {
365
        if (!active) {
305
            annotationType += "_broken";
366
            annotationType = annotationType + "_stroke";    // NOI18N
367
        } else if (isInvalid && b.isEnabled ()) {
368
            annotationType += "_broken";                    // NOI18N
306
        }
369
        }
307
        return annotationType;
370
        return annotationType;
308
    }
371
    }
Lines 481-487 Link Here
481
            throw new IllegalStateException(b.toString());
544
            throw new IllegalStateException(b.toString());
482
        }
545
        }
483
        boolean isConditional = (condition != null) && condition.trim().length() > 0;
546
        boolean isConditional = (condition != null) && condition.trim().length() > 0;
484
        String annotationType = getAnnotationType(b, isConditional);
547
        String annotationType = getAnnotationType(b, isConditional, breakpointsActive);
485
        DataObject dataObject;
548
        DataObject dataObject;
486
        try {
549
        try {
487
            dataObject = DataObject.find(fo);
550
            dataObject = DataObject.find(fo);
Lines 526-532 Link Here
526
        }
589
        }
527
    }
590
    }
528
    
591
    
529
592
    /*
530
    // Not used
593
    // Not used
531
    @Override
594
    @Override
532
    public Breakpoint[] initBreakpoints() { return new Breakpoint[] {}; }
595
    public Breakpoint[] initBreakpoints() { return new Breakpoint[] {}; }
Lines 558-562 Link Here
558
    // Not used
621
    // Not used
559
    @Override
622
    @Override
560
    public void engineRemoved(DebuggerEngine engine) {}
623
    public void engineRemoved(DebuggerEngine engine) {}
561
624
    */
562
}
625
}
(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/Bundle.properties (+1 lines)
Lines 65-70 Link Here
65
TOOLTIP_DISABLED_METHOD_BREAKPOINT=Disabled Method Breakpoint
65
TOOLTIP_DISABLED_METHOD_BREAKPOINT=Disabled Method Breakpoint
66
TOOLTIP_CLASS_BREAKPOINT=Class Breakpoint
66
TOOLTIP_CLASS_BREAKPOINT=Class Breakpoint
67
TOOLTIP_DISABLED_CLASS_BREAKPOINT=Disabled Class Breakpoint
67
TOOLTIP_DISABLED_CLASS_BREAKPOINT=Disabled Class Breakpoint
68
TOOLTIP_BREAKPOINT_STROKE=Deactivated breakpoint
68
69
69
#SourcesNodeModel
70
#SourcesNodeModel
70
CTL_SourcesModel_Column_Name_LibrarySources = {0}
71
CTL_SourcesModel_Column_Name_LibrarySources = {0}
(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/DebuggerBreakpointAnnotation.java (+4 lines)
Lines 92-97 Link Here
92
            return NbBundle.getMessage 
92
            return NbBundle.getMessage 
93
                (DebuggerBreakpointAnnotation.class, "TOOLTIP_BREAKPOINT_BROKEN"); // NOI18N
93
                (DebuggerBreakpointAnnotation.class, "TOOLTIP_BREAKPOINT_BROKEN"); // NOI18N
94
        }
94
        }
95
        if (type.endsWith("_stroke")) {
96
            return NbBundle.getMessage(DebuggerBreakpointAnnotation.class,
97
                                       "TOOLTIP_BREAKPOINT_STROKE");
98
        }
95
        if (type == EditorContext.BREAKPOINT_ANNOTATION_TYPE) {
99
        if (type == EditorContext.BREAKPOINT_ANNOTATION_TYPE) {
96
            return NbBundle.getMessage 
100
            return NbBundle.getMessage 
97
                (DebuggerBreakpointAnnotation.class, "TOOLTIP_BREAKPOINT"); // NOI18N
101
                (DebuggerBreakpointAnnotation.class, "TOOLTIP_BREAKPOINT"); // NOI18N
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/Bundle.properties (-1 / +7 lines)
Lines 45-51 Link Here
45
#Annotations
45
#Annotations
46
HINT_FIELD_BREAKPOINT=Field Breakpoint
46
HINT_FIELD_BREAKPOINT=Field Breakpoint
47
HINT_DISABLED_FIELD_BREAKPOINT=Disabled Field Breakpoint
47
HINT_DISABLED_FIELD_BREAKPOINT=Disabled Field Breakpoint
48
HINT_FIELD_BREAKPOINT_STROKE=Deactivated Field Breakpoint
49
HINT_DISABLED_FIELD_BREAKPOINT_STROKE=Deactivated Disabled Field Breakpoint
48
HINT_METHOD_BREAKPOINT=Method Breakpoint
50
HINT_METHOD_BREAKPOINT=Method Breakpoint
49
HINT_DISABLED_METHOD_BREAKPOINT=Disabled Method Breakpoint
51
HINT_DISABLED_METHOD_BREAKPOINT=Disabled Method Breakpoint
52
HINT_METHOD_BREAKPOINT_STROKE=Deactivated Method Breakpoint
53
HINT_DISABLED_METHOD_BREAKPOINT_STROKE=Deactivated Disabled Method Breakpoint
50
HINT_CLASS_BREAKPOINT=Class Breakpoint
54
HINT_CLASS_BREAKPOINT=Class Breakpoint
51
HINT_DISABLED_CLASS_BREAKPOINT=Disabled Class Breakpoint
55
HINT_DISABLED_CLASS_BREAKPOINT=Disabled Class Breakpoint
56
HINT_CLASS_BREAKPOINT_STROKE=Deactivated Class Breakpoint
57
HINT_DISABLED_CLASS_BREAKPOINT_STROKE=Deactivated Disabled Class Breakpoint
(-)55edf326bb27 (+59 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd">
48
<type
49
    name='ClassBreakpoint_stroke'
50
    description_key='HINT_CLASS_BREAKPOINT_STROKE'
51
    localizing_bundle='org.netbeans.modules.debugger.jpda.resources.Bundle'
52
    visible='true'
53
    glyph='nbresloc:/org/netbeans/modules/debugger/resources/editor/Breakpoint_nonline_stroke.png'
54
    type='line'
55
    actions='BreakpointActions'
56
    severity='ok'
57
    priority='100'
58
    custom_sidebar_color='0xFF8FD5'
59
/>
(-)55edf326bb27 (+59 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd">
48
<type
49
    name='DisabledClassBreakpoint_stroke'
50
    description_key='HINT_DISABLED_CLASS_BREAKPOINT_STROKE'
51
    localizing_bundle='org.netbeans.modules.debugger.jpda.resources.Bundle'
52
    visible='true'
53
    glyph='nbresloc:/org/netbeans/modules/debugger/resources/editor/DisabledBreakpoint_nonline_stroke.png'
54
    type='line'
55
    actions='BreakpointActions'
56
    severity='ok'
57
    priority='100'
58
    custom_sidebar_color='0xFF8FD5'
59
/>
(-)55edf326bb27 (+59 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd">
48
<type
49
    name='DisabledFieldBreakpoint_stroke'
50
    description_key='HINT_DISABLED_FIELD_BREAKPOINT_STROKE'
51
    localizing_bundle='org.netbeans.modules.debugger.jpda.resources.Bundle'
52
    visible='true'
53
    glyph='nbresloc:/org/netbeans/modules/debugger/resources/editor/DisabledBreakpoint_nonline_stroke.png'
54
    type='line'
55
    actions='BreakpointActions'
56
    severity='ok'
57
    priority='100'
58
    custom_sidebar_color='0xFF8FD5'
59
/>
(-)55edf326bb27 (+59 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd">
48
<type
49
    name='DisabledMethodBreakpoint_stroke'
50
    description_key='HINT_DISABLED_METHOD_BREAKPOINT_STROKE'
51
    localizing_bundle='org.netbeans.modules.debugger.jpda.resources.Bundle'
52
    visible='true'
53
    glyph='nbresloc:/org/netbeans/modules/debugger/resources/editor/DisabledBreakpoint_nonline_stroke.png'
54
    type='line'
55
    actions='BreakpointActions'
56
    severity='ok'
57
    priority='100'
58
    custom_sidebar_color='0xFF8FD5'
59
/>
(-)55edf326bb27 (+59 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd">
48
<type
49
    name='FieldBreakpoint_stroke'
50
    description_key='HINT_FIELD_BREAKPOINT_STROKE'
51
    localizing_bundle='org.netbeans.modules.debugger.jpda.resources.Bundle'
52
    visible='true'
53
    glyph='nbresloc:/org/netbeans/modules/debugger/resources/editor/Breakpoint_nonline_stroke.png'
54
    type='line'
55
    actions='BreakpointActions'
56
    severity='ok'
57
    priority='100'
58
    custom_sidebar_color='0xFF8FD5'
59
/>
(-)55edf326bb27 (+59 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd">
48
<type
49
    name='MethodBreakpoint_stroke'
50
    description_key='HINT_METHOD_BREAKPOINT_STROKE'
51
    localizing_bundle='org.netbeans.modules.debugger.jpda.resources.Bundle'
52
    visible='true'
53
    glyph='nbresloc:/org/netbeans/modules/debugger/resources/editor/Breakpoint_nonline_stroke.png'
54
    type='line'
55
    actions='BreakpointActions'
56
    severity='ok'
57
    priority='100'
58
    custom_sidebar_color='0xFF8FD5'
59
/>
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml (+23 lines)
Lines 119-124 Link Here
119
            <file name="FieldBreakpoint.xml" url="FieldBreakpoint.xml"/>
119
            <file name="FieldBreakpoint.xml" url="FieldBreakpoint.xml"/>
120
            <file name="MethodBreakpoint.xml" url="MethodBreakpoint.xml"/>
120
            <file name="MethodBreakpoint.xml" url="MethodBreakpoint.xml"/>
121
            <file name="ClassBreakpoint.xml" url="ClassBreakpoint.xml"/>
121
            <file name="ClassBreakpoint.xml" url="ClassBreakpoint.xml"/>
122
            <file name="DisabledFieldBreakpoint_stroke.xml" url="DisabledFieldBreakpoint_stroke.xml"/>
123
            <file name="DisabledMethodBreakpoint_stroke.xml" url="DisabledMethodBreakpoint_stroke.xml"/>
124
            <file name="DisabledClassBreakpoint_stroke.xml" url="DisabledClassBreakpoint_stroke.xml"/>
125
            <file name="FieldBreakpoint_stroke.xml" url="FieldBreakpoint_stroke.xml"/>
126
            <file name="MethodBreakpoint_stroke.xml" url="MethodBreakpoint_stroke.xml"/>
127
            <file name="ClassBreakpoint_stroke.xml" url="ClassBreakpoint_stroke.xml"/>
122
            <folder name="OtherThreadActions">
128
            <folder name="OtherThreadActions">
123
                <file name="org-netbeans-modules-debugger-jpda-ui-actions-SetAsCurrentThreadGutterAction.instance">
129
                <file name="org-netbeans-modules-debugger-jpda-ui-actions-SetAsCurrentThreadGutterAction.instance">
124
                    <attr name="position" intvalue="100"/>
130
                    <attr name="position" intvalue="100"/>
Lines 291-296 Link Here
291
        </folder>
297
        </folder>
292
    </folder>
298
    </folder>
293
299
300
    <folder name="Debugger">
301
        <folder name="netbeans-JPDASession">
302
        <folder name="BreakpointsView">
303
            <folder name="Toolbar">
304
                <file name="org-netbeans-modules-debugger-jpda-ui-models-BreakpointModelActiveSessionFilter-createActivateBreakpointsActionButton.instance">
305
                    <!--attr name="serviceName" stringvalue="org.netbeans.modules.debugger.jpda.actions.ContinueActionProvider"/-->
306
                    <attr name="serviceClass" stringvalue="java.awt.Component"/>
307
                    <attr name="instanceOf" stringvalue="java.awt.Component"/>
308
                    <attr
309
                        methodvalue="org.netbeans.modules.debugger.jpda.ui.models.BreakpointModelActiveSessionFilter.createActivateBreakpointsActionButton" name="instanceCreate"/>
310
                    <attr intvalue="150" name="position"/>
311
                </file>
312
            </folder>
313
        </folder>
314
        </folder>
315
    </folder>    
316
    
294
    <folder name="Shortcuts">
317
    <folder name="Shortcuts">
295
        <file name="SO-9.shadow">
318
        <file name="SO-9.shadow">
296
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-jpda-ui-actions-DebuggingViewAction.instance"/>
319
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-jpda-ui-actions-DebuggingViewAction.instance"/>
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/BreakpointOutput.java (+4 lines)
Lines 144-149 Link Here
144
        if (breakpoint.getSuspend() != JPDABreakpoint.SUSPEND_NONE) {
144
        if (breakpoint.getSuspend() != JPDABreakpoint.SUSPEND_NONE) {
145
            getBreakpointsNodeModel ().setCurrentBreakpoint (breakpoint);
145
            getBreakpointsNodeModel ().setCurrentBreakpoint (breakpoint);
146
        }
146
        }
147
        System.err.println("BP variable = "+event.getVariable());
148
        if (event.getVariable() != null) {
149
            System.err.println("  value = "+event.getVariable().getValue());
150
        }
147
        String printText = breakpoint.getPrintText ();
151
        String printText = breakpoint.getPrintText ();
148
        substituteAndPrintText(printText, event);
152
        substituteAndPrintText(printText, event);
149
    }
153
    }
(-)55edf326bb27 (+245 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.debugger.jpda.ui.models;
43
44
import java.awt.Dimension;
45
import java.awt.Insets;
46
import java.awt.datatransfer.Transferable;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
49
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeListener;
51
import java.io.IOException;
52
import java.util.ArrayList;
53
import java.util.List;
54
import javax.swing.AbstractButton;
55
import javax.swing.ImageIcon;
56
import javax.swing.JToggleButton;
57
import javax.swing.border.EmptyBorder;
58
import org.netbeans.api.debugger.DebuggerEngine;
59
import org.netbeans.api.debugger.DebuggerManager;
60
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
61
import org.netbeans.api.debugger.jpda.JPDADebugger;
62
import org.netbeans.api.debugger.jpda.LineBreakpoint;
63
import org.netbeans.spi.debugger.ContextProvider;
64
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
65
import org.netbeans.spi.viewmodel.ExtendedNodeModel;
66
import org.netbeans.spi.viewmodel.ExtendedNodeModelFilter;
67
import org.netbeans.spi.viewmodel.ModelEvent;
68
import org.netbeans.spi.viewmodel.ModelListener;
69
import org.netbeans.spi.viewmodel.NodeModel;
70
import org.netbeans.spi.viewmodel.UnknownTypeException;
71
import org.openide.util.ImageUtilities;
72
import org.openide.util.NbBundle;
73
import org.openide.util.RequestProcessor;
74
import org.openide.util.WeakListeners;
75
import org.openide.util.datatransfer.PasteType;
76
77
/**
78
 *
79
 * @author Martin Entlicher
80
 */
81
@DebuggerServiceRegistration(path="netbeans-JPDASession/BreakpointsView", types=ExtendedNodeModelFilter.class)
82
public class BreakpointModelActiveSessionFilter implements ExtendedNodeModelFilter,
83
                                                           PropertyChangeListener {
84
    
85
    private static final String DEACTIVATED_LINE_BREAKPOINT =
86
        "org/netbeans/modules/debugger/resources/editor/Breakpoint_stroke.png";                 // NOI18N
87
    private static final String DEACTIVATED_DISABLED_LINE_BREAKPOINT =
88
        "org/netbeans/modules/debugger/resources/editor/DisabledBreakpoint_stroke.png";         // NOI18N
89
    private static final String DEACTIVATED_NONLINE_BREAKPOINT =
90
        "org/netbeans/modules/debugger/resources/editor/Breakpoint_nonline_stroke.png";         // NOI18N
91
    private static final String DEACTIVATED_DISABLED_NONLINE_BREAKPOINT =
92
        "org/netbeans/modules/debugger/resources/editor/DisabledBreakpoint_nonline_stroke.png"; // NOI18N
93
    
94
    private static final RequestProcessor RP = new RequestProcessor(BreakpointModelActiveSessionFilter.class.getName());
95
96
    private JPDADebugger debugger;
97
    private final List<ModelListener> listeners = new ArrayList<ModelListener>();
98
    
99
    public BreakpointModelActiveSessionFilter(ContextProvider contextProvider) {
100
        debugger = contextProvider.lookupFirst(null, JPDADebugger.class);
101
        debugger.addPropertyChangeListener(WeakListeners.propertyChange(this, debugger));
102
    }
103
104
    @Override
105
    public String getDisplayName(NodeModel original, Object node) throws UnknownTypeException {
106
        return original.getDisplayName(node);
107
    }
108
109
    @Override
110
    public String getShortDescription(NodeModel original, Object node) throws UnknownTypeException {
111
        return original.getShortDescription(node);
112
    }
113
114
    @Override
115
    public String getIconBaseWithExtension(ExtendedNodeModel original, Object node) throws UnknownTypeException {
116
        if (debugger.getBreakpointsActive()) {
117
            return original.getIconBaseWithExtension(node);
118
        } else {
119
            if (node instanceof LineBreakpoint) {
120
                LineBreakpoint breakpoint = (LineBreakpoint)node;
121
                if (!breakpoint.isEnabled()) {
122
                    return DEACTIVATED_DISABLED_LINE_BREAKPOINT;
123
                } else {
124
                    return DEACTIVATED_LINE_BREAKPOINT;
125
                }
126
            } else if (node instanceof JPDABreakpoint) {
127
                JPDABreakpoint breakpoint = (JPDABreakpoint) node;
128
                if (!breakpoint.isEnabled()) {
129
                    return DEACTIVATED_DISABLED_NONLINE_BREAKPOINT;
130
                } else {
131
                    return DEACTIVATED_NONLINE_BREAKPOINT;
132
                }
133
            }
134
            throw new UnknownTypeException(node);
135
        }
136
    }
137
138
    @Override
139
    public String getIconBase(NodeModel original, Object node) throws UnknownTypeException {
140
        throw new UnsupportedOperationException("Not supported, overriden by getIconBaseWithExtension().");
141
    }
142
143
    @Override
144
    public void setName(ExtendedNodeModel original, Object node, String name) throws UnknownTypeException {
145
        throw new UnsupportedOperationException("Not supported yet.");
146
    }
147
148
    @Override
149
    public boolean canRename(ExtendedNodeModel original, Object node) throws UnknownTypeException {
150
        return original.canRename(node);
151
    }
152
153
    @Override
154
    public boolean canCopy(ExtendedNodeModel original, Object node) throws UnknownTypeException {
155
        return original.canCopy(node);
156
    }
157
158
    @Override
159
    public boolean canCut(ExtendedNodeModel original, Object node) throws UnknownTypeException {
160
        return original.canCut(node);
161
    }
162
163
    @Override
164
    public Transferable clipboardCopy(ExtendedNodeModel original, Object node) throws IOException, UnknownTypeException {
165
        return original.clipboardCopy(node);
166
    }
167
168
    @Override
169
    public Transferable clipboardCut(ExtendedNodeModel original, Object node) throws IOException, UnknownTypeException {
170
        return original.clipboardCut(node);
171
    }
172
173
    @Override
174
    public PasteType[] getPasteTypes(ExtendedNodeModel original, Object node, Transferable t) throws UnknownTypeException {
175
        return original.getPasteTypes(node, t);
176
    }
177
178
    @Override
179
    public void propertyChange(PropertyChangeEvent evt) {
180
        String propertyName = evt.getPropertyName();
181
        if (JPDADebugger.PROP_BREAKPOINTS_ACTIVE.equals(propertyName)) {
182
            fireChangeEvent(new ModelEvent.NodeChanged(this, null, ModelEvent.NodeChanged.ICON_MASK));
183
        }
184
    }
185
    
186
    @Override
187
    public void addModelListener(ModelListener l) {
188
        synchronized (listeners) {
189
            listeners.add(l);
190
        }
191
    }
192
193
    @Override
194
    public void removeModelListener(ModelListener l) {
195
        synchronized (listeners) {
196
            listeners.remove(l);
197
        }
198
    }
199
    
200
    private void fireChangeEvent(ModelEvent me) {
201
        List<ModelListener> ls;
202
        synchronized (listeners) {
203
            ls = new ArrayList<ModelListener>(listeners);
204
        }
205
        for (ModelListener ml : ls) {
206
            ml.modelChanged(me);
207
        }
208
    }
209
    
210
    
211
    @NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints",
212
                        "CTL_ActivateAllBreakpoints=Activate all breakpoints"})
213
    public static AbstractButton createActivateBreakpointsActionButton() {
214
        ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false);
215
        final JToggleButton button = new JToggleButton(icon);
216
        // ensure small size, just for the icon
217
        Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
218
        button.setPreferredSize(size);
219
        button.setMargin(new Insets(1, 1, 1, 1));
220
        button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
221
        button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints());
222
        button.setFocusable(false);
223
        button.addActionListener(new ActionListener() {
224
            @Override
225
            public void actionPerformed(ActionEvent e) {
226
                DebuggerEngine engine = DebuggerManager.getDebuggerManager().getCurrentEngine();
227
                final JPDADebugger debugger = engine.lookupFirst(null, JPDADebugger.class);
228
                final boolean active = !button.isSelected();
229
                if (active) {
230
                    button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints());
231
                } else {
232
                    button.setToolTipText(Bundle.CTL_ActivateAllBreakpoints());
233
                }
234
                RP.post(new Runnable() {
235
                    @Override
236
                    public void run() {
237
                        debugger.setBreakpointsActive(active);
238
                    }
239
                });
240
            }
241
        });
242
        return button;
243
    }
244
245
}
(-)a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java (+17 lines)
Lines 206-211 Link Here
206
    private boolean                     doContinue = true; // Whether resume() will actually resume
206
    private boolean                     doContinue = true; // Whether resume() will actually resume
207
    private Boolean                     singleThreadStepResumeDecision = null;
207
    private Boolean                     singleThreadStepResumeDecision = null;
208
    private Boolean                     stepInterruptByBptResumeDecision = null;
208
    private Boolean                     stepInterruptByBptResumeDecision = null;
209
    private boolean                     breakpointsActive = true;
209
    
210
    
210
    private InputOutput                 io;
211
    private InputOutput                 io;
211
212
Lines 554-559 Link Here
554
        }
555
        }
555
    }
556
    }
556
557
558
    @Override
559
    public boolean getBreakpointsActive() {
560
        return breakpointsActive;
561
    }
562
563
    @Override
564
    public void setBreakpointsActive(boolean active) {
565
        synchronized (this) {
566
            if (breakpointsActive == active) {
567
                return ;
568
            }
569
            breakpointsActive = active;
570
        }
571
        firePropertyChange(PROP_BREAKPOINTS_ACTIVE, !active, active);
572
    }
573
    
557
    public Session getSession() {
574
    public Session getSession() {
558
        return lookupProvider.lookupFirst(null, Session.class);
575
        return lookupProvider.lookupFirst(null, Session.class);
559
    }
576
    }
(-)a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java (-2 / +4 lines)
Lines 143-148 Link Here
143
     */
143
     */
144
    final void set () {
144
    final void set () {
145
        breakpoint.addPropertyChangeListener (this);
145
        breakpoint.addPropertyChangeListener (this);
146
        debugger.addPropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, this);
146
        if (breakpoint instanceof PropertyChangeListener && isApplicable()) {
147
        if (breakpoint instanceof PropertyChangeListener && isApplicable()) {
147
            Session s = debugger.getSession();
148
            Session s = debugger.getSession();
148
            DebuggerEngine de = s.getEngineForLanguage ("Java");
149
            DebuggerEngine de = s.getEngineForLanguage ("Java");
Lines 169-175 Link Here
169
             (getDebugger ().getState () == JPDADebugger.STATE_DISCONNECTED)
170
             (getDebugger ().getState () == JPDADebugger.STATE_DISCONNECTED)
170
        ) return;
171
        ) return;
171
        removeAllEventRequests ();
172
        removeAllEventRequests ();
172
        if (breakpoint.isEnabled () && isEnabled()) {
173
        if (breakpoint.isEnabled () && isEnabled() && debugger.getBreakpointsActive()) {
173
            setRequests ();
174
            setRequests ();
174
        }
175
        }
175
    }
176
    }
Lines 196-202 Link Here
196
        } else if (!Breakpoint.PROP_VALIDITY.equals(propertyName) &&
197
        } else if (!Breakpoint.PROP_VALIDITY.equals(propertyName) &&
197
                   !Breakpoint.PROP_GROUP_NAME.equals(propertyName) &&
198
                   !Breakpoint.PROP_GROUP_NAME.equals(propertyName) &&
198
                   !Breakpoint.PROP_GROUP_PROPERTIES.equals(propertyName)) {
199
                   !Breakpoint.PROP_GROUP_PROPERTIES.equals(propertyName)) {
199
            if (reader != null) {
200
            if (reader != null && !JPDADebugger.PROP_BREAKPOINTS_ACTIVE.equals(propertyName)) {
200
                reader.storeCachedClassName(breakpoint, null);
201
                reader.storeCachedClassName(breakpoint, null);
201
            }
202
            }
202
            debugger.getRequestProcessor().post(new Runnable() {
203
            debugger.getRequestProcessor().post(new Runnable() {
Lines 224-229 Link Here
224
            removeAllEventRequests ();
225
            removeAllEventRequests ();
225
        }
226
        }
226
        breakpoint.removePropertyChangeListener(this);
227
        breakpoint.removePropertyChangeListener(this);
228
        debugger.removePropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, this);
227
        setValidity(Breakpoint.VALIDITY.UNKNOWN, null);
229
        setValidity(Breakpoint.VALIDITY.UNKNOWN, null);
228
        if (breakpoint instanceof PropertyChangeListener) {
230
        if (breakpoint instanceof PropertyChangeListener) {
229
            Session s = debugger.getSession();
231
            Session s = debugger.getSession();
(-)55edf326bb27 (+237 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 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
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.api.debugger.jpda;
46
47
import java.beans.PropertyChangeEvent;
48
import java.beans.PropertyChangeListener;
49
import junit.framework.Test;
50
import org.netbeans.api.debugger.DebuggerManager;
51
import org.netbeans.api.debugger.jpda.event.JPDABreakpointEvent;
52
import org.netbeans.api.debugger.jpda.event.JPDABreakpointListener;
53
import org.netbeans.junit.NbTestCase;
54
55
/**
56
 * Tests breakpoints deactivation.
57
 *
58
 */
59
public class BreakpointsDeactivationTest extends NbTestCase {
60
61
    private static final String TEST_APP_PATH = System.getProperty ("test.dir.src") + 
62
        "org/netbeans/api/debugger/jpda/testapps/LineBreakpointApp.java";
63
    
64
    private JPDASupport support;
65
    
66
    
67
    public BreakpointsDeactivationTest (String s) {
68
        super (s);
69
    }
70
71
    public static Test suite() {
72
        return JPDASupport.createTestSuite(BreakpointsDeactivationTest.class);
73
    }
74
    
75
    public void testBreakpointsDeactivation () throws Exception {
76
        try {
77
            Utils.BreakPositions bp = Utils.getBreakPositions(TEST_APP_PATH);
78
            LineBreakpoint[] lb = bp.getBreakpoints().toArray(new LineBreakpoint[0]);
79
            {
80
                LineBreakpoint b;
81
                b = lb[4];
82
                lb[4] = lb[2];
83
                lb[2] = b;
84
            }
85
            /*
86
            LineBreakpoint lb1 = LineBreakpoint.create (TEST_APP, 32);
87
            LineBreakpoint lb2 = LineBreakpoint.create (TEST_APP, 37);
88
            LineBreakpoint lb3 = LineBreakpoint.create (TEST_APP, 109);
89
            lb3.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$Inner");
90
            LineBreakpoint lb4 = LineBreakpoint.create (TEST_APP, 92);
91
            lb4.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$InnerStatic");
92
            LineBreakpoint lb5 = LineBreakpoint.create (TEST_APP, 41);
93
            */
94
            DebuggerManager dm = DebuggerManager.getDebuggerManager ();
95
            for (int i = 0; i < lb.length; i++) {
96
                dm.addBreakpoint (lb[i]);
97
            }
98
99
            TestBreakpointListener[] tb = new TestBreakpointListener[lb.length];
100
            for (int i = 0; i < lb.length; i++) {
101
                tb[i] = new TestBreakpointListener (lb[i]);
102
                lb[i].addJPDABreakpointListener (tb[i]);
103
            }
104
            support = JPDASupport.attach (
105
                "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
106
            );
107
            JPDADebugger debugger = support.getDebugger();
108
            assertEquals("Breakpoints should be active initially.", true, debugger.getBreakpointsActive());
109
            
110
            support.waitState (JPDADebugger.STATE_STOPPED);  // stopped on the first breakpoint
111
            
112
            final PropertyChangeEvent[] propertyPtr = new PropertyChangeEvent[] { null };
113
            debugger.addPropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, new PropertyChangeListener() {
114
                @Override
115
                public void propertyChange(PropertyChangeEvent evt) {
116
                    propertyPtr[0] = evt;
117
                }
118
            });
119
            debugger.setBreakpointsActive(false);
120
            assertNotNull(propertyPtr[0]);
121
            assertEquals(propertyPtr[0].getSource(), debugger);
122
            assertEquals(propertyPtr[0].getOldValue(), Boolean.TRUE);
123
            assertEquals(propertyPtr[0].getNewValue(), Boolean.FALSE);
124
            assertEquals("Breakpoints should be inactive after deactivation.", false, debugger.getBreakpointsActive());
125
            
126
            int j = 0;
127
            assertEquals (
128
                "Debugger stopped at wrong line for breakpoint " + j, 
129
                lb[j].getLineNumber (), 
130
                debugger.getCurrentCallStackFrame ().getLineNumber (null)
131
            );
132
            for (int i = j+1; i < tb.length; i++) {
133
                tb[i].checkNotNotified();
134
            }
135
            if (j < lb.length - 1) {
136
                support.doContinue();
137
            }
138
            
139
            for (int i = 0; i < tb.length; i++) {
140
                dm.removeBreakpoint (lb[i]);
141
            }
142
            support.waitState (JPDADebugger.STATE_DISCONNECTED);
143
        } finally {
144
            if (support != null) {
145
                support.doFinish ();
146
            }
147
        }
148
    }
149
150
    // innerclasses ............................................................
151
    
152
    private class TestBreakpointListener implements JPDABreakpointListener {
153
154
        private LineBreakpoint  lineBreakpoint;
155
        private int             conditionResult;
156
157
        private JPDABreakpointEvent event;
158
        private AssertionError      failure;
159
160
        public TestBreakpointListener (LineBreakpoint lineBreakpoint) {
161
            this (lineBreakpoint, JPDABreakpointEvent.CONDITION_NONE);
162
        }
163
164
        public TestBreakpointListener (
165
            LineBreakpoint lineBreakpoint, 
166
            int conditionResult
167
        ) {
168
            this.lineBreakpoint = lineBreakpoint;
169
            this.conditionResult = conditionResult;
170
        }
171
172
        @Override
173
        public void breakpointReached (JPDABreakpointEvent event) {
174
            try {
175
                checkEvent (event);
176
            } catch (AssertionError e) {
177
                failure = e;
178
            } catch (Throwable e) {
179
                failure = new AssertionError (e);
180
            }
181
        }
182
183
        private void checkEvent (JPDABreakpointEvent event) {
184
            this.event = event;
185
            assertEquals (
186
                "Breakpoint event: Wrong source breakpoint", 
187
                lineBreakpoint, 
188
                event.getSource ()
189
            );
190
            assertNotNull (
191
                "Breakpoint event: Context thread is null", 
192
                event.getThread ()
193
            );
194
195
            int result = event.getConditionResult ();
196
            if ( result == JPDABreakpointEvent.CONDITION_FAILED && 
197
                 conditionResult != JPDABreakpointEvent.CONDITION_FAILED
198
            ) {
199
                failure = new AssertionError (event.getConditionException ());
200
            } else 
201
            if (result != conditionResult) {
202
                failure = new AssertionError (
203
                    "Unexpected breakpoint condition result: " + result
204
                );
205
            }
206
        }
207
208
        public void checkResult () {
209
            if (event == null) {
210
                CallStackFrame f = support.getDebugger ().
211
                    getCurrentCallStackFrame ();
212
                int ln = -1;
213
                if (f != null) {
214
                    ln = f.getLineNumber (null);
215
                }
216
                throw new AssertionError (
217
                    "Breakpoint was not hit (listener was not notified) " + ln
218
                );
219
            }
220
            if (failure != null) {
221
                throw failure;
222
            }
223
        }
224
        
225
        public void checkNotNotified() {
226
            if (event != null) {
227
                JPDAThread t = event.getThread();
228
                throw new AssertionError (
229
                    "Breakpoint was hit (listener was notified) in thread " + t
230
                );
231
            }
232
            if (failure != null) {
233
                throw failure;
234
            }
235
        }
236
    }
237
}

Return to bug 79027