Coverage details for ui.frame.MessageFrame

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.frame;
21  
22 import java.awt.BorderLayout;
23 import java.awt.FlowLayout;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26  
27 import javax.swing.JButton;
28 import javax.swing.JDialog;
29 import javax.swing.JFrame;
30 import javax.swing.JPanel;
31 import javax.swing.JScrollPane;
32 import javax.swing.border.TitledBorder;
33  
34 import org.apache.log4j.Logger;
35  
36 import ui.Messages;
37 import ui.util.MessageLogger;
38  
390@SuppressWarnings("serial") //$NON-NLS-1$
400public class MessageFrame extends JFrame {
410 
420    private static final transient Logger logger = Logger
430            .getLogger(MessageFrame.class.getName());
44  
45     private JPanel contentPanel;
46  
47     private JPanel buttonPanel;
48  
49     private JScrollPane messageScrollPanel;
50  
51     private JPanel messagePanel;
520 
530    private static MessageFrame instance = null;
54  
550    public static MessageFrame getInstance() {
560        return instance == null ? instance = new MessageFrame() : instance;
57     }
580 
590    protected MessageFrame() {
600        initialize();
610    }
62  
630    protected void initialize() {
640        this.setSize(300, 600);
650        this.setResizable(true);
660        this.setContentPane(getContentPanel());
670        this.setAlwaysOnTop(true);
680        this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
690    }
70  
71     /**
72      * @return Returns the contentPanel.
73      */
740    protected JPanel getContentPanel() {
750        if (contentPanel == null) {
760            contentPanel = new JPanel();
770            TitledBorder titledBorder = new TitledBorder(Messages.getString("common.messages")); //$NON-NLS-1$
780            contentPanel.setBorder(titledBorder);
790            contentPanel.setLayout(new BorderLayout());
800            contentPanel.add(getMessageScrollPanel(), BorderLayout.CENTER);
810            contentPanel.add(getButtonPanel(), BorderLayout.SOUTH);
820        }
830        return contentPanel;
84     }
85  
86     /**
87      * @return Returns the messageScrollPanel.
88      */
890    protected JScrollPane getMessageScrollPanel() {
900        if (messageScrollPanel == null) {
910            messageScrollPanel = new JScrollPane();
920            messageScrollPanel.setViewportView(getMessagePanel());
930            messageScrollPanel
940                    .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
950            messageScrollPanel
960                    .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
970        }
980        return messageScrollPanel;
99     }
100  
101     /**
102      * @return Returns the messagePanel.
103      */
1040    protected JPanel getMessagePanel() {
1050        if (messagePanel == null) {
1060            messagePanel = MessageLogger.getMessagePanel();
1070        }
1080        return messagePanel;
109     }
110  
111     /**
112      * @return Returns the buttonPanel.
113      */
1140    protected JPanel getButtonPanel() {
1150        if (buttonPanel == null) {
1160            buttonPanel = new JPanel();
1170            TitledBorder titledBorder = new TitledBorder(Messages.getString("dialog.availableactions")); //$NON-NLS-1$
1180            buttonPanel.setBorder(titledBorder);
1190            buttonPanel.setLayout(new FlowLayout());
1200            JButton saveButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$
1210            JButton clearButton = new JButton(Messages.getString("button.clear")); //$NON-NLS-1$
1220            JButton closeButton = new JButton(Messages.getString("button.close")); //$NON-NLS-1$
123  
1240            // buttonPanel.add(saveButton);
1250            buttonPanel.add(clearButton);
1260            buttonPanel.add(closeButton);
1270 
1280            saveButton.addActionListener(new ActionListener() {
129                 public void actionPerformed(ActionEvent arg0) {
130                     logger.debug("actionPerformed saveButton"); //$NON-NLS-1$
131                 }
132             });
1330 
1340            clearButton.addActionListener(new ActionListener() {
135                 public void actionPerformed(ActionEvent arg0) {
136                     logger.debug("actionPerformed clearButton"); //$NON-NLS-1$
137                     getMessagePanel().removeAll();
138                     getMessagePanel().updateUI();
139                 }
140             });
1410 
1420            closeButton.addActionListener(new ActionListener() {
143                 public void actionPerformed(ActionEvent arg0) {
144                     logger.debug("actionPerformed closeButton"); //$NON-NLS-1$
145                     setVisible(false);
146                 }
147             });
148  
1490        }
1500        return buttonPanel;
151     }
152  
153 }

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.