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

(-)a/gsf.testrunner/src/org/netbeans/modules/gsf/testrunner/api/Manager.java (-10 / +18 lines)
Lines 66-71 Link Here
66
import org.openide.awt.Notification;
66
import org.openide.awt.Notification;
67
import org.openide.awt.NotificationDisplayer;
67
import org.openide.awt.NotificationDisplayer;
68
import org.openide.util.*;
68
import org.openide.util.*;
69
import org.openide.windows.InputOutput;
69
import org.openide.windows.Mode;
70
import org.openide.windows.Mode;
70
import org.openide.windows.WindowManager;
71
import org.openide.windows.WindowManager;
71
72
Lines 435-455 Link Here
435
    }
436
    }
436
437
437
    /** singleton of the <code>ResultDisplayHandler</code> */
438
    /** singleton of the <code>ResultDisplayHandler</code> */
438
    private Map<TestSession,ResultDisplayHandler> displayHandlers;
439
    // the ResultDisplayHandler holds TestSession and is referenced from other
440
    // places so we use WeakReference, otherwise there would be memory leak
441
    private Map<TestSession,WeakReference<ResultDisplayHandler>> displayHandlers;
439
    private Semaphore lock;
442
    private Semaphore lock;
440
    /**
443
    /**
441
     */
444
     */
442
    private synchronized ResultDisplayHandler getDisplayHandler(final TestSession session) {
445
    private synchronized ResultDisplayHandler getDisplayHandler(final TestSession session) {
443
        ResultDisplayHandler displayHandler = (displayHandlers != null)
446
        ResultDisplayHandler displayHandler = null;
444
                                              ? displayHandlers.get(session)
447
        if (displayHandlers != null) {
445
                                              : null;
448
            WeakReference<ResultDisplayHandler> reference = displayHandlers.get(session);
449
            if (reference != null) {
450
                displayHandler = reference.get();
451
            }
452
        } else {
453
            displayHandlers = new WeakHashMap<TestSession,WeakReference<ResultDisplayHandler>>(7);
454
        }
455
446
        if (displayHandler == null) {
456
        if (displayHandler == null) {
447
            if (displayHandlers == null) {
448
                displayHandlers = new WeakHashMap<TestSession,ResultDisplayHandler>(7);
449
            }
450
            displayHandler = new ResultDisplayHandler(session);
457
            displayHandler = new ResultDisplayHandler(session);
451
            createIO(displayHandler);
458
            createIO(displayHandler);
452
            displayHandlers.put(session, displayHandler);
459
            displayHandlers.put(session, new WeakReference<ResultDisplayHandler>(displayHandler));
453
            final ResultDisplayHandler dispHandler = displayHandler;
460
            final ResultDisplayHandler dispHandler = displayHandler;
454
            lock = new Semaphore(1);
461
            lock = new Semaphore(1);
455
            try {
462
            try {
Lines 483-493 Link Here
483
    private void createIO(final ResultDisplayHandler displayHandler) {
490
    private void createIO(final ResultDisplayHandler displayHandler) {
484
        try {
491
        try {
485
            Runnable r = new Runnable() {
492
            Runnable r = new Runnable() {
493
                @Override
486
                public void run() {
494
                public void run() {
487
                    final ResultWindow window = ResultWindow.getInstance();
495
                    final ResultWindow window = ResultWindow.getInstance();
488
                    window.addDisplayComponent(displayHandler.getDisplayComponent(), displayHandler.getLookup());
489
                    window.setOutputComp(displayHandler.getOutputComponent());
496
                    window.setOutputComp(displayHandler.getOutputComponent());
490
                    displayHandler.createIO(window.getIOContainer());
497
                    InputOutput io = displayHandler.createIO(window.getIOContainer());
498
                    window.addDisplayComponent(displayHandler.getDisplayComponent(), io);
491
                }
499
                }
492
            };
500
            };
493
            if (SwingUtilities.isEventDispatchThread()){
501
            if (SwingUtilities.isEventDispatchThread()){
(-)a/gsf.testrunner/src/org/netbeans/modules/gsf/testrunner/api/ResultDisplayHandler.java (-1 / +2 lines)
Lines 108-115 Link Here
108
        return outputComponent;
108
        return outputComponent;
109
    }
109
    }
110
110
111
    void createIO(IOContainer ioContainer) {
111
    InputOutput createIO(IOContainer ioContainer) {
112
        inOut = IOProvider.getDefault().getIO("test-results", null, ioContainer); //NOI18N
112
        inOut = IOProvider.getDefault().getIO("test-results", null, ioContainer); //NOI18N
113
        return inOut;
113
    }
114
    }
114
115
115
116
(-)a/gsf.testrunner/src/org/netbeans/modules/gsf/testrunner/api/ResultWindow.java (-3 / +11 lines)
Lines 70-81 Link Here
70
import org.openide.util.Exceptions;
70
import org.openide.util.Exceptions;
71
import org.openide.util.HelpCtx;
71
import org.openide.util.HelpCtx;
72
import org.openide.util.ImageUtilities;
72
import org.openide.util.ImageUtilities;
73
import org.openide.util.Lookup;
74
import org.openide.util.NbBundle;
73
import org.openide.util.NbBundle;
75
import org.openide.windows.TopComponent;
74
import org.openide.windows.TopComponent;
76
import org.openide.windows.WindowManager;
75
import org.openide.windows.WindowManager;
77
import org.openide.windows.IOContainer;
76
import org.openide.windows.IOContainer;
78
import org.openide.windows.IOContainer.CallBacks;
77
import org.openide.windows.IOContainer.CallBacks;
78
import org.openide.windows.InputOutput;
79
79
80
/**
80
/**
81
 *
81
 *
Lines 93-98 Link Here
93
    private static WeakReference<ResultWindow> instance = null;
93
    private static WeakReference<ResultWindow> instance = null;
94
94
95
    private Map<String,JSplitPane> viewMap = new HashMap<String,JSplitPane>();
95
    private Map<String,JSplitPane> viewMap = new HashMap<String,JSplitPane>();
96
    private Map<String,InputOutput> ioMap = new HashMap<String,InputOutput>();
96
97
97
    private final JTabbedPane tabPane;
98
    private final JTabbedPane tabPane;
98
    private JPopupMenu pop;
99
    private JPopupMenu pop;
Lines 199-213 Link Here
199
200
200
    /**
201
    /**
201
     */
202
     */
202
    public void addDisplayComponent(JSplitPane displayComp, Lookup l) {
203
    public void addDisplayComponent(JSplitPane displayComp, InputOutput io) {
203
        assert EventQueue.isDispatchThread();
204
        assert EventQueue.isDispatchThread();
204
        String key = displayComp.getToolTipText();
205
        String key = displayComp.getToolTipText();
205
206
206
        JSplitPane prevComp = viewMap.put(key, displayComp);
207
        JSplitPane prevComp = viewMap.put(key, displayComp);
208
        InputOutput prevIo = ioMap.put(key, io);
207
        if (prevComp == null){
209
        if (prevComp == null){
208
            addView(displayComp);
210
            addView(displayComp);
209
        }else{
211
        }else{
210
            replaceView(prevComp, displayComp);
212
            replaceView(prevComp, displayComp);
213
            if (prevIo != null) {
214
                prevIo.closeInputOutput();
215
            }
211
        }
216
        }
212
        revalidate();
217
        revalidate();
213
    }
218
    }
Lines 384-389 Link Here
384
        }
389
        }
385
        tabPane.remove(view);
390
        tabPane.remove(view);
386
        viewMap.remove(view.getToolTipText());
391
        viewMap.remove(view.getToolTipText());
392
        InputOutput io = ioMap.remove(view.getToolTipText());
393
        if (io != null) {
394
            io.closeInputOutput();
395
        }
387
396
388
        validate();
397
        validate();
389
    }
398
    }
Lines 393-399 Link Here
393
        public void remove(JComponent comp) {
402
        public void remove(JComponent comp) {
394
            outputTab = null;
403
            outputTab = null;
395
            outputComp.remove(comp);
404
            outputComp.remove(comp);
396
            ResultWindow.getInstance().close();
397
        }
405
        }
398
406
399
        public void select(JComponent comp) {
407
        public void select(JComponent comp) {

Return to bug 215847