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.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 | ||
42 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
43 | 0 | public class SessionDialog extends JDialog { |
44 | 0 | |
45 | 0 | private static final transient Logger logger = Logger |
46 | 0 | .getLogger(SessionDialog.class.getName()); |
47 | ||
48 | private JPanel contentPanel; | |
49 | ||
50 | private JPanel buttonPanel; | |
51 | ||
52 | private JButton saveSessionButton; | |
53 | ||
54 | private SessionPanel sessionPanel; | |
55 | 0 | |
56 | 0 | private Session session; |
57 | 0 | |
58 | 0 | public SessionDialog(Session session) { |
59 | 0 | this.session = session; |
60 | 0 | initialize(); |
61 | 0 | } |
62 | ||
63 | 0 | protected void initialize() { |
64 | 0 | this.setResizable(false); |
65 | 0 | this.setSize(550, 600); |
66 | 0 | // Center the dialog |
67 | 0 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
68 | 0 | Dimension frameSize = this.getSize(); |
69 | 0 | if (frameSize.height > screenSize.height) { |
70 | 0 | frameSize.height = screenSize.height; |
71 | 0 | } |
72 | 0 | if (frameSize.width > screenSize.width) { |
73 | 0 | frameSize.width = screenSize.width; |
74 | 0 | } |
75 | 0 | this.setLocation((screenSize.width - frameSize.width) / 2, |
76 | 0 | (screenSize.height - frameSize.height) / 2); |
77 | 0 | |
78 | 0 | this.setContentPane(getContentPanel()); |
79 | 0 | this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); |
80 | 0 | } |
81 | ||
82 | /** | |
83 | * @return Returns the contentPanel. | |
84 | */ | |
85 | 0 | protected JPanel getContentPanel() { |
86 | 0 | if (contentPanel == null) { |
87 | 0 | contentPanel = new JPanel(); |
88 | 0 | contentPanel.setLayout(new BorderLayout()); |
89 | 0 | contentPanel.add(getSessionPanel(), BorderLayout.CENTER); |
90 | 0 | contentPanel.add(getButtonPanel(), BorderLayout.SOUTH); |
91 | 0 | } |
92 | 0 | return contentPanel; |
93 | } | |
94 | ||
95 | /** | |
96 | * @return Returns the sessionPanel. | |
97 | */ | |
98 | 0 | protected SessionPanel getSessionPanel() { |
99 | 0 | if (sessionPanel == null) { |
100 | 0 | sessionPanel = new SessionPanel(session); |
101 | 0 | } |
102 | 0 | return sessionPanel; |
103 | } | |
104 | ||
105 | /** | |
106 | * @return Returns the buttonPanel. | |
107 | */ | |
108 | 0 | protected JPanel getButtonPanel() { |
109 | 0 | if (buttonPanel == null) { |
110 | 0 | buttonPanel = new JPanel(); |
111 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("dialog.availableactions")); //$NON-NLS-1$ |
112 | 0 | buttonPanel.setBorder(titledBorder); |
113 | 0 | buttonPanel.setLayout(new GridLayout(1, 3)); |
114 | 0 | buttonPanel.add(new JLabel("")); //$NON-NLS-1$ |
115 | 0 | buttonPanel.add(getSaveSessionButton()); |
116 | 0 | buttonPanel.add(new JLabel("")); //$NON-NLS-1$ |
117 | 0 | } |
118 | 0 | return buttonPanel; |
119 | } | |
120 | ||
121 | /** | |
122 | * @return Returns the saveSessionButton. | |
123 | */ | |
124 | 0 | protected JButton getSaveSessionButton() { |
125 | 0 | if (saveSessionButton == null) { |
126 | 0 | saveSessionButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$ |
127 | 0 | saveSessionButton.setIcon(new ImageIcon(this.getClass() |
128 | 0 | .getResource("/icon/16x16/actions/document-save.png"))); //$NON-NLS-1$ |
129 | 0 | |
130 | 0 | 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 | }); | |
140 | 0 | } |
141 | 0 | return saveSessionButton; |
142 | } | |
143 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |