KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > view > actions > BackupConfigurationAction


1 package SnowMailClient.view.actions;
2
3 import SnowMailClient.model.accounts.*;
4 import snow.utils.storage.*;
5 import snow.utils.gui.*;
6
7 import SnowMailClient.utils.storage.Backup;
8 import SnowMailClient.view.accounts.*;
9 import SnowMailClient.SnowMailClientApp;
10 import SnowMailClient.Language.Language;
11
12 import java.awt.*;
13 import java.awt.event.*;
14 import javax.swing.*;
15 import javax.swing.event.*;
16 import javax.swing.tree.*;
17 import javax.swing.border.*;
18 import java.io.*;
19
20 public final class BackupConfigurationAction extends AbstractAction
21 {
22
23   public BackupConfigurationAction()
24   {
25      super(Language.translate("Backup Configuration"));
26
27 /* putValue(AbstractAction.SMALL_ICON,
28               SnowMailClientApp.loadImageIcon("pics/receivemail.PNG") );
29
30      putValue(AbstractAction.ACCELERATOR_KEY,
31               KeyStroke.getKeyStroke( KeyEvent.VK_R, KeyEvent.CTRL_MASK ) );*/

32
33      putValue(AbstractAction.SHORT_DESCRIPTION,
34               Language.translate("Configure the backup"));
35
36   } // Constructor
37

38
39   public void actionPerformed(ActionEvent e)
40   {
41      Backup backup = SnowMailClientApp.getInstance().getBackup();
42
43      FileField destinationDir = new FileField(backup.getBackupDestinationDirectory(),
44        true, Language.translate("Select the backup destination directory"), JFileChooser.FILES_AND_DIRECTORIES);
45
46      JCheckBox enableautomaticBackup = new JCheckBox(Language.translate("Enable automatic backups"), backup.isAutomaticBackupEnabled());
47
48      JDialog dialog = new JDialog(SnowMailClientApp.getInstance(), Language.translate("Backup Configuration"), true);
49      dialog.getContentPane().setLayout(new BorderLayout());
50
51      // north
52
//
53
JTextArea textarea = new JTextArea(
54         Language.translate(
55         "The backup makes a copy of all your snowmail data and put in"
56         +"\nthe destination directory at each closing of snowmail."
57         +"\nIt keeps only a clever set of older backups."
58        +"\nAt most one per hour today, one per day for the last week,"
59        +"\none per month for the last month..."
60        +"\nNormally, you don't have to worry about backups,"
61        +"\nthey are working silently in the background and we hope"
62        +"\nyou'll never need one of them. Backups are useful for"
63        +"\ntransferring snowmail from a computer to another."));
64
65      textarea.setBorder(new EmptyBorder(5,5,5,5));
66      textarea.setBackground( dialog.getBackground() );
67
68      textarea.setEditable(false);
69      dialog.getContentPane().add(textarea, BorderLayout.NORTH);
70
71      // south
72
//
73
CloseControlPanel ccp = new CloseControlPanel(dialog, true, true, Language.translate("Validate"));
74      dialog.getContentPane().add(ccp, BorderLayout.SOUTH);
75
76      // center
77
//
78
JPanel inputPanel = new JPanel(new GridLayout(2,2));
79      inputPanel.setBorder(new EmptyBorder(5,5,5,5));
80      dialog.getContentPane().add(SnowMailClientApp.wrapLeft(inputPanel), BorderLayout.CENTER);
81      inputPanel.add(enableautomaticBackup);
82      inputPanel.add(new JPanel());
83      inputPanel.add(new JContrastLabel(Language.translate("Destination Directory")+" "));
84      inputPanel.add(destinationDir);
85
86
87      dialog.pack();
88      SnowMailClientApp.centerComponentOnMainFrame(dialog);
89      dialog.setVisible(true);
90
91      if(!ccp.getWasCancelled())
92      {
93        File file = destinationDir.getPath();
94        if(file!=null)
95        {
96           backup.setBackupDestination(file.getAbsolutePath());
97           backup.setIsAutomaticBackupEnabled(enableautomaticBackup.isSelected());
98        }
99      }
100
101   }
102
103
104 } // BackupConfigurationAction
Popular Tags