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.JButton; | |
30 | import javax.swing.JDialog; | |
31 | import javax.swing.JLabel; | |
32 | import javax.swing.JPanel; | |
33 | import javax.swing.border.TitledBorder; | |
34 | ||
35 | import org.apache.log4j.Logger; | |
36 | ||
37 | import ui.Messages; | |
38 | import ui.panel.UserAddressBookPanel; | |
39 | import base.user.User; | |
40 | ||
41 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
42 | 0 | public class UserAddressBookDialog extends JDialog { |
43 | 0 | |
44 | 0 | private static final transient Logger logger = Logger |
45 | 0 | .getLogger(UserAddressBookDialog.class.getName()); |
46 | ||
47 | private JPanel contentPanel; | |
48 | ||
49 | private UserAddressBookPanel userAddressBookPanel; | |
50 | ||
51 | private JPanel buttonPanel; | |
52 | ||
53 | private JButton closeButton; | |
54 | ||
55 | private final User user; | |
56 | 0 | |
57 | 0 | public UserAddressBookDialog(User user) { |
58 | 0 | this.user = user; |
59 | 0 | initialize(); |
60 | 0 | } |
61 | ||
62 | 0 | protected void initialize() { |
63 | 0 | this.setResizable(false); |
64 | 0 | this.setSize(550, 600); |
65 | 0 | // Center the dialog |
66 | 0 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
67 | 0 | Dimension frameSize = this.getSize(); |
68 | 0 | if (frameSize.height > screenSize.height) { |
69 | 0 | frameSize.height = screenSize.height; |
70 | 0 | } |
71 | 0 | if (frameSize.width > screenSize.width) { |
72 | 0 | frameSize.width = screenSize.width; |
73 | 0 | } |
74 | 0 | this.setLocation((screenSize.width - frameSize.width) / 2, |
75 | 0 | (screenSize.height - frameSize.height) / 2); |
76 | 0 | |
77 | 0 | this.setContentPane(getContentPanel()); |
78 | 0 | this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); |
79 | 0 | } |
80 | ||
81 | /** | |
82 | * @return Returns the contentPanel. | |
83 | */ | |
84 | 0 | protected JPanel getContentPanel() { |
85 | 0 | if (contentPanel == null) { |
86 | 0 | contentPanel = new JPanel(); |
87 | 0 | contentPanel.setLayout(new BorderLayout()); |
88 | 0 | contentPanel.add(getUserAddressBookPanel(), BorderLayout.CENTER); |
89 | 0 | contentPanel.add(getButtonPanel(), BorderLayout.SOUTH); |
90 | 0 | } |
91 | 0 | return contentPanel; |
92 | } | |
93 | ||
94 | /** | |
95 | * @return Returns the buttonPanel. | |
96 | */ | |
97 | 0 | protected JPanel getButtonPanel() { |
98 | 0 | if (buttonPanel == null) { |
99 | 0 | buttonPanel = new JPanel(); |
100 | 0 | buttonPanel.setBorder(new TitledBorder(Messages.getString("dialog.availableactions"))); //$NON-NLS-1$ |
101 | 0 | buttonPanel.setLayout(new GridLayout(1, 3)); |
102 | 0 | buttonPanel.add(new JLabel("")); //$NON-NLS-1$ |
103 | 0 | buttonPanel.add(getCloseButton()); |
104 | 0 | buttonPanel.add(new JLabel("")); //$NON-NLS-1$ |
105 | ||
106 | 0 | } |
107 | 0 | return buttonPanel; |
108 | } | |
109 | ||
110 | /** | |
111 | * @return Returns the userAddressBookPanel. | |
112 | */ | |
113 | 0 | protected UserAddressBookPanel getUserAddressBookPanel() { |
114 | 0 | if (userAddressBookPanel == null) { |
115 | 0 | userAddressBookPanel = new UserAddressBookPanel(getUser()); |
116 | 0 | } |
117 | 0 | return userAddressBookPanel; |
118 | } | |
119 | ||
120 | /** | |
121 | * @return Returns the user. | |
122 | */ | |
123 | 0 | protected User getUser() { |
124 | 0 | return user; |
125 | } | |
126 | ||
127 | /** | |
128 | * @return Returns the closeButton. | |
129 | */ | |
130 | 0 | protected JButton getCloseButton() { |
131 | 0 | if (closeButton == null) { |
132 | 0 | closeButton = new JButton(Messages.getString("button.close")); //$NON-NLS-1$ |
133 | // closeButton.setIcon(new | |
134 | 0 | // ImageIcon(this.getClass().getResource("/icon/16x16/actions/window-close.png"))); |
135 | 0 | closeButton.addActionListener(new ActionListener() { |
136 | public void actionPerformed(ActionEvent arg0) { | |
137 | logger.debug("actionPerformed closeButton"); //$NON-NLS-1$ | |
138 | setVisible(false); | |
139 | } | |
140 | }); | |
141 | 0 | } |
142 | 0 | return closeButton; |
143 | } | |
144 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |