View Javadoc

1   /*
2    * Jour - java profiler and monitoring library
3    *
4    * Copyright (C) 2004 Jour team
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Library General Public
8    * License as published by the Free Software Foundation; either
9    * version 2 of the License, or (at your option) any later version.
10   *
11   * This library 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 GNU
14   * Library General Public License for more details.
15   *
16   * You should have received a copy of the GNU Library General Public
17   * License along with this library; if not, write to the
18   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19   * Boston, MA  02111-1307, USA.
20   */
21  package net.sf.jour.rt.swingmonitor.ui.action;
22  
23  import java.awt.Component;
24  import java.awt.event.ActionEvent;
25  import java.awt.event.ActionListener;
26  import java.io.File;
27  
28  import javax.swing.JFileChooser;
29  
30  import net.sf.jour.rt.RtProperties;
31  import net.sf.jour.rt.agent.BulkEventFileReader;
32  import net.sf.jour.rt.agent.EventProcessor;
33  
34  //import org.apache.log4j.Logger;
35  
36  /***
37   * Opend data folders and reset current statistics.
38   *
39   * Created on 14.12.2004
40   * Contributing Author(s):
41   *
42   *   Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
43   *   Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
44   *
45   * @author vlads
46   * @version $Revision: 1.2 $ ($Author: vlads $)  $Date: 2004/12/16 05:35:55 $
47   */
48  public class MonitorDataFolderAction implements ActionListener {
49  
50      Component parent;
51      
52      public MonitorDataFolderAction(Component parent) {
53          this.parent = parent;
54      }
55      /***
56       * Method actionPerformed
57       */
58      public void actionPerformed(ActionEvent e) {
59          RtProperties prop = RtProperties.getInstance(); 
60          File dir = prop.getFolder("BulkEventFileReader.folder", false);
61          if (dir == null) {
62              dir = new File(".");
63          }
64          JFileChooser fc = new JFileChooser(dir);
65          fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
66          fc.setDialogTitle("Select directory containing data files");
67          //c.setF
68          //fc.setSelectedFile(new File(".", filename));
69  
70          if (fc.showOpenDialog(this.parent) == JFileChooser.APPROVE_OPTION) {
71              prop.setProperty("BulkEventFileReader.folder",
72                      fc.getSelectedFile().getAbsolutePath());
73              // TODO make this as option.
74              EventProcessor.getInstance().reset();
75              BulkEventFileReader.start();
76          }
77      }
78  
79  }