Commit in lcsim/src/org/lcsim on MAIN
plugin/StdhepFileSelector.java+381.2 -> 1.3
      /StdhepFileListHandler.java+44added 1.1
      /StdhepDataSource.java+30added 1.1
      /StdhepFileHandler.java+3-31.2 -> 1.3
      /LCSimPlugin.java+4-31.9 -> 1.10
      /FileSelector.form+15-11.1 -> 1.2
      /FileSelector.java+22-181.1 -> 1.2
util/loop/StdhepEventSource.java+97-391.5 -> 1.6
+253-64
2 added + 6 modified, total 8 files
extend file list support to stdhep files

lcsim/src/org/lcsim/plugin
StdhepFileSelector.java 1.2 -> 1.3
diff -N StdhepFileSelector.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StdhepFileSelector.java	15 Mar 2007 06:39:39 -0000	1.3
@@ -0,0 +1,38 @@
+package org.lcsim.plugin;
+
+import java.io.IOException;
+import javax.swing.JOptionPane;
+import org.freehep.application.studio.Studio;
+import org.freehep.swing.ErrorDialog;
+import org.freehep.swing.ExtensionFileFilter;
+import org.lcsim.util.loop.StdhepEventSource;
+
+/**
+ *
+ * @author tonyj
+ */
+class StdhepFileSelector extends FileSelector
+{
+   private Studio app;
+   /** Creates a new instance of LCSimFileSelector */
+   public StdhepFileSelector(Studio app)
+   {
+      super(app,"Stdhep","stdhep.filelist",new ExtensionFileFilter("stdhep","Stdhep File"),new ExtensionFileFilter("stdhep.filelist","Stdhep File List"));
+      this.app = app;
+   }
+   
+   public void onFinish()
+   {
+      try
+      {
+         Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sidaug05");
+         StdhepEventSource source = isMultiFileSelected() ? new StdhepEventSource(getSelectedFiles(),detectorName.toString()) : new StdhepEventSource(getSelectedFile(),detectorName.toString());
+         app.getLookup().add(source);
+         dispose();
+      }
+      catch (IOException x)
+      {
+         ErrorDialog.showErrorDialog(this,"Error saving file list",x);
+      }
+   }
+}

lcsim/src/org/lcsim/plugin
StdhepFileListHandler.java added at 1.1
diff -N StdhepFileListHandler.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StdhepFileListHandler.java	15 Mar 2007 06:39:39 -0000	1.1
@@ -0,0 +1,44 @@
+package org.lcsim.plugin;
+
+import org.freehep.application.studio.Studio;
+import org.freehep.swing.ExtensionFileFilter;
+
+import javax.swing.filechooser.FileFilter;
+import java.io.File;
+import java.io.IOException;
+import javax.swing.JOptionPane;
+import org.freehep.jas.services.FileHandler;
+import org.lcsim.util.loop.FileList;
+import org.lcsim.util.loop.StdhepEventSource;
+
+/**
+ * A file handler for LCIO file lists.
+ * @author tonyj
+ * @version $Id: StdhepFileListHandler.java,v 1.1 2007/03/15 06:39:39 tonyj Exp $
+ */
+
+class StdhepFileListHandler implements FileHandler
+{
+   private Studio app;
+   StdhepFileListHandler(Studio app)
+   {
+      this.app = app;
+   }
+   public boolean accept(File file) throws IOException
+   {
+      return file.getName().endsWith(".stdhep.filelist");
+   }
+   
+   public FileFilter getFileFilter()
+   {
+      return new ExtensionFileFilter(".stdhep.filelist","Stdhep File List");
+   }
+
+   public void openFile(File file) throws IOException
+   {
+      Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sidaug05");
+      FileList fileList = new FileList(file,"Stdhep File List");
+      StdhepEventSource source = new StdhepEventSource(fileList,detectorName.toString());
+      app.getLookup().add(source);
+   }   
+}
\ No newline at end of file

lcsim/src/org/lcsim/plugin
StdhepDataSource.java added at 1.1
diff -N StdhepDataSource.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StdhepDataSource.java	15 Mar 2007 06:39:39 -0000	1.1
@@ -0,0 +1,30 @@
+package org.lcsim.plugin;
+
+import org.freehep.application.studio.Studio;
+import org.freehep.jas.services.DataSource;
+import org.freehep.swing.wizard.WizardPage;
+
+/**
+ * A data source which allows reading a single file or a set of files.
+ * @author tonyj
+ */
+
+class StdhepDataSource implements DataSource
+{
+   private Studio app;
+   
+   StdhepDataSource(Studio app)
+   {
+      this.app = app;
+   }
+   
+   public WizardPage getWizardPage()
+   {
+      return new StdhepFileSelector(app);
+   }
+   
+   public String getName()
+   {
+      return "Stdhep Files (.stdhep, .stdhep.filelist)";
+   }
+}

lcsim/src/org/lcsim/plugin
StdhepFileHandler.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- StdhepFileHandler.java	20 Jun 2005 23:23:09 -0000	1.2
+++ StdhepFileHandler.java	15 Mar 2007 06:39:39 -0000	1.3
@@ -14,7 +14,7 @@
 /**
  * A file handler for LCIO files.
  * @author tonyj
- * @version $Id: StdhepFileHandler.java,v 1.2 2005/06/20 23:23:09 tonyj Exp $
+ * @version $Id: StdhepFileHandler.java,v 1.3 2007/03/15 06:39:39 tonyj Exp $
  */
 
 class StdhepFileHandler implements FileHandler
@@ -37,9 +37,9 @@
 
    public void openFile(File file) throws IOException
    {
-      Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sdjan03");
+      Object detectorName = JOptionPane.showInputDialog(app,"Select detector name","Choose detector geometry",JOptionPane.QUESTION_MESSAGE,null,null,"sidaug05");
       StdhepEventSource source = new StdhepEventSource(file,detectorName.toString());
 
       app.getLookup().add(source);
    }   
-}
\ No newline at end of file
+}

lcsim/src/org/lcsim/plugin
LCSimPlugin.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- LCSimPlugin.java	15 Mar 2007 05:24:30 -0000	1.9
+++ LCSimPlugin.java	15 Mar 2007 06:39:39 -0000	1.10
@@ -41,7 +41,7 @@
 /**
  *
  * @author tonyj
- * @version $Id: LCSimPlugin.java,v 1.9 2007/03/15 05:24:30 tonyj Exp $
+ * @version $Id: LCSimPlugin.java,v 1.10 2007/03/15 06:39:39 tonyj Exp $
  */
 
 public class LCSimPlugin extends Plugin implements StudioListener, PageListener
@@ -65,9 +65,10 @@
                 
         lookup.add(new LCSimFileHandler(app),"org.lcsim Plugin");
         lookup.add(new LCSimFileListHandler(app),"org.lcsim Plugin");
-        lookup.add(new StdhepFileHandler(app),"org.lcsim Plugin");
         lookup.add(new LCSimDataSource(app));
-        lookup.add(new FileHandlerDataSource(new StdhepFileHandler(app)));
+        lookup.add(new StdhepFileHandler(app),"org.lcsim Plugin");
+        lookup.add(new StdhepFileListHandler(app),"org.lcsim Plugin");
+        lookup.add(new StdhepDataSource(app));
         
         // Listen for any drivers to be loaded
         app.getEventSender().addEventListener(this,ClassLoadEvent.class);

lcsim/src/org/lcsim/plugin
FileSelector.form 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FileSelector.form	15 Mar 2007 05:24:30 -0000	1.1
+++ FileSelector.form	15 Mar 2007 06:39:40 -0000	1.2
@@ -13,7 +13,7 @@
 
   <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
   <SubComponents>
-    <Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
+    <Container class="javax.swing.JTabbedPane" name="singleMultiTabbedPane">
       <Properties>
         <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
           <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
@@ -51,6 +51,10 @@
               <Properties>
                 <Property name="text" type="java.lang.String" value="File: "/>
               </Properties>
+              <AuxValues>
+                <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
+                <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
+              </AuxValues>
               <Constraints>
                 <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
                   <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
@@ -101,6 +105,10 @@
               <Properties>
                 <Property name="text" type="java.lang.String" value="List Name:"/>
               </Properties>
+              <AuxValues>
+                <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
+                <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
+              </AuxValues>
               <Constraints>
                 <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
                   <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
@@ -116,6 +124,8 @@
             </Component>
             <Container class="javax.swing.JScrollPane" name="jScrollPane1">
               <AuxValues>
+                <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
+                <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
                 <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
               </AuxValues>
               <Constraints>
@@ -141,6 +151,7 @@
             <Component class="javax.swing.JButton" name="upButton">
               <Properties>
                 <Property name="text" type="java.lang.String" value="Move Up"/>
+                <Property name="enabled" type="boolean" value="false"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="upButtonActionPerformed"/>
@@ -154,6 +165,7 @@
             <Component class="javax.swing.JButton" name="downButton">
               <Properties>
                 <Property name="text" type="java.lang.String" value="Move Down"/>
+                <Property name="enabled" type="boolean" value="false"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="downButtonActionPerformed"/>
@@ -180,6 +192,7 @@
             <Component class="javax.swing.JButton" name="removeButton">
               <Properties>
                 <Property name="text" type="java.lang.String" value="Remove"/>
+                <Property name="enabled" type="boolean" value="false"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeButtonActionPerformed"/>
@@ -193,6 +206,7 @@
             <Component class="javax.swing.JButton" name="saveButton">
               <Properties>
                 <Property name="text" type="java.lang.String" value="Save..."/>
+                <Property name="enabled" type="boolean" value="false"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveButtonActionPerformed"/>

lcsim/src/org/lcsim/plugin
FileSelector.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FileSelector.java	15 Mar 2007 05:24:30 -0000	1.1
+++ FileSelector.java	15 Mar 2007 06:39:40 -0000	1.2
@@ -42,11 +42,11 @@
       this.defaultFileListTitle = fileType+" File List";
       model.addListDataListener(this);
       initComponents();
-      boolean multi = Boolean.valueOf(app.getUserProperties().getProperty("org.lcsim.FileSelector.Multi","false"));
-      jTabbedPane1.setSelectedIndex(multi ? 1 : 0);
-      String[] list = PropertyUtilities.getStringArray(app.getUserProperties(),"org.lcsim.FileSelector.FileList",null);
+      boolean multi = Boolean.valueOf(app.getUserProperties().getProperty("org.lcsim.FileSelector.Multi."+fileType,"false"));
+      singleMultiTabbedPane.setSelectedIndex(multi ? 1 : 0);
+      String[] list = PropertyUtilities.getStringArray(app.getUserProperties(),"org.lcsim.FileSelector.FileList."+fileType,null);
       if (list != null) for (int i=0; i<list.length; i++) model.addElement(new File(list[i]));
-      listNameTextField.setText(app.getUserProperties().getProperty("org.lcsim.FileSelector.FileList.title",defaultFileListTitle));
+      listNameTextField.setText(app.getUserProperties().getProperty("org.lcsim.FileSelector.FileList.title."+fileType,defaultFileListTitle));
    }
    
    /** This method is called from within the constructor to
@@ -58,8 +58,11 @@
    private void initComponents()
    {
       java.awt.GridBagConstraints gridBagConstraints;
+      javax.swing.JLabel jLabel1;
+      javax.swing.JLabel jLabel2;
+      javax.swing.JScrollPane jScrollPane1;
 
-      jTabbedPane1 = new javax.swing.JTabbedPane();
+      singleMultiTabbedPane = new javax.swing.JTabbedPane();
       singleFilePanel = new javax.swing.JPanel();
       jLabel1 = new javax.swing.JLabel();
       fileNameTextField = new javax.swing.JTextField();
@@ -78,7 +81,7 @@
 
       setLayout(new java.awt.BorderLayout());
 
-      jTabbedPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
+      singleMultiTabbedPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
       singleFilePanel.setLayout(new java.awt.GridBagLayout());
 
       singleFilePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
@@ -101,7 +104,7 @@
 
       singleFilePanel.add(browseButton, new java.awt.GridBagConstraints());
 
-      jTabbedPane1.addTab("Single File", singleFilePanel);
+      singleMultiTabbedPane.addTab("Single File", singleFilePanel);
 
       multiFilePanel.setLayout(new java.awt.GridBagLayout());
 
@@ -138,6 +141,7 @@
       multiFilePanel.add(jScrollPane1, gridBagConstraints);
 
       upButton.setText("Move Up");
+      upButton.setEnabled(false);
       upButton.addActionListener(new java.awt.event.ActionListener()
       {
          public void actionPerformed(java.awt.event.ActionEvent evt)
@@ -155,6 +159,7 @@
       multiFilePanel.add(upButton, gridBagConstraints);
 
       downButton.setText("Move Down");
+      downButton.setEnabled(false);
       downButton.addActionListener(new java.awt.event.ActionListener()
       {
          public void actionPerformed(java.awt.event.ActionEvent evt)
@@ -185,6 +190,7 @@
       multiFilePanel.add(addButton, gridBagConstraints);
 
       removeButton.setText("Remove");
+      removeButton.setEnabled(false);
       removeButton.addActionListener(new java.awt.event.ActionListener()
       {
          public void actionPerformed(java.awt.event.ActionEvent evt)
@@ -200,6 +206,7 @@
       multiFilePanel.add(removeButton, gridBagConstraints);
 
       saveButton.setText("Save...");
+      saveButton.setEnabled(false);
       saveButton.addActionListener(new java.awt.event.ActionListener()
       {
          public void actionPerformed(java.awt.event.ActionEvent evt)
@@ -229,9 +236,9 @@
       gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
       multiFilePanel.add(restoreButton, gridBagConstraints);
 
-      jTabbedPane1.addTab("Multiple Files", multiFilePanel);
+      singleMultiTabbedPane.addTab("Multiple Files", multiFilePanel);
 
-      add(jTabbedPane1, java.awt.BorderLayout.CENTER);
+      add(singleMultiTabbedPane, java.awt.BorderLayout.CENTER);
 
    }// </editor-fold>//GEN-END:initComponents
    
@@ -249,7 +256,7 @@
       app.getUserProperties().setProperty("org.lcsim.FileSelector.Browse."+fileType,file.getAbsolutePath());
       if (file.getPath().endsWith("."+fileExtension))
       {
-         jTabbedPane1.setSelectedIndex(1);
+         singleMultiTabbedPane.setSelectedIndex(1);
          readFileList(file);
       }
       else
@@ -396,7 +403,7 @@
    
    boolean isMultiFileSelected()
    {
-      return jTabbedPane1.getSelectedIndex() == 1;
+      return singleMultiTabbedPane.getSelectedIndex() == 1;
    }
    
    FileList getSelectedFiles()
@@ -412,11 +419,11 @@
    }
    public void onFinish()
    {
-      app.getUserProperties().setProperty("org.lcsim.FileSelector.Multi",String.valueOf(isMultiFileSelected()));
+      app.getUserProperties().setProperty("org.lcsim.FileSelector.Multi."+fileType,String.valueOf(isMultiFileSelected()));
       String[] list = new String[model.getSize()];
       for (int i=0; i<list.length; i++) list[i] = model.getElementAt(i).toString();
-      PropertyUtilities.setStringArray(app.getUserProperties(),"org.lcsim.FileSelector.FileList",list);
-      app.getUserProperties().setProperty("org.lcsim.FileSelector.FileList.title",listNameTextField.getText());
+      PropertyUtilities.setStringArray(app.getUserProperties(),"org.lcsim.FileSelector.FileList."+fileType,list);
+      app.getUserProperties().setProperty("org.lcsim.FileSelector.FileList.title."+fileType,listNameTextField.getText());
       dispose();
    }
    
@@ -427,16 +434,13 @@
    private javax.swing.JButton downButton;
    private javax.swing.JList fileList;
    private javax.swing.JTextField fileNameTextField;
-   private javax.swing.JLabel jLabel1;
-   private javax.swing.JLabel jLabel2;
-   private javax.swing.JScrollPane jScrollPane1;
-   private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField listNameTextField;
    private javax.swing.JPanel multiFilePanel;
    private javax.swing.JButton removeButton;
    private javax.swing.JButton restoreButton;
    private javax.swing.JButton saveButton;
    private javax.swing.JPanel singleFilePanel;
+   private javax.swing.JTabbedPane singleMultiTabbedPane;
    private javax.swing.JButton upButton;
    // End of variables declaration//GEN-END:variables
    

lcsim/src/org/lcsim/util/loop
StdhepEventSource.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- StdhepEventSource.java	4 Oct 2006 22:57:44 -0000	1.5
+++ StdhepEventSource.java	15 Mar 2007 06:39:40 -0000	1.6
@@ -7,6 +7,8 @@
 import java.io.EOFException;
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
 import org.freehep.record.source.EndOfSourceException;
 import org.freehep.record.source.NoSuchRecordException;
 import org.freehep.record.source.RandomAccessRecordSource;
@@ -17,22 +19,39 @@
 /**
  * Convert an LCIOReader to a SequentialRecordSource
  * @author tonyj
- * @version $Id: StdhepEventSource.java,v 1.5 2006/10/04 22:57:44 tonyj Exp $
+ * @version $Id: StdhepEventSource.java,v 1.6 2007/03/15 06:39:40 tonyj Exp $
  */
 public class StdhepEventSource implements RandomAccessRecordSource
 {
-   private final File file;
+   private List<File> files;
+   private String name;
    private boolean atEnd;
    private StdhepReader reader;
    private final StdhepConverter converter;
    private EventHeader currentEvent;
    private int currentEventNumber;
+   private int currentFile = 0;
    
+   /**
+    * Create an event source from a single stdhep file
+    */
    public StdhepEventSource(File file, String detectorName) throws IOException
    {
       reader = new StdhepReader(file.getAbsolutePath());
       converter = new StdhepConverter(ParticlePropertyManager.getParticlePropertyProvider(),new LCSimFactory(detectorName));
-      this.file = file;
+      this.files = Collections.singletonList(file);
+      this.name = file.getName();
+   }
+   /**
+    * Create an event source from a list of stdhep files
+    */
+   public StdhepEventSource(FileList list, String detectorName) throws IOException
+   {
+      this.name = list.getTitle();
+      this.files = list.getFileList();
+      if (files.size() == 0) throw new IOException("File list is empty");
+      reader = new StdhepReader(files.get(0).getAbsolutePath());
+      converter = new StdhepConverter(ParticlePropertyManager.getParticlePropertyProvider(),new LCSimFactory(detectorName));
    }
    
    public Object getCurrentRecord() throws NoSuchRecordException, IOException, EndOfSourceException
@@ -44,7 +63,7 @@
    
    public long getEstimatedSize()
    {
-      return reader.getNumberOfEvents();
+      return files.size() == 1 ? reader.getNumberOfEvents() : -1;
    }
    
    public Class getRecordClass()
@@ -54,27 +73,38 @@
    
    public String getSourceName()
    {
-      return file.getName();
+      return name;
    }
    
    public void next() throws IOException
    {
-      try
+      for (;;)
       {
-         for (;;)
+         try
          {
-            StdhepRecord record = reader.nextRecord();
-            if (record instanceof StdhepEvent)
+            for (;;)
             {
-               currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
-               currentEventNumber++;
-               break;
+               StdhepRecord record = reader.nextRecord();
+               if (record instanceof StdhepEvent)
+               {
+                  currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
+                  currentEventNumber++;
+                  break;
+               }
             }
          }
-      }
-      catch (EOFException x)
-      {
-         atEnd = true;
+         catch (EOFException x)
+         {
+            currentFile++;
+            if (currentFile >= files.size()) atEnd = true;
+            else
+            {
+               reader.close();
+               reader = new StdhepReader(files.get(currentFile).getAbsolutePath());
+               continue;
+            }
+         }
+         return;
       }
    }
    public void releaseRecord(Object obj)
@@ -83,7 +113,16 @@
    }
    public void rewind() throws IOException
    {
-      reader.rewind();
+      if (currentFile == 0)
+      {
+         reader.rewind();
+      }
+      else
+      {
+         currentFile = 0;
+         reader.close();
+         reader = new StdhepReader(files.get(0).getAbsolutePath());
+      }
       atEnd = false;
       currentEventNumber = 0;
    }
@@ -101,45 +140,64 @@
       {
          close();
       }
-      catch (IOException x) {}
+      catch (IOException x)
+      {}
    }
-
+   
    public void goToRecord(int target) throws NoSuchRecordException
    {
       try
       {
-         if (target < currentEventNumber) rewind();
-         if (target == currentEventNumber) return;
-         
-         while (true)
-         {  
-            StdhepRecord record = reader.nextRecord();
-            if (record instanceof StdhepEvent)
+         for (;;)
+         {
+            try
             {
-               currentEventNumber++;  
-               if (currentEventNumber == target)
+               if (target < currentEventNumber) rewind();
+               if (target == currentEventNumber) return;
+               
+               for (;;)
                {
-                  currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
-                  break;
+                  StdhepRecord record = reader.nextRecord();
+                  if (record instanceof StdhepEvent)
+                  {
+                     currentEventNumber++;
+                     if (currentEventNumber == target)
+                     {
+                        currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
+                        break;
+                     }
+                  }
+               }
+
+            }
+            catch (EOFException x)
+            {
+               currentFile++;
+               if (currentFile >= files.size())
+               {
+                  atEnd = true;
+                  NoSuchRecordException xx = new NoSuchRecordException();
+                  xx.initCause(x);
+                  throw xx;
+               }
+               else
+               {
+                  reader.close();
+                  reader = new StdhepReader(files.get(currentFile).getAbsolutePath());
+                  continue;
                }
             }
+            return;
          }
       }
-      catch (EOFException x)
-      {
-         atEnd = true; 
-         NoSuchRecordException xx = new NoSuchRecordException();
-         xx.initCause(x);
-         throw xx;
-      }
       catch (IOException x)
       {
          NoSuchRecordException xx = new NoSuchRecordException();
          xx.initCause(x);
-         throw xx;         
+         throw xx;
       }
    }
-
+   
    public int currentIndex()
    {
       return currentEventNumber;
CVSspam 0.2.8