Print

Print


Commit in lcsim/src/org/lcsim/plugin on MAIN
LCSim.menus+121.1 -> 1.2
LCSimPlugin.java+126-1491.4 -> 1.5
+138-149
2 modified files
Added capability for multiple LCSim Event Browser windows.  The LCSim Event Browser View command is now deprecated.

lcsim/src/org/lcsim/plugin
LCSim.menus 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- LCSim.menus	14 Mar 2005 16:11:32 -0000	1.1
+++ LCSim.menus	22 Sep 2005 22:03:07 -0000	1.2
@@ -4,12 +4,24 @@
 
 <MenuSystem>
     <MenuBar id="mainMenu">
+<!--
         <Menu name="View" mnemonic="V" location="300">
              <Separator location="810"/>
              <Component type="checkbox" name="LCSim Event Browser" command="LCSimEventBrowser" mnemonic="E" location="820"/>
         </Menu>
+-->
         <Menu name="Help" mnemonic="H" location="900">
              <Component name="org.lcsim" command="LCSimHelp" location="701"/>
         </Menu>
+        <Menu name="File" mnemonic="F" location="100">
+            <Menu name="New" mnemonic="N" location="50">
+                <Component type="default" 
+                           icon="/org/freehep/jas/extension/pnuts/pnut.gif" 
+                           name="LCSim Event Browser" 
+                           mnemonic="E" 
+                           command="LCSimEventBrowser" 
+                           location="1200"/>
+            </Menu>
+        </Menu>
     </MenuBar>
 </MenuSystem>
\ No newline at end of file

lcsim/src/org/lcsim/plugin
LCSimPlugin.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- LCSimPlugin.java	21 Jun 2005 18:19:52 -0000	1.4
+++ LCSimPlugin.java	22 Sep 2005 22:03:07 -0000	1.5
@@ -28,159 +28,136 @@
 /**
  *
  * @author tonyj
- * @version $Id: LCSimPlugin.java,v 1.4 2005/06/21 18:19:52 tonyj Exp $
+ * @version $Id: LCSimPlugin.java,v 1.5 2005/09/22 22:03:07 jeremy Exp $
  */
 
 public class LCSimPlugin extends Plugin implements StudioListener, PageListener
 {
-   protected void init() throws SAXException, IOException
-   {
-      Studio app = getApplication();
-      
-      XMLMenuBuilder builder = app.getXMLMenuBuilder();
-      URL xml = getClass().getResource("LCSim.menus");
-      builder.build(xml);
-      
-      //      app.getLookup().add(this);
-      app.getLookup().add(new LCSimFileHandler(app),"org.lcsim Plugin");
-      app.getLookup().add(new StdhepFileHandler(app),"org.lcsim Plugin");
-      
-      // Listen for any drivers to be loaded
-      app.getEventSender().addEventListener(this,ClassLoadEvent.class);
-      
-      // Register the command processsor
-      app.getCommandTargetManager().add(commands = new LCSimCommands());
-      
-      LCSimEventBrowser.registerTableModels(app.getLookup());
-      
-      Template map = new Template();
-      map.set("title","org.lcsim Examples");
-      map.set("url","classpath:/org/lcsim/plugin/web/examples.html");
-      map.set("description","Examples of using the org.lcsim package");
-      app.getLookup().add(map,"examples");
-   }
-   
-   protected void postInit()
-   {
-      try
-      {
-         Class converterClass = Class.forName("org.lcsim.util.heprep.LCSimHepRepConverter");
-         Object converter = converterClass.newInstance();
-         getApplication().getLookup().add(converter);
-      }
-      catch (Throwable t)
-      {
-         System.err.println("Warning: Unable to create LCSimHepRepConverter, HepRep plugin probably not installed");
-      }
-   }
-   public void handleEvent(EventObject event)
-   {
-      if (event instanceof ClassLoadedEvent)
-      {
-         Class x = ((ClassLoadedEvent) event).getLoadedClass();
-         try
-         {
-            System.out.println("Loaded"+x+" "+Driver.class.isAssignableFrom(x));
-            if (Driver.class.isAssignableFrom(x))
-            {
-               Driver driver = (Driver) x.newInstance();
-               DriverAdapter listener = new DriverAdapter(driver);
-               getApplication().getLookup().add(listener);
-            }
-            else if (LCSimEventGenerator.class.isAssignableFrom(x))
-            {
-               LCSimEventGenerator gen = (LCSimEventGenerator) x.newInstance();
-               String name = x.getName();
-               int pos = name.lastIndexOf('.');
-               if (pos >= 0) name = name.substring(pos+1);
-               EventGeneratorRecordSource source = new EventGeneratorRecordSource(gen,name);
-               getApplication().getLookup().add(source);
-            }
-         }
-         catch (InstantiationException xx)
-         {
-            getApplication().error("Error instantiating "+x.getName(),xx);
-         }
-         catch (ExceptionInInitializerError xx)
-         {
-            getApplication().error("Error instantiating "+x.getName(),xx.getException());
-         }
-         catch (IllegalAccessException xx)
-         {
-            getApplication().error("Could not create class "+x.getName()+", missing public constructor?",xx);
-         }
-         catch (Throwable xx)
-         {
-            getApplication().error("Error instantiating "+x.getName(),xx);
-         }
-      }
-      else if (event instanceof ClassUnloadEvent)
-      {
-         // Record loop takes care of this
-      }
-   }
-   public void pageChanged(PageEvent e)
-   {
-      PageContext page = (PageContext) e.getSource();
-      if (e.getID() == PageEvent.PAGECLOSED)
-      {
-         if (page == eventBrowser)
-         {
-            eventBrowser = null;
-            commands.setChanged();
-         }
-         page.removePageListener(this);
-      }
-      else if (e.getID() == e.PAGESELECTED)
-      {
-         if (page == eventBrowser)
-         {
-            getApplication().getCommandTargetManager().add(((LCSimEventBrowser) eventBrowser.getPage()).getCommands());
-         }
-      }
-      else if (e.getID() == e.PAGEDESELECTED)
-      {
-         if (page == eventBrowser)
-         {
-            getApplication().getCommandTargetManager().remove(((LCSimEventBrowser) eventBrowser.getPage()).getCommands());
-         }
-      }
-   }
-   private PageContext eventBrowser;
-   private LCSimCommands commands;
-   
-   class LCSimCommands extends CommandProcessor
-   {
-      public void enableLCSimEventBrowser(BooleanCommandState state)
-      {
-         SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
-         state.setEnabled(loop != null);
-         state.setSelected(eventBrowser != null);
-      }
-      
-      public void onLCSimEventBrowser(boolean state)
-      {
-         if (eventBrowser != null)
-         {
-            eventBrowser.removePageListener(LCSimPlugin.this);
-            eventBrowser.close();
-            eventBrowser = null;
-         }
-         else
-         {
+    protected void init() throws SAXException, IOException
+    {        
+        Studio app = getApplication();
+        
+        XMLMenuBuilder builder = app.getXMLMenuBuilder();
+        URL xml = getClass().getResource("LCSim.menus");
+        builder.build(xml);
+                
+        app.getLookup().add(new LCSimFileHandler(app),"org.lcsim Plugin");
+        app.getLookup().add(new StdhepFileHandler(app),"org.lcsim Plugin");
+        
+        // Listen for any drivers to be loaded
+        app.getEventSender().addEventListener(this,ClassLoadEvent.class);
+        
+        // Register the command processsor
+        app.getCommandTargetManager().add(commands = new LCSimCommands());
+        
+        LCSimEventBrowser.registerTableModels(app.getLookup());
+        
+        Template map = new Template();
+        map.set("title","org.lcsim Examples");
+        map.set("url","classpath:/org/lcsim/plugin/web/examples.html");
+        map.set("description","Examples of using the org.lcsim package");
+        app.getLookup().add(map,"examples");
+    }
+    
+    protected void postInit()
+    {
+        try
+        {
+            Class converterClass = Class.forName("org.lcsim.util.heprep.LCSimHepRepConverter");
+            Object converter = converterClass.newInstance();
+            getApplication().getLookup().add(converter);
+        }
+        catch (Throwable t)
+        {
+            System.err.println("Warning: Unable to create LCSimHepRepConverter, HepRep plugin probably not installed");
+        }
+    }
+    public void handleEvent(EventObject event)
+    {
+        if (event instanceof ClassLoadedEvent)
+        {
+            Class x = ((ClassLoadedEvent) event).getLoadedClass();
+            try
+            {
+                System.out.println("Loaded"+x+" "+Driver.class.isAssignableFrom(x));
+                if (Driver.class.isAssignableFrom(x))
+                {
+                    Driver driver = (Driver) x.newInstance();
+                    DriverAdapter listener = new DriverAdapter(driver);
+                    getApplication().getLookup().add(listener);
+                }
+                else if (LCSimEventGenerator.class.isAssignableFrom(x))
+                {
+                    LCSimEventGenerator gen = (LCSimEventGenerator) x.newInstance();
+                    String name = x.getName();
+                    int pos = name.lastIndexOf('.');
+                    if (pos >= 0) name = name.substring(pos+1);
+                    EventGeneratorRecordSource source = new EventGeneratorRecordSource(gen,name);
+                    getApplication().getLookup().add(source);
+                }
+            }
+            catch (InstantiationException xx)
+            {
+                getApplication().error("Error instantiating "+x.getName(),xx);
+            }
+            catch (ExceptionInInitializerError xx)
+            {
+                getApplication().error("Error instantiating "+x.getName(),xx.getException());
+            }
+            catch (IllegalAccessException xx)
+            {
+                getApplication().error("Could not create class "+x.getName()+", missing public constructor?",xx);
+            }
+            catch (Throwable xx)
+            {
+                getApplication().error("Error instantiating "+x.getName(),xx);
+            }
+        }
+        else if (event instanceof ClassUnloadEvent)
+        {
+            // Record loop takes care of this
+        }
+    }
+    public void pageChanged(PageEvent e)
+    {
+        PageContext page = (PageContext) e.getSource();        
+        if (e.getID() == e.PAGESELECTED)
+        {
+            //            if (page == eventBrowser)
+            if ( page.getPage() instanceof LCSimEventBrowser )
+            {
+                getApplication().getCommandTargetManager().add(((LCSimEventBrowser) page.getPage()).getCommands());
+            }
+        }
+        else if (e.getID() == e.PAGEDESELECTED)
+        {
+            //if (page == eventBrowser)
+            if ( page.getPage() instanceof LCSimEventBrowser )
+            {
+                getApplication().getCommandTargetManager().remove(((LCSimEventBrowser) page.getPage()).getCommands());
+            }
+        }
+    }
+    
+    private LCSimCommands commands;
+    
+    class LCSimCommands extends CommandProcessor
+    {
+        public void onLCSimEventBrowser()
+        {
             SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
             LCSimEventBrowser tree  = new LCSimEventBrowser(getApplication(),loop);
-            eventBrowser = getApplication().getPageManager().openPage(tree,"LCSim Event",null);
-            eventBrowser.addPageListener(LCSimPlugin.this);
-         }
-         setChanged();
-      }
-      
-      public void onLCSimHelp()
-      {
-         URL help = getClass().getResource("web/index.html");
-         WebBrowser wb = (WebBrowser) getApplication().getLookup().lookup(WebBrowser.class);
-         if (wb != null && help != null) wb.showURL(help);
-      }
-   }
+            //            eventBrowser = getApplication().getPageManager().openPage(tree,"LCSim Event",null);
+            //            eventBrowser.addPageListener(LCSimPlugin.this);
+            getApplication().getPageManager().openPage(tree,"LCSim Event",null);
+            setChanged();
+        }
+        
+        public void onLCSimHelp()
+        {
+            URL help = getClass().getResource("web/index.html");
+            WebBrowser wb = (WebBrowser) getApplication().getLookup().lookup(WebBrowser.class);
+            if (wb != null && help != null) wb.showURL(help);
+        }
+    }
 }
\ No newline at end of file
CVSspam 0.2.8