commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8658 - in trunk/gnue-forms/src: . GFObjects


From: reinhard
Subject: [gnue] r8658 - in trunk/gnue-forms/src: . GFObjects
Date: Wed, 6 Sep 2006 05:50:16 -0500 (CDT)

Author: reinhard
Date: 2006-09-06 05:50:15 -0500 (Wed, 06 Sep 2006)
New Revision: 8658

Modified:
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFInstance.py
   trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Cleanup of record insertion/deletion procedures.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-09-06 09:39:18 UTC (rev 8657)
+++ trunk/gnue-forms/src/GFForm.py      2006-09-06 10:50:15 UTC (rev 8658)
@@ -1084,7 +1084,7 @@
 
 
     # -------------------------------------------------------------------------
-    # Create a new, empty record
+    # Record insertion and deletion
     # -------------------------------------------------------------------------
 
     def new_record(self):
@@ -1095,33 +1095,27 @@
         if self._currentBlock is not None:
             self._currentBlock.new_record()
 
-
     # -------------------------------------------------------------------------
-    # Delete the current record.
-    # -------------------------------------------------------------------------
 
-    def deleteRecord (self):
+    def delete_record(self):
         """
-        Deletes the actual record.
+        Deletes the current record.
         """
-        if not self.readonly and self._currentBlock is not None:
-            self._currentBlock.deleteRecord()
-            self.refreshUIEvents()
 
+        if self._currentBlock is not None:
+            self._currentBlock.delete_record()
 
     # -------------------------------------------------------------------------
-    # Undelete the current record
-    # -------------------------------------------------------------------------
 
-    def undeleteRecord (self):
+    def undelete_record(self):
         """
-        Undeletes the actual record.
+        Undeletes the current record.
         """
-        if not self.readonly and self._currentBlock is not None:
-            self._currentBlock.undeleteRecord()
-            self.refreshUIEvents()
 
+        if self._currentBlock is not None:
+            self._currentBlock.undelete_record()
 
+
     # -------------------------------------------------------------------------
     # Check all blocks in the form whether they are saved (committed) or not.
     # -------------------------------------------------------------------------
@@ -1133,8 +1127,6 @@
         """
 
         # Is the current entry changed?
-        # FIXME: should only cause the form to appear unsaved if the entry is 
bound
-        # to a field.
         if (self._currentEntry is not None and \
             self._currentEntry._type != 'GFButton' and \
             self._currentEntry._field._bound and \
@@ -1146,8 +1138,8 @@
           if block.isPending():
             return False
 
-        # Does a connection have any pending (already posted but not yet 
committed)
-        # changes?
+        # Does a connection have any pending (already posted but not yet
+        # committed) changes?
         for connection in (self.__get_connections ()).values ():
           if connection.isPending ():
             return False

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py  2006-09-06 09:39:18 UTC (rev 8657)
+++ trunk/gnue-forms/src/GFInstance.py  2006-09-06 10:50:15 UTC (rev 8658)
@@ -87,41 +87,47 @@
                            '__before__'          : self.__beforeEvent,
 
                            # Focus-related events
+                           'requestFOCUS'        : self.changeFocus,
                            'requestENTER'        : self.nextEntry,
                            'requestNEXTENTRY'    : self.nextEntry,
                            'requestPREVENTRY'    : self.previousEntry,
-                           'requestNEXTPAGE'     : self.nextPage,
-                           'requestPREVPAGE'     : self.previousPage,
                            'requestNEXTBLOCK'    : self.nextBlock,
                            'requestPREVBLOCK'    : self.previousBlock,
+                           'requestNEXTPAGE'     : self.nextPage,
+                           'requestPREVPAGE'     : self.previousPage,
+                           'requestPAGE'         : self.gotoPage,
+
+                           # Record navigation
                            'requestFIRSTRECORD'  : self.firstRecord,
-                           'requestLASTRECORD'   : self.lastRecord,
                            'requestPREVRECORD'   : self.prevRecord,
                            'requestNEXTRECORD'   : self.nextRecord,
+                           'requestLASTRECORD'   : self.lastRecord,
                            'requestJUMPPROMPT'   : self.requestJumpTo,
                            'requestJUMPRECORD'   : self.jumpRecords,
                            'requestJUMPROWSUP'   : self.jumpRowsUp,
                            'requestJUMPROWSDOWN' : self.jumpRowsDown,
-                           'requestPAGE'         : self.gotoPage,
-                           'requestFOCUS'        : self.changeFocus,
 
-                           # Data set manipulation
+                           # Record insertion/deletion
                            'requestNEWRECORD'    : self.newRecord,
                            'requestMARKFORDELETE': self.deleteRecord,
                            'requestUNDELETE'     : self.undeleteRecord,
+
+                           # Queries
+                           'requestENTERQUERY'   : self.requestQuery,
+                           'requestCOPYQUERY'    : self.copyQuery,
+                           'requestCANCELQUERY'  : self.cancelQuery,
+                           'requestEXECQUERY'    : self.executeQuery,
+
+                           # Transactions
                            'requestCOMMIT'       : self.executeCommit,
                            'requestPRINTOUT'     : self.executePrintout,
                            'requestROLLBACK'     : self.executeRollback,
-                           'requestENTERQUERY'   : self.requestQuery,
-                           'requestEXECQUERY'    : self.executeQuery,
-                           'requestCANCELQUERY'  : self.cancelQuery,
-                           'requestCOPYQUERY'    : self.copyQuery,
 
                            # Miscellaneous stuff
-                           'requestEXIT'         : self.executeExit,
-                           'requestABOUT'        : self.executeAbout,
                            'requestMODETOGGLE'   : self.toggleInsertMode,
+                           'requestABOUT'        : self.executeAbout,
                            'requestUSERCOMMAND'  : self.executeUserCommand,
+                           'requestEXIT'         : self.executeExit,
                      })
 
     self.connections = connections       # Link to the GBaseApp's GConnections
@@ -706,56 +712,41 @@
 
 
   # ---------------------------------------------------------------------------
-  # Verify state of data and exit form
+  # Record insertion/deletion
   # ---------------------------------------------------------------------------
 
-  def executeExit(self, event):
+  def newRecord(self, event):
     """
-    When exit is requested verify that the data has been saved
+    Tells the form to create a new record
     """
-    event._form.execute_close()
+    event._form.new_record()
 
-
   # ---------------------------------------------------------------------------
-  # Mark a record for deletion
-  # ---------------------------------------------------------------------------
 
   def deleteRecord (self, event):
     """
     Tells the form to mark a record for delete
     """
+    event._form.delete_record()
 
-    if event._form.readonly:
-        event._form.alert_message(u_("Form is readonly"))
-    elif not event._form._currentBlock.deletable:
-        event._form.alert_message(u_("Block does not allow delete"))
-    else:
-        event._form.deleteRecord()
-        event._form.update_record_status()
-
-
   # ---------------------------------------------------------------------------
-  # Unmark a record for deletion
-  # ---------------------------------------------------------------------------
 
   def undeleteRecord (self, event):
     """
     Tells the form to mark a record for delete
     """
+    event._form.undelete_record()
 
-    event._form.undeleteRecord ()
-    event._form.update_record_status()
 
-
   # ---------------------------------------------------------------------------
-  # Tells the form to create a new record
+  # Verify state of data and exit form
   # ---------------------------------------------------------------------------
 
-  def newRecord(self, event):
+  def executeExit(self, event):
     """
-    Tells the form to create a new record
+    When exit is requested verify that the data has been saved
     """
-    event._form.new_record()
+    event._form.execute_close()
 
 
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-09-06 09:39:18 UTC (rev 
8657)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-09-06 10:50:15 UTC (rev 
8658)
@@ -131,9 +131,9 @@
 
             # Record insertion and deletion
             'newRecord': {'function': self.new_record},
-            'duplicateRecord': {'function': self.duplicateRecord},
-            'deleteRecord': {'function': self.deleteRecord},
-            'undeleteRecord': {'function': self.undeleteRecord},
+            'duplicateRecord': {'function': self.duplicate_record},
+            'deleteRecord': {'function': self.delete_record},
+            'undeleteRecord': {'function': self.undelete_record},
 
             # Queries
             'initQuery': {'function': self.initQuery},
@@ -827,41 +827,78 @@
 
   # ---------------------------------------------------------------------------
 
-  def duplicateRecord (self, exclude = (), include = ()):
-    """
-    Create a new record and initialize it with field values from the record at
-    the current cursor position.
+  def duplicate_record(self, exclude=(), include=()):
+        """
+        Create a new record and initialize it with field values from the record
+        at the current cursor position.
 
-    @param exclude: list of fields not to copy.
-    @param include: list of fields to copy. An empty list means to copy all
-      fields except primary key fields and rowid fields, which are never copied
-      anyway.
-    """
+        @param exclude: list of fields not to copy.
+        @param include: list of fields to copy. An empty list means to copy all
+            fields except primary key fields and rowid fields, which are never
+            copied anyway.
+        """
 
-    # TODO: check if we need to do autoCommit and fire triggers here too
-    self._resultSet.duplicateRecord (exclude = exclude, include = include)
+        if not self._form.endEditing():
+            return
 
+        self.__focus_out()
 
+        self._resultSet.duplicateRecord(exclude=exclude, include=include)
+        self._recordCount = self._resultSet.getRecordCount()
+
+        self.__focus_in()
+
+        self._form.dispatchEvent('gotoENTRY', object=self._form._currentEntry,
+                _form=self._form)
+
+        self._form.beginEditing()
+
   # ---------------------------------------------------------------------------
 
-  def deleteRecord (self):
-    """
-    Mark the current record for deletion. The acutal deletion will be done on
-    the next commit, call or update.
-    """
+  def delete_record(self):
+        """
+        Mark the current record for deletion. The acutal deletion will be done
+        on the next commit, call or update.
+        """
 
-    self._resultSet.current.delete ()
+        if not self._form.endEditing():
+            return
 
+        self.__focus_out(do_auto_commit=False)
+
+        self._resultSet.current.delete()
+        self._recordCount = self._resultSet.getRecordCount()
+
+        self.__focus_in()
+
+        self._form.dispatchEvent('gotoENTRY', object=self._form._currentEntry,
+                _form=self._form)
+
+        self._form.beginEditing()
+
   # ---------------------------------------------------------------------------
 
-  def undeleteRecord (self):
-    """
-    Removes the deletion mark from the record
-    """
+  def undelete_record(self):
+        """
+        Removes the deletion mark from the current record.
+        """
 
-    self._resultSet.current.undelete ()
+        if not self._form.endEditing():
+            return
 
+        self.__focus_out(do_auto_commit=False)
 
+        self._resultSet.current.undelete()
+        self._recordCount = self._resultSet.getRecordCount()
+
+        self.__focus_in()
+
+        self._form.dispatchEvent('gotoENTRY', object=self._form._currentEntry,
+                _form=self._form)
+
+        self._form.beginEditing()
+
+
   # ---------------------------------------------------------------------------
   # Shared code called whenever focus enters or leaves a record
   # ---------------------------------------------------------------------------
@@ -869,24 +906,24 @@
   def __focus_in(self):
 
         if self._form.get_focus_block() is self:
-            self.processTrigger ('PRE-FOCUSIN')
+            self.processTrigger('PRE-FOCUSIN')
 
             self._form.update_record_counter()
             self._form.update_record_status()
 
-            self.processTrigger ('POST-FOCUSIN')
+            self.processTrigger('POST-FOCUSIN')
 
   # ---------------------------------------------------------------------------
 
-  def __focus_out(self):
+  def __focus_out(self, do_auto_commit=True):
 
         if self._form.get_focus_block() is self:
-            self.processTrigger ('PRE-FOCUSOUT')
+            self.processTrigger('PRE-FOCUSOUT')
 
-            if self.autoCommit and self._resultSet.current:
-                self._form.commit ()
+            if do_auto_commit and self.autoCommit and self._resultSet.current:
+                self._form.commit()
 
-            self.processTrigger ('POST-FOCUSOUT')
+            self.processTrigger('POST-FOCUSOUT')
 
   # ---------------------------------------------------------------------------
   # Function and Update





reply via email to

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