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 import org.lcsim.util.loop.FileList;
12 import org.lcsim.util.loop.StdhepEventSource;
13
14
15
16
17
18
19
20 class StdhepFileListHandler implements FileHandler
21 {
22 private Studio app;
23 StdhepFileListHandler(Studio app)
24 {
25 this.app = app;
26 }
27 public boolean accept(File file) throws IOException
28 {
29 return file.getName().endsWith(".stdhep.filelist");
30 }
31
32 public FileFilter getFileFilter()
33 {
34 return new ExtensionFileFilter(".stdhep.filelist","Stdhep File List");
35 }
36
37 public void openFile(File file) throws IOException
38 {
39 Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sidaug05");
40 FileList fileList = new FileList(file,"Stdhep File List");
41 StdhepEventSource source = new StdhepEventSource(fileList,detectorName.toString());
42 app.getLookup().add(source);
43 }
44 }