EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.util]

COVERAGE SUMMARY FOR SOURCE FILE [ExitManager.java]

nameclass, %method, %block, %line, %
ExitManager.java50%  (1/2)38%  (3/8)65%  (39/60)54%  (14/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExitManager$10%   (0/1)0%   (0/2)0%   (0/5)0%   (0/3)
ExitManager$1 (): void 0%   (0/1)0%   (0/3)0%   (0/1)
run (): void 0%   (0/1)0%   (0/2)0%   (0/2)
     
class ExitManager100% (1/1)50%  (3/6)71%  (39/55)61%  (14/23)
ExitManager (): void 0%   (0/1)0%   (0/3)0%   (0/2)
access$000 (): void 0%   (0/1)0%   (0/2)0%   (0/1)
exit (int): void 0%   (0/1)0%   (0/4)0%   (0/2)
exit (int, boolean): void 100% (1/1)70%  (16/23)67%  (8/12)
<static initializer> 100% (1/1)100% (3/3)100% (1/1)
disposeFrames (): void 100% (1/1)100% (20/20)100% (5/5)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveboard.util;
16 
17import java.awt.EventQueue;
18import java.awt.Frame;
19 
20/**
21 * Utility class that avoids calling <code>System.exit()</code> from the AWT
22 * Event Dispatch Thread (not good practice, and generates problems when using
23 * abbot tools for GUI testing).
24 * @author Jean-Francois Poilpret
25 */
26final public class ExitManager
27{
28        static private boolean                _exitCalled = false;
29 
30        private ExitManager()
31        {
32        }
33        
34        static public void        exit(int code)
35        {
36                exit(code, false);
37        }
38        
39        static public void        exit(final int code, boolean silent)
40        {
41                if (_exitCalled)
42                {
43                        return;
44                }
45                _exitCalled = true;
46                if (EventQueue.isDispatchThread())
47                {
48                        disposeFrames();
49                }
50                else
51                {
52                        // CSOFF: EmptyBlockCheck
53                        // CSOFF: IllegalCatchCheck
54                        try
55                        {
56                                EventQueue.invokeAndWait(new Runnable()
57                                {
58                                        public void        run()
59                                        {
60                                                disposeFrames();
61                                        }
62                                });
63                        }
64                        catch (Exception e)
65                        {
66                                // Don't do anything
67                        }
68                        // CSON: IllegalCatchCheck
69                        // CSON: EmptyBlockCheck
70                }
71                if (!silent)
72                {
73                        throw new ExitException(code);
74                }
75        }
76 
77        static private void        disposeFrames()
78        {
79                Frame[] frames = Frame.getFrames();
80                for (int i = 0; i < frames.length; i++)
81                {
82                        if (frames[i].isDisplayable())
83                        {
84                                frames[i].dispose();
85                        }
86                }
87        }
88}

[all classes][net.sourceforge.hiveboard.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov