Print

Print


Commit in lcsim/src/org/lcsim on MAIN
plugin/StdhepFileSelector.java+36added 1.1
      /LCSimDataSource.java+30added 1.1
      /FileSelector.form+224added 1.1
      /LCSimFileListHandler.java+42added 1.1
      /FileSelector.java+443added 1.1
      /LCSimPlugin.java+3-21.8 -> 1.9
util/loop/FileList.java+118added 1.1
         /LCIOEventSource.java+27-31.3 -> 1.4
+923-5
6 added + 2 modified, total 8 files
Support for opening a list of LCIO files

lcsim/src/org/lcsim/plugin
StdhepFileSelector.java added at 1.1
diff -N StdhepFileSelector.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StdhepFileSelector.java	15 Mar 2007 05:24:30 -0000	1.1
@@ -0,0 +1,36 @@
+package org.lcsim.plugin;
+
+import java.io.IOException;
+import org.freehep.application.studio.Studio;
+import org.freehep.swing.ErrorDialog;
+import org.freehep.swing.ExtensionFileFilter;
+import org.lcsim.util.loop.LCIOEventSource;
+
+/**
+ *
+ * @author tonyj
+ */
+class StdhepFileSelector extends FileSelector
+{
+   private Studio app;
+   /** Creates a new instance of LCSimFileSelector */
+   StdhepFileSelector(Studio app)
+   {
+      super("Stdhep","stdhep.filelist",new ExtensionFileFilter("stdhep","Stdhep File"),new ExtensionFileFilter("stdhep.filelist","Stdhep File List"));
+      this.app = app;
+   }
+   
+   public void onFinish()
+   {
+      try
+      {
+         LCIOEventSource source = isMultiFileSelected() ? new LCIOEventSource(getSelectedFiles()) : new LCIOEventSource(getSelectedFile());
+         app.getLookup().add(source);
+         dispose();
+      }
+      catch (IOException x)
+      {
+         ErrorDialog.showErrorDialog(this,"Error saving file list",x);
+      }
+   }
+}

lcsim/src/org/lcsim/plugin
LCSimDataSource.java added at 1.1
diff -N LCSimDataSource.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ LCSimDataSource.java	15 Mar 2007 05:24:30 -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 LCSimDataSource implements DataSource
+{
+   private Studio app;
+   
+   LCSimDataSource(Studio app)
+   {
+      this.app = app;
+   }
+   
+   public WizardPage getWizardPage()
+   {
+      return new LCSimFileSelector(app);
+   }
+   
+   public String getName()
+   {
+      return "LCIO Files (.slcio, .slcio.filelist)";
+   }
+}

lcsim/src/org/lcsim/plugin
FileSelector.form added at 1.1
diff -N FileSelector.form
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ FileSelector.form	15 Mar 2007 05:24:30 -0000	1.1
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,81,0,0,2,45"/>
+  </AuxValues>
+
+  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+  <SubComponents>
+    <Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
+      <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">
+            <EmptyBorder bottom="10" left="10" right="10" top="10"/>
+          </Border>
+        </Property>
+      </Properties>
+      <Constraints>
+        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+          <BorderConstraints direction="Center"/>
+        </Constraint>
+      </Constraints>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
+      <SubComponents>
+        <Container class="javax.swing.JPanel" name="singleFilePanel">
+          <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">
+                <EmptyBorder bottom="10" left="10" right="10" top="10"/>
+              </Border>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
+              <JTabbedPaneConstraints tabName="Single File">
+                <Property name="tabTitle" type="java.lang.String" value="Single File"/>
+              </JTabbedPaneConstraints>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JLabel" name="jLabel1">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="File: "/>
+              </Properties>
+              <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"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JTextField" name="fileNameTextField">
+              <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JButton" name="browseButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Browse..."/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
+              </Events>
+              <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"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JPanel" name="multiFilePanel">
+          <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">
+                <EmptyBorder bottom="10" left="10" right="10" top="10"/>
+              </Border>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
+              <JTabbedPaneConstraints tabName="Multiple Files">
+                <Property name="tabTitle" type="java.lang.String" value="Multiple Files"/>
+              </JTabbedPaneConstraints>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JLabel" name="jLabel2">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="List Name:"/>
+              </Properties>
+              <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"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JTextField" name="listNameTextField">
+              <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+              <AuxValues>
+                <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+              </AuxValues>
+              <Constraints>
+                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+                  <GridBagConstraints gridX="0" gridY="-1" gridWidth="2" gridHeight="6" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
+                </Constraint>
+              </Constraints>
+
+              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+              <SubComponents>
+                <Component class="javax.swing.JList" name="fileList">
+                  <Properties>
+                    <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                      <Connection code="model" type="code"/>
+                    </Property>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="fileListValueChanged"/>
+                  </Events>
+                </Component>
+              </SubComponents>
+            </Container>
+            <Component class="javax.swing.JButton" name="upButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Move Up"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="upButtonActionPerformed"/>
+              </Events>
+              <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="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JButton" name="downButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Move Down"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="downButtonActionPerformed"/>
+              </Events>
+              <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="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JButton" name="addButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Add..."/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed"/>
+              </Events>
+              <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="0" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JButton" name="removeButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Remove"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeButtonActionPerformed"/>
+              </Events>
+              <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="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JButton" name="saveButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Save..."/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveButtonActionPerformed"/>
+              </Events>
+              <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="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JButton" name="restoreButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Restore..."/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="restoreButtonActionPerformed"/>
+              </Events>
+              <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="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>

lcsim/src/org/lcsim/plugin
LCSimFileListHandler.java added at 1.1
diff -N LCSimFileListHandler.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ LCSimFileListHandler.java	15 Mar 2007 05:24:30 -0000	1.1
@@ -0,0 +1,42 @@
+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 org.freehep.jas.services.FileHandler;
+import org.lcsim.util.loop.FileList;
+import org.lcsim.util.loop.LCIOEventSource;
+
+/**
+ * A file handler for LCIO file lists.
+ * @author tonyj
+ * @version $Id: LCSimFileListHandler.java,v 1.1 2007/03/15 05:24:30 tonyj Exp $
+ */
+
+class LCSimFileListHandler implements FileHandler
+{
+   private Studio app;
+   LCSimFileListHandler(Studio app)
+   {
+      this.app = app;
+   }
+   public boolean accept(File file) throws IOException
+   {
+      return file.getName().endsWith(".slcio.filelist");
+   }
+   
+   public FileFilter getFileFilter()
+   {
+      return new ExtensionFileFilter(".slcio.filelist","LCIO File List");
+   }
+
+   public void openFile(File file) throws IOException
+   {
+      FileList fileList = new FileList(file,"LCIO File List");
+      LCIOEventSource source = new LCIOEventSource(fileList);
+      app.getLookup().add(source);
+   }   
+}
\ No newline at end of file

lcsim/src/org/lcsim/plugin
FileSelector.java added at 1.1
diff -N FileSelector.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ FileSelector.java	15 Mar 2007 05:24:30 -0000	1.1
@@ -0,0 +1,443 @@
+package org.lcsim.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.filechooser.FileFilter;
+import org.freehep.application.PropertyUtilities;
+import org.freehep.application.studio.Studio;
+import org.freehep.swing.ErrorDialog;
+import org.freehep.swing.wizard.Finishable;
+import org.freehep.swing.wizard.WizardPage;
+import org.lcsim.util.loop.FileList;
+
+/**
+ *
+ * @author tonyj
+ */
+abstract class FileSelector extends WizardPage implements Finishable, ListDataListener
+{
+   private DefaultComboBoxModel model = new DefaultComboBoxModel();
+   private String fileExtension;
+   private FileFilter fileListFileFilter;
+   private FileFilter fileFileFilter;
+   private String fileType;
+   private String defaultFileListTitle;
+   private Studio app;
+   
+   /** Creates new form LCSimFileSelector */
+   public FileSelector(Studio app, String fileType, String fileExtension, FileFilter fileFilter, FileFilter fileListFilter)
+   {
+      this.app = app;
+      this.fileType = fileType;
+      this.fileExtension = fileExtension;
+      this.fileFileFilter = fileFilter;
+      this.fileListFileFilter = fileListFilter;
+      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);
+      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));
+   }
+   
+   /** This method is called from within the constructor to
+    * initialize the form.
+    * WARNING: Do NOT modify this code. The content of this method is
+    * always regenerated by the Form Editor.
+    */
+   // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+   private void initComponents()
+   {
+      java.awt.GridBagConstraints gridBagConstraints;
+
+      jTabbedPane1 = new javax.swing.JTabbedPane();
+      singleFilePanel = new javax.swing.JPanel();
+      jLabel1 = new javax.swing.JLabel();
+      fileNameTextField = new javax.swing.JTextField();
+      browseButton = new javax.swing.JButton();
+      multiFilePanel = new javax.swing.JPanel();
+      jLabel2 = new javax.swing.JLabel();
+      listNameTextField = new javax.swing.JTextField();
+      jScrollPane1 = new javax.swing.JScrollPane();
+      fileList = new javax.swing.JList();
+      upButton = new javax.swing.JButton();
+      downButton = new javax.swing.JButton();
+      addButton = new javax.swing.JButton();
+      removeButton = new javax.swing.JButton();
+      saveButton = new javax.swing.JButton();
+      restoreButton = new javax.swing.JButton();
+
+      setLayout(new java.awt.BorderLayout());
+
+      jTabbedPane1.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));
+      jLabel1.setText("File: ");
+      singleFilePanel.add(jLabel1, new java.awt.GridBagConstraints());
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.weightx = 1.0;
+      singleFilePanel.add(fileNameTextField, gridBagConstraints);
+
+      browseButton.setText("Browse...");
+      browseButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            browseButtonActionPerformed(evt);
+         }
+      });
+
+      singleFilePanel.add(browseButton, new java.awt.GridBagConstraints());
+
+      jTabbedPane1.addTab("Single File", singleFilePanel);
+
+      multiFilePanel.setLayout(new java.awt.GridBagLayout());
+
+      multiFilePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
+      jLabel2.setText("List Name:");
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 3);
+      multiFilePanel.add(jLabel2, gridBagConstraints);
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.weightx = 1.0;
+      multiFilePanel.add(listNameTextField, gridBagConstraints);
+
+      fileList.setModel(model);
+      fileList.addListSelectionListener(new javax.swing.event.ListSelectionListener()
+      {
+         public void valueChanged(javax.swing.event.ListSelectionEvent evt)
+         {
+            fileListValueChanged(evt);
+         }
+      });
+
+      jScrollPane1.setViewportView(fileList);
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridx = 0;
+      gridBagConstraints.gridwidth = 2;
+      gridBagConstraints.gridheight = 6;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+      gridBagConstraints.weightx = 1.0;
+      gridBagConstraints.weighty = 1.0;
+      gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
+      multiFilePanel.add(jScrollPane1, gridBagConstraints);
+
+      upButton.setText("Move Up");
+      upButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            upButtonActionPerformed(evt);
+         }
+      });
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridy = 1;
+      gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
+      gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
+      multiFilePanel.add(upButton, gridBagConstraints);
+
+      downButton.setText("Move Down");
+      downButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            downButtonActionPerformed(evt);
+         }
+      });
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
+      multiFilePanel.add(downButton, gridBagConstraints);
+
+      addButton.setText("Add...");
+      addButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            addButtonActionPerformed(evt);
+         }
+      });
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+      gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
+      multiFilePanel.add(addButton, gridBagConstraints);
+
+      removeButton.setText("Remove");
+      removeButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            removeButtonActionPerformed(evt);
+         }
+      });
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
+      multiFilePanel.add(removeButton, gridBagConstraints);
+
+      saveButton.setText("Save...");
+      saveButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            saveButtonActionPerformed(evt);
+         }
+      });
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
+      multiFilePanel.add(saveButton, gridBagConstraints);
+
+      restoreButton.setText("Restore...");
+      restoreButton.addActionListener(new java.awt.event.ActionListener()
+      {
+         public void actionPerformed(java.awt.event.ActionEvent evt)
+         {
+            restoreButtonActionPerformed(evt);
+         }
+      });
+
+      gridBagConstraints = new java.awt.GridBagConstraints();
+      gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+      gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
+      multiFilePanel.add(restoreButton, gridBagConstraints);
+
+      jTabbedPane1.addTab("Multiple Files", multiFilePanel);
+
+      add(jTabbedPane1, java.awt.BorderLayout.CENTER);
+
+   }// </editor-fold>//GEN-END:initComponents
+   
+   private void browseButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_browseButtonActionPerformed
+   {//GEN-HEADEREND:event_browseButtonActionPerformed
+      String dir = app.getUserProperties().getProperty("org.lcsim.FileSelector.Browse."+fileType);
+      JFileChooser chooser = new JFileChooser(dir);
+      chooser.setDialogTitle("Open "+fileType+" File ...");
+      chooser.setMultiSelectionEnabled(false);
+      chooser.addChoosableFileFilter(fileListFileFilter);
+      chooser.setFileFilter(fileFileFilter);
+      if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
+      
+      File file = chooser.getSelectedFile();
+      app.getUserProperties().setProperty("org.lcsim.FileSelector.Browse."+fileType,file.getAbsolutePath());
+      if (file.getPath().endsWith("."+fileExtension))
+      {
+         jTabbedPane1.setSelectedIndex(1);
+         readFileList(file);
+      }
+      else
+      {
+         fileNameTextField.setText(file.getAbsolutePath());
+      }
+   }//GEN-LAST:event_browseButtonActionPerformed
+   
+   private void restoreButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_restoreButtonActionPerformed
+   {//GEN-HEADEREND:event_restoreButtonActionPerformed
+      String dir = app.getUserProperties().getProperty("org.lcsim.FileSelector.SaveRestore."+fileType);
+      JFileChooser chooser = new JFileChooser(dir);
+      chooser.setDialogTitle("Restore File Set ...");
+      chooser.setMultiSelectionEnabled(false);
+      chooser.setFileFilter(fileListFileFilter);
+      if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
+      
+      File file = chooser.getSelectedFile();
+      readFileList(file);
+      app.getUserProperties().setProperty("org.lcsim.FileSelector.SaveRestore."+fileType,file.getAbsolutePath());
+   }//GEN-LAST:event_restoreButtonActionPerformed
+   
+   private void readFileList(File file)
+   {
+      try
+      {
+         FileList utils = new FileList(file,defaultFileListTitle);
+         
+         model.removeAllElements();
+         for (File f : utils.getFileList()) model.addElement(f);
+         listNameTextField.setText(utils.getTitle());
+      }
+      catch (IOException x)
+      {
+         ErrorDialog.showErrorDialog(this,"Error restoring file list",x);
+      }
+   }
+   private void saveButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveButtonActionPerformed
+   {//GEN-HEADEREND:event_saveButtonActionPerformed
+      String dir = app.getUserProperties().getProperty("org.lcsim.FileSelector.SaveRestore."+fileType);
+      JFileChooser chooser = new JFileChooser(dir);
+      chooser.setDialogTitle("Save File Set ...");
+      chooser.setMultiSelectionEnabled(false);
+      chooser.setFileFilter(fileListFileFilter);
+      if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) return;
+      
+      File file = chooser.getSelectedFile();
+      if (file.getName().indexOf(".") < 0) file = new File(file.getAbsolutePath()+"."+fileExtension);
+      if (file.exists())
+      {
+         int rc = JOptionPane.showConfirmDialog(this,"Overwrite existing file?");
+         if (rc != JOptionPane.OK_OPTION) return;
+      }
+      try
+      {
+         List<File> fileList = new ArrayList<File>();
+         for (int i=0; i<model.getSize(); i++) fileList.add((File) model.getElementAt(i));
+         FileList utils = new FileList(fileList,listNameTextField.getText());
+         utils.write(file);
+         app.getUserProperties().setProperty("org.lcsim.FileSelector.SaveRestore."+fileType,file.getAbsolutePath());
+      }
+      catch (IOException x)
+      {
+         ErrorDialog.showErrorDialog(this,"Error saving file list",x);
+      }
+   }//GEN-LAST:event_saveButtonActionPerformed
+   
+   private void downButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_downButtonActionPerformed
+   {//GEN-HEADEREND:event_downButtonActionPerformed
+      int[] selected = fileList.getSelectedIndices();
+      for (int i=0; i<selected.length; i++)
+      {
+         int index = selected[i];
+         Object o = model.getElementAt(index);
+         model.removeElementAt(index);
+         model.insertElementAt(o,index+1);
+         selected[i]++;
+      }
+      fileList.setSelectedIndices(selected);
+   }//GEN-LAST:event_downButtonActionPerformed
+   
+   private void upButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_upButtonActionPerformed
+   {//GEN-HEADEREND:event_upButtonActionPerformed
+      int[] selected = fileList.getSelectedIndices();
+      for (int i=0; i<selected.length; i++)
+      {
+         int index = selected[i];
+         Object o = model.getElementAt(index);
+         model.removeElementAt(index);
+         model.insertElementAt(o,index-1);
+         selected[i]--;
+      }
+      fileList.setSelectedIndices(selected);
+   }//GEN-LAST:event_upButtonActionPerformed
+   
+   private void removeButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_removeButtonActionPerformed
+   {//GEN-HEADEREND:event_removeButtonActionPerformed
+      int[] selected = fileList.getSelectedIndices();
+      for (int i=selected.length-1; i>=0; i--) model.removeElementAt(selected[i]);
+   }//GEN-LAST:event_removeButtonActionPerformed
+   
+   private void fileListValueChanged(javax.swing.event.ListSelectionEvent evt)//GEN-FIRST:event_fileListValueChanged
+   {//GEN-HEADEREND:event_fileListValueChanged
+      int[] selected = fileList.getSelectedIndices();
+      removeButton.setEnabled(selected.length > 0);
+      upButton.setEnabled(selected.length > 0 && selected[0]>0);
+      downButton.setEnabled(selected.length > 0 && selected[selected.length-1] < model.getSize()-1);
+   }//GEN-LAST:event_fileListValueChanged
+   
+   private void addButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addButtonActionPerformed
+   {//GEN-HEADEREND:event_addButtonActionPerformed
+      String dir = app.getUserProperties().getProperty("org.lcsim.FileSelector.Add."+fileType);
+      JFileChooser chooser = new JFileChooser(dir);
+      chooser.setDialogTitle("Open "+fileType+" file(s)");
+      chooser.setFileFilter(fileFileFilter);
+      chooser.setMultiSelectionEnabled(true);
+      int rc = chooser.showDialog(this,"Add");
+      if (rc != JFileChooser.APPROVE_OPTION) return;
+      File[] list = chooser.getSelectedFiles();
+      if (list == null || list.length == 0) return;
+      app.getUserProperties().setProperty("org.lcsim.FileSelector.Add."+fileType,list[0].getAbsolutePath());
+      
+      for (File file : list)
+      {
+         model.addElement(file);
+      }
+   }//GEN-LAST:event_addButtonActionPerformed
+   
+   
+   public void intervalAdded(ListDataEvent e)
+   {
+      saveButton.setEnabled(model.getSize()>0);
+   }
+   
+   public void intervalRemoved(ListDataEvent e)
+   {
+      saveButton.setEnabled(model.getSize()>0);
+   }
+   
+   public void contentsChanged(ListDataEvent e)
+   {
+      saveButton.setEnabled(model.getSize()>0);
+   }
+   
+   boolean isMultiFileSelected()
+   {
+      return jTabbedPane1.getSelectedIndex() == 1;
+   }
+   
+   FileList getSelectedFiles()
+   {
+      List<File> files = new ArrayList<File>();
+      for (int i=0; i<model.getSize(); i++)  files.add((File) model.getElementAt(i));
+      return new FileList(files,listNameTextField.getText());
+   }
+   
+   File getSelectedFile()
+   {
+      return new File(fileNameTextField.getText());
+   }
+   public void onFinish()
+   {
+      app.getUserProperties().setProperty("org.lcsim.FileSelector.Multi",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());
+      dispose();
+   }
+   
+   
+   // Variables declaration - do not modify//GEN-BEGIN:variables
+   private javax.swing.JButton addButton;
+   private javax.swing.JButton browseButton;
+   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.JButton upButton;
+   // End of variables declaration//GEN-END:variables
+   
+}

lcsim/src/org/lcsim/plugin
LCSimPlugin.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- LCSimPlugin.java	22 May 2006 18:59:22 -0000	1.8
+++ LCSimPlugin.java	15 Mar 2007 05:24:30 -0000	1.9
@@ -41,7 +41,7 @@
 /**
  *
  * @author tonyj
- * @version $Id: LCSimPlugin.java,v 1.8 2006/05/22 18:59:22 tonyj Exp $
+ * @version $Id: LCSimPlugin.java,v 1.9 2007/03/15 05:24:30 tonyj Exp $
  */
 
 public class LCSimPlugin extends Plugin implements StudioListener, PageListener
@@ -64,8 +64,9 @@
         app.addToolBar(toolbar, toolbar.getName());
                 
         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 FileHandlerDataSource(new LCSimFileHandler(app)));
+        lookup.add(new LCSimDataSource(app));
         lookup.add(new FileHandlerDataSource(new StdhepFileHandler(app)));
         
         // Listen for any drivers to be loaded

lcsim/src/org/lcsim/util/loop
FileList.java added at 1.1
diff -N FileList.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ FileList.java	15 Mar 2007 05:24:30 -0000	1.1
@@ -0,0 +1,118 @@
+package org.lcsim.util.loop;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Some utitities for dealing with file lists.
+ * @author tonyj
+ */
+public class FileList
+{
+   private String title;
+   private List<File> fileList;
+   private final static String TITLE = "Title:";
+   
+   public FileList(List<File> files, String title)
+   {
+      this.fileList = files;
+      this.title = title;
+   }
+   /**
+    * Creates a FileListUtils by reading a file containing a file list.
+    * The file may contain a title (a line starting with "Title:") and any number of files.
+    * Blank lines, or lines beginning with # are ignored.
+    * Files may be absolute, or specified relative to this filelist itself.
+    * @param file The file to read.
+    * @param defaultTitle The title to be used if the file does not contain a title.
+    */
+   public FileList(File file, String defaultTitle) throws IOException
+   {
+      this.fileList = new ArrayList<File>();
+      this.title = defaultTitle;
+      File base = file.getParentFile();
+      BufferedReader fileListReader = new BufferedReader(new FileReader(file));
+      try
+      {
+         for (;;)
+         {
+            String line = fileListReader.readLine();
+            if (line == null) break;
+            line = line.trim();
+            if (line.length() == 0 || line.startsWith("#")) continue;
+            if (line.startsWith(TITLE))
+            {
+               title = line.substring(TITLE.length()).trim();
+            }
+            else
+            {
+               File item = new File(base,line);
+               if (!item.exists() || !item.canRead()) throw new IOException("File "+item+" cannot be read");
+               fileList.add(item);
+            }
+         }
+      }
+      finally
+      {
+         fileListReader.close();
+      }
+   }
+   /**
+    * Writes this filelist to a file.
+    */
+   public void write(File file) throws IOException
+   {
+      String base = file.getParent();
+      if (!base.endsWith(File.separator)) base += File.separator;
+      
+      BufferedWriter pw = new BufferedWriter(new FileWriter(file));
+      if (title != null)
+      {
+         pw.write(TITLE);
+         pw.write(' ');
+         pw.write(title);
+         pw.newLine();
+      }
+      try
+      {
+         for (File item : fileList)
+         {
+            String filePath = item.getPath();
+            if (filePath.startsWith(base)) filePath = filePath.substring(base.length());
+            pw.write(filePath);
+            pw.newLine();
+         }
+      }
+      finally
+      {
+         pw.close();
+      }
+   }
+   
+   public String getTitle()
+   {
+      return title;
+   }
+   
+   public void setTitle(String title)
+   {
+      this.title = title;
+   }
+   
+   public List<File> getFileList()
+   {
+      return fileList;
+   }
+   
+   public void setFileList(List<File> fileList)
+   {
+      this.fileList = fileList;
+   }
+   
+}

lcsim/src/org/lcsim/util/loop
LCIOEventSource.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- LCIOEventSource.java	4 Aug 2005 03:08:58 -0000	1.3
+++ LCIOEventSource.java	15 Mar 2007 05:24:30 -0000	1.4
@@ -1,8 +1,12 @@
 package org.lcsim.util.loop;
 
+import java.io.BufferedReader;
 import java.io.EOFException;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import org.freehep.record.source.EndOfSourceException;
@@ -14,7 +18,7 @@
 /**
  * Convert an LCIOReader to a SequentialRecordSource
  * @author tonyj
- * @version $Id: LCIOEventSource.java,v 1.3 2005/08/04 03:08:58 tonyj Exp $
+ * @version $Id: LCIOEventSource.java,v 1.4 2007/03/15 05:24:30 tonyj Exp $
  */
 public class LCIOEventSource implements SequentialRecordSource
 {
@@ -25,19 +29,39 @@
    private int currentFile = 0;
    private String name;
    
+   /**
+    * Create an LCIO event source for reading a single LCIO file
+    * @param file The file to read
+    */
    public LCIOEventSource(File file) throws IOException
    {
-      reader = new LCIOReader(file);
+      this.reader = new LCIOReader(file);
       this.files = Collections.singletonList(file);
       this.name = file.getName();
    }
+   /**
+    * Create an LCIO event source for reading a set of LCIO files.
+    * @param name The name of the collection of event files
+    * @param files The list of files to read.
+    */
    public LCIOEventSource(String name, List<File> files) throws IOException
    {
       if (files.isEmpty()) throw new IOException("File list is empty");
-      reader = new LCIOReader(files.get(0));
+      this.reader = new LCIOReader(files.get(0));
       this.files = files;
       this.name = name;
    }
+   /**
+    * Create an LCIO event source that will read a set of LCIO files
+    * @param list The list of files to open
+    */
+   public LCIOEventSource(FileList list) throws FileNotFoundException, IOException
+   {
+      this.name = list.getTitle();
+      this.files = list.getFileList();
+      if (files.size() == 0) throw new IOException("File list is empty");
+      this.reader = new LCIOReader(files.get(0));
+   }
    
    public Object getCurrentRecord() throws NoSuchRecordException, IOException, EndOfSourceException
    {
CVSspam 0.2.8