Parent Directory
|
Revision Log
Revision 1.18 - (view) (download) (as text)
1 : | hwang | 1.1 | from wxPython.wx import * |
2 : | from FaST.BssFactory import BssFactory | ||
3 : | efrank | 1.4 | from FaST.WitFactory import WitFactory |
4 : | efrank | 1.12 | from FaST.SeedDataFactory import SeedDataFactory |
5 : | from FaST.SeedDataFactory import SeedOrganism | ||
6 : | hwang | 1.1 | from FaST.RecoElem import RecoElem |
7 : | from RecoElempanel import RecoElemWindow | ||
8 : | |||
9 : | efrank | 1.12 | |
10 : | |||
11 : | hwang | 1.1 | class CatalogWindow: |
12 : | efrank | 1.10 | # def __init__(self, parent): |
13 : | # def initCatEvents(self ): | ||
14 : | # def initCatData( self ): | ||
15 : | # def loadBssCatalog(self, bssItemId): | ||
16 : | # def loadWitCatalog(self, witItemId): | ||
17 : | efrank | 1.12 | # def loadSeedCatalog(self, witItemId): |
18 : | efrank | 1.10 | # def onLeftClick(self,treeEvent): |
19 : | # def onLoadBtnPress(self, event): | ||
20 : | # def bssLoader( self, bssCatEntry ): | ||
21 : | # def witOrgLoader(self, orgName ): | ||
22 : | # def witPwyLoader(self, pwyName ): | ||
23 : | |||
24 : | efrank | 1.4 | #------------------------------------------------------------------------ |
25 : | hwang | 1.1 | def __init__(self, parent): |
26 : | efrank | 1.4 | #------------------------------------------------------------------------ |
27 : | efrank | 1.13 | self.parent = parent |
28 : | |||
29 : | self.to_re = parent.re | ||
30 : | efrank | 1.2 | self.selected = None #remember last selected catalog entry |
31 : | #..is used when LOAD button is hit. | ||
32 : | efrank | 1.4 | |
33 : | efrank | 1.14 | # seedItemId is the wxPython id for the "Seed" node |
34 : | # in the catalog tree under which all specific Seed servers | ||
35 : | # are listed | ||
36 : | |||
37 : | self.seedItemId = None | ||
38 : | |||
39 : | efrank | 1.4 | self.initCatEvents() |
40 : | self.initCatData() | ||
41 : | efrank | 1.14 | |
42 : | |||
43 : | self.seedServerMenu = wxMenu() | ||
44 : | self.seedServerAddId = wxNewId() | ||
45 : | self.setupSeedServerMenu() | ||
46 : | |||
47 : | efrank | 1.4 | return |
48 : | |||
49 : | |||
50 : | #------------------------------------------------------------------------ | ||
51 : | def initCatEvents(self ): | ||
52 : | #------------------------------------------------------------------------ | ||
53 : | efrank | 1.2 | button1= self.parent.OK_button |
54 : | EVT_BUTTON(self.parent, self.parent.loadbtn.GetId(), | ||
55 : | self.onLoadBtnPress) | ||
56 : | efrank | 1.6 | EVT_TREE_SEL_CHANGED(self.parent.catalog_tree, |
57 : | self.parent.catalog_treeId, | ||
58 : | self.onLeftClick) | ||
59 : | efrank | 1.14 | |
60 : | # Right click on List item for Seed will let you connect to | ||
61 : | # another Seed server | ||
62 : | |||
63 : | EVT_RIGHT_DOWN(self.parent.catalog_tree, self.onRightClickCatalogTree) | ||
64 : | |||
65 : | |||
66 : | # doesn't work... | ||
67 : | # EVT_LEFT_DCLICK (self.parent.catalog_tree, self.onLeftDClick) | ||
68 : | efrank | 1.6 | |
69 : | efrank | 1.4 | return |
70 : | |||
71 : | #------------------------------------------------------------------------ | ||
72 : | def initCatData( self ): | ||
73 : | #------------------------------------------------------------------------ | ||
74 : | efrank | 1.5 | self.parent.catalogRootId = self.parent.catalog_tree.AddRoot("Data Sources") |
75 : | hwang | 1.1 | |
76 : | efrank | 1.4 | bssItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId, |
77 : | "BioSimScratch" ) | ||
78 : | witItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId, | ||
79 : | "WIT3" ) | ||
80 : | efrank | 1.14 | self.seedItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId, |
81 : | efrank | 1.12 | "Seed" ) |
82 : | efrank | 1.4 | |
83 : | self.loadBssCatalog( bssItemId ) | ||
84 : | efrank | 1.9 | self.loadWitCatalog( witItemId ) |
85 : | efrank | 1.6 | |
86 : | efrank | 1.14 | localSeedServer = "http://localhost/FIG/" |
87 : | efrank | 1.18 | # localSeedServer = "http://float179.mcs.anl-external.org/FIG/" |
88 : | efrank | 1.14 | self.loadSeedCatalog( localSeedServer) |
89 : | efrank | 1.13 | |
90 : | efrank | 1.6 | self.parent.catalog_tree.Expand( self.parent.catalogRootId) |
91 : | efrank | 1.2 | return |
92 : | efrank | 1.4 | |
93 : | efrank | 1.14 | #------------------------------------------------------------------ |
94 : | def setupSeedServerMenu(self): | ||
95 : | #------------------------------------------------------------------ | ||
96 : | self.seedServerAddId = wxNewId() | ||
97 : | |||
98 : | self.seedServerMenu.Append( self.seedServerAddId, | ||
99 : | "Add Seed Server", "New seed server arg3" ) | ||
100 : | EVT_MENU(self.parent, self.seedServerAddId, self.doSeedServerAdd) | ||
101 : | |||
102 : | efrank | 1.4 | #------------------------------------------------------------------------ |
103 : | def loadBssCatalog(self, bssItemId): | ||
104 : | #------------------------------------------------------------------------ | ||
105 : | hwang | 1.1 | b=BssFactory() |
106 : | efrank | 1.4 | for catEntryTuple in b.getLsCat(): |
107 : | id=self.parent.catalog_tree.AppendItem(bssItemId, catEntryTuple[0]) | ||
108 : | efrank | 1.6 | self.parent.catalog_tree.SetPyData(id, (self.bssLoader, catEntryTuple) ) |
109 : | efrank | 1.4 | |
110 : | return | ||
111 : | hwang | 1.1 | |
112 : | efrank | 1.4 | #------------------------------------------------------------------------ |
113 : | def loadWitCatalog(self, witItemId): | ||
114 : | #------------------------------------------------------------------------ | ||
115 : | w=WitFactory() | ||
116 : | efrank | 1.6 | |
117 : | pwyItemId=self.parent.catalog_tree.AppendItem(witItemId, "Pathways" ) | ||
118 : | |||
119 : | efrank | 1.4 | pwyList = w.listPathways( ) |
120 : | for pwy in pwyList: | ||
121 : | efrank | 1.6 | id=self.parent.catalog_tree.AppendItem(pwyItemId, pwy) |
122 : | self.parent.catalog_tree.SetPyData(id, (self.witPwyLoader,pwy) ) | ||
123 : | |||
124 : | orgItemId=self.parent.catalog_tree.AppendItem(witItemId, "Organisms" ) | ||
125 : | |||
126 : | orgList = w.listOrganisms( ) | ||
127 : | for org in orgList: | ||
128 : | id=self.parent.catalog_tree.AppendItem(orgItemId, org) | ||
129 : | self.parent.catalog_tree.SetPyData(id, (self.witOrgLoader, org )) | ||
130 : | hwang | 1.3 | |
131 : | efrank | 1.4 | return |
132 : | hwang | 1.3 | |
133 : | efrank | 1.4 | #------------------------------------------------------------------------ |
134 : | efrank | 1.14 | def loadSeedCatalog(self, seedServer ): |
135 : | efrank | 1.12 | #------------------------------------------------------------------------ |
136 : | efrank | 1.14 | wxBeginBusyCursor() |
137 : | |||
138 : | # The SeedDataFactory ctor is slow and actually reads a bunch of | ||
139 : | # data from the server | ||
140 : | |||
141 : | seedFactory = SeedDataFactory( seedServer ) | ||
142 : | |||
143 : | efrank | 1.16 | # add it to the list in the catalog |
144 : | self.parent.factoryMgr.addFactory( seedServer, seedFactory ) | ||
145 : | |||
146 : | efrank | 1.14 | # make an entry in the tree for it |
147 : | # | ||
148 : | newSeedItemId=self.parent.catalog_tree.AppendItem(self.seedItemId, seedServer ) | ||
149 : | |||
150 : | # jam in the data | ||
151 : | # | ||
152 : | orgList = seedFactory.listOrganisms( ) | ||
153 : | efrank | 1.13 | if ( orgList== None ): |
154 : | efrank | 1.14 | orgItemId=self.parent.catalog_tree.AppendItem(newSeedItemId, |
155 : | "Could not get Org list from "+ seedServer ) | ||
156 : | efrank | 1.15 | wxEndBusyCursor() |
157 : | efrank | 1.13 | return |
158 : | |||
159 : | efrank | 1.17 | itemName="Spontaneous Reactions" |
160 : | spontaneousRxItemId=self.parent.catalog_tree.AppendItem(newSeedItemId, itemName) | ||
161 : | self.parent.catalog_tree.SetPyData(spontaneousRxItemId, | ||
162 : | (self.seedRecoElemLoader, | ||
163 : | (seedFactory.getRecoElemSpontaneousRx, None) )) | ||
164 : | |||
165 : | |||
166 : | efrank | 1.14 | orgItemId=self.parent.catalog_tree.AppendItem(newSeedItemId, "Organisms" ) |
167 : | efrank | 1.12 | for org in orgList: |
168 : | id=self.parent.catalog_tree.AppendItem(orgItemId, org.figOrgName ) | ||
169 : | efrank | 1.17 | self.parent.catalog_tree.SetPyData(id, (self.seedRecoElemLoader, |
170 : | efrank | 1.14 | (seedFactory.getRecoElemByOrg, org) )) |
171 : | efrank | 1.12 | |
172 : | efrank | 1.16 | |
173 : | efrank | 1.14 | wxEndBusyCursor() |
174 : | efrank | 1.12 | return |
175 : | |||
176 : | #------------------------------------------------------------------------ | ||
177 : | efrank | 1.6 | def onLeftClick(self,treeEvent): |
178 : | efrank | 1.4 | #------------------------------------------------------------------------ |
179 : | efrank | 1.5 | item = treeEvent.GetItem() |
180 : | hwang | 1.11 | |
181 : | efrank | 1.4 | catEntryTuple = self.parent.tree_ctr.GetPyData(item) |
182 : | efrank | 1.5 | if (catEntryTuple == None ): |
183 : | return | ||
184 : | efrank | 1.6 | self.selected = catEntryTuple |
185 : | efrank | 1.4 | |
186 : | return | ||
187 : | efrank | 1.14 | |
188 : | #------------------------------------------------------------------------ | ||
189 : | def onRightClickCatalogTree(self, event): | ||
190 : | #------------------------------------------------------------------------ | ||
191 : | |||
192 : | goober = event.GetEventObject() | ||
193 : | goober.PopupMenu(self.seedServerMenu, event.GetPosition()) | ||
194 : | |||
195 : | return | ||
196 : | |||
197 : | #------------------------------------------------------------------------ | ||
198 : | def doSeedServerAdd(self, event): | ||
199 : | #------------------------------------------------------------------------ | ||
200 : | prompt = "Name of Seed server" | ||
201 : | dlg = wxTextEntryDialog(self.parent, message=prompt, style=wxOK) | ||
202 : | |||
203 : | if ( dlg.ShowModal() == wxID_OK): | ||
204 : | serverName = dlg.GetValue() | ||
205 : | if ( serverName=="" ): return | ||
206 : | dlg.Destroy() | ||
207 : | else: | ||
208 : | #didn't get a kid name | ||
209 : | dlg.Destroy() | ||
210 : | return | ||
211 : | |||
212 : | self.loadSeedCatalog( serverName ) | ||
213 : | |||
214 : | return | ||
215 : | |||
216 : | hwang | 1.11 | #------------------------------------------------------------------------ |
217 : | def onLeftDClick(self,treeEvent): | ||
218 : | #------------------------------------------------------------------------ | ||
219 : | efrank | 1.12 | self.onLoadBtnPress(treeEvent) |
220 : | |||
221 : | pt = treeEvent.GetPosition() | ||
222 : | item = self.parent.tree_ctr.HitTest(pt) | ||
223 : | print item | ||
224 : | catEntryTuple = self.parent.tree_ctr.GetPyData(item) | ||
225 : | efrank | 1.14 | apply(catEntryTuple[0], catEntryTuple[1]) |
226 : | efrank | 1.12 | return |
227 : | |||
228 : | hwang | 1.11 | pt = treeEvent.GetPosition() |
229 : | |||
230 : | item = self.parent.tree_ctr.HitTest(pt) | ||
231 : | |||
232 : | print item | ||
233 : | catEntryTuple = self.parent.tree_ctr.GetPyData(item) | ||
234 : | #print catEntryTuple, "catEntryTuple" | ||
235 : | #self.selected = catEntryTuple | ||
236 : | |||
237 : | #catEntryTuple = self.selected | ||
238 : | #apply(catEntryTuple[0], [catEntryTuple[1]]) | ||
239 : | |||
240 : | return | ||
241 : | |||
242 : | efrank | 1.4 | |
243 : | #------------------------------------------------------------------------ | ||
244 : | efrank | 1.6 | def onLoadBtnPress(self, event): |
245 : | efrank | 1.4 | #------------------------------------------------------------------------ |
246 : | efrank | 1.6 | if ( self.selected == None ): |
247 : | print "No selection in onLoadBtnPress" | ||
248 : | return | ||
249 : | |||
250 : | catEntryTuple = self.selected | ||
251 : | apply( catEntryTuple[0], [catEntryTuple[1]] ) | ||
252 : | |||
253 : | return | ||
254 : | |||
255 : | #------------------------------------------------------------------------ | ||
256 : | def bssLoader( self, bssCatEntry ): | ||
257 : | #------------------------------------------------------------------------ | ||
258 : | wxBeginBusyCursor() | ||
259 : | b=BssFactory() | ||
260 : | top= b.getRecoElemById( bssCatEntry[1] ) | ||
261 : | self.to_re.AddRecoElemTree(self.parent.rootId, top) | ||
262 : | wxEndBusyCursor() | ||
263 : | hwang | 1.1 | |
264 : | efrank | 1.2 | return |
265 : | hwang | 1.1 | |
266 : | efrank | 1.4 | #------------------------------------------------------------------------ |
267 : | efrank | 1.6 | def witOrgLoader(self, orgName ): |
268 : | efrank | 1.4 | #------------------------------------------------------------------------ |
269 : | efrank | 1.6 | wxBeginBusyCursor() |
270 : | w=WitFactory() | ||
271 : | top= w.getRxnByOrg( orgName ) | ||
272 : | efrank | 1.12 | self.to_re.AddRecoElemTree(self.parent.rootId, top) |
273 : | wxEndBusyCursor() | ||
274 : | return | ||
275 : | |||
276 : | #------------------------------------------------------------------------ | ||
277 : | efrank | 1.17 | def seedRecoElemLoader(self, argList ): |
278 : | efrank | 1.12 | #------------------------------------------------------------------------ |
279 : | wxBeginBusyCursor() | ||
280 : | efrank | 1.13 | |
281 : | efrank | 1.14 | (theSeedFactoryMethod, org) = argList |
282 : | top = apply( theSeedFactoryMethod, [org] ) | ||
283 : | # top=self.__seedDataFactory.getRecoElemByOrg( org ) | ||
284 : | efrank | 1.6 | self.to_re.AddRecoElemTree(self.parent.rootId, top) |
285 : | efrank | 1.14 | |
286 : | efrank | 1.6 | wxEndBusyCursor() |
287 : | return | ||
288 : | efrank | 1.4 | |
289 : | efrank | 1.6 | #------------------------------------------------------------------------ |
290 : | def witPwyLoader(self, pwyName ): | ||
291 : | #------------------------------------------------------------------------ | ||
292 : | efrank | 1.2 | wxBeginBusyCursor() |
293 : | efrank | 1.6 | w=WitFactory() |
294 : | top= w.getRxnByPwy( pwyName ) | ||
295 : | hwang | 1.1 | self.to_re.AddRecoElemTree(self.parent.rootId, top) |
296 : | efrank | 1.2 | wxEndBusyCursor() |
297 : | return |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |