[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.26, Wed Jun 9 22:36:10 2004 UTC revision 1.36, Wed Jul 14 20:45:24 2004 UTC
# Line 1  Line 1 
1  from wxPython.wx             import *  from wxPython.wx             import *
2  from FaST.BssFactory         import BssFactory  from FaST.BssFactory         import BssFactory
3    from FaST.BssFactoryProxy    import BssFactoryProxy
4  from FaST.WitFactory         import WitFactory  from FaST.WitFactory         import WitFactory
5  from FaST.SeedDataFactory    import SeedDataFactory  from FaST.SeedDataFactory    import SeedDataFactory
6  from FaST.SeedDataFactory    import SeedOrganism  from FaST.SeedDataFactory    import SeedOrganism
7  from FaST.RecoElem           import RecoElem  from KahOM.RecoElem           import RecoElem
8  from RecoElempanel           import RecoElempanel  from PyGUI.RecoElempanel           import RecoElempanel
9  from CatalogServices.Catalog import Catalog  from CatalogServices.Catalog import Catalog
10    
11    
12  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 ):  
   
13      #------------------------------------------------------------------------      #------------------------------------------------------------------------
14      def __init__(self, parent):      def __init__(self, parent):
15      #------------------------------------------------------------------------      #------------------------------------------------------------------------
# Line 97  Line 86 
86          return          return
87    
88      #------------------------------------------------------------------------      #------------------------------------------------------------------------
     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  
   
     #------------------------------------------------------------------------  
89      def loadCatalog(self):      def loadCatalog(self):
90      #------------------------------------------------------------------------      #------------------------------------------------------------------------
91          wxBeginBusyCursor()          wxBeginBusyCursor()
92    
93          localSeedServer        = "http://localhost/FIG"          #localSeedServer        = "http://localhost/FIG"
94          seedFactory   = SeedDataFactory( localSeedServer )          #seedFactory   = SeedDataFactory( localSeedServer )
         b             = BssFactory()  
95    
96          try:          ##
97              Catalog.instance().addDataFactory( seedFactory )          # DO NOT CREATE BssFactory() HERE ANY LONGER
98              Catalog.instance().addDataFactory( b )          # See main progam, ModelEditor
99          except:          ##
             self.parent.error("loadCatalog: error" )  
             wxEndBusyCursor()  
             return  
100    
101          ##          ##
102          # Handle top/root of catalog/tree specially to avoid "two root"          # Handle top/root of catalog/tree specially to avoid "two root"
# Line 193  Line 146 
146          return          return
147    
148      #------------------------------------------------------------------------      #------------------------------------------------------------------------
149      def loadSeedCatalog(self, seedServer ):      def DOOMloadSeedCatalog(self, seedServer ):
150      #------------------------------------------------------------------------      #------------------------------------------------------------------------
151          wxBeginBusyCursor()          """
152            This adds a Seed instance to the catalog.  It is called from the
153          seedFactory   = SeedDataFactory( seedServer )          MainMenuBar when Data->Add Seed Instance is called, for example.
154            """
         # add it to the list in the catalog  
         try:  
             Catalog.instance().addDataFactory( seedFactory )  
         except:  
             self.parent.error("loadSeedCatalog: %s already in foundry list." % seedServer)  
             wxEndBusyCursor()  
             return  
   
         top = seedFactory.getCatalogTop()  
         self.recurseCatalog( top, self.parent.catalog_tree, self.parent.catalogRootId)  
   
         wxEndBusyCursor()  
   
         return  
155    
     #------------------------------------------------------------------------  
     def OLDloadSeedCatalog(self, seedServer ):  
     #------------------------------------------------------------------------  
156          wxBeginBusyCursor()          wxBeginBusyCursor()
157    
158          # The SeedDataFactory ctor is slow and actually reads a bunch of          # The SeedDataFactory ctor is slow and actually reads a bunch of
# Line 232  Line 168 
168              wxEndBusyCursor()              wxEndBusyCursor()
169              return              return
170    
171          # make an entry in the tree for it          top = seedFactory.getCatalogTop()
172          #          self.recurseCatalog( top, self.parent.catalog_tree, self.parent.catalogRootId)
         newSeedItemId=self.parent.catalog_tree.AppendItem(self.seedItemId, seedServer )  
173    
         # jam in the data  
         #  
         orgList = seedFactory.listOrganisms( )  
         if ( orgList== None ):  
             orgItemId=self.parent.catalog_tree.AppendItem(newSeedItemId,  
                          "Could not get Org list from "+ seedServer )  
174              wxEndBusyCursor()              wxEndBusyCursor()
             return  
   
         itemName="Spontaneous Reactions"  
         spontaneousRxItemId=self.parent.catalog_tree.AppendItem(newSeedItemId, itemName)  
         self.parent.catalog_tree.SetPyData(spontaneousRxItemId,  
                                            (self.seedRecoElemLoader,  
                                            (seedFactory.getRecoElemSpontaneousRx, None),  
                                             spontaneousRxItemId ))  
   
175    
         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()  
176          return          return
177    
178      #------------------------------------------------------------------------      #------------------------------------------------------------------------
# Line 270  Line 182 
182    
183          catEntryTuple = self.parent.tree_ctr.GetPyData(item)          catEntryTuple = self.parent.tree_ctr.GetPyData(item)
184          if (catEntryTuple == None ):          if (catEntryTuple == None ):
             print "None value for catEntryTuple"  
185              return              return
186          self.selected = catEntryTuple          self.selected = catEntryTuple
187          catEntry   = catEntryTuple[1]          catEntry   = catEntryTuple[1]
# Line 283  Line 194 
194          theBox.Clear()          theBox.Clear()
195    
196          if ( not catEntry.isTerminal() ):          if ( not catEntry.isTerminal() ):
197              self.parent.catPathValue.SetLabel( catEntry.path() + "/" )  
198                self.parent.catPathValue.SetValue( catEntry.path() + "/" )
199              self.parent.catVersionValueComboBox.SetLabel( "")              self.parent.catVersionValueComboBox.SetLabel( "")
200              self.parent.catHistoryDateValue.SetLabel( "" )              self.parent.catHistoryDateValue.SetLabel( "" )
201              self.parent.catHistoryUserValue.SetLabel( "" )              self.parent.catHistoryUserValue.SetLabel( "" )
# Line 292  Line 204 
204          else:          else:
205              versions   = catEntry.versions()              versions   = catEntry.versions()
206              if ( [] == versions ):              if ( [] == versions ):
207                  self.parent.catPathValue.SetLabel( catEntry.path()+";[None]" )                  self.parent.catPathValue.SetValue( catEntry.path()+";[None]" )
208                  theBox.SetValue( "None" )                  theBox.SetValue( "None" )
209              else:              else:
                 print "versions are ", versions  
210                  maxVersion = max( versions )                  maxVersion = max( versions )
211                  for v in versions:                  for v in versions:
212                      theBox.Append( "%s" % (v ) )                      theBox.Append( "%s" % (v ) )
213                      theBox.SetValue( "%s" % (maxVersion) )                      theBox.SetValue( "%s" % (maxVersion) )
214                  self.parent.catPathValue.SetLabel(catEntry.path()+";[%s]" % (maxVersion))                  self.parent.catPathValue.SetValue(catEntry.path()+";[%s]" % (maxVersion))
215              #              #
216              self.parent.catHistoryDateValue.SetLabel( "no date info yet" )              self.parent.catHistoryDateValue.SetLabel( "no date info yet" )
217              self.parent.catHistoryUserValue.SetLabel( "no user info yet" )              self.parent.catHistoryUserValue.SetLabel( "no user info yet" )
# Line 335  Line 246 
246      #------------------------------------------------------------------------      #------------------------------------------------------------------------
247      def onRightClickCatalogTree(self, event):      def onRightClickCatalogTree(self, event):
248      #------------------------------------------------------------------------      #------------------------------------------------------------------------
249            """ Fires off the pop-up menu to handle right click events. """
250    
251          goober = event.GetEventObject()          event.GetEventObject().PopupMenu(self.catEditMenu, event.GetPosition())
         goober.PopupMenu(self.catEditMenu, event.GetPosition())  
   
252          return          return
253    
254      #------------------------------------------------------------------------      #------------------------------------------------------------------------
# Line 368  Line 278 
278              dlg.Destroy()              dlg.Destroy()
279              return              return
280    
281          try:          #try:
282            if (1):
283              newCatEntry=catEntry.mkDir( theName )              newCatEntry=catEntry.mkDir( theName )
284              parentTree=self.parent.catalog_tree              parentTree=self.parent.catalog_tree
285              newItemId=parentTree.AppendItem(treeItemId, newCatEntry.name() )              newItemId=parentTree.AppendItem(treeItemId, newCatEntry.name() )
# Line 376  Line 287 
287                                    (self.recoElemLoader, newCatEntry, newItemId )  )                                    (self.recoElemLoader, newCatEntry, newItemId )  )
288    
289              parentTree.SortChildren( treeItemId )              parentTree.SortChildren( treeItemId )
290          except:          else:
291            #except:
292              self.parent.error( "Operation refused." )              self.parent.error( "Operation refused." )
293    
294    
# Line 427  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 446  Line 364 
364          if (catalogEntry.isTerminal() ):          if (catalogEntry.isTerminal() ):
365              ver = self.parent.catVersionValueComboBox.GetValue()              ver = self.parent.catVersionValueComboBox.GetValue()
366              if ( ver == "None" ):              if ( ver == "None" ):
367                  top = RecoElem( catalogEntry.name(), 1 )                  top = RecoElem( catalogEntry.name() )
368              else:              else:
369                  top = catalogEntry.read( int( ver ) )                  top = catalogEntry.read( int( ver ) )
370    
371              self.to_re.AddRecoElemTree(self.parent.rootId, top, catalogEntry)              self.to_re.addRecoElemTree(self.parent.rootId, top, catalogEntry)
372          else:          else:
373              # current selection is directory. can't load that!              # current selection is directory. can't load that!
374              wxEndBusyCursor()              wxEndBusyCursor()
# Line 459  Line 377 
377    
378          wxEndBusyCursor()          wxEndBusyCursor()
379          return          return
   
     #------------------------------------------------------------------------  
     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)  
         wxEndBusyCursor()  
         return  
   
     #------------------------------------------------------------------------  
     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)  
   
         wxEndBusyCursor()  
         return  
   
     #------------------------------------------------------------------------  
     def witPwyLoader(self,  pwyName ):  
     #------------------------------------------------------------------------  
         wxBeginBusyCursor()  
         w=WitFactory()  
         top= w.getRxnByPwy( pwyName )  
         self.to_re.AddRecoElemTree(self.parent.rootId, top)  
         wxEndBusyCursor()  
         return  

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.36

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3