Coverage details for ui.dialog.SessionDialog

LineHitsSource
1 /*******************************************************************************
2  * InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20 package ui.dialog;
21  
22 import java.awt.BorderLayout;
23 import java.awt.Dimension;
24 import java.awt.GridLayout;
25 import java.awt.Toolkit;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28  
29 import javax.swing.ImageIcon;
30 import javax.swing.JButton;
31 import javax.swing.JDialog;
32 import javax.swing.JLabel;
33 import javax.swing.JPanel;
34 import javax.swing.border.TitledBorder;
35  
36 import org.apache.log4j.Logger;
37  
38 import ui.Messages;
39 import ui.panel.SessionPanel;
40 import base.session.Session;
41  
420@SuppressWarnings("serial") //$NON-NLS-1$
430public class SessionDialog extends JDialog {
440 
450    private static final transient Logger logger = Logger
460            .getLogger(SessionDialog.class.getName());
47  
48     private JPanel contentPanel;
49  
50     private JPanel buttonPanel;
51  
52     private JButton saveSessionButton;
53  
54     private SessionPanel sessionPanel;
550 
560    private Session session;
570 
580    public SessionDialog(Session session) {
590        this.session = session;
600        initialize();
610    }
62  
630    protected void initialize() {
640        this.setResizable(false);
650        this.setSize(550, 600);
660        // Center the dialog
670        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
680        Dimension frameSize = this.getSize();
690        if (frameSize.height > screenSize.height) {
700            frameSize.height = screenSize.height;
710        }
720        if (frameSize.width > screenSize.width) {
730            frameSize.width = screenSize.width;
740        }
750        this.setLocation((screenSize.width - frameSize.width) / 2,
760                (screenSize.height - frameSize.height) / 2);
770 
780        this.setContentPane(getContentPanel());
790        this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
800    }
81  
82     /**
83      * @return Returns the contentPanel.
84      */
850    protected JPanel getContentPanel() {
860        if (contentPanel == null) {
870            contentPanel = new JPanel();
880            contentPanel.setLayout(new BorderLayout());
890            contentPanel.add(getSessionPanel(), BorderLayout.CENTER);
900            contentPanel.add(getButtonPanel(), BorderLayout.SOUTH);
910        }
920        return contentPanel;
93     }
94  
95     /**
96      * @return Returns the sessionPanel.
97      */
980    protected SessionPanel getSessionPanel() {
990        if (sessionPanel == null) {
1000            sessionPanel = new SessionPanel(session);
1010        }
1020        return sessionPanel;
103     }
104  
105     /**
106      * @return Returns the buttonPanel.
107      */
1080    protected JPanel getButtonPanel() {
1090        if (buttonPanel == null) {
1100            buttonPanel = new JPanel();
1110            TitledBorder titledBorder = new TitledBorder(Messages.getString("dialog.availableactions")); //$NON-NLS-1$
1120            buttonPanel.setBorder(titledBorder);
1130            buttonPanel.setLayout(new GridLayout(1, 3));
1140            buttonPanel.add(new JLabel("")); //$NON-NLS-1$
1150            buttonPanel.add(getSaveSessionButton());
1160            buttonPanel.add(new JLabel("")); //$NON-NLS-1$
1170        }
1180        return buttonPanel;
119     }
120  
121     /**
122      * @return Returns the saveSessionButton.
123      */
1240    protected JButton getSaveSessionButton() {
1250        if (saveSessionButton == null) {
1260            saveSessionButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$
1270            saveSessionButton.setIcon(new ImageIcon(this.getClass()
1280                    .getResource("/icon/16x16/actions/document-save.png"))); //$NON-NLS-1$
1290 
1300            saveSessionButton.addActionListener(new ActionListener() {
131                 public void actionPerformed(ActionEvent arg0) {
132                     logger.debug("actionPerformed saveButton"); //$NON-NLS-1$
133                     if (session != null) {
134                         session.setDescription(getSessionPanel()
135                                 .getSessionDescription());
136                         setVisible(false);
137                     }
138                 }
139             });
1400        }
1410        return saveSessionButton;
142     }
143 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.