commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8999 - in trunk/gnue-forms/src: . GFObjects input/displayHandler


From: reinhard
Subject: [gnue] r8999 - in trunk/gnue-forms/src: . GFObjects input/displayHandlers uidrivers/gtk2/widgets
Date: Wed, 8 Nov 2006 06:54:45 -0600 (CST)

Author: reinhard
Date: 2006-11-08 06:54:41 -0600 (Wed, 08 Nov 2006)
New Revision: 8999

Modified:
   trunk/gnue-forms/src/GFObjects/GFBlock.py
   trunk/gnue-forms/src/GFObjects/GFField.py
   trunk/gnue-forms/src/GFParser.py
   trunk/gnue-forms/src/input/displayHandlers/Cursor.py
   trunk/gnue-forms/src/input/displayHandlers/__init__.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py
Log:
Renamed "typecast" attribute to "datatype".
Renamed "maxLength" attribute to "length".
Added "scale" attribute (not yet used).
Replaced general "date" datatype for fields with distinct types "date", "time",
and "datetime".


Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-11-08 12:09:38 UTC (rev 
8998)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-11-08 12:54:41 UTC (rev 
8999)
@@ -1452,7 +1452,7 @@
                 # Falls through to old behaviour if no : condition given or 
                 # the : condition is unknown
                 if not match:
-                    if entry.typecast == 'text':
+                    if entry.datatype == 'text':
                         if self._convertAsterisksToPercent:
                             try:
                                 val = ("%s" % val).replace('*', '%')

Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py   2006-11-08 12:09:38 UTC (rev 
8998)
+++ trunk/gnue-forms/src/GFObjects/GFField.py   2006-11-08 12:54:41 UTC (rev 
8999)
@@ -77,14 +77,6 @@
 
         GFObj.GFObj.__init__(self, parent, 'GFField')
 
-        # Default attributes (these may be replaced by parser)
-        self.typecast = "text"
-        self.case = "mixed"
-        self.defaultToLast = False
-        self.rtrim = False
-        self.ltrim = False
-
-        # Runtime variables
         self._uppercase = False
         self._lowercase = False
         self._numeric = False
@@ -148,7 +140,22 @@
         self._block._fieldMap [self.name] = self
         self._block._fieldList.append (self)
 
-        if self.typecast == 'number':
+        # Convert depreciated "typecast" attribute to new "type" attribute
+        if hasattr(self, 'typecast'):
+            if self.typecast == 'text':
+                self.datatype = 'text'
+            elif self.typecast == 'number':
+                self.datatype = 'number'
+            elif self.typecast == 'date':
+                self.datatype = 'datetime'
+            elif self.typecast == 'boolean':
+                self.datatype = 'boolean'
+
+        # Convert depreciated "maxLength" attribute to new "length" attribute
+        if hasattr(self, 'maxLength'):
+            self.length = self.maxLength
+
+        if self.datatype == 'number':
             self._numeric = True
             self._allowFormulas = gConfigForms("AllowNumericFormulas")
 
@@ -574,7 +581,7 @@
 
     def triggerSetValue(self, value):
 
-        if self.typecast == "number" and value is not None:
+        if self.datatype == 'number' and value is not None:
             value = float (value or 0)
 
         self.setValue (value)

Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py    2006-11-08 12:09:38 UTC (rev 8998)
+++ trunk/gnue-forms/src/GFParser.py    2006-11-08 12:54:41 UTC (rev 8999)
@@ -500,11 +500,53 @@
                'Label': _('Field (Database)'),
                'Description': 'The name of the field in the datasource to '
                               'which this widget is tied.' },
+            'datatype': {
+                'Label': u_("Datatype"),
+                'Description': u_("The type of data stored in this field."),
+                'Typecast': GTypecast.name,
+                'ValueSet': {
+                    'text':     {'Label': u_("Text")},
+                    'number':   {'Label': u_('Number')},
+                    'date':     {'Label': u_("Date")},
+                    'time':     {'Label': u_("Time")},
+                    'datetime': {'Label': u_("Date and time")},
+                    'boolean':  {'Label': u_('Boolean')}},
+                'Default': 'text'},
+            'length': {
+                'Label': u_("Length"),
+                'Description': u_(
+                    "Maximum length of data stored in this field. Applies "
+                    "only to fields with a datatype of 'string' or 'number'. "
+                    "For numbers, this is the total number of digits, "
+                    "including the fractional digits."),
+                'Typecast': GTypecast.whole},
+            'scale': {
+                'Label': u_("Scale"),
+                'Description': u_(
+                    "Number of fractional digits. Applies only to fields with "
+                    "a datatype of 'number'."),
+                'Typecast': GTypecast.whole},
+            'case': {
+                'Label': u_("Case"),
+                'Description': u_(
+                    "Convert the value to uppercase/lowercase or leave it as "
+                    "it is. Applies only to fields with a datatype of "
+                    "'string'."),
+                'Typecast': GTypecast.name,
+                'ValueSet': {
+                    'mixed': {'Label': _('Mixed case')},
+                    'upper': {'Label': _('Upper case')},
+                    'lower': {'Label': _('Lower case')}},
+                'Default': 'mixed'},
+            'required': {
+                'Label': u_("Required"),
+                'Description': u_(
+                    "If set, empty values can not be stored in this field."),
+                'Typecast': GTypecast.boolean,
+                'Default': False},
             'maxLength': {
                'Typecast': GTypecast.whole,
-               'Label': _('Max Text Length'),
-               'Description': 'The maximum number of characters the user is '
-                              'allowed to enter into the entry.' },
+               'Deprecated': 'Use length'},
             'minLength': {
                'Typecast': GTypecast.whole,
                'Label': _('Min Text Length'),
@@ -513,7 +555,7 @@
                'Default': 0 },
             'max_length': {
                'Typecast': GTypecast.whole,
-               'Deprecated': 'Use maxLength',
+               'Deprecated': 'Use length',
                'Description': 'The maximum number of characters the user is '
                               'allowed to enter into the entry.' },
             'min_length': {
@@ -524,38 +566,10 @@
                'Default': 0 },
             'readonly': {
                'Typecast': GTypecast.boolean,
-               'Label': _('Read Only'),
-               'Description': 'It defined the user will be unable to alter '
-                              'the contents of this entry. Triggers can still '
-                              'alter the value.',
-# TODO: I think this should be deprecated, but will see how others use first
-#               'Deprecated': 'Use editable="N" instead.',
-               'Default': False   },
-            'required': {
-               'Description': 'This object cannot have an empty value prior '
-                              'to a commit.',
-               'Typecast': GTypecast.boolean,
-               'Default': False   },
-            'case': {
-               'Typecast': GTypecast.name,
-               'ValueSet': {
-                  'mixed': {'Label': _('As Entered')},
-                  'upper': {'Label': _('Upper case')},
-                  'lower': {'Label': _('Lower case')} },
-               'Default': 'mixed',
-               'Description': 'Convert the value to uppercase/lowercase '
-                              'or leave it as it is.'  },
+               'Deprecated': 'Use editable="N" instead.'},
             'typecast': {
                'Typecast': GTypecast.name,
-               'Label': _('Data Type'),
-               'ValueSet': {
-                  'boolean': {'Label': _('Boolean')},
-                  'text': {'Label': _('Text')},
-                  'number': {'Label': _('Numeric')},
-                  'date': {'Label': _('Date/Time')} },
-               'Default': 'text',
-               'Description': 'The type of data the entry widget will accept. '
-                              'Possible values are {text}, {number}, {date}.'},
+               'Deprecated': 'Use "type".'},
             'value': {
                'Typecast': GTypecast.text,
                'Deprecated': 'Use default="..." instead',

Modified: trunk/gnue-forms/src/input/displayHandlers/Cursor.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Cursor.py        2006-11-08 
12:09:38 UTC (rev 8998)
+++ trunk/gnue-forms/src/input/displayHandlers/Cursor.py        2006-11-08 
12:54:41 UTC (rev 8999)
@@ -264,8 +264,8 @@
     # Validate the input
     # TODO: This will be moved to the mask system!!
     # -------------------------------------------------------------------------
-    if hasattr(self.field,'maxLength') and \
-       len(self.work)  + len(value) > self.field.maxLength:
+    if hasattr(self.field,'length') and \
+       len(self.work)  + len(value) > self.field.length:
       # TODO: Should we beep?
       self.__beep()
       assert gDebug (6, "Entry %s: Max length reached"  % self.entry.name )

Modified: trunk/gnue-forms/src/input/displayHandlers/__init__.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/__init__.py      2006-11-08 
12:09:38 UTC (rev 8998)
+++ trunk/gnue-forms/src/input/displayHandlers/__init__.py      2006-11-08 
12:54:41 UTC (rev 8999)
@@ -58,9 +58,9 @@
   if entry._type == 'GFImage':
     # Images don't need input masks so just return the image now
     return Image(entry, eventHandler, subEventHandler)
-  elif entry._field.typecast == 'date':
+  elif entry._field.datatype in ['date', 'time', 'datetime']:
     key = 'date'
-  elif entry._field.typecast == 'number':
+  elif entry._field.datatype == 'number':
     key = 'number'
   else:
     key = entry.style

Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py        2006-11-08 
12:09:38 UTC (rev 8998)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py        2006-11-08 
12:54:41 UTC (rev 8999)
@@ -72,8 +72,6 @@
 
     # return self.__createOldDropDown (gfObject, event)
     newWidget = gtk.combo_box_entry_new_text ()
-    maxLen = hasattr (gfObject, 'maxLength') and gfObject.maxLength or 0
-    newWidget.child.set_max_length (maxLen)
     
     newWidget._origAllowedValues = None
     self._updateChoices (newWidget, gfObject)
@@ -190,9 +188,7 @@
 
   def __createEntry (self, gfObject, event):
 
-    maxLen = hasattr (gfObject, 'maxLength') and gfObject.maxLength or 0
-
-    newWidget = gtk.Entry (maxLen)
+    newWidget = gtk.Entry ()
     newWidget.set_size_request (self.itemWidth, self.itemHeight)
 
     newWidget._insert_handler = newWidget.connect ('insert-text',





reply via email to

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