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 | ||
21 | package ui.dialog; | |
22 | ||
23 | import java.awt.BorderLayout; | |
24 | import java.awt.Dimension; | |
25 | 0 | import java.awt.GridLayout; |
26 | import java.awt.Toolkit; | |
27 | 0 | import java.awt.event.ActionEvent; |
28 | import java.awt.event.ActionListener; | |
29 | ||
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 | 0 | import ui.command.CommandExecutor; |
39 | 0 | import ui.command.IO.SaveBackupCommand; |
40 | 0 | import ui.panel.BackupPanel; |
41 | ||
42 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
43 | 0 | public class BackupDialog extends JDialog { |
44 | 0 | |
45 | 0 | private static final transient Logger logger = Logger |
46 | 0 | .getLogger(BackupDialog.class.getName()); |
47 | 0 | |
48 | 0 | private BackupPanel backupPanel; |
49 | 0 | |
50 | private JPanel buttonPanel; | |
51 | 0 | |
52 | 0 | private JButton saveButton; |
53 | ||
54 | 0 | private JButton closeButton; |
55 | 0 | |
56 | 0 | public BackupDialog() { |
57 | 0 | initialize(); |
58 | 0 | } |
59 | 0 | |
60 | 0 | protected void initialize() { |
61 | 0 | this.setResizable(false); |
62 | 0 | this.setSize(300, 400); |
63 | 0 | // Center the dialog |
64 | 0 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
65 | 0 | Dimension frameSize = this.getSize(); |
66 | 0 | if (frameSize.height > screenSize.height) { |
67 | 0 | frameSize.height = screenSize.height; |
68 | 0 | } |
69 | 0 | if (frameSize.width > screenSize.width) { |
70 | 0 | frameSize.width = screenSize.width; |
71 | 0 | } |
72 | 0 | this.setLocation((screenSize.width - frameSize.width) / 2, |
73 | 0 | (screenSize.height - frameSize.height) / 2); |
74 | 0 | |
75 | 0 | this.setLayout(new BorderLayout()); |
76 | 0 | this.add(getBackupPanel(), BorderLayout.CENTER); |
77 | 0 | this.add(getButtonPanel(), BorderLayout.SOUTH); |
78 | 0 | } |
79 | 0 | |
80 | 0 | /** |
81 | 0 | * @return Returns the backupPanel. |
82 | */ | |
83 | 0 | protected BackupPanel getBackupPanel() { |
84 | 0 | if (backupPanel == null) { |
85 | 0 | backupPanel = new BackupPanel(); |
86 | 0 | } |
87 | 0 | return backupPanel; |
88 | } | |
89 | ||
90 | 0 | /** |
91 | 0 | * @return Returns the buttonPanel. |
92 | 0 | */ |
93 | 0 | protected JPanel getButtonPanel() { |
94 | 0 | if (buttonPanel == null) { |
95 | 0 | buttonPanel = new JPanel(); |
96 | 0 | buttonPanel.setBorder(new TitledBorder(Messages.getString("dialog.availableactions"))); //$NON-NLS-1$ |
97 | 0 | buttonPanel.setLayout(new GridLayout(1, 2)); |
98 | 0 | buttonPanel.add(getSaveButton()); |
99 | 0 | buttonPanel.add(getCloseButton()); |
100 | 0 | } |
101 | 0 | return buttonPanel; |
102 | } | |
103 | ||
104 | /** | |
105 | * @return Returns the closeButton. | |
106 | 0 | */ |
107 | 0 | protected JButton getCloseButton() { |
108 | 0 | if (closeButton == null) { |
109 | 0 | closeButton = new JButton(Messages.getString("button.close")); //$NON-NLS-1$ |
110 | 0 | closeButton.addActionListener(new ActionListener() { |
111 | public void actionPerformed(ActionEvent arg0) { | |
112 | logger.debug("actionPerformed closeButton"); //$NON-NLS-1$ | |
113 | setVisible(false); | |
114 | } | |
115 | }); | |
116 | 0 | } |
117 | 0 | return closeButton; |
118 | } | |
119 | ||
120 | /** | |
121 | * @return Returns the saveButton. | |
122 | */ | |
123 | 0 | protected JButton getSaveButton() { |
124 | 0 | if (saveButton == null) { |
125 | 0 | saveButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$ |
126 | 0 | saveButton.addActionListener(new ActionListener() { |
127 | public void actionPerformed(ActionEvent arg0) { | |
128 | logger.debug("actionPerformed saveButton"); //$NON-NLS-1$ | |
129 | CommandExecutor.getInstance().executeCommand( | |
130 | new SaveBackupCommand(getBackupPanel()), false); | |
131 | setVisible(false); | |
132 | } | |
133 | }); | |
134 | 0 | } |
135 | 0 | return saveButton; |
136 | } | |
137 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |