commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r5788 - in trunk/gnue-forms: samples/inventory/forms samples/location/fo


From: jcater
Subject: r5788 - in trunk/gnue-forms: samples/inventory/forms samples/location/forms samples/po samples/track/forms samples/zipcode src src/GFObjects
Date: Sat, 8 May 2004 00:56:54 -0500 (CDT)

Author: jcater
Date: 2004-05-08 00:56:53 -0500 (Sat, 08 May 2004)
New Revision: 5788

Modified:
   trunk/gnue-forms/samples/inventory/forms/company.gfd
   trunk/gnue-forms/samples/inventory/forms/inv_maintenance.gfd
   trunk/gnue-forms/samples/location/forms/county_maint.gfd
   trunk/gnue-forms/samples/location/forms/zip_coords_maint.gfd
   trunk/gnue-forms/samples/location/forms/zipcode_maint.gfd
   trunk/gnue-forms/samples/po/sc_po_entry.gfd
   trunk/gnue-forms/samples/track/forms/address_type.gfd
   trunk/gnue-forms/samples/track/forms/assignment_status.gfd
   trunk/gnue-forms/samples/track/forms/contact_manager.gfd
   trunk/gnue-forms/samples/track/forms/email_type.gfd
   trunk/gnue-forms/samples/track/forms/phone_type.gfd
   trunk/gnue-forms/samples/zipcode/states.gfd
   trunk/gnue-forms/samples/zipcode/zipcode.gfd
   trunk/gnue-forms/src/GFDisplayHandler.py
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFInstance.py
   trunk/gnue-forms/src/GFObjects/GFBlock.py
   trunk/gnue-forms/src/GFObjects/GFButton.py
   trunk/gnue-forms/src/GFObjects/GFContainer.py
   trunk/gnue-forms/src/GFObjects/GFEntry.py
   trunk/gnue-forms/src/GFObjects/GFImage.py
   trunk/gnue-forms/src/GFObjects/GFObj.py
   trunk/gnue-forms/src/GFObjects/GFPage.py
   trunk/gnue-forms/src/GFObjects/GFTabStop.py
   trunk/gnue-forms/src/GFParser.py
Log:
* Fixed navigation code for non-transparent blocks
* Implemented support for block.autoNextRecord (works with previous record, too)
* Mostly implemented block.autoCommit (with some strange behavior when exiting 
form)
* Cleaned up boolean usage in gnue-forms/samples


Modified: trunk/gnue-forms/samples/inventory/forms/company.gfd
===================================================================
--- trunk/gnue-forms/samples/inventory/forms/company.gfd        2004-05-08 
03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/inventory/forms/company.gfd        2004-05-08 
05:56:53 UTC (rev 5788)
@@ -30,13 +30,13 @@
         </options>
       </field>
       <field name="ntrycity" case="upper" field="city" max_length="40"
-             readonly="">
+             readonly="Y">
         <options>
           <option name="tip" value="Please enter the value for city."/>
         </options>
       </field>
       <field name="ntrystate" case="upper" field="state" max_length="2"
-             readonly="">
+             readonly="Y">
         <options>
           <option name="tip" value="Please enter the value for state."/>
         </options>

Modified: trunk/gnue-forms/samples/inventory/forms/inv_maintenance.gfd
===================================================================
--- trunk/gnue-forms/samples/inventory/forms/inv_maintenance.gfd        
2004-05-08 03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/inventory/forms/inv_maintenance.gfd        
2004-05-08 05:56:53 UTC (rev 5788)
@@ -8,7 +8,7 @@
     <option name="version" value="0.0.1"/>
   </options>
   <datasource name="inventory" connection="gnue" table="inventory"/>
-  <datasource name="available_units" connection="gnue" prequery=""
+  <datasource name="available_units" connection="gnue" prequery="Y"
               table="unit_description"/>
   <logic>
     <block name="inventory" datasource="inventory">
@@ -25,7 +25,7 @@
       <field name="ntryavailable_rty" field="available_qty" typecast="number"/>
       <field name="ntryreserved_qty" field="reserved_qty" typecast="number"/>
       <field name="ntrynonusable_qty" field="nonusable_qty" typecast="number"/>
-      <field name="ntryactual_qty" field="actual_qty" readonly=""/>
+      <field name="ntryactual_qty" field="actual_qty" readonly="Y"/>
       <field name="ntryreorder_qty" field="reorder_qty" typecast="number"/>
       <field name="ntryreorder_point" field="reorder_point" typecast="number"/>
       <field name="ntryqty_unit" field="qty_unit" fk_description="description"

Modified: trunk/gnue-forms/samples/location/forms/county_maint.gfd
===================================================================
--- trunk/gnue-forms/samples/location/forms/county_maint.gfd    2004-05-08 
03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/location/forms/county_maint.gfd    2004-05-08 
05:56:53 UTC (rev 5788)
@@ -9,7 +9,7 @@
   </options>
   <datasource name="county" cache="5" connection="gnue"
               order_by="state,county" table="county"/>
-  <datasource name="validator" connection="gnue" prequery="" table="state"/>
+  <datasource name="validator" connection="gnue" prequery="Y" table="state"/>
   <logic>
     <block name="county" datasource="county">
       <field name="county" case="upper" field="county">

Modified: trunk/gnue-forms/samples/location/forms/zip_coords_maint.gfd
===================================================================
--- trunk/gnue-forms/samples/location/forms/zip_coords_maint.gfd        
2004-05-08 03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/location/forms/zip_coords_maint.gfd        
2004-05-08 05:56:53 UTC (rev 5788)
@@ -10,7 +10,7 @@
   <datasource name="zips" cache="5" connection="gnue" order_by="state,city"
               table="zipcode"/>
   <datasource name="validator" connection="gnue" order_by="description"
-              prequery="" table="state"/>
+              prequery="Y" table="state"/>
   <logic>
     <block name="zip" datasource="zips">
       <field name="zip" field="zipcode" max_length="5" typecast="number">

Modified: trunk/gnue-forms/samples/location/forms/zipcode_maint.gfd
===================================================================
--- trunk/gnue-forms/samples/location/forms/zipcode_maint.gfd   2004-05-08 
03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/location/forms/zipcode_maint.gfd   2004-05-08 
05:56:53 UTC (rev 5788)
@@ -8,7 +8,7 @@
     <option name="version" value="0.0.1"/>
   </options>
   <datasource name="zips" connection="gnue" table="zipcode"/>
-  <datasource name="validator" connection="gnue" prequery="" table="state"/>
+  <datasource name="validator" connection="gnue" prequery="Y" table="state"/>
   <logic>
     <block name="zip" datasource="zips" rows="10">
       <field name="city" case="upper" field="city"/>

Modified: trunk/gnue-forms/samples/po/sc_po_entry.gfd
===================================================================
--- trunk/gnue-forms/samples/po/sc_po_entry.gfd 2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/samples/po/sc_po_entry.gfd 2004-05-08 05:56:53 UTC (rev 
5788)
@@ -97,7 +97,7 @@
       <field name="ntryUnitPrice" field="unit_price" value="">
         <trigger name="Trigger_3" src="trggrAmount" type="PRE-FOCUSOUT"/>
       </field>
-      <field name="ntryAmount" field="amt" readonly="" value=""/>
+      <field name="ntryAmount" field="amt" readonly="Y" value=""/>
       <field name="ntryComments" field="comments" value=""/>
       <field name="ntrySubTotal" field="sub_total" value="">
         <trigger name="Trigger_4" src="trggrTotal" type="PRE-FOCUSOUT"/>
@@ -111,7 +111,7 @@
       <field name="ntryShipping" field="shipping" value="">
         <trigger name="Trigger_7" src="trggrTotal" type="PRE-FOCUSOUT"/>
       </field>
-      <field name="ntryTotal" field="total" readonly="" value=""/>
+      <field name="ntryTotal" field="total" readonly="Y" value=""/>
     </block>
   </logic>
   <layout xmlns:c="GNUe:Layout:Char" c:height="24" tabbed="top" c:width="80">

Modified: trunk/gnue-forms/samples/track/forms/address_type.gfd
===================================================================
--- trunk/gnue-forms/samples/track/forms/address_type.gfd       2004-05-08 
03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/track/forms/address_type.gfd       2004-05-08 
05:56:53 UTC (rev 5788)
@@ -7,13 +7,13 @@
   <options>
     <option name="version" value="0.0.1"/>
   </options>
-  <datasource name="dtsrcaddress_type" cache="5" connection="gnue" prequery=""
+  <datasource name="dtsrcaddress_type" cache="5" connection="gnue" prequery="Y"
               table="address_type"/>
   <connection name="gnue" comment="" dbname="gnue" host="gnue"
               provider="postgresql"/>
   <logic>
     <block name="blckaddress_type" datasource="dtsrcaddress_type">
-      <field name="ntryid" field="id" readonly="">
+      <field name="ntryid" field="id" readonly="Y">
         <options>
           <option name="tip" value="Please enter the value for id"/>
         </options>

Modified: trunk/gnue-forms/samples/track/forms/assignment_status.gfd
===================================================================
--- trunk/gnue-forms/samples/track/forms/assignment_status.gfd  2004-05-08 
03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/track/forms/assignment_status.gfd  2004-05-08 
05:56:53 UTC (rev 5788)
@@ -8,12 +8,12 @@
     <option name="version" value="0.0.1"/>
   </options>
   <datasource name="dtsrcassignment_status" cache="5" connection="gnue"
-              prequery="" table="assignment_status"/>
+              prequery="Y" table="assignment_status"/>
   <connection name="gnue" comment="" dbname="gnue" host="gnue"
               provider="postgresql"/>
   <logic>
     <block name="blckassignment_status" datasource="dtsrcassignment_status">
-      <field name="ntryid" field="id" readonly="">
+      <field name="ntryid" field="id" readonly="Y">
         <options>
           <option name="tip" value="Please enter the value for id"/>
         </options>

Modified: trunk/gnue-forms/samples/track/forms/contact_manager.gfd
===================================================================
--- trunk/gnue-forms/samples/track/forms/contact_manager.gfd    2004-05-08 
03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/samples/track/forms/contact_manager.gfd    2004-05-08 
05:56:53 UTC (rev 5788)
@@ -11,20 +11,20 @@
     <option name="version" value="0.0.2"/>
   </options>
   <datasource name="dtsrcPerson" connection="gnue" order_by="last_name"
-              prequery="" table="person"/>
+              prequery="Y" table="person"/>
   <datasource name="dtsrcAddress" connection="gnue" detaillink="personid"
-              master="dtsrcPerson" masterlink="id" prequery="" 
table="address"/>
+              master="dtsrcPerson" masterlink="id" prequery="Y" 
table="address"/>
   <datasource name="dtsrcPhone" connection="gnue" detaillink="personid"
-              master="dtsrcPerson" masterlink="id" prequery="" table="phone"/>
+              master="dtsrcPerson" masterlink="id" prequery="Y" table="phone"/>
   <datasource name="dtsrcEmail" connection="gnue" detaillink="personid"
-              master="dtsrcPerson" masterlink="id" prequery="" table="email"/>
-  <datasource name="dtsrcAddressType" connection="gnue" prequery=""
+              master="dtsrcPerson" masterlink="id" prequery="Y" table="email"/>
+  <datasource name="dtsrcAddressType" connection="gnue" prequery="Y"
               table="address_type"/>
-  <datasource name="dtsrcPhoneType" connection="gnue" prequery=""
+  <datasource name="dtsrcPhoneType" connection="gnue" prequery="Y"
               table="phone_type"/>
-  <datasource name="dtsrcEmailType" connection="gnue" prequery=""
+  <datasource name="dtsrcEmailType" connection="gnue" prequery="Y"
               table="email_type"/>
-  <datasource name="dtsrcAssignmentStatus" connection="gnue" prequery=""
+  <datasource name="dtsrcAssignmentStatus" connection="gnue" prequery="Y"
               table="assignment_status"/>
   <datasource name="dtsrcHistory" connection="gnue" detaillink="person"
               master="dtsrcPerson" masterlink="id" table="history"/>
@@ -145,7 +145,7 @@
   if blckPerson.fields.ntryPK == "":
     blckPerson.fields.ntryPK = 
"%s"%dtsrcPerson.extensions.getSequence('seq_person_id')
 ]]></trigger>
-      <entry block="blckPerson" field="ntryPK" hidden="" c:x="1" c:y="1"/>
+      <entry block="blckPerson" field="ntryPK" hidden="Y" c:x="1" c:y="1"/>
       <box name="Box_1" c:height="11" label="Personal Information"
            c:width="33" c:x="0" c:y="0"/>
       <label name="Label_1" rows="1" text="Full Name" c:x="2" c:y="1"/>

Modified: trunk/gnue-forms/samples/track/forms/email_type.gfd
===================================================================
--- trunk/gnue-forms/samples/track/forms/email_type.gfd 2004-05-08 03:11:37 UTC 
(rev 5787)
+++ trunk/gnue-forms/samples/track/forms/email_type.gfd 2004-05-08 05:56:53 UTC 
(rev 5788)
@@ -7,11 +7,11 @@
   <options>
     <option name="version" value="0.0.1"/>
   </options>
-  <datasource name="dtsrcemail_type" cache="5" connection="gnue" prequery=""
+  <datasource name="dtsrcemail_type" cache="5" connection="gnue" prequery="Y"
               table="email_type"/>
   <logic>
     <block name="blckemail_type" datasource="dtsrcemail_type">
-      <field name="ntryid" field="id" readonly="">
+      <field name="ntryid" field="id" readonly="Y">
         <options>
           <option name="tip" value="Please enter the value for id"/>
         </options>

Modified: trunk/gnue-forms/samples/track/forms/phone_type.gfd
===================================================================
--- trunk/gnue-forms/samples/track/forms/phone_type.gfd 2004-05-08 03:11:37 UTC 
(rev 5787)
+++ trunk/gnue-forms/samples/track/forms/phone_type.gfd 2004-05-08 05:56:53 UTC 
(rev 5788)
@@ -7,13 +7,13 @@
   <options>
     <option name="version" value="0.0.1"/>
   </options>
-  <datasource name="dtsrcphone_type" cache="5" connection="gnue" prequery=""
+  <datasource name="dtsrcphone_type" cache="5" connection="gnue" prequery="Y"
               table="phone_type"/>
   <connection name="dtbsgnue" comment="" dbname="gnue" host="gnue"
               provider="postgresql"/>
   <logic>
     <block name="blckphone_type" datasource="dtsrcphone_type">
-      <field name="ntryid" field="id" readonly="">
+      <field name="ntryid" field="id" readonly="Y">
         <options>
           <option name="tip" value="Please enter the value for id"/>
         </options>

Modified: trunk/gnue-forms/samples/zipcode/states.gfd
===================================================================
--- trunk/gnue-forms/samples/zipcode/states.gfd 2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/samples/zipcode/states.gfd 2004-05-08 05:56:53 UTC (rev 
5788)
@@ -8,11 +8,11 @@
     <option name="version" value="0.0.2"/>
   </options>
   <datasource name="dsstate" cache="15" connection="gnue" order_by="state"
-              prequery="" table="state"/>
+              prequery="Y" table="state"/>
   <datasource name="dscities" cache="15" connection="gnue" detaillink="state"
               master="dsstate" masterlink="state" order_by="city" 
table="zipcode"/>
   <logic>
-    <block name="blkstate" datasource="dsstate" rows="5">
+    <block name="blkstate" datasource="dsstate" rows="5" transparent="Y" 
autoCreate="Y" autoNextRecord="Y" autoCommit="Y">
       <field name="entstate" field="state"/>
       <field name="entdesc" field="description"/>
     </block>
@@ -37,7 +37,7 @@
       <entry block="cities" field="state" c:width="3" c:x="23" c:y="10"/>
       <label name="Label_5" rows="1" text="Zip" c:x="27" c:y="9"/>
       <entry block="cities" field="zip" c:width="10" c:x="27" c:y="10"/>
-      <entry block="cities" field="zop" hidden="" c:width="1" c:x="27" 
c:y="1"/>
+      <entry block="cities" field="zop" hidden="Y" c:width="1" c:x="27" 
c:y="1"/>
     </page>
   </layout>
 </form>

Modified: trunk/gnue-forms/samples/zipcode/zipcode.gfd
===================================================================
--- trunk/gnue-forms/samples/zipcode/zipcode.gfd        2004-05-08 03:11:37 UTC 
(rev 5787)
+++ trunk/gnue-forms/samples/zipcode/zipcode.gfd        2004-05-08 05:56:53 UTC 
(rev 5788)
@@ -8,12 +8,12 @@
     <option name="version" value="0.0.1"/>
   </options>
   <datasource name="zips" cache="5" connection="gnue" order_by="state,city"
-              prequery="" table="zipcode"/>
+              prequery="Y" table="zipcode"/>
   <datasource name="validator" connection="gnue" order_by="description"
-              prequery="" table="state"/>
+              prequery="Y" table="state"/>
   <logic>
     <block name="zip" datasource="zips" rows="15">
-      <field name="city" case="upper" field="city" required="">
+      <field name="city" case="upper" field="city" required="Y">
         <options>
           <option name="tip" value="Full name of city"/>
         </options>

Modified: trunk/gnue-forms/src/GFDisplayHandler.py
===================================================================
--- trunk/gnue-forms/src/GFDisplayHandler.py    2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFDisplayHandler.py    2004-05-08 05:56:53 UTC (rev 
5788)
@@ -106,7 +106,7 @@
          ))
 
   def isPending(self):
-    return self.modified
+    return not self.editing or self.modified
 
   #####################
   #
@@ -562,8 +562,8 @@
     self.cursor = len(self.display)
     # Ensure cursor is properly placed.
     self.generateRefreshEvent()
-    
-    
+
+
   def _buildDisplayHelper(self, value, editing):
     if value == None:
       return ""
@@ -608,7 +608,7 @@
 
     if editing and type(val) == types.StringType:
       return val
-    
+
 #     if float(val) == val:
 #    try:
     value = val
@@ -617,10 +617,10 @@
           value = "%d" % value
         else:
           value = "%s" % value
-    except OverflowError:          
+    except OverflowError:
         value = "%s" % value
     except ValueError:
-        value = "%s" % value        
+        value = "%s" % value
 #     else:
 #       value = "%s" % val
 #     if not editing:

Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2004-05-08 03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/src/GFForm.py      2004-05-08 05:56:53 UTC (rev 5788)
@@ -264,16 +264,15 @@
         return None
 
     entry = None
+
+    mode = self.getCurrentMode()
+
     if isinstance(object, GFObj):
-      if (object._type in TabStops and
-          (object._navigable) and ((not object.readonly) or
-         (self._currentBlock and \
-          self._currentBlock.mode=='query' and \
-          object._queryable))):
+      if object.isNavigable(mode):
         return object
       else:
-        if hasattr(object, '_entryList'):
-          for child in object._entryList:
+        if hasattr(object, 'getFocusOrder'):
+          for child in object.getFocusOrder():
             entry = self.findFocus(child)
             if entry:
               return entry
@@ -290,6 +289,23 @@
     return entry
 
   #
+  #
+  #
+  def getCurrentMode(self):
+    """
+    Returns the editing mode of the current record
+    """
+    if self._currentBlock:
+      if self._currentBlock.mode == 'query':
+        return 'query'
+      elif self._currentBlock.isEmpty():
+        return 'new'
+      else:
+        return 'edit'
+    else:
+      return 'new'
+
+  #
   # changeFocus
   #
   # changes to the requested entry object requested by
@@ -416,17 +432,22 @@
   def isSaved(self):
     if (self._currentEntry._type != 'GFButton' and \
         self._currentEntry._displayHandler.isPending()):
-      return 0
+      return False
 
     for block in self._logic._blockList:
       if not block.isSaved():
-        return 0
+        return False
 
-    return 1
+    return True
 
   def initQuery(self):
     message = None
     if self._currentBlock.mode != 'query':
+
+      # Auto-commit?
+      if self._currentBlock.autoCommit:
+        self.commit()
+
       for block in self._logic._blockList:
         if not block.isSaved():
           message = _('Data not saved. Save changes or clear the form to 
proceed.')
@@ -585,9 +606,6 @@
       self.dispatchEvent('updateENTRY',entry, _form=self)
       #self._instance.dispatchEvent('updateENTRY',entry, _form=self)
 
-  #
-  #
-  #
 
   #
   # nextEntry
@@ -597,11 +615,24 @@
   #
   def nextEntry(self, reverse=False, first=False, onlyInBlock=False):
 
-    #if self._currentBlock.transparent and not onlyInBlock:
-    source = self._currentEntry._page._focusOrder[:]
-    #else:
-    #  source = self._currentBlock._focusOrder[:]
-    #  print source
+    currentBlock = self._currentBlock
+    mode = self.getCurrentMode()
+
+
+    if currentBlock.transparent and not (
+          onlyInBlock or
+          currentBlock.autoNextRecord and not (
+              currentBlock.isEmpty() or \
+              (not reverse and currentBlock.isLastRecord() and \
+                   not currentBlock.autoCreate) or \
+              (reverse and currentBlock.isFirstRecord())
+          )):
+      source = self._currentEntry._page.getFocusOrder()
+      stayInBlock = False
+    else:
+      source = currentBlock.getFocusOrder()
+      stayInBlock = True
+
     # If we want the previous entry, then reverse the focusorder we're using
     if reverse:
       source.reverse()
@@ -609,12 +640,12 @@
     nextEntry = None
     firstEntry = None
     keepNext = False
+
     for object in source:
 
-      if ((object._navigable) and ((not object.readonly) or
-         (self._currentBlock.mode=='query' and object._queryable))):
-
-        if (onlyInBlock or not self._currentBlock.transparent) and 
(self._currentBlock.name != object.block):
+      if object.isNavigable(mode):
+        if stayInBlock and \
+           (currentBlock.name != object.block):
           continue
         # If we only wanted the first navigable field in the block, then return
         if first:
@@ -637,24 +668,50 @@
           nextEntry = object
           break
 
-    if nextEntry == firstEntry and self._currentBlock.transparent and 
self._currentPage.transparent:
-      # Jump to the next/(previous) page if block is page as transparent
-      pages =  self._layout._pageList
-      i = pages.index(self._currentPage)
+    # If we've cycled back around to the first entry, then do special checks
+    if nextEntry == firstEntry:
 
-      if reverse:
-        try:
-          dest = self._layout._pageList[i-1]
-        except IndexError:
-          dest = self._layout._pageList[-1]
-        # TODO: this fails if last entry is not navigable
-        self.findAndChangeFocus(dest._entryList[-1])
+      # If we should navigate to the next record, do it...
+      if reverse and not currentBlock.isFirstRecord():
+        currentBlock.prevRecord()
+        self.changeFocus(nextEntry)
+      elif not reverse and \
+         currentBlock.autoNextRecord and \
+         not currentBlock.isEmpty() and \
+         not (not currentBlock.autoCreate and \
+              currentBlock.isLastRecord()):
+           currentBlock.nextRecord()
+
+           # If new record is empty, then the
+           # nextEntry logic has been taken care of...
+           if currentBlock.isEmpty():
+             return
+           else:
+             self.changeFocus(nextEntry)
+
+      # Otherwise, are we transparent? If so, go to next block/page
+      elif currentBlock.transparent and \
+         self._currentPage.transparent:
+
+        # Jump to the next/(previous) page if block is page as transparent
+        pages =  self._layout._pageList
+        i = pages.index(self._currentPage)
+
+        if reverse:
+          try:
+            dest = self._layout._pageList[i-1]
+          except IndexError:
+            dest = self._layout._pageList[-1]
+          # TODO: this fails if last entry is not navigable
+          self.findAndChangeFocus(dest._entryList[-1])
+        else:
+          try:
+            dest = self._layout._pageList[i+1]
+          except IndexError:
+            dest = self._layout._pageList[0]
+          self.findAndChangeFocus(dest)
       else:
-        try:
-          dest = self._layout._pageList[i+1]
-        except IndexError:
-          dest = self._layout._pageList[0]
-        self.findAndChangeFocus(dest)
+        self.changeFocus(nextEntry)
 
     else:
       self.changeFocus(nextEntry)

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py  2004-05-08 03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/src/GFInstance.py  2004-05-08 05:56:53 UTC (rev 5788)
@@ -737,12 +737,20 @@
     try:
       event._form.processTrigger('Pre-Exit', ignoreAbort=False)
 
+      # TODO: WTF? This isn't saving a currently edited field
+      if event._form._currentBlock.autoCommit:
+        event._form.endEditing()
+        event._form.commit()
+
+
       if not event._form.isSaved():
         self.displayMessageBox( _('Data not saved. Save changes or clear the 
form to proceed.'))
         event._form.refreshUIEvents()
       else:
         event._form.processTrigger('On-Exit')
-        self.dispatchEvent('exitApplication',_('Current data is 
saved'),_formName=event._form.name)
+        self.dispatchEvent('exitApplication',
+                           _('Current data is saved'),
+                           _formName=event._form.name)
     except AbortRequest, t:
       self.displayMessageBox(t)
       event._form.refreshUIEvents()

Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2004-05-08 05:56:53 UTC (rev 
5788)
@@ -1,4 +1,4 @@
-# #
+#
 # This file is part of GNU Enterprise.
 #
 # GNU Enterprise is free software; you can redistribute it
@@ -55,7 +55,7 @@
     self.mode = 'normal'
     self._convertAstericksToPercent = gConfigForms('AsterickWildcard')
 
-    self._inits = [self.initialize]
+    self._inits = [self.__initialize]
 
     #self._datasource = None
     self._resultSet = None
@@ -66,7 +66,7 @@
     self._queryDefaults = {}
     self._queryValues = {}
     self._lastQueryValues = {}
-#    self._autocreate =  int(gConfigForms('autocreate'))
+
     self._gap = 0
     self._rows = 1
 
@@ -171,7 +171,7 @@
   #
   # Primary initialization
   #
-  def initialize(self):
+  def __initialize(self):
     self._form = form = self.findParentOfType('GFForm')
     self._logic = logic = self.findParentOfType('GFLogic')
 
@@ -180,18 +180,12 @@
     logic._blockList.append(self)
     logic._blockMap[self.name] = self
 
-    self._autocreate =  self.autoinsert  # Historical reasons...
-
     # Initialize our events system
     events.EventAware.__init__(self, form._instance.eventController)
 
-    # Get all focusable items, ordered correctly
-    #self._focusOrder = self.getFocusOrder()
-
-
     # Create a stub/non-bound datasource if we aren't bound to one
     if not hasattr(self,'datasource') or not self.datasource:
-      ds = GFDataSource(self)
+      ds = GFDataSource(self._form)
       self.datasource = ds.name = "__dts_%s" % id(self)
       form._datasourceDictionary[ds.name] = ds
       ds._buildObject()
@@ -215,29 +209,43 @@
     else:
       object._gap = self._gap
 
+  #
+  #
+  #
+  def getFocusOrder(self):
+    list = []
+    for field in self._children:
+      list += field._entryList
 
+    return GFContainer.getFocusOrder(self,list)
+
   #
   # isSaved
   #
-  # returns a positive value if the datasource the block is associated
-  # with is saved
   #
   def isSaved(self):
+    """
+    Returns a positive value if the datasource the block is associated
+    with is saved
+    """
     return self._resultSet == None or not self._resultSet.isPending()
 
   #
   # deleteRecord
   #
-  # Doesn't really delete the record but marks it for
-  # deletion during next commit
-  #
   def deleteRecord(self):
+    """
+    Doesn't really delete the record but marks it for
+    deletion during next commit
+    """
     self._resultSet.current.delete()
 
   #
-  # Load and process a resultset
   #
   def _loadResultSet(self, resultSet):
+    """
+    Load and process a resultset
+    """
     self._resultSet = resultSet
     self._currentRecord = -1
     self._recordCount = 0
@@ -247,8 +255,7 @@
       self.switchRecord(0)
       self._recordCount = self._resultSet.getRecordCount()
     else:
-      # TODO: This means no results were returned from a query.
-      # TODO: It probably shouldn't create a new record :)  Display a message?
+      # This means no results were returned from a query.
       self.newRecord()
 
   #
@@ -259,10 +266,11 @@
 
   #
   #
-  # Moves the proper record into editing position
   #
   def switchRecord(self, adjustment):
-
+    """
+    Moves the proper record into editing position
+    """
     self._currentRecord = self._resultSet.getRecordNumber()
     for field in self._fieldList:
       for entry in field._entryList:
@@ -284,6 +292,8 @@
 
     # Focus out
     self.processTrigger('PRE-FOCUSOUT')
+    if self.autoCommit and self._resultSet.current:
+      self._form.commit()
     self.processTrigger('POST-FOCUSOUT')
 
     if self._resultSet.insertRecord():
@@ -301,13 +311,19 @@
 
       self.processTrigger('POST-FOCUSIN')
 
+  def isLastRecord(self):
+    return self._resultSet.isLastRecord()
+
+  def isFirstRecord(self):
+    return self._resultSet.isFirstRecord()
+
   def nextRecord(self):
     if not self._resultSet.isLastRecord():
 
       # Do FocusOut triggers
       self.processTrigger('PRE-FOCUSOUT')
-      # TODO: I'm not 100% sure of the definition of
-      # TODO: Post-FocusOut  In this context!
+      if self.autoCommit:
+        self._form.commit()
       self.processTrigger('POST-FOCUSOUT')
 
       self._resultSet.nextRecord()
@@ -318,7 +334,7 @@
       self.processTrigger('PRE-FOCUSIN')
       self.processTrigger('POST-FOCUSIN')
 
-    elif self._autocreate and not self.isEmpty() and not self.restrictInsert:
+    elif self.autoCreate and not self.isEmpty() and not self.restrictInsert:
       self.newRecord()
       # Go to first field
       self._form.findAndChangeFocus(self._entryList[0])
@@ -595,18 +611,15 @@
         if entry._bound and entry.isQueryable() and len(str(val)):
           if entry.typecast == 'text':
             if block._convertAstericksToPercent:
-              print val
               try:
                 val = str(val).replace('*','%')
               except ValueError:
                 pass
-            print val, val.find('%'), val.find('_')
             if (val.find('%') >= 0 or val.find('_') >= 0):
               conditionLike[entry.field] = val
             else:
               conditionEq[entry.field] = val
           else:
-##            GDebug.printMesg(5,'Adding conditional AND (%s=%s)' % 
(entry.field, val))
             conditionEq[entry.field] = val
 
     if len(conditionLike.keys()) and len(conditionEq.keys()):
@@ -629,6 +642,7 @@
 
 
 
+
 # A simple resultset iterator
 # Lets you use ResultSets as:
 #

Modified: trunk/gnue-forms/src/GFObjects/GFButton.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFButton.py  2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFButton.py  2004-05-08 05:56:53 UTC (rev 
5788)
@@ -50,6 +50,12 @@
     self._form = self.findParentOfType('GFForm')
     self._page._entryList.append(self)
 
+  def isNavigable(self, mode):
+    # Buttons aren't navigable during queries
+    if mode == 'query':
+      return False
+    else:
+      return GFTabStop.isNavigable(self, mode)
 
 
 

Modified: trunk/gnue-forms/src/GFObjects/GFContainer.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFContainer.py       2004-05-08 03:11:37 UTC 
(rev 5787)
+++ trunk/gnue-forms/src/GFObjects/GFContainer.py       2004-05-08 05:56:53 UTC 
(rev 5788)
@@ -37,12 +37,14 @@
   # Build a "focus order" from all our children
   # (and, recursively, any child containers)
   # TODO: This assumes sane focusstop values; no sanity checks!
-  def getFocusOrder(self):
+  def getFocusOrder(self, list=None):
     specificFocusStops = {}
     allFocusStops = []
-    for child in self._children:
+    if not list:
+      list = self._children
+    for child in list:
       if isinstance(child,GFContainer):
-        tabStops = child.getFocusOrder()          
+        tabStops = child.getFocusOrder()
         if len(tabStops):
           allFocusStops.append(tabStops)
           try:

Modified: trunk/gnue-forms/src/GFObjects/GFEntry.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFEntry.py   2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFEntry.py   2004-05-08 05:56:53 UTC (rev 
5788)
@@ -30,7 +30,6 @@
 
 from gnue.common.apps import GDebug
 from gnue.forms import GFDisplayHandler
-from GFValue import GFValue
 from GFTabStop import GFTabStop
 import string
 
@@ -50,6 +49,7 @@
     self.Char__width = int(gConfigForms('widgetWidth'))
     self.style = "default"
     self.label = ""
+    self._queryable = True
 
     self._inits = [self.initialize]
 
@@ -111,8 +111,8 @@
     # Navigable? or no?
     self._navigable = self.navigable
     if self.style == 'label' or self.hidden:
-      self._navigable = 0
-      self._queryable = 0 # TODO: is this used?
+      self._navigable = False
+      self._queryable = False
 
     self._formatmask = ""
     self._inputmask = hasattr(self,'inputmask') and self.inputmask or ""
@@ -165,4 +165,4 @@
 
   def _getRows(self):
     return self._rows
-  
+

Modified: trunk/gnue-forms/src/GFObjects/GFImage.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFImage.py   2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFImage.py   2004-05-08 05:56:53 UTC (rev 
5788)
@@ -1,13 +1,13 @@
 #
 # This file is part of GNU Enterprise.
 #
-# GNU Enterprise is free software; you can redistribute it 
-# and/or modify it under the terms of the GNU General Public 
-# License as published by the Free Software Foundation; either 
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
 # version 2, or (at your option) any later version.
 #
-# GNU Enterprise is distributed in the hope that it will be 
-# useful, but WITHOUT ANY WARRANTY; without even the implied 
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 # PURPOSE. See the GNU General Public License for more details.
 #
@@ -33,11 +33,12 @@
 #
 
 from GFValue import GFValue
+from GFTabStop import GFTabStop
 from gnue.forms import GFDisplayHandler
 #
 #GFLabel
 #
-class GFImage(GFValue):
+class GFImage(GFValue, GFTabStop):
   def __init__(self, parent=None, value=None):
     GFValue.__init__(self, parent, value, 'GFImage')
 
@@ -48,6 +49,8 @@
     # Runtime Variables
     self._inits = [self.initialize]
 
+    self.isNavigable = GFTabStop.isNavigable
+
   def _buildObject(self):
     if not hasattr(self, 'rows') and hasattr(self,'visibleCount'):
       self.rows = self.visibleCount
@@ -71,7 +74,7 @@
       self._block = block = 
self.findParentOfType('GFForm')._logic._blockMap[self.block]
       block._entryList.append(self)
     except KeyError:
-      raise "Entry references non-existent block '%s'" % self.block            
                     
+      raise "Entry references non-existent block '%s'" % self.block
 
     # ...Field
     try:
@@ -83,17 +86,17 @@
     # ...Page
     self._page = self.findParentOfType('GFPage')
     self._page._entryList.append(self)
-    
+
     self._form = self._block._form
 
     self._navigable = False # self.navigable
-                                        
+
     self._displayHandler = GFDisplayHandler.ImageDisplayHandler(self,
                                                                 
self._form._instance.eventController)
 
   # TODO: Conversion:  Does this belong here or not?
   def getValue(self, *args, **parms):
     return self._field.getValue(*args, **parms)
-     
 
 
+

Modified: trunk/gnue-forms/src/GFObjects/GFObj.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFObj.py     2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFObj.py     2004-05-08 05:56:53 UTC (rev 
5788)
@@ -1,18 +1,18 @@
 #
 # This file is part of GNU Enterprise.
 #
-# GNU Enterprise is free software; you can redistribute it 
-# and/or modify it under the terms of the GNU General Public 
-# License as published by the Free Software Foundation; either 
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
 # version 2, or (at your option) any later version.
 #
-# GNU Enterprise is distributed in the hope that it will be 
-# useful, but WITHOUT ANY WARRANTY; without even the implied 
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 # PURPOSE. See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public 
-# License along with program; see the file COPYING. If not, 
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
@@ -49,6 +49,14 @@
     self._rows = 1
     self._gap = 0
     self._inits = []
+
+  def isNavigable(self, mode='edit'):
+    """
+    Is the current object currently navigable?
+    Mode can be 'edit', 'query', or 'new'
+    """
+    return False
+
   #
   # get an Option
   #

Modified: trunk/gnue-forms/src/GFObjects/GFPage.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFPage.py    2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFPage.py    2004-05-08 05:56:53 UTC (rev 
5788)
@@ -1,25 +1,25 @@
 #
 # This file is part of GNU Enterprise.
 #
-# GNU Enterprise is free software; you can redistribute it 
-# and/or modify it under the terms of the GNU General Public 
-# License as published by the Free Software Foundation; either 
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
 # version 2, or (at your option) any later version.
 #
-# GNU Enterprise is distributed in the hope that it will be 
-# useful, but WITHOUT ANY WARRANTY; without even the implied 
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 # PURPOSE. See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public 
-# License along with program; see the file COPYING. If not, 
-# write to the Free Software Foundation, Inc., 59 Temple Place 
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # Copyright 2000-2004 Free Software Foundation
 #
 # FILE:
-# GFObjects.py
+# GFContainerects.py
 #
 # DESCRIPTION:
 """
@@ -28,17 +28,17 @@
 # NOTES:
 #
 
-from GFObj import GFObj
+from GFContainer import GFContainer
 
 #
 # GFPage
 #
-class GFPage(GFObj):
+class GFPage(GFContainer):
   def __init__(self, parent=None):
-    GFObj.__init__(self, parent,"GFPage")
+    GFContainer.__init__(self, parent,"GFPage")
     self._inits = [self.initialize, self.init2]
 
-    self._validTriggers = { 
+    self._validTriggers = {
                   'PRE-FOCUSOUT':   'Pre-FocusOut',
                   'POST-FOCUSOUT':  'Post-FocusOut',
                   'PRE-FOCUSIN':    'Pre-FocusIn',
@@ -50,7 +50,7 @@
 
   def initialize(self):
     self._form = self.findParentOfType('GFForm')
-    
+
     layout = self.findParentOfType('GFLayout')
     layout._pageList.append(self)
 

Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2004-05-08 03:11:37 UTC (rev 
5787)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2004-05-08 05:56:53 UTC (rev 
5788)
@@ -30,4 +30,11 @@
 
 class GFTabStop(GFObj):
   _navigable = True
-  pass
+
+  def isNavigable(self, mode="edit"):
+    # TODO: Check for read-only, etc
+    if mode == 'query':
+      return self._navigable and self._queryable
+    else:
+      return (self._navigable) and (not self.readonly)
+

Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py    2004-05-08 03:11:37 UTC (rev 5787)
+++ trunk/gnue-forms/src/GFParser.py    2004-05-08 05:56:53 UTC (rev 5788)
@@ -207,22 +207,23 @@
                               'or previous-field events. Makes navigation in '
                               'multiblock forms easier. If false, focus stays '
                               'within a block until user explicitly moves to '
-                              'another block' },
-            'autoinsert':{
+                              'another block. Note that a block\'s 
{autoNextRecord}'
+                              'setting affects {transparent} behavior' },
+            'autoCreate':{
                'Typecast': GTypecast.boolean,
                'Label': _('Auto Create Record'),
                'Default': True,
                'Description': 'If set, then if you attempt to go to the next 
record '
                               'while at the last record, a new record is 
created.'},
-            'autorecord':{
+            'autoNextRecord':{
                'Typecast': GTypecast.boolean,
                'Label': _('Auto Next Record'),
-               'Default': True,
+               'Default': False,
                'Description': 'If set, then if you tab at the end of a block, 
you '
                               'will be taken to the next record. If the 
current '
                               'record is empty and transparent is true, then '
                               'you will be taken to the next block'},
-            'autocommit':{
+            'autoCommit':{
                'Typecast': GTypecast.boolean,
                'Label': _('Auto Commit'),
                'Default': False,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]