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.panel;
21
22 import java.awt.BorderLayout;
23 import java.awt.Dimension;
24 import java.awt.GridLayout;
25 import java.io.File;
26
27 import javax.swing.JPanel;
28 import javax.swing.JTextField;
29 import javax.swing.border.TitledBorder;
30
31 import ui.Messages;
32 import base.ConfigurationManager;
33 import base.backup.BackupFactory;
34
35 @SuppressWarnings("serial")
36 public class BackupConfigurationPanel extends JPanel {
37
38 private JPanel topPanel;
39
40 private JPanel databasePanel;
41
42 private JPanel resourcesPanel;
43
44 private JPanel resourcesPathPanel;
45
46 private JTextField resourcesPathTextField;
47
48 private JPanel resourcesSizePanel;
49
50 private JTextField resourcesSizeTextField;
51
52 private JPanel backUpPanel;
53
54 public BackupConfigurationPanel() {
55 initialize();
56 }
57
58 protected void initialize() {
59 this.setLayout(new BorderLayout());
60 this.add(getTopPanel(), BorderLayout.NORTH);
61 this.add(getBackUpPanel(), BorderLayout.CENTER);
62 }
63
64 /***
65 * @return Returns the backUpPanel.
66 */
67 protected JPanel getBackUpPanel() {
68 if (backUpPanel == null) {
69 backUpPanel = new TabledBackupPanel();
70 }
71 return backUpPanel;
72 }
73
74 /***
75 * @return Returns the resourcesPanel.
76 */
77 protected JPanel getResourcesPanel() {
78 if (resourcesPanel == null) {
79 resourcesPanel = new JPanel();
80 resourcesPanel.setBorder(new TitledBorder(
81 Messages.getString("panel.backupconfigurationpanel.message1")));
82 resourcesPanel.setLayout(new BorderLayout());
83 resourcesPanel.add(getResourcesPathPanel(), BorderLayout.CENTER);
84 resourcesPanel.add(getResourcesSizePanel(), BorderLayout.EAST);
85 }
86 return resourcesPanel;
87 }
88
89 /***
90 * @return Returns the resourcesPathTextField.
91 */
92 protected JTextField getResourcesPathTextField() {
93 if (resourcesPathTextField == null) {
94 resourcesPathTextField = new JTextField();
95 resourcesPathTextField
96 .setText(ConfigurationManager.RESOURCES_DIRECTORY);
97 resourcesPathTextField.setEditable(false);
98 }
99 return resourcesPathTextField;
100 }
101
102 /***
103 * @return Returns the resourcesSizePanel.
104 */
105 protected JPanel getResourcesSizePanel() {
106 if (resourcesSizePanel == null) {
107 resourcesSizePanel = new JPanel();
108 resourcesSizePanel.setBorder(new TitledBorder(Messages.getString("common.size") + " " + Messages.getString("common.unit.kylobyte")));
109 resourcesSizePanel.setPreferredSize(new Dimension(250, 30));
110 resourcesSizePanel.setLayout(new BorderLayout());
111 resourcesSizePanel.add(getResourcesSizeTextField(),
112 BorderLayout.CENTER);
113 }
114 return resourcesSizePanel;
115 }
116
117 /***
118 * @return Returns the resourcesSizeTextField.
119 */
120 protected JTextField getResourcesSizeTextField() {
121 if (resourcesSizeTextField == null) {
122 resourcesSizeTextField = new JTextField();
123 resourcesSizeTextField.setText(""
124 + BackupFactory.fileSizeInKB(new File(
125 ConfigurationManager.RESOURCES_DIRECTORY)));
126 resourcesSizeTextField.setEditable(false);
127 }
128 return resourcesSizeTextField;
129 }
130
131 /***
132 * @return Returns the topPanel.
133 */
134 protected JPanel getTopPanel() {
135 if (topPanel == null) {
136 topPanel = new JPanel();
137 topPanel.setLayout(new GridLayout(2, 1));
138 topPanel.add(getDatabasePanel());
139 topPanel.add(getResourcesPanel());
140 }
141 return topPanel;
142 }
143
144 /***
145 * @return Returns the resourcesPathPanel.
146 */
147 protected JPanel getResourcesPathPanel() {
148 if (resourcesPathPanel == null) {
149 resourcesPathPanel = new JPanel();
150 resourcesPathPanel.setBorder(new TitledBorder(Messages.getString("common.directorypath")));
151 resourcesPathPanel.setLayout(new BorderLayout());
152 resourcesPathPanel.add(getResourcesPathTextField(),
153 BorderLayout.CENTER);
154 }
155 return resourcesPathPanel;
156 }
157
158 /***
159 * @return Returns the databasePanel.
160 */
161 protected JPanel getDatabasePanel() {
162 if (databasePanel == null) {
163 databasePanel = new DatabasePanel();
164 }
165 return databasePanel;
166 }
167 }