commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8797 - trunk/gnue-forms/src


From: reinhard
Subject: [gnue] r8797 - trunk/gnue-forms/src
Date: Mon, 16 Oct 2006 08:26:43 -0500 (CDT)

Author: reinhard
Date: 2006-10-16 08:26:43 -0500 (Mon, 16 Oct 2006)
New Revision: 8797

Modified:
   trunk/gnue-forms/src/GFForm.py
Log:
Reordered functions.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-10-16 13:20:53 UTC (rev 8796)
+++ trunk/gnue-forms/src/GFForm.py      2006-10-16 13:26:43 UTC (rev 8797)
@@ -550,10 +550,66 @@
         return rv
 
 
+    # =========================================================================
+    # Events
+    #
+    # Incoming Event handlers
+    # =========================================================================
+
     # -------------------------------------------------------------------------
-    # User feedback
+    # Function to be called at the begin of event handling code
     # -------------------------------------------------------------------------
 
+    def event_begin (self):
+        """
+        Set the form into a defined state to prepare event handling.
+
+        This function sets the form into a consistent and defined state so that
+        event handling code (like triggers and actions) can rely on everything
+        being ok.
+
+        Most notably, this function updates the field value for the currently
+        edited entry and shows an hourglass mouse cursor.
+
+        This function has to be called at the beginning of each user event
+        being handled. At the end of handling the user event, L{event_end} has
+        to be called.
+        """
+
+        if hasattr(self._currentEntry, '_displayHandler'):
+            # FIXME: what if this fails?
+            self._currentEntry._displayHandler.updateFieldValue()
+        if self.uiWidget is not None:
+            self.uiWidget._ui_begin_wait_()
+
+
+    # -------------------------------------------------------------------------
+    # Function to be called at the end of event handling code
+    # -------------------------------------------------------------------------
+
+    def event_end (self):
+        """
+        Set the form into a defined state to finalize event handling.
+
+        This function sets the form into a consistent and defined state after
+        event handling code (like triggers and actions) has been run.
+
+        Most notably, this function resets the mouse cursor from hourglass to
+        normal and updates the field values shown on the form to reflect any
+        data modifications done in the event handling code.
+
+        This function has to be called at the end of each user event being
+        handled, just like L{event_begin} is called at the beginning.
+        """
+
+        if self.uiWidget is not None:
+            self.uiWidget._ui_end_wait_()
+
+
+    # =========================================================================
+    # User feedback
+    # =========================================================================
+
     def alert_message(self, message):
 
         self.status_message(message)
@@ -686,6 +742,181 @@
     # Focus functions
     # =========================================================================
 
+    # -------------------------------------------------------------------------
+    # Move the focus to the next entry
+    # -------------------------------------------------------------------------
+
+    def nextEntry(self, reverse=False, first=False, onlyInBlock=False):
+        """
+        Called whenever an event source has requested that the focus change
+        to the next data entry object.
+        @param reverse: boolean, step focus in reverse direction?
+        @param first: boolean, change focus to the first entry in the block?
+        @param onlyInBlock: boolean, can jump out of block to next block?
+        """
+        currentBlock = self._currentBlock
+        mode = self.getCurrentMode()
+
+        if currentBlock is None or ( \
+            currentBlock.transparent and not ( \
+              onlyInBlock or \
+              currentBlock.autoNextRecord and not ( \
+                  currentBlock.is_empty() or \
+                  (not reverse and currentBlock.is_last_record() and \
+                       not (currentBlock.autoCreate and \
+                            currentBlock.editable in ('Y', 'new')) or \
+                  (reverse and currentBlock.is_first_record()) \
+              )))):
+          source = self._currentEntry._page.get_focus_order()
+          stayInBlock = False
+        else:
+          source = currentBlock.get_focus_order()
+          stayInBlock = True
+
+        # If we want the previous entry, then reverse the focusorder we're 
using
+        if reverse:
+          source.reverse()
+
+        nextEntry = None
+        firstEntry = None
+        keepNext = False
+
+        for object in source:
+
+          if object.is_navigable(mode):
+            if stayInBlock and \
+               (currentBlock.name != object.block):
+              continue
+            # If we only wanted the first navigable field in the block, then 
return
+            if first:
+              nextEntry = object
+              break
+
+            # Put the first field as the next to rollover
+            if nextEntry == None:
+              nextEntry = object
+              firstEntry = object
+
+            # If we're at the current focused entry,
+            # then the next entry will be what we want
+            if object == self._currentEntry:
+              keepNext = True
+
+            # If we've already passed the current entry
+            # Then this is the entry to return
+            elif keepNext:
+              nextEntry = object
+              break
+
+        # If we've cycled back around to the first entry, then do special 
checks
+        if nextEntry == firstEntry:
+
+          # If we should navigate to the next record, do it...
+          if currentBlock is not None \
+                  and reverse and not currentBlock.is_first_record():
+            currentBlock.prev_record()
+            self.changeFocus(nextEntry)
+          elif currentBlock is not None and not reverse and \
+             currentBlock.autoNextRecord and \
+             not currentBlock.is_empty() and \
+             not (not currentBlock.autoCreate and \
+                  currentBlock.is_last_record()):
+               currentBlock.next_record()
+
+               # If new record is empty, then the
+               # nextEntry logic has been taken care of...
+               if currentBlock.is_empty():
+                 return
+               else:
+                 self.changeFocus(nextEntry)
+
+          # Otherwise, are we transparent? If so, go to next block/page
+          elif (currentBlock is None or 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:
+            self.changeFocus(nextEntry)
+
+        else:
+          self.changeFocus(nextEntry)
+
+
+    # -------------------------------------------------------------------------
+    # Move the focus to the previous entry
+    # -------------------------------------------------------------------------
+
+    def previousEntry(self):
+        """
+        Called whenever an event source has requested that the focus change
+        to the previous data entry object.
+        """
+        self.nextEntry(reverse=True)
+
+
+    # ------------------------------------------------------------------------
+    # Move the focus to the next block
+    # -------------------------------------------------------------------------
+
+    def nextBlock(self):
+        """
+        Change focus to the next data entry block.
+        @return: None
+        """
+        try:
+          nextBlock = 
self._logic._blockList[self._logic._blockList.index(self._currentBlock) + 1]
+        except IndexError:
+          nextBlock = self._logic._blockList[0]
+        self.findAndChangeFocus(nextBlock)
+
+
+    # -------------------------------------------------------------------------
+    # Convenience routine to find the previous block
+    # -------------------------------------------------------------------------
+
+    def findPreviousBlock(self):
+        """
+        Finds the previous block.
+        @return: the block found
+        """
+        try:
+          return 
self._logic._blockList[self._logic._blockList.index(self._currentBlock) - 1]
+        except IndexError:
+          return self._logic._blockList[-1]
+
+
+    # -------------------------------------------------------------------------
+    # Move the focus to the previous block
+    # -------------------------------------------------------------------------
+
+    def previousBlock(self):
+        """
+        Change focus to the previous data entry block.
+        @return: None
+        """
+        self.findAndChangeFocus(self.findPreviousBlock())
+
+
+    # -------------------------------------------------------------------------
+    # Move the focus to a new object
+    # -------------------------------------------------------------------------
+
     def findAndChangeFocus(self, object):
         """
         Change the focus to the first focusable element of the given object.
@@ -859,62 +1090,6 @@
 
 
     # =========================================================================
-    # Events
-    #
-    # Incoming Event handlers
-    # =========================================================================
-
-    # -------------------------------------------------------------------------
-    # Function to be called at the begin of event handling code
-    # -------------------------------------------------------------------------
-
-    def event_begin (self):
-        """
-        Set the form into a defined state to prepare event handling.
-
-        This function sets the form into a consistent and defined state so that
-        event handling code (like triggers and actions) can rely on everything
-        being ok.
-
-        Most notably, this function updates the field value for the currently
-        edited entry and shows an hourglass mouse cursor.
-
-        This function has to be called at the beginning of each user event
-        being handled. At the end of handling the user event, L{event_end} has
-        to be called.
-        """
-
-        if hasattr(self._currentEntry, '_displayHandler'):
-            # FIXME: what if this fails?
-            self._currentEntry._displayHandler.updateFieldValue()
-        if self.uiWidget is not None:
-            self.uiWidget._ui_begin_wait_()
-
-
-    # -------------------------------------------------------------------------
-    # Function to be called at the end of event handling code
-    # -------------------------------------------------------------------------
-
-    def event_end (self):
-        """
-        Set the form into a defined state to finalize event handling.
-
-        This function sets the form into a consistent and defined state after
-        event handling code (like triggers and actions) has been run.
-
-        Most notably, this function resets the mouse cursor from hourglass to
-        normal and updates the field values shown on the form to reflect any
-        data modifications done in the event handling code.
-
-        This function has to be called at the end of each user event being
-        handled, just like L{event_begin} is called at the beginning.
-        """
-
-        if self.uiWidget is not None:
-            self.uiWidget._ui_end_wait_()
-
-
-    # =========================================================================
     # Data navigation and manipulation
     # =========================================================================
 
@@ -1380,136 +1555,6 @@
 
 
     # -------------------------------------------------------------------------
-    # Called whenever an event source has requested that the
-    # focus change to the next data entry object
-    # -------------------------------------------------------------------------
-
-    def nextEntry(self, reverse=False, first=False, onlyInBlock=False):
-        """
-        Called whenever an event source has requested that the focus change
-        to the next data entry object.
-        @param reverse: boolean, step focus in reverse direction?
-        @param first: boolean, change focus to the first entry in the block?
-        @param onlyInBlock: boolean, can jump out of block to next block?
-        """
-        currentBlock = self._currentBlock
-        mode = self.getCurrentMode()
-
-        if currentBlock is None or ( \
-            currentBlock.transparent and not ( \
-              onlyInBlock or \
-              currentBlock.autoNextRecord and not ( \
-                  currentBlock.is_empty() or \
-                  (not reverse and currentBlock.is_last_record() and \
-                       not (currentBlock.autoCreate and \
-                            currentBlock.editable in ('Y', 'new')) or \
-                  (reverse and currentBlock.is_first_record()) \
-              )))):
-          source = self._currentEntry._page.get_focus_order()
-          stayInBlock = False
-        else:
-          source = currentBlock.get_focus_order()
-          stayInBlock = True
-
-        # If we want the previous entry, then reverse the focusorder we're 
using
-        if reverse:
-          source.reverse()
-
-        nextEntry = None
-        firstEntry = None
-        keepNext = False
-
-        for object in source:
-
-          if object.is_navigable(mode):
-            if stayInBlock and \
-               (currentBlock.name != object.block):
-              continue
-            # If we only wanted the first navigable field in the block, then 
return
-            if first:
-              nextEntry = object
-              break
-
-            # Put the first field as the next to rollover
-            if nextEntry == None:
-              nextEntry = object
-              firstEntry = object
-
-            # If we're at the current focused entry,
-            # then the next entry will be what we want
-            if object == self._currentEntry:
-              keepNext = True
-
-            # If we've already passed the current entry
-            # Then this is the entry to return
-            elif keepNext:
-              nextEntry = object
-              break
-
-        # If we've cycled back around to the first entry, then do special 
checks
-        if nextEntry == firstEntry:
-
-          # If we should navigate to the next record, do it...
-          if currentBlock is not None \
-                  and reverse and not currentBlock.is_first_record():
-            currentBlock.prev_record()
-            self.changeFocus(nextEntry)
-          elif currentBlock is not None and not reverse and \
-             currentBlock.autoNextRecord and \
-             not currentBlock.is_empty() and \
-             not (not currentBlock.autoCreate and \
-                  currentBlock.is_last_record()):
-               currentBlock.next_record()
-
-               # If new record is empty, then the
-               # nextEntry logic has been taken care of...
-               if currentBlock.is_empty():
-                 return
-               else:
-                 self.changeFocus(nextEntry)
-
-          # Otherwise, are we transparent? If so, go to next block/page
-          elif (currentBlock is None or 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:
-            self.changeFocus(nextEntry)
-
-        else:
-          self.changeFocus(nextEntry)
-
-
-    # -------------------------------------------------------------------------
-    # Called whenever an event source has requested that the
-    # focus change to the previous data entry object
-    # -------------------------------------------------------------------------
-
-    def previousEntry(self):
-        """
-        Called whenever an event source has requested that the focus change
-        to the previous data entry object.
-        """
-        self.nextEntry(reverse=True)
-
-
-    # -------------------------------------------------------------------------
     # Signal the UI Drivers of navigation button relevance
     # -------------------------------------------------------------------------
 
@@ -1562,52 +1607,7 @@
           dispatchEvent('canROLLBACK')
 
 
-    # ------------------------------------------------------------------------
-    # Called whenever an event source has requested that the
-    # focus change to the next data entry block
     # -------------------------------------------------------------------------
-
-    def nextBlock(self):
-        """
-        Change focus to the next data entry block.
-        @return: None
-        """
-        try:
-          nextBlock = 
self._logic._blockList[self._logic._blockList.index(self._currentBlock) + 1]
-        except IndexError:
-          nextBlock = self._logic._blockList[0]
-        self.findAndChangeFocus(nextBlock)
-
-
-    # -------------------------------------------------------------------------
-    # Convenience routine to find the previous block
-    # -------------------------------------------------------------------------
-
-    def findPreviousBlock(self):
-        """
-        Finds the previous block.
-        @return: the block found
-        """
-        try:
-          return 
self._logic._blockList[self._logic._blockList.index(self._currentBlock) - 1]
-        except IndexError:
-          return self._logic._blockList[-1]
-
-
-    # -------------------------------------------------------------------------
-    # Called whenever an event source has requested that the
-    # focus change to the previous data entry block
-    # -------------------------------------------------------------------------
-
-    def previousBlock(self):
-        """
-        Change focus to the previous data entry block.
-        @return: None
-        """
-        self.findAndChangeFocus(self.findPreviousBlock())
-
-
-    # -------------------------------------------------------------------------
     # Signal to the current Entry to stop editing
     # mode and save it's value to the virtual form
     # -------------------------------------------------------------------------





reply via email to

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