commit-gnue
[Top][All Lists]
Advanced

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

r6572 - in trunk/gnue-appserver/src: . gld


From: johannes
Subject: r6572 - in trunk/gnue-appserver/src: . gld
Date: Wed, 27 Oct 2004 03:58:55 -0500 (CDT)

Author: johannes
Date: 2004-10-27 03:58:54 -0500 (Wed, 27 Oct 2004)
New Revision: 6572

Modified:
   trunk/gnue-appserver/src/gld/GLParser.py
   trunk/gnue-appserver/src/gld/readgld.py
   trunk/gnue-appserver/src/labels.py
Log:
1.) label-attribute of class tag is used as form title
2.) special properties (stamps) are always at the bottom of the pages
3.) special properties (stamps) have an extra empty row before
4.) labels with pos = 0 are hidden
5.) the master source is ordered by the first search property with lowest order


Modified: trunk/gnue-appserver/src/gld/GLParser.py
===================================================================
--- trunk/gnue-appserver/src/gld/GLParser.py    2004-10-26 21:18:02 UTC (rev 
6571)
+++ trunk/gnue-appserver/src/gld/GLParser.py    2004-10-27 08:58:54 UTC (rev 
6572)
@@ -95,6 +95,8 @@
             'Typecast': GTypecast.name},
           'page': {
             'Typecast': GTypecast.text},
+          'label': {
+            'Typecast': GTypecast.text},
         },
         'ParentTags': ('module',)
       },
@@ -240,7 +242,7 @@
     GLObject.__init__ (self, parent, type = 'GLClass')
     self.fullName = None
     self.page     = None
-    self._inits.extend ([None, self._validate])
+    self._inits.extend ([None, self._validate, self._complete])
 
   # ---------------------------------------------------------------------------
   # Validate a class definition
@@ -263,6 +265,27 @@
     self.fullName = Namespace.createName (self.module, self.name)
 
 
+  # ---------------------------------------------------------------------------
+  # Complete a class definition
+  # ---------------------------------------------------------------------------
+
+  def _complete (self):
+    """
+    """
+
+    if hasattr (self, 'label') and self.label is not None:
+      add = GLProperty (self)
+
+      add.module   = 'gnue'
+      add.name     = 'id'
+      add.fullName = 'gnue_id'
+      add.label    = self.label
+      add.page     = self.page
+      add.search   = None
+      add.info     = None
+      add.pos      = None
+
+
 # =============================================================================
 # The property object
 # =============================================================================

Modified: trunk/gnue-appserver/src/gld/readgld.py
===================================================================
--- trunk/gnue-appserver/src/gld/readgld.py     2004-10-26 21:18:02 UTC (rev 
6571)
+++ trunk/gnue-appserver/src/gld/readgld.py     2004-10-27 08:58:54 UTC (rev 
6572)
@@ -268,7 +268,7 @@
       moduleId = self.__findModule (aClass.module)
       self.modules [aClass.module] = {'gnue_id': moduleId}
 
-    cDef = self.fetchTags (aClass, ['name', 'page'])
+    cDef = self.fetchTags (aClass, ['name', 'page', 'label'])
     cDef ['module']     = self.modules [aClass.module]['gnue_id']
     cDef ['gnue_id']    = self.__findClass (aClass.module, cDef ['name'])
     cDef ['properties'] = []
@@ -482,9 +482,9 @@
     if stat [0] + stat [1]:
       self.connections.commitAll ()
 
-    print u_("  Labels  : %(ins)3d inserted, %(upd)3d updated, %(kept)3d "
+    print o(u_("  Labels  : %(ins)3d inserted, %(upd)3d updated, %(kept)3d "
              "unchanged.") \
-          % {'ins': stat [0], 'upd': stat [1], 'kept': stat [2]}
+          % {'ins': stat [0], 'upd': stat [1], 'kept': stat [2]})
 
 
   # ---------------------------------------------------------------------------
@@ -535,7 +535,7 @@
     if stat [0] + stat [1]:
       self.connections.commitAll ()
 
-    print o (u_("  Messages: %(ins)3d inserted, %(upd)3d updated, %(kept)3d "
+    print o(u_("  Messages: %(ins)3d inserted, %(upd)3d updated, %(kept)3d "
                 "unchanged.") \
               % {'ins': stat [0], 'upd': stat [1], 'kept': stat [2]})
 

Modified: trunk/gnue-appserver/src/labels.py
===================================================================
--- trunk/gnue-appserver/src/labels.py  2004-10-26 21:18:02 UTC (rev 6571)
+++ trunk/gnue-appserver/src/labels.py  2004-10-27 08:58:54 UTC (rev 6572)
@@ -76,6 +76,7 @@
     self.displayMask = None
     self.buddy       = None
     self.triggers    = {}
+    self.isSpecial   = False
 
     masks  = ['%x', '%X', '%x %X']
 
@@ -269,6 +270,8 @@
     self.languages  = ['C']
     self.connection = connection
     self.fullName   = Namespace.createName (aClass.module.name, aClass.name)
+    self.formTitle  = "%s %s" % (aClass.module.name.title (),
+                                 aClass.name.title ())
 
     self.maxWidth   = formWidth
     self.maxHeight  = formHeight
@@ -291,6 +294,7 @@
 
     self.__loadLabels (self.fullName, self.properties)
     self.__fillupReferences ()
+    self.__removeHiddenProperties ()
     self.__updateEntryStyle ()
     self.__updateSources ()
     self.__updateSpecials ()
@@ -331,6 +335,7 @@
         if prop.gnue_name in ['createdate', 'modifydate', 'createuser',
                               'modifyuser']:
           record = Property (prop)
+          record.isSpecial = True
           specials [record.fullName] = record
 
         continue
@@ -396,6 +401,10 @@
 
         full = Namespace.createName (label.gnue_property.module.name,
                                      label.gnue_property.name)
+        if full == 'gnue_id' and len (label.label):
+          self.formTitle = label.label
+          continue
+
         pDict [full].updateLabel (label)
 
       # Add labels for calculated properties
@@ -454,6 +463,21 @@
 
 
   # ---------------------------------------------------------------------------
+  # Hide away all properties with position 0
+  # ---------------------------------------------------------------------------
+
+  def __removeHiddenProperties (self):
+    """
+    This function removes all properties with an explicit zero-position. We
+    treat them as 'hidden'.
+    """
+
+    for (key, item) in self.properties.items ():
+      if item.pos == 0:
+        del self.properties [key]
+
+
+  # ---------------------------------------------------------------------------
   # Update the property-dictionary with entry-style information
   # ---------------------------------------------------------------------------
 
@@ -500,8 +524,14 @@
     """
     This function updates the datasource- and blocks-dictionaries.
     """
-    self.__addToSources ('dtsMaster', self.fullName)
 
+    attrs = {}
+    orderBy = self.__getSortColumn ()
+    if orderBy is not None:
+      attrs ['order_by'] = orderBy
+
+    self.__addToSources ('dtsMaster', self.fullName, attrs)
+
     for prop in self.properties.values () + self.specials.values ():
       if prop.ref is None:
         dtsName    = "dtsMaster"
@@ -567,6 +597,25 @@
 
 
   # ---------------------------------------------------------------------------
+  # Get the name of the first search property
+  # ---------------------------------------------------------------------------
+
+  def __getSortColumn (self):
+    """
+    This function get's the name of the search property with the lowest search
+    index or None if no search property is available.
+    """
+
+    search = []
+    for item in self.properties.values ():
+      if item.search is not None:
+        search.append ((item.search, item.fullName))
+
+    search.sort ()
+
+    return len (search) and search [0] [1] or None
+
+  # ---------------------------------------------------------------------------
   # Add a property to the given block dictionary
   # ---------------------------------------------------------------------------
 
@@ -652,14 +701,6 @@
 
       result [item.page].append (item)
 
-    # add special properties to *all* pages
-    for item in self.specials.values ():
-      item.addHeight = 0
-      item.minHeight = 1
-
-    for plist in result.values ():
-      plist.extend ([copy.deepcopy (p) for p in self.specials.values ()])
-
     # now order all fields per virtual page
     for page in result.keys ():
       pOrder = []
@@ -676,6 +717,14 @@
 
       result [page] = [p [1] for p in pOrder] + [n [1] for n in nOrder]
 
+    # Add the special fields at the bottom of every page
+    for item in self.specials.values ():
+      item.addHeight = 0
+      item.minHeight = 1
+
+    for plist in result.values ():
+      plist.extend ([copy.deepcopy (p) for p in self.specials.values ()])
+
     return result
 
 
@@ -731,9 +780,16 @@
       row     = self._START_ROW
       pageNum = 1
       cPage   = []
+
+      firstSpecial      = True
       result [pageName] = cPage
 
       for item in virtPage:
+        # Insert a blank line before the first special property
+        if item.isSpecial and firstSpecial:
+          row += 1
+          firstSpecial = False
+
         item.height = item.minHeight or self._MIN_HEIGHT + item.addHeight
 
         if row + item.height - 1 > self.maxHeight:
@@ -794,8 +850,7 @@
     """
     self.code = [u'<?xml version="1.0" encoding="utf-8"?>']
     self.code.extend (self._getXMLTag ('form',
-        {'title': "%s %s" % (self.aClass.module.name.title (),
-                             self.aClass.name.title ())}, "", True))
+                                       {'title': self.formTitle}, "", True))
 
     cont = []
     cont.extend (self._getXMLTag ('author',





reply via email to

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