KickJava   Java API By Example, From Geeks To Geeks.

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


1 package SnowMailClient.view.actions;
2
3 import SnowMailClient.model.accounts.*;
4 import SnowMailClient.utils.storage.*;
5 import snow.utils.gui.*;
6
7 import SnowMailClient.view.accounts.*;
8 import SnowMailClient.SnowMailClientApp;
9 import SnowMailClient.Language.Language;
10
11 import java.awt.*;
12 import java.awt.event.*;
13 import javax.swing.*;
14 import javax.swing.event.*;
15 import javax.swing.tree.*;
16 import javax.swing.border.*;
17 import java.io.*;
18
19 public class ExportStatisticsAction extends AbstractAction
20 {
21
22   public ExportStatisticsAction()
23   {
24      super(Language.translate("Export SPAM word statistics to file"));
25
26
27
28   } // Constructor
29

30
31   public void actionPerformed(ActionEvent e)
32   {
33      FileField destinationDir = new FileField("c:/data/SnowMailWordStatExport.txt",
34         true,
35         Language.translate("Select the file to export the statistics"), JFileChooser.FILES_ONLY);
36
37      JDialog dialog = new JDialog(SnowMailClientApp.getInstance(), Language.translate("Statistics file export"), true);
38      dialog.getContentPane().setLayout(new BorderLayout());
39
40      // south
41
//
42
CloseControlPanel ccp = new CloseControlPanel(dialog, true, true, Language.translate("Close"));
43      dialog.getContentPane().add(ccp, BorderLayout.SOUTH);
44
45      // center
46
//
47

48      JPanel inputPanel = new JPanel();
49      GridLayout3 gl = new GridLayout3(2,inputPanel);
50      inputPanel.setBorder(new EmptyBorder(5,5,5,5));
51      dialog.getContentPane().add(SnowMailClientApp.wrapLeft(inputPanel), BorderLayout.CENTER);
52      gl.add(new JContrastLabel(Language.translate("Destination file")+" "), false);
53      gl.add(destinationDir, true);
54
55
56      dialog.pack();
57      SnowMailClientApp.centerComponentOnMainFrame(dialog);
58      dialog.setVisible(true);
59
60      if(!ccp.getWasCancelled())
61      {
62        final File file = destinationDir.getPath();
63        if(file!=null)
64        {
65           Thread JavaDoc t = new Thread JavaDoc()
66           {
67             public void run()
68             {
69               try
70               {
71                  SnowMailClientApp.getInstance().getWordStatistic().exportStatToFile(file);
72               }
73               catch(Exception JavaDoc e)
74               {
75                  e.printStackTrace();
76               }
77             }
78           };
79           t.setPriority(Thread.NORM_PRIORITY-1);
80           t.start();
81
82
83        }
84      }
85
86   }
87
88
89 } // ExportStatisticsAction
Popular Tags