| 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.panel; | |
| 22 | ||
| 23 | import java.awt.BorderLayout; | |
| 24 | import java.awt.GridLayout; | |
| 25 | import java.awt.event.ActionEvent; | |
| 26 | import java.awt.event.ActionListener; | |
| 27 | import java.util.Date; | |
| 28 | 0 | |
| 29 | import javax.swing.ImageIcon; | |
| 30 | 0 | import javax.swing.JButton; |
| 31 | import javax.swing.JFileChooser; | |
| 32 | import javax.swing.JPanel; | |
| 33 | import javax.swing.JTextField; | |
| 34 | import javax.swing.border.TitledBorder; | |
| 35 | ||
| 36 | import org.apache.log4j.Logger; | |
| 37 | ||
| 38 | import ui.Messages; | |
| 39 | import base.ConfigurationManager; | |
| 40 | ||
| 41 | /** | |
| 42 | * @author skunk | |
| 43 | * | |
| 44 | */ | |
| 45 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
| 46 | 0 | public class BackupPanel extends JPanel { |
| 47 | 0 | |
| 48 | 0 | private static final transient Logger logger = Logger |
| 49 | 0 | .getLogger(BackupPanel.class.getName()); |
| 50 | 0 | |
| 51 | /* | |
| 52 | * private final int id; private String name; private String description; | |
| 53 | * private Date date; private String originalBackupDestinationPath; private | |
| 54 | * String currentBackupLocationPath=""; | |
| 55 | */ | |
| 56 | ||
| 57 | private JPanel namePanel; | |
| 58 | ||
| 59 | private JTextField nameTextField; | |
| 60 | ||
| 61 | private JPanel descriptionPanel; | |
| 62 | ||
| 63 | 0 | private JTextField descriptionTextField; |
| 64 | 0 | |
| 65 | 0 | private JPanel datePanel; |
| 66 | ||
| 67 | private Date currentDate; | |
| 68 | 0 | |
| 69 | 0 | private JTextField dateTextField; |
| 70 | 0 | |
| 71 | 0 | private JPanel dbLocationPathPanel; |
| 72 | 0 | |
| 73 | 0 | private JTextField dbLocationPathTextField; |
| 74 | 0 | |
| 75 | private JPanel zipLocationPathPanel; | |
| 76 | ||
| 77 | private JTextField zipLocationPathTextField; | |
| 78 | ||
| 79 | private JButton chooseZipLocationPathButton; | |
| 80 | 0 | |
| 81 | 0 | public BackupPanel() { |
| 82 | 0 | initialize(); |
| 83 | 0 | } |
| 84 | 0 | |
| 85 | 0 | protected void initialize() { |
| 86 | 0 | this.setLayout(new GridLayout(5, 1)); |
| 87 | 0 | this.add(getNamePanel()); |
| 88 | 0 | this.add(getDatePanel()); |
| 89 | 0 | this.add(getDescriptionPanel()); |
| 90 | 0 | this.add(getDbLocationPathPanel()); |
| 91 | 0 | this.add(getZipLocationPathPanel()); |
| 92 | 0 | } |
| 93 | 0 | |
| 94 | 0 | /** |
| 95 | 0 | * @return Returns the datePanel. |
| 96 | 0 | */ |
| 97 | 0 | protected JPanel getDatePanel() { |
| 98 | 0 | if (datePanel == null) { |
| 99 | 0 | datePanel = new JPanel(); |
| 100 | 0 | datePanel.setBorder(new TitledBorder(Messages.getString("common.date"))); //$NON-NLS-1$ |
| 101 | 0 | datePanel.setLayout(new BorderLayout()); |
| 102 | 0 | datePanel.add(getDateTextField(), BorderLayout.CENTER); |
| 103 | 0 | } |
| 104 | 0 | return datePanel; |
| 105 | 0 | } |
| 106 | 0 | |
| 107 | 0 | /** |
| 108 | 0 | * @return Returns the dateTextField. |
| 109 | 0 | */ |
| 110 | 0 | protected JTextField getDateTextField() { |
| 111 | 0 | if (dateTextField == null) { |
| 112 | 0 | dateTextField = new JTextField(); |
| 113 | 0 | dateTextField.setText(getCurrentDate().toString()); |
| 114 | 0 | dateTextField.setEditable(false); |
| 115 | 0 | } |
| 116 | 0 | return dateTextField; |
| 117 | 0 | } |
| 118 | ||
| 119 | 0 | /** |
| 120 | 0 | * @return Returns the descriptionPanel. |
| 121 | */ | |
| 122 | 0 | protected JPanel getDescriptionPanel() { |
| 123 | 0 | if (descriptionPanel == null) { |
| 124 | 0 | descriptionPanel = new JPanel(); |
| 125 | 0 | descriptionPanel.setBorder(new TitledBorder(Messages.getString("common.description"))); //$NON-NLS-1$ |
| 126 | 0 | descriptionPanel.setLayout(new BorderLayout()); |
| 127 | 0 | descriptionPanel |
| 128 | 0 | .add(getDescriptionTextField(), BorderLayout.CENTER); |
| 129 | 0 | } |
| 130 | 0 | return descriptionPanel; |
| 131 | 0 | } |
| 132 | ||
| 133 | 0 | /** |
| 134 | 0 | * @return Returns the descriptionTextField. |
| 135 | */ | |
| 136 | 0 | protected JTextField getDescriptionTextField() { |
| 137 | 0 | if (descriptionTextField == null) { |
| 138 | 0 | descriptionTextField = new JTextField(); |
| 139 | 0 | } |
| 140 | 0 | return descriptionTextField; |
| 141 | 0 | } |
| 142 | ||
| 143 | /** | |
| 144 | * @return Returns the zipLocationPathPanel. | |
| 145 | */ | |
| 146 | 0 | protected JPanel getZipLocationPathPanel() { |
| 147 | 0 | if (zipLocationPathPanel == null) { |
| 148 | 0 | zipLocationPathPanel = new JPanel(); |
| 149 | 0 | zipLocationPathPanel.setBorder(new TitledBorder( |
| 150 | 0 | Messages.getString("panel.backuppanel.zippedarchivedestinationpath"))); //$NON-NLS-1$ |
| 151 | 0 | zipLocationPathPanel.setLayout(new BorderLayout()); |
| 152 | 0 | zipLocationPathPanel.add(getZipLocationPathTextField(), |
| 153 | 0 | BorderLayout.CENTER); |
| 154 | 0 | zipLocationPathPanel.add(getChooseZipLocationPathButton(), |
| 155 | 0 | BorderLayout.EAST); |
| 156 | 0 | } |
| 157 | 0 | return zipLocationPathPanel; |
| 158 | 0 | } |
| 159 | 0 | |
| 160 | /** | |
| 161 | 0 | * @return Returns the zipLocationPathTextField. |
| 162 | 0 | */ |
| 163 | 0 | protected JTextField getZipLocationPathTextField() { |
| 164 | 0 | if (zipLocationPathTextField == null) { |
| 165 | 0 | zipLocationPathTextField = new JTextField(); |
| 166 | 0 | zipLocationPathTextField.setEditable(false); |
| 167 | 0 | } |
| 168 | 0 | return zipLocationPathTextField; |
| 169 | 0 | } |
| 170 | ||
| 171 | /** | |
| 172 | 0 | * @return Returns the dbLocationPathPanel. |
| 173 | 0 | */ |
| 174 | 0 | protected JPanel getDbLocationPathPanel() { |
| 175 | 0 | if (dbLocationPathPanel == null) { |
| 176 | 0 | dbLocationPathPanel = new JPanel(); |
| 177 | 0 | dbLocationPathPanel |
| 178 | 0 | .setBorder(new TitledBorder(Messages.getString("panel.backuppanel.envolveddatabase"))); //$NON-NLS-1$ |
| 179 | 0 | dbLocationPathPanel.setLayout(new BorderLayout()); |
| 180 | 0 | dbLocationPathPanel.add(getDbLocationPathTextField(), |
| 181 | 0 | BorderLayout.CENTER); |
| 182 | 0 | } |
| 183 | 0 | return dbLocationPathPanel; |
| 184 | 0 | } |
| 185 | 0 | |
| 186 | 0 | /** |
| 187 | 0 | * @return Returns the dbLocationPathTextField. |
| 188 | 0 | */ |
| 189 | 0 | protected JTextField getDbLocationPathTextField() { |
| 190 | 0 | if (dbLocationPathTextField == null) { |
| 191 | 0 | dbLocationPathTextField = new JTextField(); |
| 192 | 0 | dbLocationPathTextField.setText(ConfigurationManager.getInstance() |
| 193 | 0 | .getDataBasePath()); |
| 194 | 0 | dbLocationPathTextField.setEditable(false); |
| 195 | 0 | } |
| 196 | 0 | return dbLocationPathTextField; |
| 197 | 0 | } |
| 198 | 0 | |
| 199 | 0 | /** |
| 200 | 0 | * @return Returns the namePanel. |
| 201 | */ | |
| 202 | 0 | protected JPanel getNamePanel() { |
| 203 | 0 | if (namePanel == null) { |
| 204 | 0 | namePanel = new JPanel(); |
| 205 | 0 | namePanel.setBorder(new TitledBorder(Messages.getString("common.name"))); //$NON-NLS-1$ |
| 206 | 0 | namePanel.setLayout(new BorderLayout()); |
| 207 | 0 | namePanel.add(getNameTextField(), BorderLayout.CENTER); |
| 208 | 0 | } |
| 209 | 0 | return namePanel; |
| 210 | 0 | } |
| 211 | 0 | |
| 212 | 0 | /** |
| 213 | * @return Returns the nameTextField. | |
| 214 | 0 | */ |
| 215 | 0 | protected JTextField getNameTextField() { |
| 216 | 0 | if (nameTextField == null) { |
| 217 | 0 | nameTextField = new JTextField(); |
| 218 | 0 | nameTextField.setText(Messages.getString("common.backup")); //$NON-NLS-1$ |
| 219 | 0 | } |
| 220 | 0 | return nameTextField; |
| 221 | 0 | } |
| 222 | ||
| 223 | /** | |
| 224 | * @return Returns the chooseZipLocationPathButton. | |
| 225 | */ | |
| 226 | 0 | protected JButton getChooseZipLocationPathButton() { |
| 227 | 0 | if (chooseZipLocationPathButton == null) { |
| 228 | 0 | chooseZipLocationPathButton = new JButton(); |
| 229 | 0 | chooseZipLocationPathButton.setToolTipText(Messages.getString("common.choosefolder")); //$NON-NLS-1$ |
| 230 | 0 | chooseZipLocationPathButton.setIcon(new ImageIcon(this.getClass() |
| 231 | 0 | .getResource("/icon/16x16/actions/document-open.png"))); //$NON-NLS-1$ |
| 232 | 0 | chooseZipLocationPathButton.addActionListener(new ActionListener() { |
| 233 | 0 | public void actionPerformed(ActionEvent arg0) { |
| 234 | logger.debug("actionPerformed chooseZipLocationPathButton"); //$NON-NLS-1$ | |
| 235 | JFileChooser chooser = new JFileChooser(); | |
| 236 | 0 | chooser |
| 237 | .setDialogTitle(Messages.getString("panel.backuppanel.message1")); //$NON-NLS-1$ | |
| 238 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | |
| 239 | chooser.setApproveButtonText(Messages.getString("button.select")); //$NON-NLS-1$ | |
| 240 | if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { | |
| 241 | getZipLocationPathTextField().setText( | |
| 242 | chooser.getSelectedFile().getPath()); | |
| 243 | 0 | } |
| 244 | } | |
| 245 | }); | |
| 246 | 0 | } |
| 247 | 0 | return chooseZipLocationPathButton; |
| 248 | 0 | } |
| 249 | ||
| 250 | 0 | /** |
| 251 | * @return The backup's date. | |
| 252 | */ | |
| 253 | 0 | public Date getBackupDate() { |
| 254 | 0 | return this.getCurrentDate(); |
| 255 | 0 | } |
| 256 | ||
| 257 | 0 | /** |
| 258 | * @return The backup's name. | |
| 259 | */ | |
| 260 | 0 | public String getBackupName() { |
| 261 | 0 | return this.getNameTextField().getText(); |
| 262 | 0 | } |
| 263 | ||
| 264 | 0 | /** |
| 265 | * @return The backup's description. | |
| 266 | */ | |
| 267 | 0 | public String getBackupDescription() { |
| 268 | 0 | return this.getDescriptionTextField().getText(); |
| 269 | 0 | } |
| 270 | ||
| 271 | 0 | /** |
| 272 | 0 | * @return The backup's database location path. |
| 273 | */ | |
| 274 | 0 | public String getDbLocationPath() { |
| 275 | 0 | return this.getDbLocationPathTextField().getText(); |
| 276 | 0 | } |
| 277 | ||
| 278 | /** | |
| 279 | * @return The compressed backup file's path. | |
| 280 | */ | |
| 281 | 0 | public String getZipLocationPath() { |
| 282 | 0 | return this.getZipLocationPathTextField().getText(); |
| 283 | 0 | } |
| 284 | ||
| 285 | /** | |
| 286 | * @return Returns the currentDate. | |
| 287 | */ | |
| 288 | 0 | protected Date getCurrentDate() { |
| 289 | 0 | if (currentDate == null) { |
| 290 | 0 | currentDate = new Date(); |
| 291 | 0 | } |
| 292 | 0 | return currentDate; |
| 293 | 0 | } |
| 294 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |