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

(-)a/api.debugger.jpda/nbproject/project.xml (-1 / +1 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.16</specification-version>
58
                        <specification-version>1.34</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
(-)a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/JPDABreakpoint.java (+5 lines)
Lines 251-256 Link Here
251
    synchronized JPDADebugger getSession() {
251
    synchronized JPDADebugger getSession() {
252
        return session;
252
        return session;
253
    }
253
    }
254
255
    @Override
256
    public boolean canHaveDependentBreakpoints() {
257
        return true;
258
    }
254
    
259
    
255
    /** 
260
    /** 
256
     * Adds a JPDABreakpointListener.
261
     * Adds a JPDABreakpointListener.
(-)a/api.debugger/apichanges.xml (+25 lines)
Lines 463-468 Link Here
463
        <issue number="191394"/>
463
        <issue number="191394"/>
464
    </change>
464
    </change>
465
465
466
    <change id="DependentBreakpoints">
467
        <api name="DebuggerCoreAPI"/>
468
        <summary>Added a possibility to enable/disable other breakpoints when one is hit.</summary>
469
        <version major="1" minor="34"/>
470
        <date day="19" month="12" year="2011"/>
471
        <author login="mentlicher"/>
472
        <compatibility addition="yes" source="compatible" binary="compatible"/>
473
        <description>
474
            Four methods are added to the Breakpoint class, that allow to
475
            get or set a set of breakpoints, that are enabled or disabled when
476
            the breakpoint is hit. One test method is provided, which determines
477
            if the dependent breakpoints are supported by the implementation.
478
            <p>
479
                Added methods:<br/>
480
                <code>Breakpoint.canHaveDependentBreakpoints()</code>,
481
                <code>Breakpoint.getBreakpointsToEnable()</code>,
482
                <code>Breakpoint.setBreakpointsToEnable()</code>,
483
                <code>Breakpoint.getBreakpointsToDisable()</code>,
484
                <code>Breakpoint.setBreakpointsToDisable()</code>.
485
            </p>
486
        </description>
487
        <class package="org.netbeans.api.debugger" name="Breakpoint" />
488
        <issue number="197707"/>
489
    </change>
490
466
</changes>
491
</changes>
467
492
468
  <!-- Now the surrounding HTML text and document structure: -->
493
  <!-- Now the surrounding HTML text and document structure: -->
(-)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.33
4
OpenIDE-Module-Specification-Version: 1.34
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 (+9 lines)
Lines 50-55 Link Here
50
            <code-name-base>org.netbeans.api.debugger</code-name-base>
50
            <code-name-base>org.netbeans.api.debugger</code-name-base>
51
            <module-dependencies>
51
            <module-dependencies>
52
                <dependency>
52
                <dependency>
53
                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
58
                        <specification-version>1.11</specification-version>
59
                    </run-dependency>
60
                </dependency>
61
                <dependency>
53
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
62
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
54
                    <build-prerequisite/>
63
                    <build-prerequisite/>
55
                    <compile-dependency/>
64
                    <compile-dependency/>
(-)a/api.debugger/src/org/netbeans/api/debugger/Breakpoint.java (+92 lines)
Lines 46-51 Link Here
46
46
47
import java.beans.PropertyChangeListener;
47
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeSupport;
48
import java.beans.PropertyChangeSupport;
49
import java.util.Collections;
50
import java.util.Set;
51
import org.netbeans.api.annotations.common.NonNull;
49
import org.netbeans.api.project.Project;
52
import org.netbeans.api.project.Project;
50
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
51
54
Lines 86-91 Link Here
86
    private String                      validityMessage;
89
    private String                      validityMessage;
87
    private int                         hitCountFilter;
90
    private int                         hitCountFilter;
88
    private HIT_COUNT_FILTERING_STYLE   hitCountFilteringStyle;
91
    private HIT_COUNT_FILTERING_STYLE   hitCountFilteringStyle;
92
    private volatile Set<Breakpoint>    breakpointsToEnable = Collections.EMPTY_SET;
93
    private volatile Set<Breakpoint>    breakpointsToDisable = Collections.EMPTY_SET;
89
    
94
    
90
    { pcs = new PropertyChangeSupport (this); }
95
    { pcs = new PropertyChangeSupport (this); }
91
96
Lines 230-235 Link Here
230
        return null;
235
        return null;
231
    }
236
    }
232
    
237
    
238
    /**
239
     * Determines if the breakpoint supports dependent breakpoints.
240
     * If true, get/setBreakpointsToEnable/Disable methods can be used to get
241
     * or set dependent breakpoints.
242
     * If false, the methods throw an UnsupportedOperationException.
243
     * @return <code>true</code> if the dependent breakpoints are supported,
244
     * <code>false</code> otherwise.
245
     * @since 1.34
246
     */
247
    public boolean canHaveDependentBreakpoints() {
248
        return false;
249
    }
250
    
251
    /**
252
     * Get the set of breakpoints that will be enabled after this breakpoint
253
     * is hit.
254
     * <p>
255
     * Not all breakpoint implementations honor dependent breakpoints.
256
     * Use {@link #canHaveDependentBreakpoints()} to determine if the operation is supported.
257
     * @return The set of breakpoints.
258
     * @throws UnsupportedOperationException if the breakpoint does not support
259
     * dependent breakpoints - see {@link #canHaveDependentBreakpoints()}.
260
     * @since 1.34
261
     */
262
    @NonNull
263
    public Set<Breakpoint> getBreakpointsToEnable() {
264
        if (!canHaveDependentBreakpoints()) {
265
            throw new UnsupportedOperationException("Cannot have dependent breakpoints."); // NOI18N
266
        }
267
        return breakpointsToEnable;
268
    }
269
    
270
    /**
271
     * Get the set of breakpoints that will be disabled after this breakpoint
272
     * is hit.
273
     * <p>
274
     * Not all breakpoint implementations honor dependent breakpoints.
275
     * Use {@link #canHaveDependentBreakpoints()} to determine if the operation is supported.
276
     * @throws UnsupportedOperationException if the breakpoint does not support
277
     * dependent breakpoints - see {@link #canHaveDependentBreakpoints()}.
278
     * @return The set of breakpoints.
279
     * @since 1.34
280
     */
281
    @NonNull
282
    public Set<Breakpoint> getBreakpointsToDisable() {
283
        if (!canHaveDependentBreakpoints()) {
284
            throw new UnsupportedOperationException("Cannot have dependent breakpoints."); // NOI18N
285
        }
286
        return breakpointsToDisable;
287
    }
288
    
289
    /**
290
     * Set the set of breakpoints that will be enabled after this breakpoint
291
     * is hit.
292
     * <p>
293
     * Not all breakpoint implementations honor dependent breakpoints.
294
     * Use {@link #canHaveDependentBreakpoints()} to determine if the operation is supported.
295
     * @param breakpointsToEnable The set of breakpoints.
296
     * @throws UnsupportedOperationException if the breakpoint does not support
297
     * dependent breakpoints - see {@link #canHaveDependentBreakpoints()}.
298
     * @since 1.34
299
     */
300
    public void setBreakpointsToEnable(@NonNull Set<Breakpoint> breakpointsToEnable) {
301
        if (!canHaveDependentBreakpoints()) {
302
            throw new UnsupportedOperationException("Cannot have dependent breakpoints."); // NOI18N
303
        }
304
        this.breakpointsToEnable = breakpointsToEnable;
305
    }
306
    
307
    /**
308
     * Set the set of breakpoints that will be disabled after this breakpoint
309
     * is hit.
310
     * <p>
311
     * Not all breakpoint implementations honor dependent breakpoints.
312
     * Use {@link #canHaveDependentBreakpoints()} to determine if the operation is supported.
313
     * @param breakpointsToEnable The set of breakpoints.
314
     * @throws UnsupportedOperationException if the breakpoint does not support
315
     * dependent breakpoints - see {@link #canHaveDependentBreakpoints()}.
316
     * @since 1.34
317
     */
318
    public void setBreakpointsToDisable(@NonNull Set<Breakpoint> breakpointsToDisable) {
319
        if (!canHaveDependentBreakpoints()) {
320
            throw new UnsupportedOperationException("Cannot have dependent breakpoints."); // NOI18N
321
        }
322
        this.breakpointsToDisable = breakpointsToDisable;
323
    }
324
    
233
    /** 
325
    /** 
234
     * Add a listener to property changes.
326
     * Add a listener to property changes.
235
     *
327
     *
(-)a/debugger.jpda.ui/nbproject/project.xml (+9 lines)
Lines 151-156 Link Here
151
                    </run-dependency>
151
                    </run-dependency>
152
                </dependency>
152
                </dependency>
153
                <dependency>
153
                <dependency>
154
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
155
                    <build-prerequisite/>
156
                    <compile-dependency/>
157
                    <run-dependency>
158
                        <release-version>1</release-version>
159
                        <specification-version>1.39</specification-version>
160
                    </run-dependency>
161
                </dependency>
162
                <dependency>
154
                    <code-name-base>org.netbeans.spi.debugger.ui</code-name-base>
163
                    <code-name-base>org.netbeans.spi.debugger.ui</code-name-base>
155
                    <build-prerequisite/>
164
                    <build-prerequisite/>
156
                    <compile-dependency/>
165
                    <compile-dependency/>
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/ActionsPanel.form (-37 / +112 lines)
Lines 29-51 Link Here
29
29
30
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
30
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
31
  <SubComponents>
31
  <SubComponents>
32
    <Component class="javax.swing.JTextField" name="tfPrintText">
33
      <Properties>
34
        <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
35
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="TTT_TF_Actions_Panel_Print_Text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
36
        </Property>
37
      </Properties>
38
      <AccessibilityProperties>
39
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
40
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSD_TF_Actions_Panel_Print_Text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
41
        </Property>
42
      </AccessibilityProperties>
43
      <Constraints>
44
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45
          <GridBagConstraints gridX="1" gridY="1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="1.0" weightY="0.0"/>
46
        </Constraint>
47
      </Constraints>
48
    </Component>
49
    <Component class="javax.swing.JLabel" name="jLabel1">
32
    <Component class="javax.swing.JLabel" name="jLabel1">
50
      <Properties>
33
      <Properties>
51
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
34
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
Lines 89-114 Link Here
89
        </Constraint>
72
        </Constraint>
90
      </Constraints>
73
      </Constraints>
91
    </Component>
74
    </Component>
92
    <Component class="javax.swing.JLabel" name="jLabel2">
93
      <Properties>
94
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
95
          <ComponentRef name="tfPrintText"/>
96
        </Property>
97
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
98
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="L_Actions_Panel_Print_Text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
99
        </Property>
100
      </Properties>
101
      <AccessibilityProperties>
102
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
103
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSD_PrintText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
104
        </Property>
105
      </AccessibilityProperties>
106
      <Constraints>
107
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
108
          <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="17" weightX="0.0" weightY="0.0"/>
109
        </Constraint>
110
      </Constraints>
111
    </Component>
112
    <Container class="javax.swing.JPanel" name="checkBoxPanel">
75
    <Container class="javax.swing.JPanel" name="checkBoxPanel">
113
      <Constraints>
76
      <Constraints>
114
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
77
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
Lines 133-137 Link Here
133
        </Component>
96
        </Component>
134
      </SubComponents>
97
      </SubComponents>
135
    </Container>
98
    </Container>
99
    <Component class="javax.swing.JCheckBox" name="enableGroupCheckBox">
100
      <Properties>
101
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
102
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="MSG_EnableGroup" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
103
        </Property>
104
      </Properties>
105
      <Constraints>
106
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
107
          <GridBagConstraints gridX="-1" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
108
        </Constraint>
109
      </Constraints>
110
    </Component>
111
    <Component class="javax.swing.JLabel" name="enableGroupLabel">
112
      <Properties>
113
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
114
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="MSG_EnableGroup" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
115
        </Property>
116
      </Properties>
117
      <Constraints>
118
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
119
          <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="3" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
120
        </Constraint>
121
      </Constraints>
122
    </Component>
123
    <Component class="javax.swing.JComboBox" name="enableGroupComboBox">
124
      <Properties>
125
        <Property name="editable" type="boolean" value="true"/>
126
      </Properties>
127
      <AuxValues>
128
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineComboBox();"/>
129
      </AuxValues>
130
      <Constraints>
131
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
132
          <GridBagConstraints gridX="1" gridY="1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="1.0" weightY="0.0"/>
133
        </Constraint>
134
      </Constraints>
135
    </Component>
136
    <Component class="javax.swing.JCheckBox" name="disableGroupCheckBox">
137
      <Properties>
138
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
139
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="MSG_DisableGroup" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
140
        </Property>
141
      </Properties>
142
      <Constraints>
143
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
144
          <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
145
        </Constraint>
146
      </Constraints>
147
    </Component>
148
    <Component class="javax.swing.JLabel" name="disableGroupLabel">
149
      <Properties>
150
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
151
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="MSG_DisableGroup" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
152
        </Property>
153
      </Properties>
154
      <Constraints>
155
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
156
          <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="3" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
157
        </Constraint>
158
      </Constraints>
159
    </Component>
160
    <Component class="javax.swing.JComboBox" name="disableGroupComboBox">
161
      <Properties>
162
        <Property name="editable" type="boolean" value="true"/>
163
      </Properties>
164
      <AuxValues>
165
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OutlineComboBox();"/>
166
        <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value=""/>
167
      </AuxValues>
168
      <Constraints>
169
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
170
          <GridBagConstraints gridX="1" gridY="2" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="1.0" weightY="0.0"/>
171
        </Constraint>
172
      </Constraints>
173
    </Component>
174
    <Component class="javax.swing.JLabel" name="jLabel2">
175
      <Properties>
176
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
177
          <ComponentRef name="tfPrintText"/>
178
        </Property>
179
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
180
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="L_Actions_Panel_Print_Text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
181
        </Property>
182
      </Properties>
183
      <AccessibilityProperties>
184
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
185
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSD_PrintText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
186
        </Property>
187
      </AccessibilityProperties>
188
      <Constraints>
189
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
190
          <GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="17" weightX="0.0" weightY="0.0"/>
191
        </Constraint>
192
      </Constraints>
193
    </Component>
194
    <Component class="javax.swing.JTextField" name="tfPrintText">
195
      <Properties>
196
        <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
197
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="TTT_TF_Actions_Panel_Print_Text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
198
        </Property>
199
      </Properties>
200
      <AccessibilityProperties>
201
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
202
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSD_TF_Actions_Panel_Print_Text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
203
        </Property>
204
      </AccessibilityProperties>
205
      <Constraints>
206
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
207
          <GridBagConstraints gridX="1" gridY="3" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="1.0" weightY="0.0"/>
208
        </Constraint>
209
      </Constraints>
210
    </Component>
136
  </SubComponents>
211
  </SubComponents>
137
</Form>
212
</Form>
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/ActionsPanel.java (-23 / +294 lines)
Lines 45-54 Link Here
45
package org.netbeans.modules.debugger.jpda.ui.breakpoints;
45
package org.netbeans.modules.debugger.jpda.ui.breakpoints;
46
46
47
import java.awt.Dimension;
47
import java.awt.Dimension;
48
import java.util.ArrayList;
49
import java.util.Collections;
50
import java.util.List;
48
51
49
import java.util.ResourceBundle;
52
import java.util.ResourceBundle;
53
import java.util.Set;
54
import java.util.TreeSet;
50
import java.util.prefs.Preferences;
55
import java.util.prefs.Preferences;
56
import org.netbeans.api.debugger.Breakpoint;
57
import org.netbeans.api.debugger.DebuggerManager;
51
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
58
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
59
import org.netbeans.api.project.Project;
60
import org.netbeans.modules.debugger.jpda.breakpoints.BreakpointsFromGroup;
61
import org.netbeans.modules.debugger.jpda.breakpoints.BreakpointsFromGroup.TestGroupProperties;
62
import org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointsExpandableGroup.FileItem;
63
import org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointsExpandableGroup.FilesGroup;
64
import org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointsExpandableGroup.ProjectItem;
65
import org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointsExpandableGroup.ProjectsGroup;
66
import org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointsExpandableGroup.TypeItem;
67
import org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointsExpandableGroup.TypesGroup;
68
import org.openide.filesystems.FileObject;
52
import org.openide.util.NbBundle;
69
import org.openide.util.NbBundle;
53
import org.openide.util.NbPreferences;
70
import org.openide.util.NbPreferences;
54
71
Lines 64-69 Link Here
64
    private int defaultSuspendAction;
81
    private int defaultSuspendAction;
65
    private int checkedSuspendAction;
82
    private int checkedSuspendAction;
66
    private Preferences preferences = NbPreferences.forModule(JPDABreakpoint.class).node("debugging"); // NOI18N
83
    private Preferences preferences = NbPreferences.forModule(JPDABreakpoint.class).node("debugging"); // NOI18N
84
    private static final Object NONE_BREAKPOINT_GROUP = new NoneBreakpointGroup();
67
85
68
    /** Creates new form LineBreakpointPanel */
86
    /** Creates new form LineBreakpointPanel */
69
    public ActionsPanel (JPDABreakpoint b) {
87
    public ActionsPanel (JPDABreakpoint b) {
Lines 105-110 Link Here
105
                30*tfPrintText.getFontMetrics(tfPrintText.getFont()).charWidth('W'),
123
                30*tfPrintText.getFontMetrics(tfPrintText.getFont()).charWidth('W'),
106
                tfPrintText.getPreferredSize().height));
124
                tfPrintText.getPreferredSize().height));
107
        tfPrintText.setCaretPosition(0);
125
        tfPrintText.setCaretPosition(0);
126
        
127
        enableGroupCheckBox.setVisible(false);
128
        disableGroupCheckBox.setVisible(false);
129
        Object[] groups = getGroups();
130
        Set<Breakpoint> breakpointsToEnable = breakpoint.getBreakpointsToEnable();
131
        Set<Breakpoint> breakpointsToDisable = breakpoint.getBreakpointsToDisable();
132
        BreakpointsFromGroup bfgToEnable = null;
133
        BreakpointsFromGroup bfgToDisable = null;
134
        if (breakpointsToEnable instanceof BreakpointsFromGroup) {
135
            bfgToEnable = (BreakpointsFromGroup) breakpointsToEnable;
136
        }
137
        if (breakpointsToDisable instanceof BreakpointsFromGroup) {
138
            bfgToDisable = (BreakpointsFromGroup) breakpointsToDisable;
139
        }
140
        fillGroups((OutlineComboBox) enableGroupComboBox, groups, bfgToEnable);
141
        fillGroups((OutlineComboBox) disableGroupComboBox, groups, bfgToDisable);
108
    }
142
    }
109
    
143
    
110
    /** This method is called from within the constructor to
144
    /** This method is called from within the constructor to
Lines 116-143 Link Here
116
    private void initComponents() {
150
    private void initComponents() {
117
        java.awt.GridBagConstraints gridBagConstraints;
151
        java.awt.GridBagConstraints gridBagConstraints;
118
152
119
        tfPrintText = new javax.swing.JTextField();
120
        jLabel1 = new javax.swing.JLabel();
153
        jLabel1 = new javax.swing.JLabel();
121
        cbSuspend = new javax.swing.JComboBox();
154
        cbSuspend = new javax.swing.JComboBox();
122
        jLabel2 = new javax.swing.JLabel();
123
        checkBoxPanel = new javax.swing.JPanel();
155
        checkBoxPanel = new javax.swing.JPanel();
124
        defaultActionCheckBox = new javax.swing.JCheckBox();
156
        defaultActionCheckBox = new javax.swing.JCheckBox();
157
        enableGroupCheckBox = new javax.swing.JCheckBox();
158
        enableGroupLabel = new javax.swing.JLabel();
159
        enableGroupComboBox = new OutlineComboBox();
160
        disableGroupCheckBox = new javax.swing.JCheckBox();
161
        disableGroupLabel = new javax.swing.JLabel();
162
        disableGroupComboBox = new OutlineComboBox();
163
        jLabel2 = new javax.swing.JLabel();
164
        tfPrintText = new javax.swing.JTextField();
125
165
126
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle"); // NOI18N
166
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle"); // NOI18N
127
        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("L_Actions_Panel_BorderTitle"))); // NOI18N
167
        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("L_Actions_Panel_BorderTitle"))); // NOI18N
128
        setLayout(new java.awt.GridBagLayout());
168
        setLayout(new java.awt.GridBagLayout());
129
169
130
        tfPrintText.setToolTipText(bundle.getString("TTT_TF_Actions_Panel_Print_Text")); // NOI18N
131
        gridBagConstraints = new java.awt.GridBagConstraints();
132
        gridBagConstraints.gridx = 1;
133
        gridBagConstraints.gridy = 1;
134
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
135
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
136
        gridBagConstraints.weightx = 1.0;
137
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
138
        add(tfPrintText, gridBagConstraints);
139
        tfPrintText.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TF_Actions_Panel_Print_Text")); // NOI18N
140
141
        jLabel1.setLabelFor(cbSuspend);
170
        jLabel1.setLabelFor(cbSuspend);
142
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, bundle.getString("L_Actions_Panel_Suspend")); // NOI18N
171
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, bundle.getString("L_Actions_Panel_Suspend")); // NOI18N
143
        gridBagConstraints = new java.awt.GridBagConstraints();
172
        gridBagConstraints = new java.awt.GridBagConstraints();
Lines 162-177 Link Here
162
        add(cbSuspend, gridBagConstraints);
191
        add(cbSuspend, gridBagConstraints);
163
        cbSuspend.getAccessibleContext().setAccessibleDescription(bundle.getString("ASCD_CB_Actions_Panel_Suspend")); // NOI18N
192
        cbSuspend.getAccessibleContext().setAccessibleDescription(bundle.getString("ASCD_CB_Actions_Panel_Suspend")); // NOI18N
164
193
165
        jLabel2.setLabelFor(tfPrintText);
166
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, bundle.getString("L_Actions_Panel_Print_Text")); // NOI18N
167
        gridBagConstraints = new java.awt.GridBagConstraints();
168
        gridBagConstraints.gridx = 0;
169
        gridBagConstraints.gridy = 1;
170
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
171
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
172
        add(jLabel2, gridBagConstraints);
173
        jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ActionsPanel.class, "ACSD_PrintText")); // NOI18N
174
175
        checkBoxPanel.setLayout(new java.awt.GridBagLayout());
194
        checkBoxPanel.setLayout(new java.awt.GridBagLayout());
176
195
177
        org.openide.awt.Mnemonics.setLocalizedText(defaultActionCheckBox, "jCheckBox1");
196
        org.openide.awt.Mnemonics.setLocalizedText(defaultActionCheckBox, "jCheckBox1");
Lines 194-199 Link Here
194
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
213
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
195
        add(checkBoxPanel, gridBagConstraints);
214
        add(checkBoxPanel, gridBagConstraints);
196
215
216
        org.openide.awt.Mnemonics.setLocalizedText(enableGroupCheckBox, org.openide.util.NbBundle.getMessage(ActionsPanel.class, "MSG_EnableGroup")); // NOI18N
217
        gridBagConstraints = new java.awt.GridBagConstraints();
218
        gridBagConstraints.gridy = 1;
219
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
220
        add(enableGroupCheckBox, gridBagConstraints);
221
222
        org.openide.awt.Mnemonics.setLocalizedText(enableGroupLabel, org.openide.util.NbBundle.getMessage(ActionsPanel.class, "MSG_EnableGroup")); // NOI18N
223
        gridBagConstraints = new java.awt.GridBagConstraints();
224
        gridBagConstraints.gridx = 0;
225
        gridBagConstraints.gridy = 1;
226
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
227
        gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
228
        add(enableGroupLabel, gridBagConstraints);
229
230
        enableGroupComboBox.setEditable(true);
231
        gridBagConstraints = new java.awt.GridBagConstraints();
232
        gridBagConstraints.gridx = 1;
233
        gridBagConstraints.gridy = 1;
234
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
235
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
236
        gridBagConstraints.weightx = 1.0;
237
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
238
        add(enableGroupComboBox, gridBagConstraints);
239
240
        org.openide.awt.Mnemonics.setLocalizedText(disableGroupCheckBox, org.openide.util.NbBundle.getMessage(ActionsPanel.class, "MSG_DisableGroup")); // NOI18N
241
        gridBagConstraints = new java.awt.GridBagConstraints();
242
        gridBagConstraints.gridy = 2;
243
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
244
        add(disableGroupCheckBox, gridBagConstraints);
245
246
        org.openide.awt.Mnemonics.setLocalizedText(disableGroupLabel, org.openide.util.NbBundle.getMessage(ActionsPanel.class, "MSG_DisableGroup")); // NOI18N
247
        gridBagConstraints = new java.awt.GridBagConstraints();
248
        gridBagConstraints.gridx = 0;
249
        gridBagConstraints.gridy = 2;
250
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
251
        gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
252
        add(disableGroupLabel, gridBagConstraints);
253
254
        disableGroupComboBox.setEditable(true);
255
        gridBagConstraints = new java.awt.GridBagConstraints();
256
        gridBagConstraints.gridx = 1;
257
        gridBagConstraints.gridy = 2;
258
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
259
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
260
        gridBagConstraints.weightx = 1.0;
261
        gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3);
262
        add(disableGroupComboBox, gridBagConstraints);
263
264
        jLabel2.setLabelFor(tfPrintText);
265
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, bundle.getString("L_Actions_Panel_Print_Text")); // NOI18N
266
        gridBagConstraints = new java.awt.GridBagConstraints();
267
        gridBagConstraints.gridx = 0;
268
        gridBagConstraints.gridy = 3;
269
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
270
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
271
        add(jLabel2, gridBagConstraints);
272
        jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ActionsPanel.class, "ACSD_PrintText")); // NOI18N
273
274
        tfPrintText.setToolTipText(bundle.getString("TTT_TF_Actions_Panel_Print_Text")); // NOI18N
275
        gridBagConstraints = new java.awt.GridBagConstraints();
276
        gridBagConstraints.gridx = 1;
277
        gridBagConstraints.gridy = 3;
278
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
279
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
280
        gridBagConstraints.weightx = 1.0;
281
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
282
        add(tfPrintText, gridBagConstraints);
283
        tfPrintText.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TF_Actions_Panel_Print_Text")); // NOI18N
284
197
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ActionsPanel.class, "ACSD_Actions")); // NOI18N
285
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ActionsPanel.class, "ACSD_Actions")); // NOI18N
198
    }// </editor-fold>//GEN-END:initComponents
286
    }// </editor-fold>//GEN-END:initComponents
199
287
Lines 236-241 Link Here
236
        if (checkedSuspendAction != defaultSuspendAction) {
324
        if (checkedSuspendAction != defaultSuspendAction) {
237
            preferences.putInt(DEFAULT_SUSPEND_ACTION, checkedSuspendAction);
325
            preferences.putInt(DEFAULT_SUSPEND_ACTION, checkedSuspendAction);
238
        }
326
        }
327
        Object breakpointsToEnableGroup = enableGroupComboBox.getSelectedItem();
328
        breakpoint.setBreakpointsToEnable(createBreakpointsSet(breakpointsToEnableGroup));
329
        Object breakpointsToDisableGroup = disableGroupComboBox.getSelectedItem();
330
        breakpoint.setBreakpointsToDisable(createBreakpointsSet(breakpointsToDisableGroup));
331
        /*
332
        if (breakpointsToDisableGroup == null || breakpointsToDisableGroup == NONE_BREAKPOINT_GROUP) {
333
            breakpoint.setBreakpointsToDisable(Collections.EMPTY_SET);
334
        } else {
335
            TestGroupProperties tgp = createTestProperties(breakpointsToDisableGroup);
336
            if (tgp != null) {
337
                breakpoint.setBreakpointsToDisable(new BreakpointsFromGroup(tgp));
338
            } else {
339
                String customGroup = (String) breakpointsToDisableGroup;
340
                customGroup = customGroup.trim();
341
                if (!customGroup.isEmpty()) {
342
                    breakpoint.setBreakpointsToDisable(new BreakpointsFromGroup(customGroup));
343
                } else {
344
                    breakpoint.setBreakpointsToDisable(Collections.EMPTY_SET);
345
                }
346
            }
347
        }
348
         */
349
    }
350
    
351
    private static Set<Breakpoint> createBreakpointsSet(Object selectedGroup) {
352
        if (selectedGroup == null || selectedGroup == NONE_BREAKPOINT_GROUP) {
353
            return Collections.EMPTY_SET;
354
        } else {
355
            TestGroupProperties tgp = createTestProperties(selectedGroup);
356
            if (tgp != null) {
357
                return new BreakpointsFromGroup(tgp);
358
            } else {
359
                String customGroup = (String) selectedGroup;
360
                customGroup = customGroup.trim();
361
                if (!customGroup.isEmpty()) {
362
                    return new BreakpointsFromGroup(customGroup);
363
                } else {
364
                    return Collections.EMPTY_SET;
365
                }
366
            }
367
        }
368
    }
369
    
370
    /*
371
    private static Object getItem(JComboBox cb, BreakpointsFromGroup bfg) {
372
        String groupName = bfg.getGroupName();
373
        if (groupName != null) {
374
            return groupName;
375
        }
376
        TestGroupProperties testProperties = bfg.getTestProperties();
377
        
378
        FileObject fo = testProperties.getFileObject();
379
        if (fo != null) {
380
            
381
        }
382
    }
383
     */
384
    
385
    private static TestGroupProperties createTestProperties(Object group) {
386
        if (group instanceof FileItem) {
387
            return new TestGroupProperties(((FileItem) group).getFileObject());
388
        }
389
        if (group instanceof ProjectItem) {
390
            return new TestGroupProperties(((ProjectItem) group).getProject());
391
        }
392
        if (group instanceof TypeItem) {
393
            return new TestGroupProperties(((TypeItem) group).getType());
394
        }
395
        return null;
396
    }
397
    
398
    private void fillGroupNames(OutlineComboBox cb, Object[] groupNames) {
399
        //DefaultComboBoxModel cbm = new DefaultComboBoxModel(groupNames);
400
        cb.setItems(groupNames);
401
        cb.setSelectedIndex(0);
402
    }
403
    
404
    private Object[] fillGroups(OutlineComboBox cb, Object[] groups, BreakpointsFromGroup groupToSelect) {
405
        int index = groups.length - 3;
406
        FilesGroup fg = new FilesGroup();
407
        ProjectsGroup pg = new ProjectsGroup();
408
        TypesGroup tg = new TypesGroup();
409
        groups[index++] = fg;
410
        groups[index++] = pg;
411
        groups[index++] = tg;
412
        cb.setItems(groups);
413
        if (groupToSelect == null) {
414
            cb.setSelectedIndex(0);
415
        } else {
416
            String groupName = groupToSelect.getGroupName();
417
            if (groupName != null) {
418
                cb.setSelectedItem(groupName);
419
            } else {
420
                TestGroupProperties tgp = groupToSelect.getTestGroupProperties();
421
                FileObject fo = tgp.getFileObject();
422
                if (fo != null) {
423
                    FileItem[] items = fg.getItems();
424
                    for (FileItem fi : items) {
425
                        if (fo.equals(fi.getFileObject())) {
426
                            cb.getModel().setSelectedItem(fg); // To expand it and fill the items
427
                            cb.setSelectedItem(fi);
428
                            break;
429
                        }
430
                    }
431
                }
432
                Project project = tgp.getProject();
433
                if (project != null) {
434
                    ProjectItem[] items = pg.getItems();
435
                    for (ProjectItem pi : items) {
436
                        if (project.equals(pi.getProject())) {
437
                            cb.getModel().setSelectedItem(pg); // To expand it and fill the items
438
                            cb.setSelectedItem(pi);
439
                            break;
440
                        }
441
                    }
442
                }
443
                String type = tgp.getType();
444
                if (type != null) {
445
                    TypeItem[] items = tg.getItems();
446
                    for (TypeItem ti : items) {
447
                        if (type.equals(ti.getType())) {
448
                            cb.getModel().setSelectedItem(tg); // To expand it and fill the items
449
                            cb.setSelectedItem(ti);
450
                            break;
451
                        }
452
                    }
453
                }
454
            }
455
        }
456
        return groups;
457
    }
458
    
459
    private static String[] getGroupNames() {
460
        Set<String> groupNamesSorted = new TreeSet<String>();
461
        Breakpoint[] bs = DebuggerManager.getDebuggerManager ().getBreakpoints ();
462
        for (int i = 0; i < bs.length; i++) {
463
            String gn = bs[i].getGroupName();
464
            groupNamesSorted.add(gn);
465
        }
466
        groupNamesSorted.remove(""); // Remove the defalt group
467
        List<String> groupNames = new ArrayList<String>(groupNamesSorted);
468
        groupNames.add(0, NbBundle.getMessage(ActionsPanel.class, "LBL_NoneBreakpointGroup"));
469
        return groupNames.toArray(new String[0]);
470
    }
471
    
472
    private static Object[] getGroups() {
473
        Set<String> groupNamesSorted = new TreeSet<String>();
474
        Breakpoint[] bs = DebuggerManager.getDebuggerManager ().getBreakpoints ();
475
        for (int i = 0; i < bs.length; i++) {
476
            String gn = bs[i].getGroupName();
477
            groupNamesSorted.add(gn);
478
        }
479
        groupNamesSorted.remove(""); // Remove the defalt group
480
        Object[] groups = new Object[1 + groupNamesSorted.size() + 3]; // 3 expandable groups
481
        groups[0] = NONE_BREAKPOINT_GROUP;
482
        int i = 1;
483
        for (String gn : groupNamesSorted) {
484
            groups[i++] = gn;
485
        }
486
        return groups;
487
    }
488
    
489
    private static final class NoneBreakpointGroup {
490
491
        @Override
492
        public String toString() {
493
            return NbBundle.getMessage(ActionsPanel.class, "LBL_NoneBreakpointGroup");
494
        }
495
        
496
        public static Object valueOf(String newString) {
497
            if (newString.isEmpty() || NbBundle.getMessage(ActionsPanel.class, "LBL_NoneBreakpointGroup").equals(newString)) {
498
                return NONE_BREAKPOINT_GROUP;
499
            } else {
500
                return newString;
501
            }
502
        }
503
        
239
    }
504
    }
240
    
505
    
241
    
506
    
Lines 243-248 Link Here
243
    private javax.swing.JComboBox cbSuspend;
508
    private javax.swing.JComboBox cbSuspend;
244
    private javax.swing.JPanel checkBoxPanel;
509
    private javax.swing.JPanel checkBoxPanel;
245
    private javax.swing.JCheckBox defaultActionCheckBox;
510
    private javax.swing.JCheckBox defaultActionCheckBox;
511
    private javax.swing.JCheckBox disableGroupCheckBox;
512
    private javax.swing.JComboBox disableGroupComboBox;
513
    private javax.swing.JLabel disableGroupLabel;
514
    private javax.swing.JCheckBox enableGroupCheckBox;
515
    private javax.swing.JComboBox enableGroupComboBox;
516
    private javax.swing.JLabel enableGroupLabel;
246
    private javax.swing.JLabel jLabel1;
517
    private javax.swing.JLabel jLabel1;
247
    private javax.swing.JLabel jLabel2;
518
    private javax.swing.JLabel jLabel2;
248
    private javax.swing.JTextField tfPrintText;
519
    private javax.swing.JTextField tfPrintText;
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointsExpandableGroup.java (+360 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.debugger.jpda.ui.breakpoints;
43
44
import java.io.IOException;
45
import java.net.MalformedURLException;
46
import java.net.URL;
47
import java.util.Set;
48
import java.util.TreeSet;
49
import org.netbeans.api.debugger.Breakpoint;
50
import org.netbeans.api.debugger.Breakpoint.GroupProperties;
51
import org.netbeans.api.debugger.DebuggerManager;
52
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.ProjectManager;
54
import org.netbeans.api.project.ProjectUtils;
55
import org.netbeans.modules.debugger.jpda.ui.breakpoints.OutlineComboBox.PopupMenuItem;
56
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileStateInvalidException;
58
import org.openide.filesystems.FileUtil;
59
import org.openide.filesystems.URLMapper;
60
import org.openide.util.NbBundle;
61
62
/**
63
 * Representation of an expandable group category in ActionsPanel
64
 * 
65
 * @author Martin
66
 */
67
abstract class BreakpointsExpandableGroup<T> implements OutlineComboBox.Expandable {
68
    
69
    private boolean expanded = false;
70
    private T[] items;
71
72
    @Override
73
    public boolean isExpanded() {
74
        return expanded;
75
    }
76
77
    @Override
78
    public void setExpanded(boolean expanded) {
79
        this.expanded = expanded;
80
    }
81
    
82
    @Override
83
    public T[] getItems() {
84
        if (items == null) {
85
            items = createItems();
86
        }
87
        return items;
88
    }
89
    
90
    protected abstract T[] createItems();
91
    
92
    static class FilesGroup extends BreakpointsExpandableGroup<FileItem> {
93
        
94
        @Override
95
        public FileItem[] createItems() {
96
            Set<FileItem> items = new TreeSet<FileItem>();
97
            Breakpoint[] bs = DebuggerManager.getDebuggerManager ().getBreakpoints ();
98
            for (int i = 0; i < bs.length; i++) {
99
                GroupProperties groupProperties = bs[i].getGroupProperties();
100
                if (groupProperties != null) {
101
                    FileObject[] files = groupProperties.getFiles();
102
                    if (files != null) {
103
                        for (FileObject fo : files) {
104
                            items.add(new FileItem(fo));
105
                        }
106
                    }
107
                }
108
            }
109
            return items.toArray(new FileItem[]{});
110
        }
111
112
        @Override
113
        public String toString() {
114
            return NbBundle.getMessage(ActionsPanel.class, "LBL_FilesGroup");
115
        }
116
        
117
    }
118
    
119
    static class ProjectsGroup extends BreakpointsExpandableGroup<ProjectItem> {
120
121
        @Override
122
        public ProjectItem[] createItems() {
123
            Set<ProjectItem> items = new TreeSet<ProjectItem>();
124
            Breakpoint[] bs = DebuggerManager.getDebuggerManager ().getBreakpoints ();
125
            for (int i = 0; i < bs.length; i++) {
126
                GroupProperties groupProperties = bs[i].getGroupProperties();
127
                if (groupProperties != null) {
128
                    Project[] projects = groupProperties.getProjects();
129
                    if (projects != null) {
130
                        for (Project p : projects) {
131
                            items.add(new ProjectItem(p));
132
                        }
133
                    }
134
                }
135
            }
136
            return items.toArray(new ProjectItem[]{});
137
        }
138
139
        @Override
140
        public String toString() {
141
            return NbBundle.getMessage(ActionsPanel.class, "LBL_ProjectsGroup");
142
        }
143
        
144
    }
145
    
146
    static class TypesGroup extends BreakpointsExpandableGroup<TypeItem> {
147
148
        @Override
149
        public TypeItem[] createItems() {
150
            Set<TypeItem> items = new TreeSet<TypeItem>();
151
            Breakpoint[] bs = DebuggerManager.getDebuggerManager ().getBreakpoints ();
152
            for (int i = 0; i < bs.length; i++) {
153
                GroupProperties groupProperties = bs[i].getGroupProperties();
154
                if (groupProperties != null) {
155
                    String type = groupProperties.getType();
156
                    if (type != null) {
157
                        items.add(new TypeItem(type));
158
                    }
159
                }
160
            }
161
            return items.toArray(new TypeItem[]{});
162
        }
163
164
        @Override
165
        public String toString() {
166
            return NbBundle.getMessage(ActionsPanel.class, "LBL_TypesGroup");
167
        }
168
        
169
    }
170
    
171
    static class FileItem implements Comparable<FileItem>, PopupMenuItem {
172
        
173
        private FileObject fo;
174
        
175
        public FileItem(FileObject fo) {
176
            this.fo = fo;
177
        }
178
        
179
        public FileObject getFileObject() {
180
            return fo;
181
        }
182
183
        @Override
184
        public int hashCode() {
185
            return fo.hashCode();
186
        }
187
188
        @Override
189
        public boolean equals(Object obj) {
190
            return (obj instanceof FileItem) && ((FileItem) obj).fo.equals(fo);
191
        }
192
        
193
        @Override
194
        public int compareTo(FileItem o) {
195
            return o.toString().compareTo(toString());
196
        }
197
        
198
        @Override
199
        public String toString() {
200
            try {
201
                return fo.getURL().toExternalForm();
202
            } catch (FileStateInvalidException ex) {
203
                return "file://"+fo.getPath();
204
            }
205
        }
206
207
        @Override
208
        public String toPopupMenuString() {
209
            //return FileUtil.getFileDisplayName(fo);
210
            return fo.getNameExt();
211
        }
212
213
        public static Object valueOf(String newString) {
214
            URL url;
215
            try {
216
                url = new URL(newString);
217
            } catch (MalformedURLException ex) {
218
                return newString;
219
            }
220
            FileObject fo = URLMapper.findFileObject(url);
221
            if (fo != null) {
222
                return new FileItem(fo);
223
            } else {
224
                return newString;
225
            }
226
        }
227
228
    }
229
    
230
    static class ProjectItem implements Comparable<ProjectItem>, PopupMenuItem {
231
        
232
        private Project p;
233
        
234
        public ProjectItem(Project p) {
235
            this.p = p;
236
        }
237
        
238
        public Project getProject() {
239
            return p;
240
        }
241
242
        @Override
243
        public int hashCode() {
244
            return p.hashCode();
245
        }
246
247
        @Override
248
        public boolean equals(Object obj) {
249
            return (obj instanceof ProjectItem) && ((ProjectItem) obj).p.equals(p);
250
        }
251
        
252
        @Override
253
        public int compareTo(ProjectItem o) {
254
            return o.toString().compareTo(toString());
255
        }
256
257
        @Override
258
        public String toString() {
259
            return NbBundle.getMessage(ActionsPanel.class, "LBL_ProjectGroupItem", p.getProjectDirectory().getPath());
260
        }
261
262
        @Override
263
        public String toPopupMenuString() {
264
            return ProjectUtils.getInformation(p).getDisplayName();
265
        }
266
        
267
        public static Object valueOf(String newString) {
268
            String format = NbBundle.getMessage(ActionsPanel.class, "LBL_ProjectGroupItem", "");
269
            String dir = getFormattedValue(format, newString);
270
            if (dir != null) {
271
                FileObject fo = FileUtil.toFileObject(new java.io.File(dir));
272
                if (fo != null) {
273
                    try {
274
                        Project project = ProjectManager.getDefault().findProject(fo);
275
                        if (project != null) {
276
                            return new ProjectItem(project);
277
                        }
278
                    } catch (IOException ex) {
279
                    } catch (IllegalArgumentException ex) {
280
                    }
281
                }
282
            }
283
            return newString;
284
        }
285
        
286
    }
287
    
288
    static class TypeItem implements Comparable<TypeItem>, PopupMenuItem {
289
        
290
        private String type;
291
        
292
        public TypeItem(String type) {
293
            this.type = type;
294
        }
295
        
296
        public String getType() {
297
            return type;
298
        }
299
300
        @Override
301
        public int hashCode() {
302
            return type.hashCode();
303
        }
304
305
        @Override
306
        public boolean equals(Object obj) {
307
            return (obj instanceof TypeItem) && ((TypeItem) obj).type.equals(type);
308
        }
309
        
310
        @Override
311
        public int compareTo(TypeItem o) {
312
            return o.toString().compareTo(toString());
313
        }
314
315
        @Override
316
        public String toString() {
317
            return NbBundle.getMessage(ActionsPanel.class, "LBL_TypeGroupItem", type);
318
        }
319
320
        @Override
321
        public String toPopupMenuString() {
322
            return type;
323
        }
324
        
325
        public static Object valueOf(String newString) {
326
            String format = NbBundle.getMessage(ActionsPanel.class, "LBL_ProjectGroupItem", "");
327
            String type = getFormattedValue(format, newString);
328
            if (type != null) {
329
                return new TypeItem(type);
330
            }
331
            return newString;
332
        }
333
    }
334
    
335
    private static String getFormattedValue(String format, String newString) {
336
        int i;
337
        for (i = 0; i < newString.length() && i < format.length(); i++) {
338
            if (Character.toUpperCase(newString.charAt(i)) !=
339
                Character.toUpperCase(format.charAt(i))) {
340
341
                break;
342
            }
343
        }
344
        int i2 = format.length() - 1;
345
        int i2ns = newString.length() - 1;
346
        for (; i2 > i && i2ns > i; i2--, i2ns--) {
347
            if (Character.toUpperCase(newString.charAt(i2ns)) !=
348
                Character.toUpperCase(format.charAt(i2))) {
349
350
                break;
351
            }
352
        }
353
        if (i >= i2 && i <= i2ns) {
354
            return newString.substring(i, i2ns + 1);
355
        } else {
356
            return null;
357
        }
358
    }
359
    
360
}
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties (+9 lines)
Lines 60-65 Link Here
60
    LBL_CB_Actions_Panel_Suspend_All=All threads
60
    LBL_CB_Actions_Panel_Suspend_All=All threads
61
    TTT_CB_Actions_Panel_Suspend=The suspend mode.
61
    TTT_CB_Actions_Panel_Suspend=The suspend mode.
62
62
63
    MSG_EnableGroup=Enable Group:
64
    MSG_DisableGroup=Disable Group:
65
    LBL_NoneBreakpointGroup=<NONE>
66
    LBL_FilesGroup=Breakpoints in Files
67
    LBL_ProjectsGroup=Breakpoints in Projects
68
    LBL_TypesGroup=Breakpoint Types
69
    LBL_ProjectGroupItem=Project: {0}
70
    LBL_TypeGroupItem=Breakpoint Type: {0}
71
63
    L_Actions_Panel_Print_Text=Print &Text\:
72
    L_Actions_Panel_Print_Text=Print &Text\:
64
73
65
    ACSD_TF_Actions_Panel_Print_Text=
74
    ACSD_TF_Actions_Panel_Print_Text=
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/OutlineComboBox.java (+262 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.debugger.jpda.ui.breakpoints;
43
44
import java.awt.Component;
45
import java.awt.Graphics;
46
import java.awt.Insets;
47
import java.util.HashSet;
48
import java.util.Set;
49
import javax.swing.DefaultComboBoxModel;
50
import javax.swing.Icon;
51
import javax.swing.JComboBox;
52
import javax.swing.JLabel;
53
import javax.swing.JList;
54
import javax.swing.ListCellRenderer;
55
import javax.swing.SwingUtilities;
56
import javax.swing.UIManager;
57
import javax.swing.border.Border;
58
59
/**
60
 * Combo box with a tree-like outline in the popup menu.
61
 * Only one expansion level is supported, for simplicity.
62
 * 
63
 * @author martin
64
 */
65
public class OutlineComboBox extends JComboBox {
66
    
67
    private JList popupList;
68
    private boolean keepPopupVisible = false;
69
    private Set<Object> expandedItems = new HashSet<Object>();
70
    
71
    public OutlineComboBox() {
72
        setRenderer(new OutlineComboBoxRenderer());
73
    }
74
    
75
    public void setItems(Object[] items) {
76
        expandedItems.clear();
77
        setModel(new OutlineComboBoxModel(items));
78
    }
79
        
80
    private void setKeepPopupVisible(boolean keepPopupVisible) {
81
        this.keepPopupVisible = keepPopupVisible;
82
    }
83
84
    @Override
85
    public void setPopupVisible(boolean v) {
86
        if (v || !keepPopupVisible) {
87
            super.setPopupVisible(v);
88
        }
89
    }
90
    
91
    public static interface Expandable {
92
        
93
        Object[] getItems();
94
        
95
        boolean isExpanded();
96
        
97
        void setExpanded(boolean expanded);
98
        
99
    }
100
    
101
    public static interface PopupMenuItem {
102
        
103
        String toPopupMenuString();
104
    }
105
    
106
    private class OutlineComboBoxModel extends DefaultComboBoxModel {
107
        
108
        public OutlineComboBoxModel(Object[] items) {
109
            super(items);
110
        }
111
112
        @Override
113
        public void setSelectedItem(Object item) {
114
            if (item instanceof Expandable) {
115
                Expandable exp = (Expandable) item;
116
                exp.setExpanded(!exp.isExpanded());
117
                if (popupList != null) {
118
                    OutlineComboBox.this.setKeepPopupVisible(true);
119
                    popupList.repaint();
120
                    SwingUtilities.invokeLater(new Runnable() {
121
                        @Override
122
                        public void run() {
123
                            OutlineComboBox.this.setKeepPopupVisible(false);
124
                        }
125
                    });
126
                }
127
                addRemoveSubItems(exp);
128
            } else {
129
                super.setSelectedItem(item);
130
            }
131
        }
132
        
133
        private void addRemoveSubItems(Expandable exp) {
134
            int index = getIndexOf(exp);
135
            if (exp.isExpanded()) {
136
                for (Object item : exp.getItems()) {
137
                    insertElementAt(item, ++index);
138
                    expandedItems.add(item);
139
                }
140
            } else {
141
                index++;
142
                for (Object item : exp.getItems()) {
143
                    removeElementAt(index);
144
                    expandedItems.remove(item);
145
                }
146
            }
147
        }
148
    }
149
    
150
    private class OutlineComboBoxRenderer extends JLabel
151
                                          implements ListCellRenderer {
152
        
153
        private ShiftBorder sborder;
154
        
155
        public OutlineComboBoxRenderer() {
156
            setOpaque(true);
157
            sborder = new ShiftBorder(getBorder());
158
            setBorder(sborder);
159
        }
160
        
161
        @Override
162
        public Component getListCellRendererComponent(
163
                                           JList list,
164
                                           Object value,
165
                                           int index,
166
                                           boolean isSelected,
167
                                           boolean cellHasFocus) {
168
            popupList = list;
169
            if (value instanceof Expandable) {
170
                Expandable exp = (Expandable) value;
171
                if (exp.isExpanded()) {
172
                    setIcon(getExpandedIcon());
173
                } else {
174
                    setIcon(getCollapsedIcon());
175
                }
176
            } else {
177
                setIcon(null);
178
            }
179
            String text;
180
            if (value instanceof PopupMenuItem) {
181
                text = ((PopupMenuItem) value).toPopupMenuString();
182
            } else {
183
                text = value.toString();
184
            }
185
            setText(text);
186
            if (expandedItems.contains(value)) {
187
                sborder.setShift(getExpansionHandleWidth());
188
            } else {
189
                sborder.setShift(0);
190
            }
191
            
192
            if (isSelected) {
193
                setBackground(list.getSelectionBackground());
194
                setForeground(list.getSelectionForeground());
195
            } else {
196
                setBackground(list.getBackground());
197
                setForeground(list.getForeground());
198
            }
199
            return this;
200
        }
201
        
202
        private class ShiftBorder implements Border {
203
            
204
            private Border b;
205
            private int shift;
206
            private Insets NO_INSETS = new Insets(0, 0, 0, 0);
207
            
208
            public ShiftBorder(Border b) {
209
                this.b = b;
210
            }
211
            
212
            public void setShift(int shift) {
213
                this.shift = shift;
214
            }
215
216
            @Override
217
            public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
218
                if (b != null) {
219
                    b.paintBorder(c, g, x, y, width, height);
220
                }
221
            }
222
223
            @Override
224
            public Insets getBorderInsets(Component c) {
225
                Insets in;
226
                if (b == null) {
227
                    in = NO_INSETS;
228
                } else {
229
                    in = b.getBorderInsets(c);
230
                }
231
                if (shift != 0) {
232
                    in = new Insets(in.top, shift + in.left, in.bottom, in.right);
233
                }
234
                return in;
235
            }
236
237
            @Override
238
            public boolean isBorderOpaque() {
239
                if (b == null) return false;
240
                return b.isBorderOpaque();
241
            }
242
            
243
        } 
244
    }
245
    
246
    private static Icon getExpandedIcon() {
247
        return UIManager.getIcon ("Tree.expandedIcon"); //NOI18N
248
    }
249
    
250
    private static Icon getCollapsedIcon() {
251
        return UIManager.getIcon ("Tree.collapsedIcon"); //NOI18N
252
    }
253
    
254
    private static int expansionHandleWidth;
255
    private static int getExpansionHandleWidth() {
256
        if (expansionHandleWidth == 0) {
257
            expansionHandleWidth = getExpandedIcon ().getIconWidth ();
258
        }
259
        return expansionHandleWidth;
260
    }
261
262
}
(-)a/debugger.jpda/nbproject/project.xml (-1 / +10 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.28</specification-version>
58
                        <specification-version>1.34</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
Lines 119-124 Link Here
119
                    </run-dependency>
119
                    </run-dependency>
120
                </dependency>
120
                </dependency>
121
                <dependency>
121
                <dependency>
122
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
123
                    <build-prerequisite/>
124
                    <compile-dependency/>
125
                    <run-dependency>
126
                        <release-version>1</release-version>
127
                        <specification-version>1.39</specification-version>
128
                    </run-dependency>
129
                </dependency>
130
                <dependency>
122
                    <code-name-base>org.netbeans.spi.debugger.ui</code-name-base>
131
                    <code-name-base>org.netbeans.spi.debugger.ui</code-name-base>
123
                    <build-prerequisite/>
132
                    <build-prerequisite/>
124
                    <compile-dependency/>
133
                    <compile-dependency/>
(-)a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java (+13 lines)
Lines 66-71 Link Here
66
import java.beans.PropertyChangeEvent;
66
import java.beans.PropertyChangeEvent;
67
import java.util.HashMap;
67
import java.util.HashMap;
68
import java.util.Map;
68
import java.util.Map;
69
import java.util.Set;
69
import java.util.logging.Level;
70
import java.util.logging.Level;
70
import java.util.logging.Logger;
71
import java.util.logging.Logger;
71
import javax.swing.SwingUtilities;
72
import javax.swing.SwingUtilities;
Lines 471-476 Link Here
471
            getBreakpoint (),
472
            getBreakpoint (),
472
            e
473
            e
473
        );
474
        );
475
        enableDisableDependentBreakpoints();
474
        Integer brkpSuspend = (Integer) event.request().getProperty("brkpSuspend");
476
        Integer brkpSuspend = (Integer) event.request().getProperty("brkpSuspend");
475
        if (brkpSuspend == null) {
477
        if (brkpSuspend == null) {
476
            brkpSuspend = getBreakpoint().getSuspend();
478
            brkpSuspend = getBreakpoint().getSuspend();
Lines 493-498 Link Here
493
        return resume; 
495
        return resume; 
494
    }
496
    }
495
    
497
    
498
    private void enableDisableDependentBreakpoints() {
499
        Set<Breakpoint> breakpoints = breakpoint.getBreakpointsToEnable();
500
        for (Breakpoint b : breakpoints) {
501
            b.enable();
502
        }
503
        breakpoints = breakpoint.getBreakpointsToDisable();
504
        for (Breakpoint b : breakpoints) {
505
            b.disable();
506
        }
507
    }
508
    
496
    private boolean checkWhetherResumeToFinishStep(ThreadReference thread) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper {
509
    private boolean checkWhetherResumeToFinishStep(ThreadReference thread) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper {
497
        List<StepRequest> stepRequests = EventRequestManagerWrapper.stepRequests(
510
        List<StepRequest> stepRequests = EventRequestManagerWrapper.stepRequests(
498
                VirtualMachineWrapper.eventRequestManager(MirrorWrapper.virtualMachine(thread)));
511
                VirtualMachineWrapper.eventRequestManager(MirrorWrapper.virtualMachine(thread)));
(-)a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointsFromGroup.java (+232 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.debugger.jpda.breakpoints;
43
44
import java.util.ArrayList;
45
import java.util.Collection;
46
import java.util.Iterator;
47
import java.util.List;
48
import java.util.Set;
49
50
import org.netbeans.api.debugger.Breakpoint;
51
import org.netbeans.api.debugger.Breakpoint.GroupProperties;
52
import org.netbeans.api.debugger.DebuggerManager;
53
import org.netbeans.api.project.Project;
54
import org.openide.filesystems.FileObject;
55
56
/**
57
 * Set of breakpoints from a group.
58
 * 
59
 * @author Martin
60
 */
61
public final class BreakpointsFromGroup implements Set<Breakpoint> {
62
    
63
    private final String groupName;
64
    private final TestGroupProperties testProperties;
65
    
66
    public BreakpointsFromGroup(String groupName) {
67
        this.groupName = groupName;
68
        this.testProperties = null;
69
    }
70
    
71
    public BreakpointsFromGroup(TestGroupProperties testProperties) {
72
        this.groupName = null;
73
        this.testProperties = testProperties;
74
    }
75
    
76
    public String getGroupName() {
77
        return groupName;
78
    }
79
    
80
    public TestGroupProperties getTestGroupProperties() {
81
        return testProperties;
82
    }
83
    
84
    private List<Breakpoint> getBreakpointsFromGroup() {
85
        List<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
86
        Breakpoint[] bps = DebuggerManager.getDebuggerManager().getBreakpoints();
87
        if (groupName != null) {
88
            for (Breakpoint b : bps) {
89
                if (groupName.equals(b.getGroupName())) {
90
                    breakpoints.add(b);
91
                }
92
            }
93
        } else if (testProperties != null) {
94
            for (Breakpoint b : bps) {
95
                GroupProperties groupProperties = b.getGroupProperties();
96
                if (groupProperties != null &&
97
                    !groupProperties.isHidden() &&
98
                    testProperties.accept(groupProperties)) {
99
                    
100
                    breakpoints.add(b);
101
                }
102
            }
103
        }
104
        return breakpoints;
105
    }
106
    
107
    @Override
108
    public int size() {
109
        return getBreakpointsFromGroup().size();
110
    }
111
112
    @Override
113
    public boolean isEmpty() {
114
        return getBreakpointsFromGroup().isEmpty();
115
    }
116
117
    @Override
118
    public boolean contains(Object o) {
119
        return getBreakpointsFromGroup().contains(o);
120
    }
121
122
    @Override
123
    public Iterator<Breakpoint> iterator() {
124
        return getBreakpointsFromGroup().iterator();
125
    }
126
127
    @Override
128
    public boolean containsAll(Collection<?> c) {
129
        return getBreakpointsFromGroup().containsAll(c);
130
    }
131
132
    @Override
133
    public Object[] toArray() {
134
        return getBreakpointsFromGroup().toArray();
135
    }
136
137
    @Override
138
    public <T> T[] toArray(T[] a) {
139
        return getBreakpointsFromGroup().toArray(a);
140
    }
141
142
    @Override
143
    public boolean add(Breakpoint e) {
144
        throw new UnsupportedOperationException("Not supported.");
145
    }
146
147
    @Override
148
    public boolean remove(Object o) {
149
        throw new UnsupportedOperationException("Not supported.");
150
    }
151
152
    @Override
153
    public boolean addAll(Collection<? extends Breakpoint> c) {
154
        throw new UnsupportedOperationException("Not supported.");
155
    }
156
157
    @Override
158
    public boolean retainAll(Collection<?> c) {
159
        throw new UnsupportedOperationException("Not supported.");
160
    }
161
162
    @Override
163
    public boolean removeAll(Collection<?> c) {
164
        throw new UnsupportedOperationException("Not supported.");
165
    }
166
167
    @Override
168
    public void clear() {
169
        throw new UnsupportedOperationException("Not supported.");
170
    }
171
    
172
    public static final class TestGroupProperties {
173
        
174
        private FileObject fo;
175
        private Project p;
176
        private String type;
177
        
178
        public TestGroupProperties(FileObject fo) {
179
            this.fo = fo;
180
        }
181
        
182
        public TestGroupProperties(Project p) {
183
            this.p = p;
184
        }
185
        
186
        public TestGroupProperties(String type) {
187
            this.type = type;
188
        }
189
        
190
        public FileObject getFileObject() {
191
            return fo;
192
        }
193
        
194
        public Project getProject() {
195
            return p;
196
        }
197
        
198
        public String getType() {
199
            return type;
200
        }
201
        
202
        boolean accept(GroupProperties gp) {
203
            if (fo != null) {
204
                FileObject[] files = gp.getFiles();
205
                if (files != null) {
206
                    for (FileObject f : files) {
207
                        if (fo.equals(f)) {
208
                            return true;
209
                        }
210
                    }
211
                }
212
            }
213
            if (p != null) {
214
                Project[] projects = gp.getProjects();
215
                if (projects != null) {
216
                    for (Project pp : projects) {
217
                        if (p.equals(pp)) {
218
                            return true;
219
                        }
220
                    }
221
                }
222
            }
223
            if (type != null) {
224
                if (type.equals(gp.getType())) {
225
                    return true;
226
                }
227
            }
228
            return false;
229
        }
230
    }
231
    
232
}
(-)a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointsReader.java (+100 lines)
Lines 46-52 Link Here
46
46
47
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeEvent;
48
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeListener;
49
import java.io.IOException;
50
import java.net.MalformedURLException;
51
import java.net.URL;
52
import java.util.Collections;
49
import java.util.Map;
53
import java.util.Map;
54
import java.util.Set;
50
import java.util.WeakHashMap;
55
import java.util.WeakHashMap;
51
56
52
import org.netbeans.api.debugger.Breakpoint;
57
import org.netbeans.api.debugger.Breakpoint;
Lines 58-64 Link Here
58
import org.netbeans.api.debugger.jpda.LineBreakpoint;
63
import org.netbeans.api.debugger.jpda.LineBreakpoint;
59
import org.netbeans.api.debugger.jpda.MethodBreakpoint;
64
import org.netbeans.api.debugger.jpda.MethodBreakpoint;
60
import org.netbeans.api.debugger.jpda.ThreadBreakpoint;
65
import org.netbeans.api.debugger.jpda.ThreadBreakpoint;
66
import org.netbeans.api.project.Project;
67
import org.netbeans.api.project.ProjectManager;
68
import org.netbeans.modules.debugger.jpda.breakpoints.BreakpointsFromGroup.TestGroupProperties;
61
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
69
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
70
import org.openide.filesystems.FileObject;
71
import org.openide.filesystems.FileStateInvalidException;
72
import org.openide.filesystems.URLMapper;
73
import org.openide.util.Exceptions;
62
74
63
75
64
/**
76
/**
Lines 68-73 Link Here
68
@DebuggerServiceRegistration(types={Properties.Reader.class})
80
@DebuggerServiceRegistration(types={Properties.Reader.class})
69
public class BreakpointsReader implements Properties.Reader, PropertyChangeListener {
81
public class BreakpointsReader implements Properties.Reader, PropertyChangeListener {
70
    
82
    
83
    private static final String BREAKPOINTS_TO_ENABLE = "breakpointsToEnable";
84
    private static final String BREAKPOINTS_TO_DISABLE = "breakpointsToDisable";
85
    private static final String BP_CUSTOM_GROUP = "CustomGroup";
86
    private static final String BP_FILE_GROUP = "FileGroup";
87
    private static final String BP_PROJECT_GROUP = "ProjectGroup";
88
    private static final String BP_TYPE_GROUP = "TypeGroup";
89
    
71
    private Map<JPDABreakpoint, String> cachedClassNames = new WeakHashMap<JPDABreakpoint, String>();
90
    private Map<JPDABreakpoint, String> cachedClassNames = new WeakHashMap<JPDABreakpoint, String>();
72
    private Map<JPDABreakpoint, String> cachedSourceRoots = new WeakHashMap<JPDABreakpoint, String>();
91
    private Map<JPDABreakpoint, String> cachedSourceRoots = new WeakHashMap<JPDABreakpoint, String>();
73
    
92
    
Lines 274-282 Link Here
274
            b.enable ();
293
            b.enable ();
275
        else
294
        else
276
            b.disable ();
295
            b.disable ();
296
        b.setBreakpointsToEnable(getBreakpointsFromGroup(properties, BREAKPOINTS_TO_ENABLE));
297
        b.setBreakpointsToDisable(getBreakpointsFromGroup(properties, BREAKPOINTS_TO_DISABLE));
277
        return b;
298
        return b;
278
    }
299
    }
279
    
300
    
301
    private static Set<Breakpoint> getBreakpointsFromGroup(Properties properties, String base) {
302
        String bpGroup = properties.getString(base + BP_CUSTOM_GROUP, null);
303
        if (bpGroup != null) {
304
            return new BreakpointsFromGroup(bpGroup);
305
        }
306
        bpGroup = properties.getString(base + BP_FILE_GROUP, null);
307
        if (bpGroup != null) {
308
            try {
309
                URL url = new URL(bpGroup);
310
                FileObject fo = URLMapper.findFileObject(url);
311
                if (fo != null) {
312
                    return new BreakpointsFromGroup(new TestGroupProperties(fo));
313
                }
314
            } catch (MalformedURLException ex) {
315
            }
316
        }
317
        bpGroup = properties.getString(base + BP_PROJECT_GROUP, null);
318
        if (bpGroup != null) {
319
            try {
320
                URL url = new URL(bpGroup);
321
                FileObject fo = URLMapper.findFileObject(url);
322
                if (fo != null) {
323
                    Project project = ProjectManager.getDefault().findProject(fo);
324
                    if (project != null) {
325
                        return new BreakpointsFromGroup(new TestGroupProperties(project));
326
                    }
327
                }
328
            } catch (MalformedURLException ex) {
329
            } catch (IOException ex) {
330
            } catch (IllegalArgumentException ex) {
331
            }
332
        }
333
        bpGroup = properties.getString(base + BP_TYPE_GROUP, null);
334
        if (bpGroup != null) {
335
            return new BreakpointsFromGroup(new TestGroupProperties(bpGroup));
336
        }
337
        return Collections.EMPTY_SET;
338
    }
339
    
340
    private static void setBreakpointsFromGroup(Properties properties, String base, Set<Breakpoint> breakpointsFromGroup) {
341
        String customGroup = null;
342
        String fileURL = null;
343
        String projectURL = null;
344
        String type = null;
345
        if (breakpointsFromGroup instanceof BreakpointsFromGroup) {
346
            BreakpointsFromGroup bfg = (BreakpointsFromGroup) breakpointsFromGroup;
347
            customGroup = bfg.getGroupName();
348
            TestGroupProperties tgp = bfg.getTestGroupProperties();
349
            if (tgp != null) {
350
                FileObject fo = tgp.getFileObject();
351
                if (fo != null) {
352
                    try {
353
                        URL url = fo.getURL();
354
                        fileURL = url.toExternalForm();
355
                    } catch (FileStateInvalidException ex) {
356
                    }
357
                }
358
                Project project = tgp.getProject();
359
                if (project != null) {
360
                    fo = project.getProjectDirectory();
361
                    try {
362
                        URL url = fo.getURL();
363
                        projectURL = url.toExternalForm();
364
                    } catch (FileStateInvalidException ex) {
365
                    }
366
                }
367
                type = tgp.getType();
368
            }
369
        }
370
        properties.setString(base + BP_CUSTOM_GROUP, customGroup);
371
        properties.setString(base + BP_FILE_GROUP, fileURL);
372
        properties.setString(base + BP_PROJECT_GROUP, projectURL);
373
        properties.setString(base + BP_TYPE_GROUP, type);
374
    }
375
    
280
    public void write (Object object, Properties properties) {
376
    public void write (Object object, Properties properties) {
281
        JPDABreakpoint b = (JPDABreakpoint) object;
377
        JPDABreakpoint b = (JPDABreakpoint) object;
282
        properties.setString (
378
        properties.setString (
Lines 292-297 Link Here
292
        properties.setInt(JPDABreakpoint.PROP_HIT_COUNT_FILTER, b.getHitCountFilter());
388
        properties.setInt(JPDABreakpoint.PROP_HIT_COUNT_FILTER, b.getHitCountFilter());
293
        Breakpoint.HIT_COUNT_FILTERING_STYLE style = b.getHitCountFilteringStyle();
389
        Breakpoint.HIT_COUNT_FILTERING_STYLE style = b.getHitCountFilteringStyle();
294
        properties.setInt(JPDABreakpoint.PROP_HIT_COUNT_FILTER+"_style", style != null ? style.ordinal() : 0); // NOI18N
390
        properties.setInt(JPDABreakpoint.PROP_HIT_COUNT_FILTER+"_style", style != null ? style.ordinal() : 0); // NOI18N
391
        Set<Breakpoint> breakpointsToEnable = b.getBreakpointsToEnable();
392
        setBreakpointsFromGroup(properties, BREAKPOINTS_TO_ENABLE, breakpointsToEnable);
393
        Set<Breakpoint> breakpointsToDisable = b.getBreakpointsToDisable();
394
        setBreakpointsFromGroup(properties, BREAKPOINTS_TO_DISABLE, breakpointsToDisable);
295
        
395
        
296
        if (object instanceof LineBreakpoint) {
396
        if (object instanceof LineBreakpoint) {
297
            LineBreakpoint lb = (LineBreakpoint) object;
397
            LineBreakpoint lb = (LineBreakpoint) object;

Return to bug 197707