[Bio] / PyGUI / Catalogpanel.py Repository:
ViewVC logotype

Diff of /PyGUI/Catalogpanel.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25, Wed May 26 01:38:25 2004 UTC revision 1.27, Wed Jun 23 19:02:51 2004 UTC
# Line 9  Line 9 
9    
10    
11  class Catalogpanel:  class Catalogpanel:
 #    def __init__(self, parent):  
 #    def initCatEvents(self ):  
 #    def initCatData( self ):  
 #    def loadBssCatalog(self, bssItemId):  
 #    def loadWitCatalog(self, witItemId):  
 #    def loadSeedCatalog(self, witItemId):  
 #    def onLeftClick(self,treeEvent):  
 #    def onLoadBtnPress(self, event):  
 #    def bssLoader( self, bssCatEntry ):  
 #    def witOrgLoader(self,  orgName ):  
 #    def witPwyLoader(self,  pwyName ):  
   
12      #------------------------------------------------------------------------      #------------------------------------------------------------------------
13      def __init__(self, parent):      def __init__(self, parent):
14      #------------------------------------------------------------------------      #------------------------------------------------------------------------
# Line 75  Line 63 
63      #------------------------------------------------------------------------      #------------------------------------------------------------------------
64      def initCatData( self ):      def initCatData( self ):
65      #------------------------------------------------------------------------      #------------------------------------------------------------------------
         self.parent.catalogRootId = self.parent.catalog_tree.AddRoot("Data Sources")  
   
         #bssItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId,  
         #                                           "BioSimScratch" )  
         #witItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId,  
         #                                           "WIT3" )  
         #self.seedItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId,  
         #                                           "Seed" )  
   
         #self.loadBssCatalog( bssItemId )  
         #self.loadWitCatalog( witItemId )  
   
         localSeedServer        = "http://localhost/FIG/"  
 #        localSeedServer        = "http://float179.mcs.anl-external.org/FIG/"  
         #self.loadSeedCatalog( localSeedServer)  
66    
67            self.parent.catalogRootId = self.parent.catalog_tree.AddRoot("/")
68          self.loadCatalog()          self.loadCatalog()
69    
   
70          self.parent.catalog_tree.Expand( self.parent.catalogRootId)          self.parent.catalog_tree.Expand( self.parent.catalogRootId)
71          return          return
72    
# Line 112  Line 85 
85          return          return
86    
87      #------------------------------------------------------------------------      #------------------------------------------------------------------------
     def loadBssCatalog(self, bssItemId):  
     #------------------------------------------------------------------------  
         b=BssFactory()  
         Catalog.instance().addDataFactory( b )  
         for catEntryTuple in b.getLsCat():  
             id=self.parent.catalog_tree.AppendItem(bssItemId, catEntryTuple[0])  
             self.parent.catalog_tree.SetPyData(id, (self.bssLoader, catEntryTuple, id) )  
   
         return  
   
     #------------------------------------------------------------------------  
     def loadWitCatalog(self, witItemId):  
     #------------------------------------------------------------------------  
         w=WitFactory()  
         Catalog.instance().addDataFactory( w )  
         pwyItemId=self.parent.catalog_tree.AppendItem(witItemId, "Pathways" )  
   
         pwyList = w.listPathways( )  
         for pwy in pwyList:  
             id=self.parent.catalog_tree.AppendItem(pwyItemId, pwy)  
             self.parent.catalog_tree.SetPyData(id, (self.witPwyLoader,pwy, id) )  
   
         orgItemId=self.parent.catalog_tree.AppendItem(witItemId, "Organisms" )  
   
         orgList = w.listOrganisms( )  
         for org in orgList:  
             id=self.parent.catalog_tree.AppendItem(orgItemId, org)  
             self.parent.catalog_tree.SetPyData(id, (self.witOrgLoader, org, id ))  
   
         return  
   
     #------------------------------------------------------------------------  
88      def loadCatalog(self):      def loadCatalog(self):
89      #------------------------------------------------------------------------      #------------------------------------------------------------------------
90          wxBeginBusyCursor()          wxBeginBusyCursor()
91    
92          localSeedServer        = "http://localhost/FIG/"          localSeedServer        = "http://localhost/FIG"
93          seedFactory   = SeedDataFactory( localSeedServer )          seedFactory   = SeedDataFactory( localSeedServer )
94          b             = BssFactory()          b             = BssFactory()
95    
# Line 160  Line 101 
101              wxEndBusyCursor()              wxEndBusyCursor()
102              return              return
103    
104          top = Catalog.instance().getCatalogTop()          ##
105          self.recurseCatalog( top, self.parent.catalog_tree, self.parent.catalogRootId)          # Handle top/root of catalog/tree specially to avoid "two root"
106            # on display problem
107          wxEndBusyCursor()          ##
   
         return  
   
     #------------------------------------------------------------------------  
     def loadSeedCatalog(self, seedServer ):  
     #------------------------------------------------------------------------  
         wxBeginBusyCursor()  
108    
109          seedFactory   = SeedDataFactory( seedServer )          top = Catalog.instance().getCatalogTop()
110            parentTree = self.parent.catalog_tree
111            parentTree.SetPyData( self.parent.catalogRootId,
112                                  (self.recoElemLoader, top, self.parent.catalogRootId) )
113    
114          # add it to the list in the catalog          for e in top.entries():
115          try:              self.recurseCatalog( e, parentTree, self.parent.catalogRootId)
             Catalog.instance().addDataFactory( seedFactory )  
         except:  
             self.parent.error("loadSeedCatalog: %s already in foundry list." % seedServer)  
             wxEndBusyCursor()  
             return  
116    
117          top = seedFactory.getCatalogTop()          parentTree.SortChildren( self.parent.catalogRootId)
         #self.recurseCatalog( top, self.parent.catalog_tree, self.seedItemId )  
         self.recurseCatalog( top, self.parent.catalog_tree, self.parent.catalogRootId)  
118    
119          wxEndBusyCursor()          wxEndBusyCursor()
120    
# Line 194  Line 124 
124      def recurseCatalog( self, catEntry, parentTree, parentItemId):      def recurseCatalog( self, catEntry, parentTree, parentItemId):
125      #------------------------------------------------------------------------      #------------------------------------------------------------------------
126          """          """
127          terminal nodes have FoundryItemKeys associated with them that we          Create a new item under parentItemId in wxTree, parentTree.  Associate
128          can read if requested.  associate that key and a handler with the          catEntry with it.  If catEntry has entries, recurse on them.
         wxTree item in that case.  
129          """          """
130    
131          newItemId=parentTree.AppendItem(parentItemId, catEntry.name() )          if ( catEntry.isTerminal() ):
132                displayedName = catEntry.name()
133            else:
134                displayedName = catEntry.name() + "/"
135    
136            newItemId=parentTree.AppendItem(parentItemId, displayedName )
137    
138            # associate data needed to manipulate the catEntry
139    
140          parentTree.SetPyData( newItemId,          parentTree.SetPyData( newItemId,
141                                (self.recoElemLoader, catEntry, newItemId )                                (self.recoElemLoader, catEntry, newItemId ) )
                               )  
142    
143          if ( not catEntry.isTerminal() ):          if ( not catEntry.isTerminal() ):
144              for e in catEntry.entries():              for e in catEntry.entries():
145                  self.recurseCatalog( e, parentTree, newItemId)                  self.recurseCatalog( e, parentTree, newItemId)
146    
         # not efficient becaure of re-sort  
   
147          parentTree.SortChildren( newItemId )          parentTree.SortChildren( newItemId )
148    
149          return          return
150    
151      #------------------------------------------------------------------------      #------------------------------------------------------------------------
152      def OLDloadSeedCatalog(self, seedServer ):      def loadSeedCatalog(self, seedServer ):
153      #------------------------------------------------------------------------      #------------------------------------------------------------------------
154            """
155            This adds a Seed instance to the catalog.  It is called from the
156            MainMenuBar when Data->Add Seed Instance is called, for example.
157            """
158    
159          wxBeginBusyCursor()          wxBeginBusyCursor()
160    
161          # The SeedDataFactory ctor is slow and actually reads a bunch of          # The SeedDataFactory ctor is slow and actually reads a bunch of
# Line 233  Line 171 
171              wxEndBusyCursor()              wxEndBusyCursor()
172              return              return
173    
174          # make an entry in the tree for it          top = seedFactory.getCatalogTop()
175          #          self.recurseCatalog( top, self.parent.catalog_tree, self.parent.catalogRootId)
         newSeedItemId=self.parent.catalog_tree.AppendItem(self.seedItemId, seedServer )  
176    
         # jam in the data  
         #  
         orgList = seedFactory.listOrganisms( )  
         if ( orgList== None ):  
             orgItemId=self.parent.catalog_tree.AppendItem(newSeedItemId,  
                          "Could not get Org list from "+ seedServer )  
177              wxEndBusyCursor()              wxEndBusyCursor()
             return  
178    
         itemName="Spontaneous Reactions"  
         spontaneousRxItemId=self.parent.catalog_tree.AppendItem(newSeedItemId, itemName)  
         self.parent.catalog_tree.SetPyData(spontaneousRxItemId,  
                                            (self.seedRecoElemLoader,  
                                            (seedFactory.getRecoElemSpontaneousRx, None),  
                                             spontaneousRxItemId ))  
   
   
         orgItemId=self.parent.catalog_tree.AppendItem(newSeedItemId, "Organisms" )  
         for org in orgList:  
             id=self.parent.catalog_tree.AppendItem(orgItemId, org.figOrgName )  
             self.parent.catalog_tree.SetPyData(id, (self.seedRecoElemLoader,  
                                                    (seedFactory.getRecoElemByOrg, org), id) )  
   
   
         wxEndBusyCursor()  
179          return          return
180    
181      #------------------------------------------------------------------------      #------------------------------------------------------------------------
# Line 271  Line 185 
185    
186          catEntryTuple = self.parent.tree_ctr.GetPyData(item)          catEntryTuple = self.parent.tree_ctr.GetPyData(item)
187          if (catEntryTuple == None ):          if (catEntryTuple == None ):
             print "None value for catEntryTuple"  
188              return              return
189          self.selected = catEntryTuple          self.selected = catEntryTuple
190          catEntry   = catEntryTuple[1]          catEntry   = catEntryTuple[1]
# Line 284  Line 197 
197          theBox.Clear()          theBox.Clear()
198    
199          if ( not catEntry.isTerminal() ):          if ( not catEntry.isTerminal() ):
200              self.parent.catPathValue.SetLabel( catEntry.path() )              self.parent.catPathValue.SetLabel( catEntry.path() + "/" )
201              self.parent.catVersionValueComboBox.SetLabel( "")              self.parent.catVersionValueComboBox.SetLabel( "")
202              self.parent.catHistoryDateValue.SetLabel( "" )              self.parent.catHistoryDateValue.SetLabel( "" )
203              self.parent.catHistoryUserValue.SetLabel( "" )              self.parent.catHistoryUserValue.SetLabel( "" )
204              self.parent.catHistoryCreatedFromValue.SetLabel( "")              self.parent.catHistoryCreatedFromValue.SetLabel( "")
205                theBox.SetValue( "" )
206          else:          else:
207              versions   = catEntry.versions()              versions   = catEntry.versions()
208              if ( [] == versions ):              if ( [] == versions ):
209                  self.parent.catPathValue.SetLabel( catEntry.path()+";[None]" )                  self.parent.catPathValue.SetLabel( catEntry.path()+";[None]" )
210                    theBox.SetValue( "None" )
211              else:              else:
212                  maxVersion = max( versions )                  maxVersion = max( versions )
213                  for v in versions:                  for v in versions:
# Line 316  Line 231 
231    
232          # get the value selected in the combo box.          # get the value selected in the combo box.
233          choice = event.GetString()          choice = event.GetString()
234            self.parent.catVersionValueComboBox.SetValue( "%s" % (choice) )
235    
236          # the operation is interpreted relative to the currently selected          # the operation is interpreted relative to the currently selected
237          # catalogEntry.  find what that is.          # catalogEntry.  find what that is.
# Line 332  Line 248 
248      #------------------------------------------------------------------------      #------------------------------------------------------------------------
249      def onRightClickCatalogTree(self, event):      def onRightClickCatalogTree(self, event):
250      #------------------------------------------------------------------------      #------------------------------------------------------------------------
251            """ Fires off the pop-up menu to handle right click events. """
252    
253          goober = event.GetEventObject()          event.GetEventObject().PopupMenu(self.catEditMenu, event.GetPosition())
         goober.PopupMenu(self.catEditMenu, event.GetPosition())  
   
254          return          return
255    
256      #------------------------------------------------------------------------      #------------------------------------------------------------------------
# Line 424  Line 339 
339      #------------------------------------------------------------------------      #------------------------------------------------------------------------
340      def onLeftDClick(self, event):      def onLeftDClick(self, event):
341      #------------------------------------------------------------------------      #------------------------------------------------------------------------
342            """ Double left-click means, "Load the currently selected item." """
343    
344          if ( self.selected == None ):          if ( self.selected == None ):
345              print "No selection in onLoadBtnPress"              self.parent.error( "You must select a catalog entry before requesting load.")
346              return              return
347    
348            # We store a loader to actually load the selected item.  This dates
349            # back to a time before a single loader could handle all the various
350            # data factory kinds.
351    
352          catEntryTuple = self.selected          catEntryTuple = self.selected
353          apply( catEntryTuple[0], [catEntryTuple[1]] )          apply( catEntryTuple[0], [catEntryTuple[1]] )
354    
# Line 441  Line 362 
362          (catalogEntry) = argList          (catalogEntry) = argList
363    
364          if (catalogEntry.isTerminal() ):          if (catalogEntry.isTerminal() ):
365              top = catalogEntry.getRecoElem()              ver = self.parent.catVersionValueComboBox.GetValue()
366              self.to_re.AddRecoElemTree(self.parent.rootId, top, catalogEntry)              if ( ver == "None" ):
367                    top = RecoElem( catalogEntry.name() )
368          else:          else:
369              # current selection is directory. can't load that!                  top = catalogEntry.read( int( ver ) )
             wxEndBusyCursor()  
             return  
370    
371                self.to_re.addRecoElemTree(self.parent.rootId, top, catalogEntry)
372          wxEndBusyCursor()          else:
373          return              # current selection is directory. can't load that!
   
     #------------------------------------------------------------------------  
     def bssLoader( self, bssCatEntry ):  
     #------------------------------------------------------------------------  
         wxBeginBusyCursor()  
         b=BssFactory()  
         top= b.getRecoElemById( bssCatEntry[1] )  
         self.to_re.AddRecoElemTree(self.parent.rootId, top)  
         wxEndBusyCursor()  
   
         return  
   
     #------------------------------------------------------------------------  
     def witOrgLoader(self,  orgName ):  
     #------------------------------------------------------------------------  
         wxBeginBusyCursor()  
         w=WitFactory()  
         top= w.getRxnByOrg( orgName )  
         self.to_re.AddRecoElemTree(self.parent.rootId, top)  
374          wxEndBusyCursor()          wxEndBusyCursor()
375          return          return
376    
     #------------------------------------------------------------------------  
     def seedRecoElemLoader(self,  argList ):  
     #------------------------------------------------------------------------  
         wxBeginBusyCursor()  
   
         (theSeedFactoryMethod, org) = argList  
         top = apply( theSeedFactoryMethod, [org] )  
         # top=self.__seedDataFactory.getRecoElemByOrg( org )  
         self.to_re.AddRecoElemTree(self.parent.rootId, top)  
377    
378          wxEndBusyCursor()          wxEndBusyCursor()
379          return          return
380    
381      #------------------------------------------------------------------------      #------------------------------------------------------------------------
382      def witPwyLoader(self,  pwyName ):      def DOOMwitPwyLoader(self,  pwyName ):
383      #------------------------------------------------------------------------      #------------------------------------------------------------------------
384          wxBeginBusyCursor()          wxBeginBusyCursor()
385          w=WitFactory()          w=WitFactory()
386          top= w.getRxnByPwy( pwyName )          top= w.getRxnByPwy( pwyName )
387          self.to_re.AddRecoElemTree(self.parent.rootId, top)          self.to_re.addRecoElemTree(self.parent.rootId, top)
388          wxEndBusyCursor()          wxEndBusyCursor()
389          return          return

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.27

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3