| Line | Hits | Source |
|---|---|---|
| 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 | ||
| 39 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
| 40 | 0 | public class MessageFrame extends JFrame { |
| 41 | 0 | |
| 42 | 0 | private static final transient Logger logger = Logger |
| 43 | 0 | .getLogger(MessageFrame.class.getName()); |
| 44 | ||
| 45 | private JPanel contentPanel; | |
| 46 | ||
| 47 | private JPanel buttonPanel; | |
| 48 | ||
| 49 | private JScrollPane messageScrollPanel; | |
| 50 | ||
| 51 | private JPanel messagePanel; | |
| 52 | 0 | |
| 53 | 0 | private static MessageFrame instance = null; |
| 54 | ||
| 55 | 0 | public static MessageFrame getInstance() { |
| 56 | 0 | return instance == null ? instance = new MessageFrame() : instance; |
| 57 | } | |
| 58 | 0 | |
| 59 | 0 | protected MessageFrame() { |
| 60 | 0 | initialize(); |
| 61 | 0 | } |
| 62 | ||
| 63 | 0 | protected void initialize() { |
| 64 | 0 | this.setSize(300, 600); |
| 65 | 0 | this.setResizable(true); |
| 66 | 0 | this.setContentPane(getContentPanel()); |
| 67 | 0 | this.setAlwaysOnTop(true); |
| 68 | 0 | this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); |
| 69 | 0 | } |
| 70 | ||
| 71 | /** | |
| 72 | * @return Returns the contentPanel. | |
| 73 | */ | |
| 74 | 0 | protected JPanel getContentPanel() { |
| 75 | 0 | if (contentPanel == null) { |
| 76 | 0 | contentPanel = new JPanel(); |
| 77 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("common.messages")); //$NON-NLS-1$ |
| 78 | 0 | contentPanel.setBorder(titledBorder); |
| 79 | 0 | contentPanel.setLayout(new BorderLayout()); |
| 80 | 0 | contentPanel.add(getMessageScrollPanel(), BorderLayout.CENTER); |
| 81 | 0 | contentPanel.add(getButtonPanel(), BorderLayout.SOUTH); |
| 82 | 0 | } |
| 83 | 0 | return contentPanel; |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * @return Returns the messageScrollPanel. | |
| 88 | */ | |
| 89 | 0 | protected JScrollPane getMessageScrollPanel() { |
| 90 | 0 | if (messageScrollPanel == null) { |
| 91 | 0 | messageScrollPanel = new JScrollPane(); |
| 92 | 0 | messageScrollPanel.setViewportView(getMessagePanel()); |
| 93 | 0 | messageScrollPanel |
| 94 | 0 | .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
| 95 | 0 | messageScrollPanel |
| 96 | 0 | .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
| 97 | 0 | } |
| 98 | 0 | return messageScrollPanel; |
| 99 | } | |
| 100 | ||
| 101 | /** | |
| 102 | * @return Returns the messagePanel. | |
| 103 | */ | |
| 104 | 0 | protected JPanel getMessagePanel() { |
| 105 | 0 | if (messagePanel == null) { |
| 106 | 0 | messagePanel = MessageLogger.getMessagePanel(); |
| 107 | 0 | } |
| 108 | 0 | return messagePanel; |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * @return Returns the buttonPanel. | |
| 113 | */ | |
| 114 | 0 | protected JPanel getButtonPanel() { |
| 115 | 0 | if (buttonPanel == null) { |
| 116 | 0 | buttonPanel = new JPanel(); |
| 117 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("dialog.availableactions")); //$NON-NLS-1$ |
| 118 | 0 | buttonPanel.setBorder(titledBorder); |
| 119 | 0 | buttonPanel.setLayout(new FlowLayout()); |
| 120 | 0 | JButton saveButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$ |
| 121 | 0 | JButton clearButton = new JButton(Messages.getString("button.clear")); //$NON-NLS-1$ |
| 122 | 0 | JButton closeButton = new JButton(Messages.getString("button.close")); //$NON-NLS-1$ |
| 123 | ||
| 124 | 0 | // buttonPanel.add(saveButton); |
| 125 | 0 | buttonPanel.add(clearButton); |
| 126 | 0 | buttonPanel.add(closeButton); |
| 127 | 0 | |
| 128 | 0 | saveButton.addActionListener(new ActionListener() { |
| 129 | public void actionPerformed(ActionEvent arg0) { | |
| 130 | logger.debug("actionPerformed saveButton"); //$NON-NLS-1$ | |
| 131 | } | |
| 132 | }); | |
| 133 | 0 | |
| 134 | 0 | 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 | }); | |
| 141 | 0 | |
| 142 | 0 | closeButton.addActionListener(new ActionListener() { |
| 143 | public void actionPerformed(ActionEvent arg0) { | |
| 144 | logger.debug("actionPerformed closeButton"); //$NON-NLS-1$ | |
| 145 | setVisible(false); | |
| 146 | } | |
| 147 | }); | |
| 148 | ||
| 149 | 0 | } |
| 150 | 0 | return buttonPanel; |
| 151 | } | |
| 152 | ||
| 153 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |