52
52
import java .util .ArrayList ;
53
53
import java .util .Collection ;
54
54
import java .util .Enumeration ;
55
+ import java .util .Iterator ;
55
56
import javax .swing .AbstractButton ;
56
57
import javax .swing .BorderFactory ;
57
58
import javax .swing .Box ;
71
72
import org .netbeans .lib .profiler .ui .swing .GrayLabel ;
72
73
import org .netbeans .modules .profiler .api .icons .Icons ;
73
74
import org .netbeans .modules .profiler .heapwalk .details .api .DetailsSupport ;
75
+ import org .netbeans .modules .profiler .heapwalk .details .spi .DetailsUtils ;
74
76
import org .netbeans .modules .profiler .heapwalk .ui .icons .HeapWalkerIcons ;
75
77
import org .openide .util .Lookup ;
76
78
import org .openide .util .RequestProcessor ;
@@ -233,8 +235,8 @@ public void run() {
233
235
final Heap heap = context .getFragment ().getHeap ();
234
236
235
237
final Collection <Instance > windows = new ArrayList ();
236
- windows .addAll (getFrames (heap ));
237
- windows .addAll (getDialogs (heap ));
238
+ windows .addAll (getVisibleFrames (heap ));
239
+ windows .addAll (getVisibleDialogs (heap ));
238
240
239
241
SwingUtilities .invokeLater (new Runnable () {
240
242
public void run () {
@@ -510,22 +512,30 @@ public void componentRemoved(ContainerEvent e) {
510
512
}
511
513
512
514
513
- private static Collection <Instance > getFrames (Heap heap ) {
515
+ private static Collection <Instance > getVisibleFrames (Heap heap ) {
514
516
Collection <JavaClass > framesC = HeapUtils .getSubclasses (heap , "java.awt.Frame" ); // NOI18N
515
517
516
518
Collection <Instance > framesI = new ArrayList ();
517
519
for (JavaClass frameC : framesC ) framesI .addAll (frameC .getInstances ());
518
520
519
- return framesI ;
521
+ return onlyVisible ( framesI ) ;
520
522
}
521
523
522
- private static Collection <Instance > getDialogs (Heap heap ) {
524
+ private static Collection <Instance > getVisibleDialogs (Heap heap ) {
523
525
Collection <JavaClass > dialogsC = HeapUtils .getSubclasses (heap , "java.awt.Dialog" ); // NOI18N
524
526
525
527
Collection <Instance > dialogsI = new ArrayList ();
526
528
for (JavaClass dialogC : dialogsC ) dialogsI .addAll (dialogC .getInstances ());
527
529
528
- return dialogsI ;
530
+ return onlyVisible (dialogsI );
531
+ }
532
+
533
+ private static Collection <Instance > onlyVisible (Collection <Instance > instances ) {
534
+ Iterator <Instance > framesIt = instances .iterator ();
535
+ while (framesIt .hasNext ())
536
+ if (!DetailsUtils .getBooleanFieldValue (framesIt .next (), "visible" , false )) // NOI18N
537
+ framesIt .remove ();
538
+ return instances ;
529
539
}
530
540
531
541
@@ -536,8 +546,8 @@ public HeapViewerFeature getFeature(HeapContext context, HeapViewerActions actio
536
546
if (!JavaHeapFragment .isJavaHeap (context )) return null ;
537
547
538
548
Heap heap = context .getFragment ().getHeap ();
539
- int estWindowsCount = getFrames (heap ).size ();
540
- if (estWindowsCount <= 1 ) estWindowsCount += getDialogs (heap ).size ();
549
+ int estWindowsCount = getVisibleFrames (heap ).size ();
550
+ if (estWindowsCount <= 1 ) estWindowsCount += getVisibleDialogs (heap ).size ();
541
551
542
552
return estWindowsCount == 0 ? null : new JavaWindowsView (context , actions , estWindowsCount );
543
553
}
0 commit comments