View Javadoc

1   package org.lcsim.plugin;
2   
3   import org.freehep.application.studio.Studio;
4   import org.freehep.swing.ExtensionFileFilter;
5   
6   import javax.swing.filechooser.FileFilter;
7   import java.io.File;
8   import java.io.IOException;
9   import javax.swing.JOptionPane;
10  import org.freehep.jas.services.FileHandler;
11  
12  import org.lcsim.util.loop.StdhepEventSource;
13  
14  /**
15   * A file handler for LCIO files.
16   * @author tonyj
17   * @version $Id: StdhepFileHandler.java,v 1.3 2007/03/15 06:39:39 tonyj Exp $
18   */
19  
20  class StdhepFileHandler implements FileHandler
21  {
22     private Studio app;
23     StdhepFileHandler(Studio app)
24     {
25        this.app = app;
26     }
27  
28     public boolean accept(File file) throws IOException
29     {
30        return file.getName().endsWith(".stdhep");
31     }
32  
33     public FileFilter getFileFilter()
34     {
35        return new ExtensionFileFilter("stdhep","Stdhep Files");
36     }
37  
38     public void openFile(File file) throws IOException
39     {
40        Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sidaug05");
41        StdhepEventSource source = new StdhepEventSource(file,detectorName.toString());
42  
43        app.getLookup().add(source);
44     }   
45  }