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

(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/Bundle.properties (+5 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_HITCOUNT=Hit count: {0} {1}
69
TOOLTIP_CONDITION=Condition: {0}
70
TOOLTIP_HITCOUNTSTYLE_EQUAL=\=
71
TOOLTIP_HITCOUNTSTYLE_GREATER=>
72
TOOLTIP_HITCOUNTSTYLE_MULTIPLE=multiple of
68
73
69
#SourcesNodeModel
74
#SourcesNodeModel
70
CTL_SourcesModel_Column_Name_LibrarySources = {0}
75
CTL_SourcesModel_Column_Name_LibrarySources = {0}
(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/DebuggerBreakpointAnnotation.java (+73 lines)
Lines 44-51 Link Here
44
44
45
package org.netbeans.modules.debugger.jpda.projects;
45
package org.netbeans.modules.debugger.jpda.projects;
46
46
47
import java.util.ArrayList;
48
import java.util.List;
47
import org.netbeans.api.debugger.Breakpoint;
49
import org.netbeans.api.debugger.Breakpoint;
50
import org.netbeans.api.debugger.Breakpoint.HIT_COUNT_FILTERING_STYLE;
51
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint;
52
import org.netbeans.api.debugger.jpda.FieldBreakpoint;
48
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
53
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
54
import org.netbeans.api.debugger.jpda.LineBreakpoint;
55
import org.netbeans.api.debugger.jpda.MethodBreakpoint;
49
import org.netbeans.spi.debugger.jpda.EditorContext;
56
import org.netbeans.spi.debugger.jpda.EditorContext;
50
import org.netbeans.spi.debugger.ui.BreakpointAnnotation;
57
import org.netbeans.spi.debugger.ui.BreakpointAnnotation;
51
58
Lines 81-87 Link Here
81
        return line;
88
        return line;
82
    }
89
    }
83
    
90
    
91
    /**
92
     * Gets the condition of a breakpoint. 
93
     * @param b
94
     * @return empty {@link String} if no condition is supported. 
95
     */
96
    private String getCondition (Breakpoint b) {
97
        // Copied from org.netbeans.modules.debugger.jpda.projects.BreakpointAnnotationProvider#addAnnotationTo
98
        String condition = "";
99
        if (b instanceof LineBreakpoint) {
100
            condition = ((LineBreakpoint) b).getCondition();
101
        } else if (b instanceof FieldBreakpoint) {
102
            condition = ((FieldBreakpoint) b).getCondition();
103
        } else if (b instanceof MethodBreakpoint) {
104
            condition = ((MethodBreakpoint) b).getCondition();
105
        }
106
        return condition;
107
    }
108
109
    @Override
84
    public String getShortDescription () {
110
    public String getShortDescription () {
111
112
        List<String> list = new ArrayList<String>();
113
        //add condition if available
114
        String condition = getCondition(breakpoint);
115
        if (!condition.trim().isEmpty()) {
116
            String tooltip=NbBundle.getMessage(DebuggerBreakpointAnnotation.class, "TOOLTIP_CONDITION", condition);
117
            list.add(tooltip);
118
        }
119
120
        // add hit count if available
121
        HIT_COUNT_FILTERING_STYLE hitCountFilteringStyle = breakpoint.getHitCountFilteringStyle();
122
        if (null != hitCountFilteringStyle) {
123
            String op = "";
124
            switch (hitCountFilteringStyle) {
125
                case EQUAL:
126
                    op = NbBundle.getMessage(DebuggerBreakpointAnnotation.class, "TOOLTIP_HITCOUNTSTYLE_EQUAL");
127
                    break;
128
                case GREATER:
129
                    op = NbBundle.getMessage(DebuggerBreakpointAnnotation.class, "TOOLTIP_HITCOUNTSTYLE_GREATER");
130
                    break;
131
                case MULTIPLE:
132
                    op = NbBundle.getMessage(DebuggerBreakpointAnnotation.class, "TOOLTIP_HITCOUNTSTYLE_MULTIPLE");
133
                    break;
134
            }
135
            String tooltip=NbBundle.getMessage(DebuggerBreakpointAnnotation.class, "TOOLTIP_HITCOUNT", op, breakpoint.getHitCountFilter());
136
            list.add(tooltip);
137
        }
138
139
140
        String shortDesc = getShortDescriptionIntern();
141
        StringBuilder result = new StringBuilder();
142
        if (null!=shortDesc){
143
            result.append(shortDesc);
144
        }
145
        //append more information if available
146
        if (!list.isEmpty()){
147
            result.append("\n");
148
            for (String text : list) {
149
                result.append("\n");
150
                result.append(text);
151
            }
152
        }
153
154
        return result.toString();
155
    }
156
    
157
    private String getShortDescriptionIntern () {
85
        if (type.endsWith("_broken")) {
158
        if (type.endsWith("_broken")) {
86
            if (breakpoint.getValidity() == Breakpoint.VALIDITY.INVALID) {
159
            if (breakpoint.getValidity() == Breakpoint.VALIDITY.INVALID) {
87
                String msg = breakpoint.getValidityMessage();
160
                String msg = breakpoint.getValidityMessage();
(-)500ab731bbdc (+211 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 Oracle
41
 * Portions Copyrighted 2012 markiewb@netbeans.org
42
 */
43
package org.netbeans.modules.debugger.jpda.projects;
44
45
import org.junit.After;
46
import org.junit.AfterClass;
47
import org.junit.BeforeClass;
48
import org.junit.Test;
49
import static org.junit.Assert.*;
50
import org.junit.Before;
51
import org.netbeans.api.debugger.Breakpoint;
52
import org.netbeans.api.debugger.jpda.FieldBreakpoint;
53
import org.netbeans.api.debugger.jpda.LineBreakpoint;
54
import org.netbeans.api.debugger.jpda.MethodBreakpoint;
55
import org.netbeans.spi.debugger.jpda.EditorContext;
56
import org.openide.text.Line;
57
import org.openide.util.Lookup;
58
59
/**
60
 *
61
 * @author markiewb@netbeans.org
62
 */
63
public class DebuggerBreakpointAnnotationTest {
64
65
    private LineBreakpoint breakpoint;
66
67
    @Before
68
    public void setUp () {
69
        //FIXME next line will throw nasty java.net.MalformedURLException in the log
70
        breakpoint = LineBreakpoint.create("java.util.ArrayList", 2);
71
    }
72
73
    @Test
74
    public void testGetShortDescription_Condition_None () {
75
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
76
        assertEquals("Conditional Breakpoint", sut.getShortDescription());
77
    }
78
79
    @Test
80
    public void testGetShortDescription_Condition_HitCount_Equal () {
81
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
82
        breakpoint.setHitCountFilter(42, Breakpoint.HIT_COUNT_FILTERING_STYLE.EQUAL);
83
84
        assertEquals("Conditional Breakpoint\n\nHit count: = 42", sut.getShortDescription());
85
    }
86
87
    @Test
88
    public void testGetShortDescription_Condition_HitCount_Greater () {
89
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
90
        breakpoint.setHitCountFilter(42, Breakpoint.HIT_COUNT_FILTERING_STYLE.GREATER);
91
92
        assertEquals("Conditional Breakpoint\n\nHit count: > 42", sut.getShortDescription());
93
    }
94
95
    @Test
96
    public void testGetShortDescription_Condition_HitCount_MultipleOf () {
97
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
98
        breakpoint.setHitCountFilter(2, Breakpoint.HIT_COUNT_FILTERING_STYLE.MULTIPLE);
99
100
        assertEquals("Conditional Breakpoint\n\nHit count: multiple of 2", sut.getShortDescription());
101
    }
102
103
    @Test
104
    public void testGetShortDescription_Condition_Code_Null () {
105
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
106
        breakpoint.setCondition(null);
107
108
        assertEquals("Conditional Breakpoint", sut.getShortDescription());
109
    }
110
111
    @Test
112
    public void testGetShortDescription_Condition_Code_NotNull () {
113
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
114
        breakpoint.setCondition("a==6");
115
116
        assertEquals("Conditional Breakpoint\n\nCondition: a==6", sut.getShortDescription());
117
    }
118
119
    @Test
120
    public void testGetShortDescription_Condition_Multiple () {
121
        DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
122
        breakpoint.setCondition("a==6");
123
        breakpoint.setHitCountFilter(42, Breakpoint.HIT_COUNT_FILTERING_STYLE.EQUAL);
124
125
        assertEquals("Conditional Breakpoint\n\nCondition: a==6\nHit count: = 42", sut.getShortDescription());
126
    }
127
128
    /**
129
     * Test whether {@link FieldBreakpoint}, {@link MethodBreakpoint} and {@link
130
     * LineBreakpoint} are supported. Tests the {@link DebuggerBreakpointAnnotation#getCondition(org.netbeans.api.debugger.Breakpoint)} too.
131
     */
132
    @Test
133
    public void testGetShortDescription_Condition_SupportedBreakpointTypes () {
134
        {
135
            //FIXME next line will throw nasty java.net.MalformedURLExceptionin the log
136
            FieldBreakpoint b = FieldBreakpoint.create(
137
                    "org.netbeans.modules.editor.EditorPanel",
138
                    "state",
139
                    FieldBreakpoint.TYPE_MODIFICATION);
140
            DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), b);
141
            b.setCondition("a==6");
142
            assertEquals("Conditional Breakpoint\n\nCondition: a==6", sut.getShortDescription());
143
        }
144
        {
145
            //FIXME next line will throw nasty java.net.MalformedURLExceptionin the log
146
            MethodBreakpoint b = MethodBreakpoint.create(
147
                    "org.netbeans.modules.editor.EditorPanel",
148
                    "state");
149
            DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), b);
150
            b.setCondition("a==6");
151
152
            assertEquals("Conditional Breakpoint\n\nCondition: a==6", sut.getShortDescription());
153
154
        }
155
        {
156
            DebuggerBreakpointAnnotation sut = new DebuggerBreakpointAnnotation((EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE), new LineMock(), breakpoint);
157
            breakpoint.setCondition("a==6");
158
159
            assertEquals("Conditional Breakpoint\n\nCondition: a==6", sut.getShortDescription());
160
161
        }
162
163
    }
164
165
    private static class LineMock extends Line {
166
167
        public LineMock () {
168
            super(Lookup.EMPTY);
169
        }
170
171
        @Override
172
        public int getLineNumber () {
173
            throw new UnsupportedOperationException("Not supported yet.");
174
        }
175
176
        @Override
177
        public void show (int kind, int column) {
178
            throw new UnsupportedOperationException("Not supported yet.");
179
        }
180
181
        @Override
182
        public void setBreakpoint (boolean b) {
183
            throw new UnsupportedOperationException("Not supported yet.");
184
        }
185
186
        @Override
187
        public boolean isBreakpoint () {
188
            throw new UnsupportedOperationException("Not supported yet.");
189
        }
190
191
        @Override
192
        public void markError () {
193
            throw new UnsupportedOperationException("Not supported yet.");
194
        }
195
196
        @Override
197
        public void unmarkError () {
198
            throw new UnsupportedOperationException("Not supported yet.");
199
        }
200
201
        @Override
202
        public void markCurrentLine () {
203
            throw new UnsupportedOperationException("Not supported yet.");
204
        }
205
206
        @Override
207
        public void unmarkCurrentLine () {
208
            throw new UnsupportedOperationException("Not supported yet.");
209
        }
210
    }
211
}

Return to bug 109831