View Javadoc

1   package org.lcsim.plugin;
2   
3   import java.io.IOException;
4   import javax.swing.JOptionPane;
5   import org.freehep.application.studio.Studio;
6   import org.freehep.swing.ErrorDialog;
7   import org.freehep.swing.ExtensionFileFilter;
8   import org.lcsim.util.loop.StdhepEventSource;
9   
10  /**
11   *
12   * @author tonyj
13   */
14  class StdhepFileSelector extends FileSelector
15  {
16     private Studio app;
17     /** Creates a new instance of LCSimFileSelector */
18     public StdhepFileSelector(Studio app)
19     {
20        super(app,"Stdhep","stdhep.filelist",new ExtensionFileFilter("stdhep","Stdhep File"),new ExtensionFileFilter("stdhep.filelist","Stdhep File List"));
21        this.app = app;
22     }
23     
24     public void onFinish()
25     {
26        try
27        {
28           Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sidaug05");
29           StdhepEventSource source = isMultiFileSelected() ? new StdhepEventSource(getSelectedFiles(),detectorName.toString()) : new StdhepEventSource(getSelectedFile(),detectorName.toString());
30           app.getLookup().add(source);
31           super.onFinish();
32        }
33        catch (IOException x)
34        {
35           ErrorDialog.showErrorDialog(this,"Error saving file list",x);
36        }
37     }
38  }