| 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.JPanel; | |
| 33 | import javax.swing.border.TitledBorder; | |
| 34 | ||
| 35 | import org.apache.log4j.Logger; | |
| 36 | ||
| 37 | import ui.Messages; | |
| 38 | import ui.command.CommandExecutor; | |
| 39 | import ui.command.IO.SaveEAddressCommand; | |
| 40 | import ui.panel.EAddressPanel; | |
| 41 | import base.user.EAddress; | |
| 42 | import base.user.User; | |
| 43 | ||
| 44 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
| 45 | 0 | public class EAddressDialog extends JDialog { |
| 46 | 0 | |
| 47 | 0 | private static final transient Logger logger = Logger |
| 48 | 0 | .getLogger(EAddressDialog.class.getName()); |
| 49 | ||
| 50 | private EAddressPanel eAddressPanel; | |
| 51 | ||
| 52 | private JPanel buttonPanel; | |
| 53 | ||
| 54 | private JButton saveAddressButton; | |
| 55 | ||
| 56 | private JButton clearAddressDataButton; | |
| 57 | 0 | |
| 58 | 0 | private final User user; |
| 59 | ||
| 60 | private EAddress eAddress; | |
| 61 | 0 | |
| 62 | 0 | public EAddressDialog(User user) { |
| 63 | 0 | this.user = user; |
| 64 | 0 | initialize(); |
| 65 | 0 | } |
| 66 | 0 | |
| 67 | 0 | public EAddressDialog(User user, EAddress eAddress) { |
| 68 | 0 | this.user = user; |
| 69 | 0 | this.eAddress = eAddress; |
| 70 | 0 | initialize(); |
| 71 | 0 | } |
| 72 | ||
| 73 | 0 | protected void initialize() { |
| 74 | 0 | this.setResizable(false); |
| 75 | 0 | this.setSize(300, 300); |
| 76 | 0 | // Center the dialog |
| 77 | 0 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
| 78 | 0 | Dimension frameSize = this.getSize(); |
| 79 | 0 | if (frameSize.height > screenSize.height) { |
| 80 | 0 | frameSize.height = screenSize.height; |
| 81 | 0 | } |
| 82 | 0 | if (frameSize.width > screenSize.width) { |
| 83 | 0 | frameSize.width = screenSize.width; |
| 84 | 0 | } |
| 85 | 0 | this.setLocation((screenSize.width - frameSize.width) / 2, |
| 86 | 0 | (screenSize.height - frameSize.height) / 2); |
| 87 | 0 | |
| 88 | 0 | this.setLayout(new BorderLayout()); |
| 89 | 0 | this.add(getEAddressPanel(), BorderLayout.CENTER); |
| 90 | 0 | this.add(getButtonPanel(), BorderLayout.SOUTH); |
| 91 | 0 | } |
| 92 | ||
| 93 | /** | |
| 94 | * @return Returns the buttonPanel. | |
| 95 | */ | |
| 96 | 0 | protected JPanel getButtonPanel() { |
| 97 | 0 | if (buttonPanel == null) { |
| 98 | 0 | buttonPanel = new JPanel(); |
| 99 | 0 | buttonPanel.setBorder(new TitledBorder(Messages.getString("dialog.availableactions"))); //$NON-NLS-1$ |
| 100 | 0 | buttonPanel.setLayout(new GridLayout(1, 2)); |
| 101 | 0 | buttonPanel.add(getSaveAddressButton()); |
| 102 | 0 | buttonPanel.add(getClearAddressDataButton()); |
| 103 | 0 | } |
| 104 | 0 | return buttonPanel; |
| 105 | } | |
| 106 | ||
| 107 | /** | |
| 108 | * @return Returns the saveAddressButton. | |
| 109 | */ | |
| 110 | 0 | protected JButton getSaveAddressButton() { |
| 111 | 0 | if (saveAddressButton == null) { |
| 112 | 0 | saveAddressButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$ |
| 113 | 0 | saveAddressButton.setIcon(new ImageIcon(this.getClass() |
| 114 | 0 | .getResource("/icon/16x16/actions/document-save.png"))); //$NON-NLS-1$ |
| 115 | 0 | |
| 116 | 0 | saveAddressButton.addActionListener(new ActionListener() { |
| 117 | public void actionPerformed(ActionEvent arg0) { | |
| 118 | logger.debug("actionPerformed saveAddressButton"); //$NON-NLS-1$ | |
| 119 | CommandExecutor.getInstance().executeCommand( | |
| 120 | new SaveEAddressCommand(user, getEAddressPanel()), | |
| 121 | false); | |
| 122 | setVisible(false); | |
| 123 | } | |
| 124 | }); | |
| 125 | 0 | } |
| 126 | 0 | return saveAddressButton; |
| 127 | } | |
| 128 | ||
| 129 | /** | |
| 130 | * @return Returns the clearAddressDataButton. | |
| 131 | */ | |
| 132 | 0 | protected JButton getClearAddressDataButton() { |
| 133 | 0 | if (clearAddressDataButton == null) { |
| 134 | 0 | clearAddressDataButton = new JButton(Messages.getString("button.clear")); //$NON-NLS-1$ |
| 135 | 0 | clearAddressDataButton.setIcon(new ImageIcon(this.getClass() |
| 136 | 0 | .getResource("/icon/16x16/actions/view-refresh.png"))); //$NON-NLS-1$ |
| 137 | 0 | |
| 138 | 0 | clearAddressDataButton.addActionListener(new ActionListener() { |
| 139 | public void actionPerformed(ActionEvent arg0) { | |
| 140 | logger.debug("actionPerformed clearAddressDataButton"); //$NON-NLS-1$ | |
| 141 | } | |
| 142 | }); | |
| 143 | 0 | } |
| 144 | 0 | return clearAddressDataButton; |
| 145 | } | |
| 146 | ||
| 147 | /** | |
| 148 | * @return Returns the eAddressPanel. | |
| 149 | */ | |
| 150 | 0 | protected EAddressPanel getEAddressPanel() { |
| 151 | 0 | if (eAddressPanel == null) { |
| 152 | 0 | eAddressPanel = new EAddressPanel(eAddress != null ? eAddress |
| 153 | 0 | : (eAddress = user.newEAddress(Messages.getString("eaddress.default.eaddress")))); //$NON-NLS-1$ |
| 154 | 0 | } |
| 155 | 0 | return eAddressPanel; |
| 156 | } | |
| 157 | ||
| 158 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |