commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8291 - in trunk/gnue-forms/src: GFObjects uidrivers/gtk2/widgets


From: johannes
Subject: [gnue] r8291 - in trunk/gnue-forms/src: GFObjects uidrivers/gtk2/widgets uidrivers/win32/widgets uidrivers/wx/widgets uidrivers/wx26/widgets
Date: Mon, 3 Apr 2006 18:22:30 -0500 (CDT)

Author: johannes
Date: 2006-03-30 10:56:28 -0600 (Thu, 30 Mar 2006)
New Revision: 8291

Modified:
   trunk/gnue-forms/src/GFObjects/GFBlock.py
   trunk/gnue-forms/src/GFObjects/GFBox.py
   trunk/gnue-forms/src/GFObjects/GFButton.py
   trunk/gnue-forms/src/GFObjects/GFComponent.py
   trunk/gnue-forms/src/GFObjects/GFContainer.py
   trunk/gnue-forms/src/GFObjects/GFLayout.py
   trunk/gnue-forms/src/GFObjects/GFPage.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/button.py
   trunk/gnue-forms/src/uidrivers/win32/widgets/button.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/button.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
Log:
More code rearrangement. renamed the button's doFire into _event_fire


Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-03-30 15:01:28 UTC (rev 
8290)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-03-30 16:56:28 UTC (rev 
8291)
@@ -1,4 +1,4 @@
-# GNU Enterprise Forms - GF Class Hierarchy - Block
+# GNU Enterprise Forms - GF Object Hierarchy - Block
 #
 # Copyright 2001-2006 Free Software Foundation
 #
@@ -24,45 +24,61 @@
 Classes making up the Block object
 """
 
-__revision__ = "$Id$"
-
 from gnue.forms.GFObjects.GFDataSource import GFDataSource
 
 from gnue.common.apps import errors
 from gnue.common.datasources import GConditions
 from GFContainer import GFContainer
 from gnue.common import events
+from gnue.common.definitions import GParser
 
-class GFBlock(GFContainer, events.EventAware):
+# =============================================================================
+# Exceptions
+# =============================================================================
+
+class DatasourceNotFoundError (GParser.MarkupError):
+  def __init__ (self, source, block):
+    msg = u_("Datasource '%(datasource)s' in block '%(block)s' not found") \
+          % {'datasource': source, 'block': block.name}
+    GParser.MarkupError.__init__ (self, msg, block._url, block._lineNumber)
+
+
+# =============================================================================
+# Wrapper of a block
+# =============================================================================
+
+class GFBlock (GFContainer, events.EventAware):
   """
   Class that represents the <block> tag in a gfd file.
   """
-  def __init__(self, parent=None):
-    GFContainer.__init__(self, parent, 'GFBlock')
 
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self, parent = None):
+
+    GFContainer.__init__ (self, parent, 'GFBlock')
+
     self.mode = 'normal'
     self._convertAsterisksToPercent = gConfigForms('AsteriskWildcard')
 
-    #self._datasource = None
-    self._resultSet = None
+    self._resultSet      = None
     self._dataSourceLink = None
 
-    self._currentRecord = 0
-    self._recordCount = 0
-    self._queryDefaults = {}
-    self._queryValues = {}
+    self._currentRecord   = 0
+    self._recordCount     = 0
+    self._queryDefaults   = {}
+    self._queryValues     = {}
     self._lastQueryValues = {}
 
-    self._gap = 0
-    self._rows = 1
+    self._scrollbars      = []
 
-    self._scrollbars= []
-
     # Populated by GFEntry's initialize
     self._entryList = []
 
     # Populated by GFField's initialize
-    self._fieldMap = {}
+    self._fieldMap  = {}
     self._fieldList = []
 
     # Current top of visible portion
@@ -71,132 +87,161 @@
     # Are we scrolling the visible portion along with record movement?
     self.__scrolling = False
 
-    #
     # Trigger exposure
-    #
     self._validTriggers = {
-                  'ON-NEWRECORD':   'On-NewRecord',
-                  'ON-RECORDLOADED':'On-RecordLoaded',
-                  'PRE-COMMIT':     'Pre-Commit',
-                  'POST-COMMIT':    'Post-Commit',
-                  'PRE-QUERY':      'Pre-Query',
-                  'POST-QUERY':     'Post-Query',
-                  'PRE-MODIFY':     'Pre-Modify',
-                  'PRE-INSERT':     'Pre-Insert',
-                  'PRE-DELETE':     'Pre-Delete',
-                  'PRE-UPDATE':     'Pre-Update',
-                  'PRE-FOCUSOUT':   'Pre-FocusOut',
-                  'POST-FOCUSOUT':  'Post-FocusOut',
-                  'PRE-FOCUSIN':    'Pre-FocusIn',
-                  'POST-FOCUSIN':   'Post-FocusIn',
-                  'PRE-CHANGE':     'Pre-Change',
-                  'POST-CHANGE':    'Post-Change',
-                  }
+      'ON-NEWRECORD':   'On-NewRecord',
+      'ON-RECORDLOADED':'On-RecordLoaded',
+      'PRE-COMMIT':     'Pre-Commit',
+      'POST-COMMIT':    'Post-Commit',
+      'PRE-QUERY':      'Pre-Query',
+      'POST-QUERY':     'Post-Query',
+      'PRE-MODIFY':     'Pre-Modify',
+      'PRE-INSERT':     'Pre-Insert',
+      'PRE-DELETE':     'Pre-Delete',
+      'PRE-UPDATE':     'Pre-Update',
+      'PRE-FOCUSOUT':   'Pre-FocusOut',
+      'POST-FOCUSOUT':  'Post-FocusOut',
+      'PRE-FOCUSIN':    'Pre-FocusIn',
+      'POST-FOCUSIN':   'Post-FocusIn',
+      'PRE-CHANGE':     'Pre-Change',
+      'POST-CHANGE':    'Post-Change',
+    }
 
-
     self._triggerGlobal = 1
-    self._triggerFunctions={
-        'clear':{'function':self.processClear,
-                  'description':''},
-        'getResultSet':{'function':self.getResultSet,
-                  'description':''},
-        'commit':{'function':self.commit,
-                  'description':''},
-        'newRecord':{'function':self.newRecord,
-                      'description':''},
-        'deleteRecord':{'function':self.deleteRecord,
-                        'description':''},
-        'duplicateRecord':{'function':self.duplicateRecord,
-                        'description':'Duplicates the current (non-empty) 
record into a new record.'},
-        'gotoRecord':{'function':self.jumpRecord,
-                      'description':''},
-        'firstRecord':{'function':self.firstRecord,
-                        'description':'Navigates the block to the first record 
it contains.'},
-        'isEmpty':{'function':self.isEmpty,
-                    'description':'Returns True if block is empty.'},
-        'isSaved':{'function':self.isSaved,
-                    'description':'Depriciated: Returns True if block contains 
no modified records.'},
-        'isPending':{'function':self.isPending,
-                    'description':'Returns True if block contains modified 
records.'},
-        'lastRecord':{'function':self.lastRecord,
-                  'description':'Navigates the block to the last record it 
contains.'},
-        'nextRecord':{'function':self.nextRecord,
-                      'description':'Navigates the block to the next record in 
sequence.'},
-        'prevRecord':{'function':self.prevRecord,
-                      'description':'Navigates the block to the previous 
record in sequence.'},
-        'jumpRecords':{'function':self.jumpRecords,
-                      'description':'Navigates the specified number of 
records.'},
-        'rollback':{'function':self.processRollback,
-                    'description':'Clears all records regardless of state from 
the block'},
-        'initQuery':{'function':self.initQuery,
-                    'description':'Prepares the block for query input.'},
-        'copyQuery':{'function':self.copyQuery,
-                    'description':'Prepares the block for query input.'},
-        'cancelQuery':{'function':self.cancelQuery,
-                    'description':'Cancels query input.'},
-        'executeQuery':{'function':self.processQuery,
-                        'description':'Executes the current query.'},
-        'call': {'function'   : self.callFunction,
-                 'description': 'Executes a function of the datasource'},
-        'update': {'function': self.updateCurrentRecordSet}
-        }
+    self._triggerFunctions = {
+      'clear': {
+        'function'   : self.processClear,
+        'description': ''},
+      'getResultSet': {
+        'function'   : self.getResultSet,
+        'description': ''},
+      'commit': {
+        'function'   : self.commit,
+        'description': ''},
+      'newRecord': {
+        'function'   : self.newRecord,
+        'description': ''},
+      'deleteRecord': {
+        'function'   : self.deleteRecord,
+        'description': ''},
+      'duplicateRecord': {
+        'function': self.duplicateRecord,
+        'description': 'Duplicates the current (non-empty) record into a ' \
+                       'new record.'},
+      'gotoRecord': {
+        'function'   : self.jumpRecord,
+        'description': ''},
+      'firstRecord': {
+        'function'   : self.firstRecord,
+        'description': 'Navigates the block to the first record it contains.'},
+      'isEmpty': {
+        'function'   : self.isEmpty,
+        'description': 'Returns True if block is empty.'},
+      'isSaved': {
+        'function'   : self.isSaved,
+        'description': 'Depriciated: Returns True if block contains no ' \
+                       'modified records.'},
+      'isPending': {
+        'function'   : self.isPending,
+        'description': 'Returns True if block contains modified records.'},
+      'lastRecord': {
+        'function'   : self.lastRecord,
+        'description': 'Navigates the block to the last record it contains.'},
+      'nextRecord': {
+        'function'   : self.nextRecord,
+        'description': 'Navigates the block to the next record in sequence.'},
+      'prevRecord': {
+        'function'   : self.prevRecord,
+        'description': 'Navigates the block to the previous record in ' \
+                       'sequence.'},
+      'jumpRecords': {
+        'function'   : self.jumpRecords,
+        'description': 'Navigates the specified number of records.'},
+      'rollback': {
+        'function'   : self.processRollback,
+        'description': 'Clears all records regardless of state from the 
block'},
+      'initQuery': {
+        'function'   : self.initQuery,
+        'description': 'Prepares the block for query input.'},
+      'copyQuery': {
+        'function'   : self.copyQuery,
+        'description': 'Prepares the block for query input.'},
+      'cancelQuery': {
+        'function'   : self.cancelQuery,
+        'description': 'Cancels query input.'},
+      'executeQuery': {
+        'function'   : self.processQuery,
+        'description': 'Executes the current query.'},
+      'call': {
+        'function'   : self.callFunction,
+        'description': 'Executes a function of the datasource'},
+      'update': {
+        'function'   : self.updateCurrentRecordSet,
+        'description': ''}
+    }
 
-    self._triggerProperties={
-          'parent':        {'get':self.getParent},
-          'autoCommit':    {'set':self.triggerSetAutoCommit,
-                            'get':self.triggerGetAutoCommit },
-          'queryable':     {'set':self.triggerSetQueryable,
-                            'get':self.triggerGetQueryable },
-          'editable':      {'set':self.triggerSetEditable,
-                            'get':self.triggerGetEditable },
-          'autoCreate':    {'set':self.triggerSetAutoCreate,
-                            'get':self.triggerGetAutoCreate },
-          'deletable':     {'set':self.triggerSetDeletable,
-                            'get':self.triggerGetDeletable },
-          'transparent':   {'set':self.triggerSetTransparent,
-                            'get':self.triggerGetTransparent },
-          'autoNextRecord':{'set':self.triggerSetAutoNextRecord,
-                            'get':self.triggerGetAutoNextRecord },
-       }
+    self._triggerProperties = {
+      'parent':        {'get': self.getParent},
+      'autoCommit':    {'set': self.triggerSetAutoCommit,
+                        'get': self.triggerGetAutoCommit },
+      'queryable':     {'set': self.triggerSetQueryable,
+                        'get': self.triggerGetQueryable },
+      'editable':      {'set': self.triggerSetEditable,
+                        'get': self.triggerGetEditable },
+      'autoCreate':    {'set': self.triggerSetAutoCreate,
+                        'get': self.triggerGetAutoCreate },
+      'deletable':     {'set': self.triggerSetDeletable,
+                        'get': self.triggerGetDeletable },
+      'transparent':   {'set': self.triggerSetTransparent,
+                        'get': self.triggerGetTransparent },
+      'autoNextRecord':{'set': self.triggerSetAutoNextRecord,
+                        'get': self.triggerGetAutoNextRecord },
+    }
 
 
-  # Iterator support (Python 2.2+)
-  def __iter__(self):
+  # ---------------------------------------------------------------------------
+  # Iterator support
+  # ---------------------------------------------------------------------------
+
+  def __iter__ (self):
     """
-    Iterator support for Python 2.2+
+    Iterator support
 
     Allows you to do:
       for foo in myBlock:
         ....
     """
 
-    return _BlockIter(self)
+    return _BlockIter (self)
 
 
-  def _buildObject(self):
+  # ---------------------------------------------------------------------------
+  # Object construction from xml
+  # ---------------------------------------------------------------------------
 
-    if hasattr(self, 'rows'):
-      self._rows = self.rows
+  def _buildObject (self):
 
-    if hasattr(self, 'rowSpacer'):
-      self._gap = self.rowSpacer
+    self._rows = getattr (self, 'rows', self._rows)
+    self._gap  = getattr (self, 'rowSpacer', self._gap)
 
-    if hasattr(self, 'restrictDelete') and self.restrictDelete:
+    if hasattr (self, 'restrictDelete') and self.restrictDelete:
       self.deletable = False
-      del self.__dict__['restrictDelete']
+      del self.__dict__ ['restrictDelete']
 
-    if hasattr(self, 'restrictInsert') and self.restrictInsert:
+    if hasattr (self, 'restrictInsert') and self.restrictInsert:
       self.editable = 'update'
-      del self.__dict__['restrictInsert']
+      del self.__dict__ ['restrictInsert']
 
-    if hasattr(self,'datasource'):
-      self.datasource = self.datasource.lower()
+    if hasattr (self,'datasource'):
+      self.datasource = self.datasource.lower ()
 
-    return GFContainer._buildObject(self)
+    return GFContainer._buildObject (self)
 
-  #
-  # Primary initialization
-  #
+
+  # ---------------------------------------------------------------------------
+  # Implementation of virtual methods
+  # ---------------------------------------------------------------------------
+
   def _phase1Init_ (self):
 
     GFContainer._phase1Init_ (self)
@@ -212,20 +257,19 @@
     events.EventAware.__init__ (self, self._form._instance.eventController)
 
     # 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._form)
+    if not hasattr (self, 'datasource') or not self.datasource:
+      ds = GFDataSource (self._form)
       ds.type = 'unbound'
-      self.datasource = ds.name = "__dts_%s" % id(self)
-      self._form._datasourceDictionary[ds.name] = ds
-      ds._buildObject()
-      ds.phaseInit()
+      self.datasource = ds.name = "__dts_%s" % id (self)
+      self._form._datasourceDictionary [ds.name] = ds
+      ds._buildObject ()
+      ds.phaseInit ()
 
-    self._dataSourceLink = self._form._datasourceDictionary.get 
(self.datasource)
+    dsDict = self._form._datasourceDictionary
+    self._dataSourceLink = dsDict.get (self.datasource)
+
     if self._dataSourceLink is None:
-      raise errors.ApplicationError, \
-          u_("Datasource '%(datasource)s' in block '%(block)s' not found") \
-          % {'datasource': self.datasource,
-             'block': self.name}
+      raise DatasourceNotFoundError, (self.datasource, self)
 
     # Register event handling functions
     self._dataSourceLink.registerEventListeners ({
@@ -240,34 +284,29 @@
         'dsCommitDelete'      : self.__dsCommitDelete})
 
     # Get min and max child rows, if applicable
-    try:
-      self._minChildRows = self._dataSourceLink.detailmin
-    except AttributeError:
-      self._minChildRows = 0
-    try:
-      self._maxChildRows = self._dataSourceLink.detailmax
-    except AttributeError:
-      self._maxChildRows = None
+    self._minChildRows = getattr (self._dataSourceLink, 'detailmin', 0)
+    self._maxChildRows = getattr (self._dataSourceLink, 'detailmax', None)
 
     self.walk (self.__setChildRowSettings)
 
-  def __setChildRowSettings(self, object):
-    if hasattr(object,'rows'):
-      rows = object._rows = object.rows
-    else:
-      rows = object._rows = self._rows
+  # ---------------------------------------------------------------------------
+  # Distribute the rows and gaps to all children missing such an attribute
+  # ---------------------------------------------------------------------------
 
-    if hasattr(object,'rowSpacer'):
-      object._gap = object.rowSpacer
-    else:
-      object._gap = self._gap
+  def __setChildRowSettings (self, child):
 
+    # If a child has no rows- or rowSpacer-attribute copy the blocks values to
+    # the child 
+    child._rows = getattr (child, 'rows', self._rows)
+    child._gap  = getattr (child, 'rowSpacer', self._gap)
 
+
   # ---------------------------------------------------------------------------
   # Event handling functions for datasource events
   # ---------------------------------------------------------------------------
 
   def __dsResultSetActivated (self, event):
+
     self._resultSet = event.resultSet
     self._recordCount = self._resultSet.getRecordCount ()
     recno = self._resultSet.getRecordNumber ()
@@ -344,18 +383,18 @@
 
 
   # ---------------------------------------------------------------------------
-  #
-  #
-  def getFocusOrder(self):
-    list = []
+  # Get an ordered list of focus-controls
+  # ---------------------------------------------------------------------------
+
+  def getFocusOrder (self):
+
+    ctrlList = []
     for field in self._children:
-      try:
-        list += field._entryList
-      except AttributeError:
-        pass # Triggers, etc
+      ctrlList += getattr (field, '_entryList', [])
 
-    return GFContainer.getFocusOrder(self,list)
+    return GFContainer.getFocusOrder (self, ctrlList)
 
+
   #
   # isSaved
   #

Modified: trunk/gnue-forms/src/GFObjects/GFBox.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBox.py     2006-03-30 15:01:28 UTC (rev 
8290)
+++ trunk/gnue-forms/src/GFObjects/GFBox.py     2006-03-30 16:56:28 UTC (rev 
8291)
@@ -1,52 +1,42 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Box
 #
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
 #
-# 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 
+# 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
 # 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 
+# 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-2006 Free Software Foundation
-#
-# FILE:
-# GFObjects.py
-#
-# DESCRIPTION:
+# $Id$
 """
 Logical box support
 """
-# NOTES:
-#
 
 from GFContainer import GFContainer
 
-#
-# GFBox
-#
-class GFBox(GFContainer):
-  def __init__(self, parent=None):
-    GFContainer.__init__(self, parent,"GFBox")
-    self.label = ""
+# =============================================================================
+# Box widget
+# =============================================================================
 
+class GFBox (GFContainer):
 
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
 
+  def __init__ (self, parent = None):
 
-
-
-
-
-
-
-
-
-
+    GFContainer.__init__ (self, parent, "GFBox")
+    self.label = ""

Modified: trunk/gnue-forms/src/GFObjects/GFButton.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFButton.py  2006-03-30 15:01:28 UTC (rev 
8290)
+++ trunk/gnue-forms/src/GFObjects/GFButton.py  2006-03-30 16:56:28 UTC (rev 
8291)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Button
 #
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
 #
+# 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
@@ -16,38 +19,45 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# GFObjects.py
-#
-# DESCRIPTION:
+# $Id$
 """
 Logical button support
 """
-# NOTES:
-#
+
 from GFTabStop import GFTabStop
 
-#
-# GFButton
-#
+# =============================================================================
+# Class implementing a button
+# =============================================================================
+
 class GFButton (GFTabStop):
 
-  _navigableInQuery_ = False
+  _navigableInQuery_ = False            # Buttons don't get focus in query mode
 
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
   def __init__(self, parent=None):
+
     GFTabStop.__init__(self, parent, 'GFButton')
+
     self.label = ""
-    self._validTriggers ={ 'ON-ACTION':      'On-Action',
-                           'PRE-FOCUSOUT':   'Pre-FocusOut',
-                           'POST-FOCUSOUT':  'Post-FocusOut',
-                           'PRE-FOCUSIN':    'Pre-FocusIn',
-                           'POST-FOCUSIN':   'Post-FocusIn',
-                           'ON-NEXT-ENTRY':  'On-Next-Entry',
-                           'ON-PREVIOUS-ENTRY':  'On-Previous-Entry'}
 
+    self._validTriggers = {
+      'ON-ACTION'        : 'On-Action',
+      'PRE-FOCUSOUT'     : 'Pre-FocusOut',
+      'POST-FOCUSOUT'    : 'Post-FocusOut',
+      'PRE-FOCUSIN'      : 'Pre-FocusIn',
+      'POST-FOCUSIN'     : 'Post-FocusIn',
+      'ON-NEXT-ENTRY'    : 'On-Next-Entry',
+      'ON-PREVIOUS-ENTRY': 'On-Previous-Entry'}
 
+
+  # ---------------------------------------------------------------------------
+  # Implementation of virtual methods
+  # ---------------------------------------------------------------------------
+
   def _phase1Init_ (self):
 
     GFTabStop._phase1Init_ (self)
@@ -60,20 +70,18 @@
     self.subEventHandler.registerEventListeners (listeners)
 
 
-  # Helper method for user events: fire button
-  def __fire (self):
-    self.processTrigger ('On-Action', False)
-    self._form.refreshDisplay (self._form)
+  # ---------------------------------------------------------------------------
+  # Sub-Eventhandlers
+  # ---------------------------------------------------------------------------
 
-
-  # Event handlers
-
   def __handleKEYPRESS (self, event):
 
     if event.text == ' ':
       self.__fire ()
       event.drop ()
 
+  # ---------------------------------------------------------------------------
+
   def __handleENTER (self, event):
     self.__fire ()
     event.drop ()
@@ -83,13 +91,20 @@
   # Fire the trigger associated with the button from outside GF
   # ---------------------------------------------------------------------------
 
-  def doFire (self):
+  def _event_fire (self):
     """
-    Update the current entrie's value and execute the trigger associated with
-    the button.
+    Update the value of the current entry and execute the trigger associated
+    with the button. Use this function to fire a button from the UI layer.
     """
 
     if hasattr (self._form._currentEntry, '_displayHandler'):
       self._form._currentEntry._displayHandler.updateFieldValue ()
 
     self.__fire ()
+
+  # ---------------------------------------------------------------------------
+
+  def __fire (self):
+
+    self.processTrigger ('On-Action', False)
+    self._form.refreshDisplay (self._form)

Modified: trunk/gnue-forms/src/GFObjects/GFComponent.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFComponent.py       2006-03-30 15:01:28 UTC 
(rev 8290)
+++ trunk/gnue-forms/src/GFObjects/GFComponent.py       2006-03-30 16:56:28 UTC 
(rev 8291)
@@ -1,13 +1,16 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Component
 #
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
 #
-# 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 
+# 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
 # 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.
 #
@@ -16,83 +19,99 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-#
-# FILE:
-# GFComponent.py
-#
-# DESCRIPTION:
+# $Id$
 """
 Component support (bonobo for gtk2, ole for win32, etc.)
 """
-#
-# NOTES:
-#
 
 from gnue.common import events
 from GFValue import GFValue
 from gnue.forms.input import displayHandlers
+from gnue.common.apps import errors
+from gnue.common.definitions import GParser
 
-#
-#GFComponent
-#
-class GFComponent(GFValue):
-  def __init__(self, parent=None, value=None):
-    GFValue.__init__(self, parent, value, 'GFComponent')
-    self.subEventHandler = events.EventController()
+# =============================================================================
+# Exceptions
+# =============================================================================
 
+class BlockNotFoundError (GParser.MarkupError):
+  def __init__ (self, block, comp):
+    msg = u_("Component '%(comp)s' references non-existent block '%(block)s'") 
\
+          % {'comp': comp.name, 'block': block}
+    GParser.MarkupError.__init__ (self, msg, comp._url, comp._lineNumber)
+
+class FieldNotFoundError (GParser.MarkupError):
+  def __init__ (self, field, comp):
+    msg = u_("Component '%(comp)s' references non-existent field '%(field)s'") 
\
+          % {'comp': comp.name, 'field': field}
+    GParser.MarkupError.__init__ (self, msg, comp._url, comp._lineNumber)
+
+# =============================================================================
+# A component wrapper class
+# =============================================================================
+
+class GFComponent (GFValue):
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self, parent = None, value = None):
+
+    GFValue.__init__ (self, parent, value, 'GFComponent')
+    self.subEventHandler = events.EventController ()
+
     # Default attributes (these may be replaced by parser)
     self.type = "URL"
-    self.Char__height = int(gConfigForms('widgetHeight'))
+    self.Char__height = int (gConfigForms ('widgetHeight'))
 
 
-  def _buildObject(self):
-    if not hasattr(self, 'rows') and hasattr(self,'visibleCount'):
-      self.rows = self.visibleCount
-      del self.visibleCount
-    return GFValue._buildObject(self)
+  # ---------------------------------------------------------------------------
+  # Get the current value
+  # ---------------------------------------------------------------------------
 
-  def setValue(self, value):
+  def getValue (self, *args, **parms):
+
+    return self._field.getValue (*args, **parms)
+
+
+  # ---------------------------------------------------------------------------
+  # Set the object's value (by passing the new value to the bound field)
+  # ---------------------------------------------------------------------------
+
+  def setValue (self, value):
+
+    self._field.setValue (value)
     if not self._value:
-      GFValue.setValue(self,value)
+      GFValue.setValue (self, value)
 
-  #
-  # Routines called during a phaseInit
-  #
+
+  # ---------------------------------------------------------------------------
+  # Implementation of virtual methods
+  # ---------------------------------------------------------------------------
+
   def _phase1Init_ (self):
     
     GFValue._phase1Init_ (self)
 
-    #
-    # Find parents/relatives
-    #
-
     # ...Block
-    try:
-      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            
                     
+    if not self.block in self._form._logic._blockMap:
+      raise BlockNotFoundError, (self.block, self)
 
-    # ...Field
-    try:
-      self._field = field = block._fieldMap[self.field]
-      field._entryList.append(self)
-    except KeyError:
-      raise "Entry references non-existent field '%s'" % self.field
+    self._block = block = self._form._logic._blockMap [self.block]
+    block._entryList.append (self)
 
-    # ...Page
-    self._page = self.findParentOfType('GFPage')
-    self._page._entryList.append(self)
+    # ... Field
+    if not self.field in block._fieldMap:
+      raise FieldNotFoundError, (self.field, self)
+
+    self._field = field = block._fieldMap [self.field]
+    field._entryList.append (self)
+
+    # ... Page
+    self._page = self.findParentOfType ('GFPage')
+    self._page._entryList.append (self)
     
-    self._displayHandler = displayHandlers.Component(self,
+    self._displayHandler = displayHandlers.Component (self,
                               self._form._instance.eventController,
                               self.subEventHandler)
-
-  # 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/GFContainer.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFContainer.py       2006-03-30 15:01:28 UTC 
(rev 8290)
+++ trunk/gnue-forms/src/GFObjects/GFContainer.py       2006-03-30 16:56:28 UTC 
(rev 8291)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - GFObjects - Container objects
 #
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
 #
+# 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
@@ -16,34 +19,31 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2002-2006 Free Software Foundation
-#
-# FILE:
-# GFContainer.py
-#
-# DESCRIPTION:
+# $Id$
 """
 A base class for all GFObjects that can be containers
 """
-__revision__ = "$Id$"
 
 from GFObj import GFObj
 from GFTabStop import GFTabStop
 
-class GFContainer(GFObj):
+# =============================================================================
+# Base class for container objects
+# =============================================================================
+
+class GFContainer (GFObj):
   """
   A base class for all GFObjects that can be containers
   """
-  def __init__(self, parent=None, type='GFContainer'):
-    """
-    Constructor
-    """
-    GFObj.__init__(self, parent, type)
 
-  def getFocusOrder(self, list=None):
+  # ---------------------------------------------------------------------------
+  # Determine the focus order of a given list of entries
+  # ---------------------------------------------------------------------------
+
+  def getFocusOrder (self, list = None):
     """
-    Builds a list of objects ordered in the way in which they
-    should receive focus.
+    Builds a list of objects ordered in the way in which they should receive
+    focus.
     
     @param list: An optional list of objects to scan for focus
     @return: A list of objects in the order that they should receive focus
@@ -61,43 +61,42 @@
 
     # Build the missing and has focus lists          
     for child in list:
-      if isinstance(child,GFContainer):
-        tabStops = child.getFocusOrder()
-      elif isinstance(child,GFTabStop):
+      if isinstance (child, GFContainer):
+        tabStops = child.getFocusOrder ()
+      elif isinstance (child, GFTabStop):
         tabStops = [child]
       else:
         tabStops = None  # Things like labels
                  
-      if bool(tabStops):
+      if bool (tabStops):
         try:
           index = child.focusorder - 1
-          hasFocusOrder.append([index, tabStops])
+          hasFocusOrder.append ([index, tabStops])
         except AttributeError:
-          missingFocusOrder.append(tabStops)
+          missingFocusOrder.append (tabStops)
 
     # Sort the focus stops on items that had defined focus order
-    hasFocusOrder.sort()
+    hasFocusOrder.sort ()
 
     # Create a None filled list that will contain all the tab stops
-    maxFocusIndex = hasFocusOrder and hasFocusOrder[-1][0] or 0
-    totalLength = len(hasFocusOrder) + len(missingFocusOrder)    
-    workingList = [None] * max(maxFocusIndex + 1, totalLength)
+    maxFocusIndex = hasFocusOrder and hasFocusOrder [-1][0] or 0
+    totalLength = len (hasFocusOrder) + len (missingFocusOrder)
+    workingList = [None] * max (maxFocusIndex + 1, totalLength)
     
     # Merge in the items with defined focus orders
     for index, tabStop in hasFocusOrder:
-      workingList[index] = tabStop
+      workingList [index] = tabStop
       
-    # Merge in the items missing defined focus orders 
-    # where ever there is a gap
+    # Merge in the items missing defined focus orders where ever there is a gap
     while bool(missingFocusOrder):
       tabStop = missingFocusOrder.pop(0)
       workingList[workingList.index(None)] = tabStop
     
-    # Remove any None entries in the list.  This would 
-    # happen if the focusorder settings skipped numbers  
+    # Remove any None entries in the list. This would happen if the focusorder
+    # settings skipped numbers
     returnValue = []
     for tabStop in workingList:
       if tabStop is not None:
-        returnValue.extend(tabStop)
+        returnValue.extend (tabStop)
 
     return returnValue

Modified: trunk/gnue-forms/src/GFObjects/GFLayout.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFLayout.py  2006-03-30 15:01:28 UTC (rev 
8290)
+++ trunk/gnue-forms/src/GFObjects/GFLayout.py  2006-03-30 16:56:28 UTC (rev 
8291)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Layout
 #
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
 #
+# 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
@@ -16,68 +19,85 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# GFLayout.py
-#
-# DESCRIPTION:
+# $Id$
 """
 Handles the <layout> tag.
 """
-# NOTES:
-#
-# HISTORY:
-#
 
 from gnue.common.apps import GDebug
-import string
 from GFObj import GFObj
 
 
-class GFLayout(GFObj):
-  def __init__(self, parent=None):
-    GFObj.__init__(self, parent, "GFLayout")
-    self._pageList = []
-    self.tabbed = 'none'
+# =============================================================================
+# Class implementing the layout tag
+# =============================================================================
+
+class GFLayout (GFObj):
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self, parent = None):
+
+    GFObj.__init__ (self, parent, "GFLayout")
+
+    self._pageList      = []
+    self.tabbed         = 'none'
     self._triggerGlobal = 1
 
-  def _buildObject(self):
 
+  # ---------------------------------------------------------------------------
+  # Object creation
+  # ---------------------------------------------------------------------------
+
+  def _buildObject (self):
+
     # TODO: This is temporary until layout management support works
-    self.walk(_addxy)
+    self.walk (self.__addxy)
 
-    return GFObj._buildObject(self)
+    return GFObj._buildObject (self)
 
+
+  # ---------------------------------------------------------------------------
+
+  def __addxy (self, object):
+
+    for attr in ('x','y','height','width'):
+      try:
+        v = int (object.__dict__ ['Char__%s' % attr])
+        object.__dict__ ['Char__%s' % attr] = v
+        object.__dict__ ['_Layout__%s' % attr] = v
+
+      except KeyError:
+        pass
+
+
+  # ---------------------------------------------------------------------------
+  # Implementation of virtual methods
+  # ---------------------------------------------------------------------------
+
   def _phase1Init_ (self):
 
     GFObj._phase1Init_ (self)
-    self._xmlchildnamespaces = self._findNamespaces(self)
+    self._xmlchildnamespaces = self.__findNamespaces (self)
 
 
-  # Find the xml namespace in use by any child objects
-  def _findNamespaces(self, object):
+  # ---------------------------------------------------------------------------
+  # Find the XML namespace in use by any child objects
+  # ---------------------------------------------------------------------------
+
+  def __findNamespaces (self, object):
+
     ns = {}
     for child in object._children:
       try:
         if child._xmlnamespaces:
-          ns.update(list(child._xmlnamespaces))
+          ns.update (list (child._xmlnamespaces))
         else:
-          ns.update(self._findNamespace(child))
+          ns.update (self._findNamespace (child))
+
       except AttributeError:
         pass
+
     return ns
-
-
-
-# TODO: Temporary until layout mgmt works
-def _addxy(object):
-  for attr in ('x','y','height','width'):
-    try:
-      v = int(object.__dict__['Char__%s' % attr])
-      object.__dict__['Char__%s' % attr] = v
-      # object.__dict__[attr] = v
-      object.__dict__['_Layout__%s' % attr] = v
-    except KeyError:
-      pass
-

Modified: trunk/gnue-forms/src/GFObjects/GFPage.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFPage.py    2006-03-30 15:01:28 UTC (rev 
8290)
+++ trunk/gnue-forms/src/GFObjects/GFPage.py    2006-03-30 16:56:28 UTC (rev 
8291)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Logical Page
 #
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
 #
+# 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
@@ -16,55 +19,48 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# GFContainerects.py
-#
-# DESCRIPTION:
+# $Id$
 """
 Logical page support
 """
-# NOTES:
-#
 
 from GFContainer import GFContainer
 
-#
-# GFPage
-#
+# =============================================================================
+# Implementation of a logical page object
+# =============================================================================
+
 class GFPage(GFContainer):
-  def __init__(self, parent=None):
-    GFContainer.__init__(self, parent,"GFPage")
-    self._inits.append (self.phase2Init)
 
-    self._validTriggers = {
-                  'PRE-FOCUSOUT':   'Pre-FocusOut',
-                  'POST-FOCUSOUT':  'Post-FocusOut',
-                  'PRE-FOCUSIN':    'Pre-FocusIn',
-                  'POST-FOCUSIN':   'Post-FocusIn',
-                  }
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
 
-    self._entryList = []
+  def __init__ (self, parent = None):
 
+    GFContainer.__init__ (self, parent, "GFPage")
 
-  def _phase1Init_ (self):
-    GFContainer._phase1Init_ (self)
+    self._validTriggers = {
+      'PRE-FOCUSOUT' : 'Pre-FocusOut',
+      'POST-FOCUSOUT': 'Post-FocusOut',
+      'PRE-FOCUSIN'  : 'Pre-FocusIn',
+      'POST-FOCUSIN' : 'Post-FocusIn',
+    }
 
-    layout = self.findParentOfType('GFLayout')
-    layout._pageList.append(self)
+    self._entryList = []
 
-  def phase2Init (self):
-    # Get all focusable items, ordered correctly
-    self._focusOrder = self._entryList # self.getFocusOrder()
 
+  # ---------------------------------------------------------------------------
+  # Implementation of virtual methods
+  # ---------------------------------------------------------------------------
 
+  def _phase1Init_ (self):
+    """
+    On phase 1 initialization a logical page registers itself at the logic
+    object.
+    """
 
+    GFContainer._phase1Init_ (self)
 
-
-
-
-
-
-
-
+    layout = self.findParentOfType ('GFLayout')
+    layout._pageList.append (self)

Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/button.py       2006-03-30 
15:01:28 UTC (rev 8290)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/button.py       2006-03-30 
16:56:28 UTC (rev 8291)
@@ -62,7 +62,7 @@
   def buttonHandler (self, widget):
 
     gfObject = self._uiDriver._WidgetToGFObj [widget]
-    gfObject.doFire ()
+    gfObject._event_fire ()
 
 
 # -----------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/button.py      2006-03-30 
15:01:28 UTC (rev 8290)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/button.py      2006-03-30 
16:56:28 UTC (rev 8291)
@@ -54,7 +54,7 @@
 
   def buttonHandler(self, id):
       gfObject = self._uiDriver._IdToGFObj[id]
-      gfObject.doFire ()
+      gfObject._event_fire ()
 
 configuration = {
     'baseClass'  : UIButton,

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/button.py 2006-03-30 15:01:28 UTC 
(rev 8290)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/button.py 2006-03-30 16:56:28 UTC 
(rev 8291)
@@ -80,7 +80,7 @@
       object = _eventObjTowxWindow(event)
       id = object.GetId()
       gfObject = self._uiDriver._IdToGFObj[id]
-      gfObject.doFire ()
+      gfObject._event_fire ()
 
 
 # ----------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-03-30 
15:01:28 UTC (rev 8290)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-03-30 
16:56:28 UTC (rev 8291)
@@ -78,7 +78,7 @@
 
   def __on_button (self, event):
     
-    self._gfObject.doFire ()
+    self._gfObject._event_fire ()
 
 
   # ---------------------------------------------------------------------------





reply via email to

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