[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/forms/src GFForm.py GFInstance.py GFObject...
From: |
James Thompson |
Subject: |
gnue/forms/src GFForm.py GFInstance.py GFObject... |
Date: |
Tue, 02 Apr 2002 22:46:59 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/04/02 22:46:58
Modified files:
forms/src : GFForm.py GFInstance.py
forms/src/GFObjects: GFBlock.py GFEntry.py GFObj.py
Log message:
Code cleanup
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.159&tr2=1.160&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFInstance.py.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFObjects/GFBlock.py.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFObjects/GFEntry.py.diff?tr1=1.47&tr2=1.48&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFObjects/GFObj.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.159 gnue/forms/src/GFForm.py:1.160
*** gnue/forms/src/GFForm.py:1.159 Thu Mar 28 02:56:51 2002
--- gnue/forms/src/GFForm.py Tue Apr 2 22:46:58 2002
***************
*** 166,175 ****
if self._currentBlock == None:
self._currentBlock = object
- #try:
- # self._triggerns[object.name] = GFTrigger.GFTriggerHelper( object )
- #except AttributeError: pass
-
elif object.getObjectType() == 'GFPage':
self._pageList.append(object)
if self._currentPage == None:
--- 166,171 ----
***************
*** 180,189 ****
self._currentEntry = object
elif object.getObjectType() =='GFDataSource':
- #try:
- # self._triggerns[object.name] = GFTrigger.GFTriggerHelper( object )
- #except AttributeError: pass
-
object.name = string.lower(object.name)
self._datasourceDictionary[object.name]=object
--- 176,181 ----
***************
*** 291,297 ****
self._currentPage.processTrigger('Post-FocusIn')
except TriggerError, t:
! message = self.TriggerErrorFunc(t)
return message
--- 283,290 ----
self._currentPage.processTrigger('Post-FocusIn')
except TriggerError, t:
! GDebug.printMesg(1, "Trigger Error!")
! message = "Trigger Exception :\n" + t.msg
return message
***************
*** 506,723 ****
block.processRollback(recover)
self.refreshDisplay(self)
self._currentBlock.jumpRecord(self._currentBlock._currentRecord)
!
!
! # i question if this fuction is needed as one could just use t.msg
! # however i gave it a return and converted print to debugas some of the
! # stuff using this hasnt been migrated to use the return
!
! def TriggerErrorFunc(self, t):
! 't is an instance of TriggerError'
! trigMsg = "Trigger Exception :\n" + t.msg
! GDebug.printMesg(0, trigMsg)
! return trigMsg
!
!
! ## #
! ## # moveCursor
! ## #
! ## # called whenever an event source has requested that the
! ## # current input (cursor) position in current entry object be
! ## # moved to a new location
! ## #
! ## def moveCursor(self, position):
! ##
! ## # If an input mask handler is being used, we
! ## # need to use its logic to move the cursor.
! ##
! ## if not self._currentEntry._maskHandler:
! ##
! ## # use default logic
! ##
! ## if position == 'end':
! ## self._currentEntry._cursorPosition = \
! ## len(self._currentEntry.getDisplay(hasFocus=1))
! ## elif position == 'home':
! ## self._currentEntry._cursorPosition = 0
! ## elif position == 'left' and self._currentEntry._cursorPosition > 0:
! ## self._currentEntry._cursorPosition -= 1
! ## elif ( position == 'right' ) and \
! ## ( self._currentEntry._cursorPosition < \
! ## len(self._currentEntry.getDisplay(hasFocus=1)) ):
! ## self._currentEntry._cursorPosition += 1
! ##
! ## else:
! ##
! ## # use mask handler's logic
! ##
! ## if position == 'end':
! ## self._currentEntry._cursorPosition = \
! ## self._currentEntry._maskHandler.moveCursorToEnd()
! ## elif position == 'home':
! ## self._currentEntry._cursorPosition = \
! ## self._currentEntry._maskHandler.moveCursorToBegin()
! ## elif position == 'left':
! ## self._currentEntry._cursorPosition = \
! ## self._currentEntry._maskHandler.moveCursorRelative(-1)
! ## elif position == 'right':
! ## self._currentEntry._cursorPosition = \
! ## self._currentEntry._maskHandler.moveCursorRelative(1)
! ##
! ##
! ## def replaceValue(self,object, value):
! ## replacement = ""
! ## validValues = object.allowedValues()
! ## for key in validValues.keys():
! ## if validValues[key] == value:
! ## replacement = key
! ## break
! ## GDebug.printMesg(2,"(%s, %s)"%(object,value))
! ## GDebug.printMesg(2,"Replacing with %s"% replacement)
! ## self._currentEntry.processTrigger('pre-change')
! ## object.setValue(replacement)
! ## self._currentEntry.processTrigger('post-change')
! ##
! ## # Hack!
! ## self.dispatchEvent(GFEvent('updateDETAILBLOCK',self._currentBlock))
! ##
! ## #
! ## # keyPress
! ## #
! ## # Called whenever an event source has requested that a
! ## # charater be inserted into current entry object
! ## #
! ## def keyPress(self, value):
! ## modified = 0
! ##
! ## if (self._currentEntry != None):
! ## currentvalue = self._currentEntry.getValue()
! ## if ord(value) == 13:
! ## if self._currentEntry.height > 1: value = '\n';
! ## else:
! ## self._app.nextEntry(None)
! ## #self._app.dispatchEvent(GFEvent('requestNEXTENTRY'))
! ## return modified
! ##
! ## if hasattr(self._currentEntry,'foreign_key_description') and
hasattr(self._currentEntry,'style') and (self._currentEntry.style=='dropdown'):
! ## value= self._currentEntry.findClosestValue(value)
! ## if not value: return modified
! ##
! ## self._currentEntry.processTrigger('pre-change')
! ## self._currentEntry.setValue(value)
! ## self._currentEntry.processTrigger('post-change')
! ## modified = 1
! ## return modified
! ##
! ## if self._currentEntry._lowercase:
! ## value = string.lower(value)
! ## if self._currentEntry._uppercase:
! ## value = string.upper(value)
! ## if hasattr(self._currentEntry,'max_length'):
! ## if len(currentvalue) >= int(self._currentEntry.max_length):
! ## return modified
! ##
! ## if ( self._currentEntry._numeric and \
! ## self._currentBlock.mode == 'normal' ):
! ## if not (value in string.digits or value in '.'):
! ## return modified
! ##
! ##
! ##
! ## # If an input mask handler is being
! ## # used, we need to use its logic.
! ##
! ## if not self._currentEntry._maskHandler:
! ##
! ## # use default logic
! ##
! ## currentvalue = currentvalue[:self._currentEntry._cursorPosition] \
! ## + value \
! ## + currentvalue[self._currentEntry._cursorPosition \
! ## + (not self._insertMode):]
! ##
! ## self._currentEntry._cursorPosition += 1
! ##
! ## else:
! ##
! ## # use mask handler's logic
! ##
! ## currentvalue, display, cursor = \
! ## self._currentEntry._maskHandler.addText(
! ## currentvalue,
! ## value,
! ## self._currentEntry._cursorPosition,
! ## not self._insertMode,
! ## '_' )
! ##
! ## print "New value: %s" % currentvalue
! ##
! ## self._currentEntry._cursorPosition = cursor
! ##
! ##
! ## # Set the field's value, performing pre-/post-change triggers
! ## self._currentEntry.processTrigger('pre-change')
! ## self._currentEntry.setValue(currentvalue)
! ## self._currentEntry.processTrigger('post-change')
! ## modified = 1
! ##
! ## return modified
! ##
! ##
! ## #
! ## # removeCharacter
! ## #
! ## # Called whenever an event source has requested that a
! ## # charater be removed from the current entry object
! ## #
! ## def removeCharacter(self, action):
! ##
! ##
! ## # For a backspace, we will fudge by simply
! ## # moving the cursor left one position and
! ## # performing a "delete".
! ## #
! ## # If an input mask handler is being used, we
! ## # need to use its logic to move the cursor.
! ##
! ## if not self._currentEntry._maskHandler:
! ## if action == 'backspace':
! ## if self._currentEntry._cursorPosition > 0:
! ## self._currentEntry._cursorPosition -= 1
! ## else:
! ## # Cannot backspace if we are at pos 0
! ## return 0
! ##
! ## newvalue = self._currentEntry.getValue()
! ## newvalue = newvalue[:self._currentEntry._cursorPosition] \
! ## + newvalue[self._currentEntry._cursorPosition+1:]
! ##
! ## else:
! ##
! ## if action == 'backspace':
! ## newPos = self._currentEntry._maskHandler.moveCursorRelative(-1)
! ## if self._currentEntry._cursorPosition != newPos:
! ## self._currentEntry._cursorPosition = newPos
! ## else:
! ## # Cannot backspace if we are at pos 0
! ## return 0
! ##
! ## newvalue = self._currentEntry._maskHandler.processEdit(
! ## self._currentEntry.getValue(),
! ## "",
! ## self._currentEntry._maskHandler.cursorToIndex(
! ## self._currentEntry._cursorPosition),
! ## 1)
! ##
! ##
! ##
! ## self._currentEntry.processTrigger('pre-change')
! ## self._currentEntry.setValue(newvalue)
! ## self._currentEntry.processTrigger('post-change')
! ##
! ## return 1
! ##
!
#
# fireTrigger
#
--- 499,505 ----
block.processRollback(recover)
self.refreshDisplay(self)
self._currentBlock.jumpRecord(self._currentBlock._currentRecord)
!
#
# fireTrigger
#
Index: gnue/forms/src/GFInstance.py
diff -c gnue/forms/src/GFInstance.py:1.39 gnue/forms/src/GFInstance.py:1.40
*** gnue/forms/src/GFInstance.py:1.39 Thu Mar 28 02:56:51 2002
--- gnue/forms/src/GFInstance.py Tue Apr 2 22:46:58 2002
***************
*** 448,472 ****
self.updateRecordStatus()
self.updateRecordCounter()
- ## #
- ## # cursorMove
- ## #
- ## # called whenever an event source has requested that the
- ## # current input (cursor) position in current entry object be
- ## # moved to a new location
- ## #
- ## def cursorMove(self, event):
- ## eventType = event.getEvent()
- ## if eventType == 'requestCURSOREND':
- ## self._form.moveCursor('end')
- ## elif eventType == 'requestCURSORHOME':
- ## self._form.moveCursor('home')
- ## elif eventType == 'requestCURSORLEFT':
- ## self._form.moveCursor('left')
- ## elif eventType == 'requestCURSORRIGHT':
- ## self._form.moveCursor('right')
- ##
- ## self.dispatchEvent(GFEvent('updateENTRY',self._form._currentEntry));
#
# Routines to update parts of the UI's status bar
--- 448,453 ----
***************
*** 514,559 ****
self.updateRecordStatus()
self.updatePageCounter()
- ## #
- ## # keyPress
- ## #
- ## # Called whenever an event source has requested that a
- ## # charater be inserted into current entry object
- ## #
- ## def keyPress(self, event):
- ## GDebug.printMesg(10, "Keypress event %s"%event.data)
- ## if (self._form._currentEntry != None):
- ## if (self._form._currentEntry.readonly and not
self._form._currentBlock.mode=='query'):
- ## self.dispatchEvent(GFEvent('formALERT','Field is readonly'))
- ## elif self._form._currentEntry.editOnNull and \
- ## len(self._form._currentEntry.getValue()) > 0 and \
- ## not self._form._currentBlock._resultSet.current.isPending():
- ## self.dispatchEvent(GFEvent('formALERT','Field cannot be modified
after entry'));
- ## else:
- ## if self._form.keyPress(event.data):
- ##
self.dispatchEvent(GFEvent('updateENTRY',self._form._currentEntry));
- ## self.updateRecordStatus()
- ##
- ## #
- ## # removeCharacter
- ## #
- ## # Called whenever an event source has requested that a
- ## # charater be removed from the current entry object
- ## #
- ## def removeCharacter(self, event):
- ## if not self._form._currentEntry.readonly or
self._form._currentBlock.mode=='query':
- ## if event.getEvent() == 'requestBACKSPACE':
- ## action = 'backspace'
- ## else:
- ## action = 'delete'
- ##
- ## if self._form.removeCharacter(action):
- ## self.dispatchEvent(GFEvent('updateENTRY',self._form._currentEntry));
- ## self.updateRecordStatus()
- ## self.updateRecordStatus()
- ## else:
- ## self.dispatchEvent(GFEvent('formALERT','Field is readonly'))
-
#
# changeFocus
#
--- 495,500 ----
***************
*** 626,633 ****
#
def fireTrigger(self, event):
self._form.fireTrigger(event.data)
-
-
#
# Activate this puppy...
--- 567,572 ----
Index: gnue/forms/src/GFObjects/GFBlock.py
diff -c gnue/forms/src/GFObjects/GFBlock.py:1.41
gnue/forms/src/GFObjects/GFBlock.py:1.42
*** gnue/forms/src/GFObjects/GFBlock.py:1.41 Thu Mar 28 02:56:52 2002
--- gnue/forms/src/GFObjects/GFBlock.py Tue Apr 2 22:46:58 2002
***************
*** 94,100 ****
return self
-
def triggerAutofillBySequence(self,fieldName,sequenceName):
# Find the datasource field name bound to the named entry
entry=""
--- 94,99 ----
***************
*** 190,196 ****
if self._resultSet.firstRecord():
self.switchRecord(0)
- #self._recordCount = self._resultSet.getCacheCount()
self._recordCount = self._resultSet.getRecordCount()
else:
# TODO: This means no results were returned from a query.
--- 189,194 ----
***************
*** 210,216 ****
def switchRecord(self, adjustment):
self._currentRecord = self._resultSet.getRecordNumber()
for entry in self._entryList:
- entry.switchRecord()
entry.recalculateVisible( adjustment, self._currentRecord,
self._recordCount)
self._form.updateUIEntry(entry)
--- 208,213 ----
***************
*** 224,237 ****
#
def newRecord(self):
if self._resultSet.insertRecord():
- #self._recordCount = self._resultSet.getCacheCount()
self._recordCount = self._resultSet.getRecordCount()
self.switchRecord(1)
self.processTrigger('on-newrecord')
def nextRecord(self):
if self._resultSet.nextRecord():
- #self._recordCount = self._resultSet.getCacheCount()
self._recordCount = self._resultSet.getRecordCount()
self.switchRecord(1)
elif int(GConfig.get('autocreate')) and not self.isEmpty() and not
self.restrictInsert:
--- 221,232 ----
***************
*** 240,249 ****
def lastRecord(self):
self._resultSet.lastRecord()
self.switchRecord(0)
- # end = self._resultSet.lastRecord() - self._resultSet.getRecordNumber()
- # self._currentRecord = self._resultSet.getRecordNumber()
- # self.switchRecord(end)
-
def firstRecord(self):
self._resultSet.firstRecord()
--- 235,240 ----
***************
*** 306,312 ****
# (but not lose state information)
#
def processRollback(self, recovering=0):
- #self.mode='normal'
if not recovering:
self._currentRecord = 0
self._recordCount = 0
--- 297,302 ----
***************
*** 390,396 ****
conditions = {}
self._dataSourceLink.createResultSet(conditions)
- #self._recordCount = self._resultSet.getCacheCount()
self._recordCount = self._resultSet.getRecordCount()
self.processTrigger('Post-Query')
--- 380,385 ----
Index: gnue/forms/src/GFObjects/GFEntry.py
diff -c gnue/forms/src/GFObjects/GFEntry.py:1.47
gnue/forms/src/GFObjects/GFEntry.py:1.48
*** gnue/forms/src/GFObjects/GFEntry.py:1.47 Mon Feb 18 00:11:37 2002
--- gnue/forms/src/GFObjects/GFEntry.py Tue Apr 2 22:46:58 2002
***************
*** 19,28 ****
# Copyright 2000-2002 Free Software Foundation
#
# FILE:
! # GFObjects.py
#
# DESCRIPTION:
! # The majority of the objects that make up a form
#
# NOTES:
#
--- 19,28 ----
# Copyright 2000-2002 Free Software Foundation
#
# FILE:
! # GFEntry.py
#
# DESCRIPTION:
! # The primary data entry widget in forms
#
# NOTES:
#
***************
*** 113,119 ****
self._queryable = 0
return GFValue._buildObject(self)
-
def initialize(self):
if self.typecast == 'number':
--- 113,118 ----
***************
*** 128,147 ****
self._inputmask = ""
self._displaymask = ""
- ## if hasattr(self,'formatmask') and len(self.formatmask):
- ## self._formatmask = self.formatmask
- ## self._inputmask = self.formatmask
- ## self._displaymask = self.formatmask
- ##
- ## if hasattr(self,'inputmask') and len(self.inputmask):
- ## self._inputmask = self.inputmask
- ##
- ## if hasattr(self,'displaymask') and len(self.displaymask):
- ## self._displaymask = self.displaymask
- ##
- ## self._maskHandler = formatMaskHandlers[self.typecast](
- ## self._formatmask, self._inputmask, self._displaymask)
-
self._cursorPosition = len(self._oldval)
self._block = self.findParentOfType('GFBlock')
--- 127,132 ----
***************
*** 168,176 ****
self._bound and \
len(self.queryDefault):
self._block._queryDefaults[self] = self.queryDefault
- else:
- default = None
-
# Create an appropriate display handler
if self.style == 'checkbox':
--- 153,158 ----
***************
*** 191,198 ****
self._displayHandler = GFDisplayHandler.DateDisplayHandler(self,
self._block._form._app.eventController, self._inputmask,
self._displaymask)
-
-
def isQueryable(self):
return self._queryable
--- 173,178 ----
***************
*** 223,255 ****
self._oldval = value
return value
-
- ## #
- ## # Returns a string formatted for display
- ## #
- ## def getDisplay(self, hasFocus=0, value=None):
- ##
- ## if value == None:
- ## v = self.getValue()
- ## else:
- ## v = value
- ## if v == None:
- ## v = ""
- ##
- ##
- ## # TODO: How would format masks work w/styles other than default
- ##
- ## if not self._maskHandler or self.style != 'default':
- ## return str(v)
- ## else:
- ## if hasFocus:
- ## GDebug.printMesg(15,"calling getFormattedInput with '%s'" % v)
- ## return self._maskHandler.getFormattedInput(v, "_")
- ## else:
- ## return self._maskHandler.getFormattedOutput(v, secondary=1)
- ##
-
-
def setValue(self, value):
if value =='' and self.style=='checkbox':
value = 0
--- 203,208 ----
***************
*** 266,283 ****
self._block._form.updateUIEntry(self)
#
- # switchRecord
- #
- def switchRecord(self):
- ## value = self._block._resultSet.current.getField(self.field)
- ## if value == None:
- ## value = ''
- ## else:
- ## value = "%s" % value
- ## self._cursorPosition = len(value)
- pass
-
- #
# verifyValue
#
def verifyValue(self):
--- 219,224 ----
***************
*** 293,316 ****
if self._allowedValues:
value = self._allowedValues.has_key("%s" % self._oldval)
return value
- #
- # findClosestValue
- #
- def findClosestValue(self, value):
- newvalue=None
- if hasattr(self,'foreign_key'):
-
- datasourceName,fieldName = string.split(self.foreign_key,'.')
- rs =
self._block._form._datasourceDictionary[datasourceName]._currentResultSet
-
- more = rs.firstRecord()
- while more:
- if
string.lower(rs.current.getField(self.foreign_key_description)[:len(value)]) ==
string.lower(value):
- newvalue = rs.current.getField(fieldName)
- if newvalue == self._oldval: continue
- break
- more = rs.nextRecord()
- return newvalue
#
# allowedValues
--- 234,239 ----
***************
*** 341,347 ****
GDebug.printMesg (5,'Created for DropDown: %s' % self._allowedValues)
return self._allowedValues
-
- ##formatMaskHandlers = { 'text': FormatMasks.TextMask,
- ## 'number': FormatMasks.NumberMask,
- ## 'date': FormatMasks.DateMask }
--- 264,266 ----
Index: gnue/forms/src/GFObjects/GFObj.py
diff -c gnue/forms/src/GFObjects/GFObj.py:1.8
gnue/forms/src/GFObjects/GFObj.py:1.9
*** gnue/forms/src/GFObjects/GFObj.py:1.8 Sun Sep 16 17:16:24 2001
--- gnue/forms/src/GFObjects/GFObj.py Tue Apr 2 22:46:58 2002
***************
*** 48,54 ****
self.name = "__%s__" % self
self._rows = 1
self._gap = 0
- #self._inits = [self.initialize]#
self._inits = []
#
# get an Option
--- 48,53 ----
***************
*** 83,104 ****
if lowestVisible + index > recordCount:
index = index -1
!
! # If the current record has rolled around
! # from the top to the bottom then reset
! # the counter
if currentRecord == 0:
index = 0
-
-
- # if the current record has rolled from
- # bottom to top then flip to bottom keeping
- # in mind the number of records in memory
- if currentRecord == recordCount:
- if recordCount > int(self._rows)-1:
- index = int(self._rows)-1
- else:
- index = recordCount
self._visibleIndex = index
self.lowestVisible = lowestVisible
--- 82,92 ----
if lowestVisible + index > recordCount:
index = index -1
! # # If the current record has rolled around
! # # from the top to the bottom then reset
! # # the counter
if currentRecord == 0:
index = 0
self._visibleIndex = index
self.lowestVisible = lowestVisible
- gnue/forms/src GFForm.py GFInstance.py GFObject...,
James Thompson <=