16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2000-2002 Free Software Foundation |
# Copyright 2000-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# GFForm.py |
# GFForm.py |
32 |
import string |
import string |
33 |
import traceback |
import traceback |
34 |
|
|
35 |
from gnue.common import GDebug, GConnections, GTrigger |
from gnue.common import GDebug # , GConnections, GTrigger |
36 |
from gnue.common import events |
from gnue.common import events |
|
from gnue.common.FileUtils import openResource |
|
|
from GFObjects import * |
|
37 |
from gnue.common.GDataObjects import ConnectionError as DBError |
from gnue.common.GDataObjects import ConnectionError as DBError |
38 |
from gnue.common.GRootObj import GRootObj |
from gnue.common.GRootObj import GRootObj |
39 |
from gnue.common.GTrigger import TriggerError |
from gnue.common.GTrigger import TriggerError |
40 |
from gnue.common.GParser import GImportItem |
from gnue.common.GObjects import GObj |
41 |
from GFLibrary import * |
#from gnue.common.GParser import GImportItem |
|
import GFLibrary |
|
|
import GFParser |
|
42 |
|
|
43 |
# Defines which objects are "Tab Stops" |
from gnue.forms.GFObjects import * |
44 |
TabStops = ('GFEntry','GFButton') |
from gnue.forms import GFParser |
45 |
|
|
|
class GFMainMenuBar(GFObj, events.EventAware): |
|
|
def __init__(self, parent=None, window=None): |
|
|
GFObj.__init__(self, parent) |
|
|
self._type = "GFMainMenuBar" |
|
|
self._currentObject = [self] |
|
46 |
|
|
47 |
class GFMainToolBar(GFObj, events.EventAware): |
# Defines which objects are "Tab Stops" |
48 |
def __init__(self, parent=None, window=None): |
TabStops = ('GFEntry','GFButton') |
|
GFObj.__init__(self, parent) |
|
|
self._type = "GFMainToolBar" |
|
|
self._currentObject = [self] |
|
|
|
|
49 |
|
|
50 |
class GFForm(GFObj, GRootObj, events.EventAware): |
# |
51 |
def __init__(self, parent=None, app=None): |
# GFForm |
52 |
|
# |
53 |
|
# instance is passed into the initializer so that |
54 |
|
# designer can pass that in |
55 |
|
# |
56 |
|
class GFForm(GRootObj, GFObj, events.EventAware): |
57 |
|
def __init__(self, parent=None, instance=None): |
58 |
# TODO: with a little tweaking we can now stop passing GFParser.getXMLelements |
# TODO: with a little tweaking we can now stop passing GFParser.getXMLelements |
59 |
GRootObj.__init__(self, 'form', GFParser.getXMLelements, GFParser) |
GRootObj.__init__(self, 'form', GFParser.getXMLelements, GFParser) |
60 |
GFObj.__init__(self, parent) |
GFObj.__init__(self, parent) |
75 |
self._currentBlock = None |
self._currentBlock = None |
76 |
self._currentEntry = None |
self._currentEntry = None |
77 |
|
|
78 |
self._blockList = [] |
# set |
79 |
self._pageList = [] |
self._instance = instance |
80 |
|
self._app = self._instance #TODO: Imports are broken do to |
81 |
|
#TODO: switch from _app to _instance |
82 |
|
self._triggerns={} |
83 |
|
|
84 |
self._app = app |
self._dialogDictionary={} |
85 |
|
# Hackery until proper layout support is added |
86 |
|
self._standardnamespaces = {'Char': 'GNUe:Forms:Char'} |
87 |
|
|
|
self._triggerns={} |
|
88 |
|
|
89 |
# The "None" init gives datasources time to setup master/detail |
# The "None" init gives datasources time to setup master/detail |
90 |
self._inits = [self.primaryInit, None, self.secondaryInit] |
self._inits = [self.primaryInit, None, self.secondaryInit] |
101 |
self._triggerFunctions = {'setFocus':{'function':self.triggerSetFocus, |
self._triggerFunctions = {'setFocus':{'function':self.triggerSetFocus, |
102 |
'global': 1, |
'global': 1, |
103 |
}, |
}, |
104 |
|
'getAuthenticatedUser':{'function':self.getAuthenticatedUser, |
105 |
|
'global': 1, |
106 |
|
}, |
107 |
'getCurrentEntry':{'function':self.triggerGetCurrentEntry, |
'getCurrentEntry':{'function':self.triggerGetCurrentEntry, |
108 |
'global': 1, |
'global': 1, |
109 |
}, |
}, |
138 |
}, |
}, |
139 |
'setFeature':{'function':self.triggerSetFeature, |
'setFeature':{'function':self.triggerSetFeature, |
140 |
'global': 1, |
'global': 1, |
141 |
} |
}, |
142 |
|
'runForm':{'function':self.triggerRunForm, |
143 |
|
'global': 1, |
144 |
|
} , |
145 |
|
'activateDialog':{'function':self.triggerActivateDialog, |
146 |
|
'global': 1, |
147 |
|
} , |
148 |
|
'initQuery':{'function':self.initQuery, |
149 |
|
}, |
150 |
} |
} |
151 |
|
|
152 |
self._features = { |
self._features = { |
153 |
'GUI:MENUBAR:SUPPRESS': 0, |
'GUI:MENUBAR:SUPPRESS': 1, |
154 |
'GUI:TOOLBAR:SUPPRESS': 0 |
'GUI:TOOLBAR:SUPPRESS': 1 |
155 |
} |
} |
156 |
|
|
157 |
|
|
158 |
|
## # |
159 |
|
## # Modify the base phaseInit to only process |
160 |
|
## # |
161 |
|
## def phaseInit(self, iterations=5, dialogInit=0): |
162 |
|
## if self.style != 'dialog' or dialogInit: |
163 |
|
## for phase in range(iterations): |
164 |
|
## self._phaseInit(phase, dialogInit=dialogInit) |
165 |
|
|
166 |
|
## def _phaseInit(self,phase,dialogInit=0): |
167 |
|
## if self.style != 'dialog' or dialogInit: |
168 |
|
## if (len(self._inits) > phase) and self._inits[phase]: |
169 |
|
## GDebug.printMesg(6,"%s: Init Phase %s" % (self._type, phase+1)) |
170 |
|
## self._inits[phase]() |
171 |
|
|
172 |
|
## for child in self._children: |
173 |
|
## if isinstance(child, GObj): |
174 |
|
## child._phaseInit(phase) |
175 |
|
|
176 |
# |
# |
177 |
# Convert some deprecated options to new style |
# Convert some deprecated options to new style |
178 |
# |
# |
204 |
# Called during phaseInit startup by GParser. |
# Called during phaseInit startup by GParser. |
205 |
# |
# |
206 |
def primaryInit(self): |
def primaryInit(self): |
|
|
|
207 |
# Initialize our events system |
# Initialize our events system |
208 |
events.EventAware.__init__(self, self._app.eventController) |
events.EventAware.__init__(self, self._instance.eventController) |
209 |
|
|
210 |
|
# Find the logic and layout controllers |
211 |
|
for child in self._children: |
212 |
|
if child._type == 'GFLogic': |
213 |
|
self._logic = child |
214 |
|
elif child._type == 'GFLayout': |
215 |
|
self._layout = child |
216 |
|
|
217 |
self.initTriggerSystem() |
self.initTriggerSystem() |
218 |
self._triggerns.update(self._triggerNamespaceTree._globalNamespace) |
self._triggerns.update(self._triggerNamespaceTree._globalNamespace) |
219 |
# TODO: Is this right |
|
220 |
self._triggerns['runForm'] = self._app.manager.runFormFromTrigger |
## TODO: This ain't right! Fix after 0.5.0 |
221 |
|
self._triggerns['runForm'] = self.triggerRunForm |
222 |
|
## TODO |
223 |
|
|
224 |
|
|
225 |
# |
# |
226 |
# Secondary init (stuff that must happen |
# Secondary init (stuff that must happen |
235 |
# Set initial focus |
# Set initial focus |
236 |
self.findAndChangeFocus(self) |
self.findAndChangeFocus(self) |
237 |
self.processTrigger('On-Startup') |
self.processTrigger('On-Startup') |
238 |
|
|
|
|
|
239 |
# |
# |
240 |
# Get a user parameter. If parameter not specified, pull default value |
# Get a user parameter. If parameter not specified, pull default value |
241 |
# |
# |
275 |
# an item of type Page, Block, or Entry |
# an item of type Page, Block, or Entry |
276 |
# |
# |
277 |
def findFocus(self, object): |
def findFocus(self, object): |
278 |
|
|
279 |
|
if object._type == 'GFField': |
280 |
|
GDebug.printMesg(0,"Ack! A GFField was passed to 'findFocus'.") |
281 |
|
object = object._entryList[0] |
282 |
|
|
283 |
entry = None |
entry = None |
284 |
|
|
285 |
if isinstance(object, GFObj): |
if isinstance(object, GFObj): |
286 |
if (object._type in TabStops and |
if (object._type in TabStops and |
287 |
(not object.hidden) and ((not object.readonly) or |
(object._navigable) and ((not object.readonly) or |
288 |
(self._currentBlock and \ |
(self._currentBlock and \ |
289 |
self._currentBlock.mode=='query' and \ |
self._currentBlock.mode=='query' and \ |
290 |
object._queryable))): |
object._queryable))): |
291 |
return object |
return object |
292 |
else: |
else: |
293 |
|
if hasattr(object, '_entryList'): |
294 |
|
for child in object._entryList: |
295 |
|
entry = self.findFocus(child) |
296 |
|
if entry: |
297 |
|
break |
298 |
for child in object._children: |
for child in object._children: |
299 |
entry = self.findFocus(child) |
entry = self.findFocus(child) |
300 |
if entry: |
if entry: |
322 |
# |
# |
323 |
def changeFocus(self, widget, fireFocusTriggers=1): |
def changeFocus(self, widget, fireFocusTriggers=1): |
324 |
|
|
|
if not hasattr(widget,'_block'): |
|
|
return None |
|
|
|
|
325 |
message = None |
message = None |
326 |
|
|
327 |
try: |
try: |
328 |
if self._currentEntry: |
if self._currentEntry: |
329 |
event = events.Event('endEDITMODE', None) |
event = events.Event('endEDITMODE',_form=self) |
330 |
self._app.dispatchEvent(event) |
|
331 |
|
self._instance.dispatchEvent(event) |
332 |
if event.__error__: |
if event.__error__: |
333 |
return 1 |
return 1 |
334 |
|
|
335 |
fieldChange = widget != self._currentEntry |
fieldChange = widget != self._currentEntry |
336 |
blockChange = widget._block != self._currentBlock |
try: |
337 |
pageChange = widget._block._page != self._currentPage |
blockChange = widget._block != self._currentBlock |
338 |
|
except AttributeError: |
339 |
|
# Buttons don't have a block, but also |
340 |
|
# don't trigger a block change |
341 |
|
blockChange = 0 |
342 |
|
pageChange = widget._page != self._currentPage |
343 |
|
|
344 |
if fireFocusTriggers: |
if fireFocusTriggers: |
345 |
try: |
try: |
346 |
if fieldChange: |
if fieldChange: |
347 |
self._currentEntry.processTrigger('Pre-FocusOut') |
self._currentEntry.processTrigger('Pre-FocusOut') |
348 |
|
if hasattr(self._currentEntry,'_field'): |
349 |
|
self._currentEntry._field.processTrigger('Pre-FocusOut') |
350 |
if blockChange: |
if blockChange: |
351 |
self._currentBlock.processTrigger('Pre-FocusOut') |
self._currentBlock.processTrigger('Pre-FocusOut') |
352 |
if pageChange: |
if pageChange: |
356 |
self._currentBlock.processTrigger('Post-FocusOut') |
self._currentBlock.processTrigger('Post-FocusOut') |
357 |
if fieldChange: |
if fieldChange: |
358 |
self._currentEntry.processTrigger('Post-FocusOut') |
self._currentEntry.processTrigger('Post-FocusOut') |
359 |
|
if hasattr(self._currentEntry,'_field'): |
360 |
|
self._currentEntry._field.processTrigger('Post-FocusOut') |
361 |
except AttributeError: |
except AttributeError: |
362 |
pass |
pass |
363 |
|
|
364 |
oldEntry = self._currentEntry |
oldEntry = self._currentEntry |
365 |
|
|
366 |
self._currentEntry = widget |
self._currentEntry = widget |
367 |
self._currentBlock = self._currentEntry._block |
try: |
368 |
self._currentPage = self._currentBlock._page |
self._currentBlock = self._currentEntry._block |
369 |
|
except AttributeError: |
370 |
|
pass # Buttons, et al |
371 |
|
self._currentPage = self._currentEntry._page |
372 |
|
|
373 |
if pageChange: |
if pageChange: |
374 |
self.dispatchEvent(events.Event('gotoPAGE',self._currentPage)); |
self.dispatchEvent('gotoPAGE',self._currentPage, _form=self); |
375 |
|
|
376 |
if blockChange: |
if blockChange: |
377 |
self.refreshDisplay(self._currentBlock) |
self.refreshDisplay(self._currentBlock) |
378 |
|
|
379 |
self.dispatchEvent(events.Event('updateENTRY', oldEntry)) |
self.dispatchEvent('updateENTRY', oldEntry, _form=self) |
380 |
self.dispatchEvent(events.Event('updateENTRY', self._currentEntry)) |
self.dispatchEvent('updateENTRY', self._currentEntry, _form=self) |
381 |
|
|
382 |
if fireFocusTriggers: |
if fireFocusTriggers: |
383 |
if pageChange: |
if pageChange: |
386 |
self._currentBlock.processTrigger('Pre-FocusIn') |
self._currentBlock.processTrigger('Pre-FocusIn') |
387 |
if fieldChange: |
if fieldChange: |
388 |
self._currentEntry.processTrigger('Pre-FocusIn') |
self._currentEntry.processTrigger('Pre-FocusIn') |
389 |
|
if hasattr(self._currentEntry,'_field'): |
390 |
|
self._currentEntry._field.processTrigger('Pre-FocusIn') |
391 |
|
if hasattr(self._currentEntry,'_field'): |
392 |
|
self._currentEntry._field.processTrigger('Post-FocusIn') |
393 |
self._currentEntry.processTrigger('Post-FocusIn') |
self._currentEntry.processTrigger('Post-FocusIn') |
394 |
if blockChange: |
if blockChange: |
395 |
self._currentBlock.processTrigger('Post-FocusIn') |
self._currentBlock.processTrigger('Post-FocusIn') |
406 |
# |
# |
407 |
|
|
408 |
|
|
409 |
def updateUIEntry(self,entry): |
def updateUIEntry(self,field): |
410 |
self._app.dispatchEvent(events.Event('updateENTRY',entry)); |
for entry in field._entryList: |
411 |
|
self._instance.dispatchEvent('updateENTRY',entry, _form=self); |
412 |
|
|
413 |
# |
# |
414 |
# Incomming Event handlers |
# Incoming Event handlers |
415 |
# |
# |
416 |
|
|
417 |
def newRecord(self): |
def newRecord(self): |
423 |
self._currentBlock.deleteRecord() |
self._currentBlock.deleteRecord() |
424 |
|
|
425 |
def isSaved(self): |
def isSaved(self): |
426 |
saved = 1 |
for block in self._logic._blockList: |
|
for block in self._blockList: |
|
427 |
if not block.isSaved(): |
if not block.isSaved(): |
428 |
saved = 0 |
return 0 |
429 |
break |
return 1 |
|
return saved |
|
430 |
|
|
431 |
def prepQuery(self): |
def initQuery(self): |
432 |
message = None |
message = None |
433 |
if self._currentBlock.mode != 'query': |
if self._currentBlock.mode != 'query': |
434 |
for block in self._blockList: |
for block in self._logic._blockList: |
435 |
if not block.isSaved(): |
if not block.isSaved(): |
436 |
message = _('Data not saved. Save changes or clear the form to proceed.') |
message = _('Data not saved. Save changes or clear the form to proceed.') |
437 |
return message |
return message |
438 |
|
|
439 |
for block in self._blockList: |
for block in self._logic._blockList: |
440 |
block.processRollback() |
block.processRollback() |
441 |
for entry in block._entryList: |
for entry in block._entryList: |
442 |
if hasattr(entry,'queryDefault'): |
if hasattr(entry,'queryDefault'): |
443 |
GDebug.printMesg(1, "%s will be set to %s" % (entry.name, entry.queryDefault)) |
GDebug.printMesg(1, "%s will be set to %s" % (entry.name, entry.queryDefault)) |
444 |
entry.setValue(entry.queryDefault) |
entry.setValue(entry.queryDefault) |
445 |
self._currentBlock.initQuery() |
|
446 |
|
# If Enter-Query is hit once, enter query mode |
447 |
|
# If Enter-Query is hit twice, bring back conditions from last query. |
448 |
|
# If Enter-Query is hit thrice, cancel the query and go into normal mode. |
449 |
|
|
450 |
|
for block in self._logic._blockList: |
451 |
|
block.initQuery() |
452 |
|
|
453 |
return message |
return message |
454 |
|
|
455 |
def executeQuery(self): |
def executeQuery(self): |
456 |
self._app.dispatchEvent(events.Event('beginWAIT',None)); |
self._instance.dispatchEvent('beginWAIT',None, _form=self); |
457 |
|
|
458 |
message = None |
message = None |
459 |
try: |
try: |
463 |
self.rollback(1) |
self.rollback(1) |
464 |
message = _("Database query error:\n%s\n%s ") % (sys.exc_info()[0], sys.exc_info()[1]) |
message = _("Database query error:\n%s\n%s ") % (sys.exc_info()[0], sys.exc_info()[1]) |
465 |
|
|
466 |
self._app.dispatchEvent(events.Event('endWAIT',None)); |
self._instance.dispatchEvent('endWAIT',None, _form=self) |
467 |
|
|
468 |
def commit(self): |
def commit(self): |
469 |
self._app.dispatchEvent(events.Event('beginWAIT',None)); |
self._instance.dispatchEvent('beginWAIT',None, _form=self) |
470 |
|
|
471 |
message = None |
message = None |
472 |
|
|
477 |
self.processTrigger('Pre-Commit') |
self.processTrigger('Pre-Commit') |
478 |
except TriggerError: |
except TriggerError: |
479 |
GDebug.printMesg(1, "Trigger form Pre-Commit threw a TriggerError!") |
GDebug.printMesg(1, "Trigger form Pre-Commit threw a TriggerError!") |
480 |
self._app.dispatchEvent(events.Event('endWAIT',None)); |
self._instance.dispatchEvent('endWAIT',None, _form=self) |
481 |
return _("Form trigger returned error") |
return _("Form trigger returned error") |
482 |
|
|
483 |
for block in self._blockList: |
for block in self._logic._blockList: |
484 |
GDebug.printMesg(1, "Saving %s"%block.name) |
GDebug.printMesg(1, "Saving %s"%block.name) |
485 |
try: |
try: |
486 |
|
|
490 |
block.processCommit() |
block.processCommit() |
491 |
except TriggerError: |
except TriggerError: |
492 |
GDebug.printMesg(1, "Trigger block Pre-Commit threw a TriggerError!") |
GDebug.printMesg(1, "Trigger block Pre-Commit threw a TriggerError!") |
493 |
self._app.dispatchEvent(events.Event('endWAIT',None)); |
self._instance.dispatchEvent('endWAIT',None, _form=self) |
494 |
return _("Block trigger returned error") |
return _("Block trigger returned error") |
495 |
block.processTrigger('Post-Commit') |
block.processTrigger('Post-Commit') |
496 |
|
|
497 |
for block in self._blockList: |
for block in self._logic._blockList: |
498 |
block.switchRecord(0) |
block.switchRecord(0) |
499 |
|
|
500 |
else: |
else: |
501 |
message = _('Form is readonly') |
message = _('Form is readonly') |
502 |
self._app.dispatchEvent(events.Event('endWAIT',None)); |
self._instance.dispatchEvent('endWAIT',None, _form=self) |
503 |
return message |
return message |
504 |
|
|
505 |
self.processTrigger('Post-Commit') |
self.processTrigger('Post-Commit') |
513 |
traceback.print_exc(file=sys.stdout) |
traceback.print_exc(file=sys.stdout) |
514 |
print '-'*60 |
print '-'*60 |
515 |
|
|
516 |
self._app.dispatchEvent(events.Event('endWAIT',None)); |
self._instance.dispatchEvent('endWAIT',None, _form=self) |
517 |
|
|
518 |
return message |
return message |
519 |
|
|
524 |
author = self.getOption('author') or "Unknown" |
author = self.getOption('author') or "Unknown" |
525 |
description = self.getOption('description') or "Unknown" |
description = self.getOption('description') or "Unknown" |
526 |
|
|
527 |
self.dispatchEvent(events.Event('uiABOUT',[version,name,formversion,author,description])) |
self.dispatchEvent('uiABOUT',[version,name,formversion,author,description], _form=self) |
528 |
|
|
529 |
def rollback(self, recover=0): |
def rollback(self, recover=0): |
530 |
self.endEditing() |
self.endEditing() |
531 |
for block in self._blockList: |
for block in self._logic._blockList: |
532 |
block.processRollback(recover) |
block.processRollback(recover) |
533 |
self.refreshDisplay(self) |
self.refreshDisplay(self) |
534 |
self._currentBlock.jumpRecord(self._currentBlock._currentRecord) |
self._currentBlock.jumpRecord(self._currentBlock._currentRecord) |
555 |
firstEntry = None |
firstEntry = None |
556 |
keepNext = 0 |
keepNext = 0 |
557 |
|
|
558 |
for object in self._currentEntry._block._focusOrder: |
|
559 |
|
if self._currentBlock.transparent: |
560 |
|
source = self._currentEntry._page._focusOrder |
561 |
|
else: |
562 |
|
source = self._currentBlock._focusOrder |
563 |
|
|
564 |
|
# if self._currentEntry._page.transparent: |
565 |
|
|
566 |
|
for object in source: |
567 |
# Put the first field as the next to rollover |
# Put the first field as the next to rollover |
568 |
if ((not object.hidden) and ((not object.readonly) or |
if ((object._navigable) and ((not object.readonly) or |
569 |
(self._currentBlock.mode=='query' and object._queryable))): |
(self._currentBlock.mode=='query' and object._queryable))): |
570 |
if nextEntry == None: |
if nextEntry == None: |
571 |
nextEntry = object |
nextEntry = object |
575 |
keepNext = 1 |
keepNext = 1 |
576 |
continue |
continue |
577 |
|
|
578 |
if keepNext == 1: |
if keepNext: |
579 |
nextEntry = object |
nextEntry = object |
580 |
break |
break |
581 |
|
|
582 |
if nextEntry == firstEntry and self._currentBlock.transparentBlock: |
if nextEntry == firstEntry and self._currentBlock.transparent and self._currentPage.transparent: |
583 |
# Jump to the next block if block is tagged as transparent |
# Jump to the next page if block is page as transparent |
584 |
self.nextBlock() |
i = self._layout._pageList.index(self._currentPage) |
585 |
|
try: |
586 |
|
dest = self._layout._pageList[i+1] |
587 |
|
except IndexError: |
588 |
|
dest = self._layout._pageList[0] |
589 |
|
self.findAndChangeFocus(dest) |
590 |
else: |
else: |
591 |
self.changeFocus(nextEntry) |
self.changeFocus(nextEntry) |
592 |
|
|
601 |
nextEntry = None |
nextEntry = None |
602 |
lastEntry = self._currentEntry |
lastEntry = self._currentEntry |
603 |
|
|
604 |
for object in self._currentBlock._focusOrder: |
if self._currentBlock.transparent: |
605 |
if ((not object.hidden) and ((not object.readonly) or |
source = self._currentEntry._page._focusOrder |
606 |
|
else: |
607 |
|
source = self._currentBlock._focusOrder |
608 |
|
|
609 |
|
for object in source: |
610 |
|
if ((object._navigable) and ((not object.readonly) or |
611 |
(self._currentBlock.mode=='query' and object._queryable))): |
(self._currentBlock.mode=='query' and object._queryable))): |
612 |
nextEntry = object |
nextEntry = object |
613 |
lastEntry = object |
lastEntry = object |
614 |
|
|
615 |
keepNext = 0 |
keepNext = 0 |
616 |
for object in self._currentBlock._focusOrder: |
for object in source: |
617 |
# Put the first field as the next to rollover |
# Put the first field as the next to rollover |
618 |
if ((not object.hidden) and ((not object.readonly) or |
if ((not object.hidden) and ((not object.readonly) or |
619 |
(self._currentBlock.mode=='query' and object._queryable))): |
(self._currentBlock.mode=='query' and object._queryable))): |
622 |
|
|
623 |
nextEntry = object |
nextEntry = object |
624 |
|
|
625 |
if self._currentBlock.transparentBlock and nextEntry == lastEntry: # Jump to the prev block if block is tagged as transparent |
if nextEntry == lastEntry and self._currentBlock.transparent and self._currentPage.transparent: |
626 |
prevBlock = self.findPreviousBlock() |
i = self._pageList.index(self._currentPage) |
627 |
# Move to the new last record of the new current block |
try: |
628 |
for object in prevBlock._focusOrder: |
dest = self._layout._pageList[i - 1] |
629 |
if not object.hidden and (not object.readonly or self._currentBlock.mode=='query'): |
except IndexError: |
630 |
nextEntry = object |
dest = self._layout._pageList[-1] |
631 |
|
# TODO: This fails if last entry is not navigable |
632 |
|
self.findAndChangeFocus(dest._entryList[-1]) |
633 |
|
|
634 |
self.findAndChangeFocus(nextEntry) |
self.findAndChangeFocus(nextEntry) |
635 |
|
|
645 |
|
|
646 |
def __refreshDisplay(self, object): |
def __refreshDisplay(self, object): |
647 |
if object._type == 'GFEntry': |
if object._type == 'GFEntry': |
648 |
self.dispatchEvent(events.Event('updateENTRY',object)) |
self.dispatchEvent('updateENTRY',object, _form=self) |
649 |
|
|
650 |
|
|
651 |
|
|
658 |
def nextBlock(self): |
def nextBlock(self): |
659 |
|
|
660 |
try: |
try: |
661 |
nextBlock = self._blockList[self._blockList.index(self._currentBlock)+1] |
nextBlock = self._logic._blockList[self._logic._blockList.index(self._currentBlock)+1] |
662 |
except IndexError: |
except IndexError: |
663 |
nextBlock = self._blockList[0] |
nextBlock = self._logic._blockList[0] |
664 |
|
|
665 |
self.findAndChangeFocus(nextBlock) |
self.findAndChangeFocus(nextBlock) |
666 |
|
|
672 |
# |
# |
673 |
def findPreviousBlock(self): |
def findPreviousBlock(self): |
674 |
try: |
try: |
675 |
return self._blockList[self._blockList.index(self._currentBlock)-1] |
return self._logic._blockList[self._logic._blockList.index(self._currentBlock)-1] |
676 |
except IndexError: |
except IndexError: |
677 |
return self._blockList[-1] |
return self._logic._blockList[-1] |
678 |
|
|
679 |
|
|
680 |
# |
# |
694 |
# mode and save it's value to the virtual form |
# mode and save it's value to the virtual form |
695 |
# |
# |
696 |
def endEditing(self): |
def endEditing(self): |
697 |
event = events.Event('endEDITMODE',None) |
event = events.Event('endEDITMODE',None, _form=self) |
698 |
self.dispatchEvent(event) |
self.dispatchEvent(event) |
699 |
return not event.__error__ |
return not event.__error__ |
700 |
|
|
733 |
self._insertMode = not self._insertMode |
self._insertMode = not self._insertMode |
734 |
|
|
735 |
def triggerSetFocus(self,object): |
def triggerSetFocus(self,object): |
|
# print _("If i was working then %s would now have focus") % object._object |
|
736 |
self.changeFocus(object._object,1) |
self.changeFocus(object._object,1) |
737 |
self.dispatchEvent(events.Event('gotoENTRY',{'object':self._currentEntry})) |
self.dispatchEvent('gotoENTRY',object=self._currentEntry,_form=self) |
738 |
|
|
739 |
def triggerGetCurrentEntry(self): |
def triggerGetCurrentEntry(self): |
740 |
return self._currentEntry |
return self._currentEntry |
745 |
def triggerGetCurrentPage(self): |
def triggerGetCurrentPage(self): |
746 |
return self._currentPage |
return self._currentPage |
747 |
|
|
748 |
def triggerSetStatusText(self,tip=''): |
def triggerSetStatusText(self, tip=None, recordStatus=None, insertMode=None, |
749 |
self.dispatchEvent(events.Event('uiUPDATESTATUS',[tip,None,None,None,None,None,None])) |
currentRecord=None,maxRecord=None, currentPage=None, |
750 |
|
maxPage=None): |
751 |
|
self.dispatchEvent('uiUPDATESTATUS',tip=tip, recordStatus=recordStatus, |
752 |
|
insertMode=insertMode, currentRecord=currentRecord, |
753 |
|
maxRecord=maxRecord, currentPage=currentPage, |
754 |
|
maxPage=maxPage, _form=self) |
755 |
|
|
756 |
|
def triggerRunForm(self,fileName, parameters={}): |
757 |
|
from GFInstance import GFInstance |
758 |
|
instance = GFInstance(self._instance.manager, |
759 |
|
self._instance.connections, |
760 |
|
self._instance._uimodule, disableSplash=1, parameters=parameters) |
761 |
|
instance.addFormFromFile(fileName) |
762 |
|
instance.activate() |
763 |
|
|
764 |
|
def triggerActivateDialog(self,dialogName): |
765 |
|
self._instance.activateForm(dialogName) |
766 |
|
|
767 |
# Close this form. |
# Close this form. |
768 |
def close(self): |
def close(self): |
769 |
event = events.Event('requestEXIT') |
event = events.Event('requestEXIT', _form=self) |
770 |
self._app.dispatchEvent(event) |
self._instance.dispatchEvent(event) |
771 |
if event.__error__: |
if event.__error__: |
772 |
return 1 |
return 1 |
773 |
|
|
787 |
event = events.Event('genericBox', [message,buttonSet]) |
event = events.Event('genericBox', [message,buttonSet]) |
788 |
self.dispatchEvent(event) |
self.dispatchEvent(event) |
789 |
return event.data[0] |
return event.data[0] |
790 |
|
|
791 |
def triggerCallTrigger(self, triggerName): |
def triggerCallTrigger(self, triggerName): |
792 |
self._triggerDictionary[triggerName](self) |
self._triggerDictionary[triggerName](self) |
793 |
|
|
794 |
|
def getAuthenticatedUser(self, connection=None): |
795 |
|
return self._instance.connections.getAuthenticatedUser(connection) |