|
36 | 36 | import javax.swing.JCheckBoxMenuItem;
|
37 | 37 | import javax.swing.JLabel;
|
38 | 38 | import javax.swing.JPopupMenu;
|
| 39 | +import javax.swing.JToggleButton; |
39 | 40 | import javax.swing.JTree;
|
40 | 41 | import javax.swing.RowFilter;
|
41 | 42 | import javax.swing.SortOrder;
|
| 43 | +import javax.swing.SwingUtilities; |
42 | 44 | import javax.swing.tree.TreeNode;
|
43 | 45 | import javax.swing.tree.TreePath;
|
44 | 46 | import org.graalvm.visualvm.lib.jfluid.client.ClientUtils;
|
@@ -325,34 +327,64 @@ public boolean include(RowFilter.Entry entry) {
|
325 | 327 | }
|
326 | 328 |
|
327 | 329 | protected Component[] getFilterOptions() {
|
328 |
| - if (!reverse) return super.getFilterOptions(); |
329 |
| - |
330 |
| - PopupButton pb = new PopupButton (Icons.getIcon(ProfilerIcons.TAB_CALL_TREE)) { |
331 |
| - protected void populatePopup(JPopupMenu popup) { |
332 |
| - popup.add(new JCheckBoxMenuItem(FILTER_CALLEES_SCOPE, filterTopMethods) { |
333 |
| - { |
334 |
| - if (!filterCallerMethods) setEnabled(false); |
335 |
| - } |
336 |
| - protected void fireActionPerformed(ActionEvent e) { |
337 |
| - super.fireActionPerformed(e); |
338 |
| - filterTopMethods = !filterTopMethods; |
339 |
| - enableFilter(); |
340 |
| - } |
341 |
| - }); |
342 |
| - popup.add(new JCheckBoxMenuItem(FILTER_CALLERS_SCOPE, filterCallerMethods) { |
343 |
| - { |
344 |
| - if (!filterTopMethods) setEnabled(false); |
345 |
| - } |
346 |
| - protected void fireActionPerformed(ActionEvent e) { |
347 |
| - super.fireActionPerformed(e); |
348 |
| - filterCallerMethods = !filterCallerMethods; |
349 |
| - enableFilter(); |
350 |
| - } |
351 |
| - }); |
| 330 | + if (reverse) { |
| 331 | + PopupButton pb = new PopupButton (Icons.getIcon(ProfilerIcons.TAB_CALL_TREE)) { |
| 332 | + protected void populatePopup(JPopupMenu popup) { |
| 333 | + popup.add(new JCheckBoxMenuItem(FILTER_CALLEES_SCOPE, filterTopMethods) { |
| 334 | + { |
| 335 | + if (!filterCallerMethods) setEnabled(false); |
| 336 | + } |
| 337 | + protected void fireActionPerformed(ActionEvent e) { |
| 338 | + super.fireActionPerformed(e); |
| 339 | + filterTopMethods = !filterTopMethods; |
| 340 | + enableFilter(); |
| 341 | + } |
| 342 | + }); |
| 343 | + popup.add(new JCheckBoxMenuItem(FILTER_CALLERS_SCOPE, filterCallerMethods) { |
| 344 | + { |
| 345 | + if (!filterTopMethods) setEnabled(false); |
| 346 | + } |
| 347 | + protected void fireActionPerformed(ActionEvent e) { |
| 348 | + super.fireActionPerformed(e); |
| 349 | + filterCallerMethods = !filterCallerMethods; |
| 350 | + enableFilter(); |
| 351 | + } |
| 352 | + }); |
| 353 | + } |
| 354 | + }; |
| 355 | + pb.setToolTipText(FILTER_SCOPE_TOOLTIP); |
| 356 | + return new Component[] { Box.createHorizontalStrut(5), pb }; |
| 357 | + } else { |
| 358 | + final RowFilter zeroFilter = new RowFilterImpl(); |
| 359 | + final JToggleButton zeroSelfTime = new JToggleButton(Icons.getIcon(ProfilerIcons.NODE_LEAF)) { |
| 360 | + |
| 361 | + protected void fireActionPerformed(ActionEvent e) { |
| 362 | + super.fireActionPerformed(e); |
| 363 | + boolean selected = isSelected(); |
| 364 | + |
| 365 | + SwingUtilities.invokeLater(() -> { |
| 366 | + if (selected) { |
| 367 | + treeTable.addRowFilter(zeroFilter); |
| 368 | + } else { |
| 369 | + treeTable.removeRowFilter(zeroFilter); |
| 370 | + } |
| 371 | + }); |
| 372 | + } |
| 373 | + }; |
| 374 | + zeroSelfTime.setToolTipText(HIDE_ZERO_SELF_TIME_TOOLTIP); |
| 375 | + return new Component[]{Box.createHorizontalStrut(5), zeroSelfTime}; |
| 376 | + } |
| 377 | + } |
| 378 | + |
| 379 | + private static class RowFilterImpl extends RowFilter implements ProfilerTreeTable.DeleteNodes { |
| 380 | + |
| 381 | + public boolean include(RowFilter.Entry entry) { |
| 382 | + PrestimeCPUCCTNode node = (PrestimeCPUCCTNode) entry.getIdentifier(); |
| 383 | + if (node.isSelfTimeNode() && node.getTotalTime0() == 0) { |
| 384 | + return false; |
352 | 385 | }
|
353 |
| - }; |
354 |
| - pb.setToolTipText(FILTER_SCOPE_TOOLTIP); |
355 |
| - return new Component[] { Box.createHorizontalStrut(5), pb }; |
| 386 | + return true; |
| 387 | + } |
356 | 388 | }
|
357 | 389 |
|
358 | 390 | protected SearchUtils.TreeHelper getSearchHelper() {
|
|
0 commit comments