EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hivegui.dialog]

COVERAGE SUMMARY FOR SOURCE FILE [GenericDialog.java]

nameclass, %method, %block, %line, %
GenericDialog.java0%   (0/3)0%   (0/9)0%   (0/141)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GenericDialog0%   (0/1)0%   (0/6)0%   (0/118)0%   (0/30)
GenericDialog (JDialog, DialogPanel): void 0%   (0/1)0%   (0/14)0%   (0/5)
GenericDialog (JFrame, DialogPanel): void 0%   (0/1)0%   (0/14)0%   (0/5)
close (boolean): void 0%   (0/1)0%   (0/9)0%   (0/4)
init (String): void 0%   (0/1)0%   (0/46)0%   (0/10)
setContext (ApplicationContext): void 0%   (0/1)0%   (0/32)0%   (0/7)
wasCancelled (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
     
class GenericDialog$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class GenericDialog$CloseListener0%   (0/1)0%   (0/3)0%   (0/23)0%   (0/5)
GenericDialog$CloseListener (GenericDialog): void 0%   (0/1)0%   (0/6)0%   (0/1)
GenericDialog$CloseListener (GenericDialog, GenericDialog$1): void 0%   (0/1)0%   (0/4)0%   (0/1)
windowClosing (WindowEvent): void 0%   (0/1)0%   (0/13)0%   (0/4)

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.hivegui.dialog;
16 
17import java.awt.event.WindowAdapter;
18import java.awt.event.WindowEvent;
19 
20import javax.swing.JDialog;
21import javax.swing.JFrame;
22 
23import org.jdesktop.application.ApplicationContext;
24 
25/**
26 * @author Jean-Francois Poilpret
27 */
28public class GenericDialog extends JDialog
29{
30        public GenericDialog(JDialog parent, DialogPanel panel)
31        {
32                super(parent, true);
33                _panel = panel;
34        }
35        
36        public GenericDialog(JFrame parent, DialogPanel panel)
37        {
38                super(parent, true);
39                _panel = panel;
40        }
41 
42        public void setContext(ApplicationContext context)
43        {
44                _context = context;
45                String name = _panel.getPanel().getName();
46                setName(name + "-dialog");
47                setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
48                addWindowListener(new CloseListener());
49                init(name);
50//                pack();
51        }
52 
53        protected void        init(String name)
54        {
55                if (_panel.getPanel().getClientProperty(DIALOGPANEL_INITED) == null)
56                {
57                        _panel.setContext(_context);
58                        _panel.getPanel().putClientProperty(DIALOGPANEL_INITED, "true");
59                }
60                _panel.setParent(this);
61                _panel.reset();
62                setTitle(_panel.getDialogTitle());
63                // Workaround a bug with JFileDialog and substance: 
64                // use add() instead of setCOntentPane()
65//                setContentPane(_panel.getPanel());
66                add(_panel.getPanel());
67                if (_panel.getDefaultButton() != null)
68                {
69                        getRootPane().setDefaultButton(_panel.getDefaultButton());
70                }
71        }
72 
73        // Should be called back by DialogPanel to close the dialog
74        public void close(boolean cancel)
75        {
76                _cancelled = cancel;
77                setVisible(false);
78                dispose();
79        }
80        
81        public boolean        wasCancelled()
82        {
83                return _cancelled;
84        }
85        
86        private class CloseListener extends WindowAdapter
87        {
88                @Override public void windowClosing(WindowEvent event)
89                {
90                        if (_panel.canClose())
91                        {
92                                setVisible(false);
93                                dispose();
94                        }
95                }
96        }
97        
98        final protected DialogPanel                _panel;
99        protected ApplicationContext        _context = null;
100        protected boolean                                _cancelled = true;
101        
102        static final private String                DIALOGPANEL_INITED = "GenericDialog.inited";
103}

[all classes][net.sourceforge.hivegui.dialog]
EMMA 2.0.5312 (C) Vladimir Roubtsov