commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/GObjects.py designer/src/base/I...


From: Jason Cater
Subject: gnue common/src/GObjects.py designer/src/base/I...
Date: Sun, 22 Dec 2002 20:31:39 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/12/22 20:31:38

Modified files:
        common/src     : GObjects.py 
        designer/src/base: Instance.py 
        designer/src/templates/forms: FormBuilder.py Simple.py 
        forms/src/GFObjects: GFBlock.py 

Log message:
        reworking the format of designer wizards and namespace support

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GObjects.py.diff?tr1=1.48&tr2=1.49&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/Instance.py.diff?tr1=1.77&tr2=1.78&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/templates/forms/FormBuilder.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/templates/forms/Simple.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFObjects/GFBlock.py.diff?tr1=1.71&tr2=1.72&r1=text&r2=text

Patches:
Index: gnue/common/src/GObjects.py
diff -c gnue/common/src/GObjects.py:1.48 gnue/common/src/GObjects.py:1.49
*** gnue/common/src/GObjects.py:1.48    Tue Dec  3 13:06:32 2002
--- gnue/common/src/GObjects.py Sun Dec 22 20:31:38 2002
***************
*** 388,390 ****
--- 388,403 ----
      else:
        return self._type[2:] + " (%s)" % self._type[2:]
  
+   # Hooks
+   def __getitem__(self, key):
+     return self._getItemHook(key)
+ 
+   def __setitem__(self, key, value):
+     return self._setItemHook(key, value)
+ 
+   def _getItemHook(self, key):
+     return self.__dict__[key]
+ 
+   def _setItemHook(self, key, value):
+     self.__dict__[key] = value
+ 
Index: gnue/designer/src/base/Instance.py
diff -c gnue/designer/src/base/Instance.py:1.77 
gnue/designer/src/base/Instance.py:1.78
*** gnue/designer/src/base/Instance.py:1.77     Sat Dec 21 19:59:55 2002
--- gnue/designer/src/base/Instance.py  Sun Dec 22 20:31:38 2002
***************
*** 174,180 ****
      self._menubar = MainMenuBar(self)
      self.SetMenuBar(self._menubar)
  
- 
      self.rootObject.walk(self.__inventory)
  
  
--- 174,179 ----
***************
*** 431,436 ****
--- 430,438 ----
    # until it is useful to us
    def __inventory (self, object):
  
+     # Add a GObjectHelper to intercept __getitem__ calls on GObject
+     GObjectHelper(self, object)
+ 
      if object != self.rootObject:
  
        # just a hack for designer.reports.TreeView.py (btami)
***************
*** 655,661 ****
        DebugSession(self)
  
  
- 
    #################################################################
    #
    #################################################################
--- 657,662 ----
***************
*** 716,722 ****
        except ValueError:
          continue
  
! 
  
  
  #
--- 717,747 ----
        except ValueError:
          continue
  
! #
! class GObjectHelper:
!   def __init__(self, instance, object):
!     self.instance = instance
!     self.object = object
!     object._getItemHook = self._getItemHook
!     object._setItemHook = self._setItemHook
! 
!   # Replace the getitem hooks from GObject
!   # This is for the wizards, so they can do
!   # entry['Char:x']-type calls and get back
!   # what they expected.
!   def _getItemHook(self, key):
!     return self.object.__dict__[key.replace(':','__')]
! 
!   def _setItemHook(self, key, value):
!     ek = key.replace(':','__')
!     object = self.object
!     try:
!       ov = {key: object.__dict__[ek]}
!     except KeyError:
!       ov = {}
!     object.__dict__[key.replace(':','__')] = value
!     self.instance.dispatchEvent('ObjectModified',
!        object = object, new={key:value}, old=ov, originator = '__inline__')
  
  
  #
***************
*** 729,733 ****
    description = 'undefined'
    fileExtensions = {}
    defaultFileExtension = 'undefined'
- 
  
--- 754,757 ----
Index: gnue/designer/src/templates/forms/FormBuilder.py
diff -c gnue/designer/src/templates/forms/FormBuilder.py:1.9 
gnue/designer/src/templates/forms/FormBuilder.py:1.10
*** gnue/designer/src/templates/forms/FormBuilder.py:1.9        Thu Nov  7 
23:32:05 2002
--- gnue/designer/src/templates/forms/FormBuilder.py    Sun Dec 22 20:31:38 2002
***************
*** 62,68 ****
    #
    def Start(self, form, current):
      self.form = form
!     print current
      # The first table can never have a master
      self.variables['hasmaster0'] = '0'
      self.variables['newPage0'] = '0'
--- 62,68 ----
    #
    def Start(self, form, current):
      self.form = form
! 
      # The first table can never have a master
      self.variables['hasmaster0'] = '0'
      self.variables['newPage0'] = '0'
***************
*** 93,99 ****
          if self.variables['singleconnection'] == '1':
            self.variables['connection%s' % iteration] = 
self.variables['connection0']
            step = '2'
!             
  
        else:
          # We are done... record the total number of children
--- 93,99 ----
          if self.variables['singleconnection'] == '1':
            self.variables['connection%s' % iteration] = 
self.variables['connection0']
            step = '2'
! 
  
        else:
          # We are done... record the total number of children
***************
*** 437,446 ****
                 string.capwords(string.replace(field.name,'_',' ')) + ':'
  
          labelQueue.append(self.AddElement('label', page,
!                     {'x':1, 'y': 1,
                       'name': "lbl%s" % fieldKey,
                       'text': text,
!                      'width': len(text)}))
  
          # Keep track of the greatest label width
          largestLabel = largestLabel < len(text) and len(text) or largestLabel
--- 437,446 ----
                 string.capwords(string.replace(field.name,'_',' ')) + ':'
  
          labelQueue.append(self.AddElement('label', page,
!                     {'Char:x':1, 'Char:y': 1,
                       'name': "lbl%s" % fieldKey,
                       'text': text,
!                      'Char:width': len(text)}))
  
          # Keep track of the greatest label width
          largestLabel = largestLabel < len(text) and len(text) or largestLabel
***************
*** 448,471 ****
  
          # Create an entry for this field.
  
!         attrs={'x':1, 'y': 1,
                 'name': "inp%s" % fieldKey,
                 'field': field.name,
                 'typecast': field.datatype,
!                'width': 10}
  
          # If we have a length for the field, use this as the max_length
          # for the entry. Also, adjust the display width if necessary.
          if hasattr(field,'length'):
            attrs['max_length'] = field.length
            if field.length < 25:
!             attrs['width'] = field.length
            else:
!             attrs['width'] = 25
  
          # Keep track of the greatest field width
!         largestField = largestField < attrs['width'] and \
!                attrs['width'] or largestField
  
          # Create the entry element
          entryQueue.append(self.AddElement('entry', block, attrs))
--- 448,471 ----
  
          # Create an entry for this field.
  
!         attrs={'Char:x':1, 'Char:y': 1,
                 'name': "inp%s" % fieldKey,
                 'field': field.name,
                 'typecast': field.datatype,
!                'Char:width': 10}
  
          # If we have a length for the field, use this as the max_length
          # for the entry. Also, adjust the display width if necessary.
          if hasattr(field,'length'):
            attrs['max_length'] = field.length
            if field.length < 25:
!             attrs['Char:width'] = field.length
            else:
!             attrs['Char:width'] = 25
  
          # Keep track of the greatest field width
!         largestField = largestField < attrs['Char:width'] and \
!                attrs['Char:width'] or largestField
  
          # Create the entry element
          entryQueue.append(self.AddElement('entry', block, attrs))
Index: gnue/designer/src/templates/forms/Simple.py
diff -c gnue/designer/src/templates/forms/Simple.py:1.13 
gnue/designer/src/templates/forms/Simple.py:1.14
*** gnue/designer/src/templates/forms/Simple.py:1.13    Sun Dec 22 17:05:51 2002
--- gnue/designer/src/templates/forms/Simple.py Sun Dec 22 20:31:38 2002
***************
*** 30,35 ****
--- 30,36 ----
  
  
  from gnue.designer.forms.TemplateSupport import *
+ 
  import string
  
  # NOTE: It is VERY important that in any references to a
***************
*** 57,62 ****
--- 58,64 ----
    #
    def Start(self, form, current):
      self.form = form
+     self.current = current
  
  
  
***************
*** 169,208 ****
      leftlabels = self.variables['arrangement'] == 'left'
  
      # Set the basic attributes of the form
!     self.ModifyElement(self.form, title=self.variables['title'])
  
      # Create a single datasource based on user's input
      datasource = self.AddElement('datasource', self.form,
!        {  'database': self.variables['connection'],
            'table': self.variables['table'],
            'type': 'object',
            'name': 'dts%s' %  tableKey })
  
!     logic = None
!     for child in self.form._children:
!       if child._type == 'GFLogic':
!         logic = child
!         break
!     if not logic:
!       logic = self.AddElement('logic', self.form, {})
! 
!     layout = None
!     for child in self.form._children:
!       if child._type == 'GFLayout':
!         layout = child
!         break
!     if not layout:
!       layout = self.AddElement('layout', self.form, {})
! 
!     page = None
!     for child in layout._children:
!       if child._type == 'GFPage':
!         page = child
!         break
! 
!     if not page:
!       # Create a single page on which to place blocks and labels
!       page = self.AddElement('page', layout,
           {  'name': 'pg%s' % tableKey })
  
  
--- 171,188 ----
      leftlabels = self.variables['arrangement'] == 'left'
  
      # Set the basic attributes of the form
!     self.form['title'] = self.variables['title']
  
      # Create a single datasource based on user's input
      datasource = self.AddElement('datasource', self.form,
!        {  'connection': self.variables['connection'],
            'table': self.variables['table'],
            'type': 'object',
            'name': 'dts%s' %  tableKey })
  
!     logic = self.current['logic']
!     layout = self.current['layout']
!     page = self.current['page'] or self.AddElement('page', layout,
           {  'name': 'pg%s' % tableKey })
  
  
***************
*** 235,250 ****
        if field.name in self.variables['fields']:
          fields[field.name] = field
  
-     fieldQueue = []
      entryQueue = []
      labelQueue = []
      largestField = 0
      largestLabel = 0
  
!     # Now, let's make all the entries
      for name in self.variables['fields']:
  
        field = fields[name]
        # We will use the field name as the basis for all our
        # entry and label names.  Capitalize the first letter
        # and strip all spaces...
--- 215,230 ----
        if field.name in self.variables['fields']:
          fields[field.name] = field
  
      entryQueue = []
      labelQueue = []
      largestField = 0
      largestLabel = 0
  
!     # First, let's make all the fields
      for name in self.variables['fields']:
  
        field = fields[name]
+ 
        # We will use the field name as the basis for all our
        # entry and label names.  Capitalize the first letter
        # and strip all spaces...
***************
*** 254,310 ****
          fieldKey = string.join(string.split(string.capwords( \
                       string.replace(field.name,'_',' '))),'')
  
-       # Create the field element
-       attrs={'name': "inp%s" % fieldKey,
-              'field': field.name}
-       # If we have a length for the field, use this as the max_length
-       # for the field.
-       if hasattr(field,'length'):
-         attrs['max_length'] = field.length
- 
-       fieldQueue.append(self.AddElement('field', block, attrs))
-       
        # Create a label. If the schema specified a label for a field,
        # use that as is.  If not, use the field name, replacing any '_'
        # with spaces and tacking on a colon.
        text = hasattr(field,'label') and label or \
               string.capwords(string.replace(field.name,'_',' ')) + ':'
  
!       labelQueue.append(self.AddElement('label', page,
!                   {'Char:x':1, 'Char:y': 1,
!                    'name': "lbl%s" % fieldKey,
!                    'text': text,
!                    'Char:width': len(text)}))
  
        # Keep track of the greatest label width
!       largestLabel = largestLabel < len(text) and len(text) or largestLabel
! 
  
        # Create an entry for this field.
  
!       attrs={'Char:x':1, 'Char:y': 1,
!              'block': 'blk%s' % tableKey,
!              'field': "inp%s" % fieldKey,
!              'typecast': field.datatype,
!              'Char:width': 10}
  
!       # If we have a length, adjust the display width if necessary.
        if hasattr(field,'length'):
!         if field.length < 25:
!           attrs['Char:width'] = field.length
!         else:
!           attrs['Char:width'] = 25
! 
!       # Keep track of the greatest field width
!       largestField = largestField < attrs['Char:width'] and \
!              attrs['Char:width'] or largestField
  
        # Create the entry element
!       entryQueue.append(self.AddElement('entry', page, attrs))
  
  
      # Rearrange the fields and labels to snugly fit the screen
      # based on the layout arrangement selected by the user.
  
      # Grid/multirecord layout
      if multirecord:
--- 234,278 ----
          fieldKey = string.join(string.split(string.capwords( \
                       string.replace(field.name,'_',' '))),'')
  
        # Create a label. If the schema specified a label for a field,
        # use that as is.  If not, use the field name, replacing any '_'
        # with spaces and tacking on a colon.
        text = hasattr(field,'label') and label or \
               string.capwords(string.replace(field.name,'_',' ')) + ':'
  
!       # Add text, x, y to labelQueue
!       # The x,y will be replaced by logic later on...
!       labelQueue.append([text,0,0])
  
        # Keep track of the greatest label width
!       largestLabel = max(len(text),largestLabel)
  
        # Create an entry for this field.
  
!       attrs={ 'name': "fld%s" % fieldKey,
!               'field': field.name,
!               'typecast': field.datatype }
  
!       # If we have a length for the field, use this as the max_length
!       # for the entry. Also, adjust the display width if necessary.
        if hasattr(field,'length'):
!         ln = min(field.length, 25)
!         attrs['max_length'] = ln
!         largestField = max(largestField, ln)
!       else:
!         largestField = max(largestField, 10)
  
        # Create the entry element
!       fld = self.AddElement('field', block, attrs)
  
+       # and queue it so we can create entry's later
+       entryQueue.append([fld, 0, 0] )
  
+ 
+     #
      # Rearrange the fields and labels to snugly fit the screen
      # based on the layout arrangement selected by the user.
+     #
  
      # Grid/multirecord layout
      if multirecord:
***************
*** 314,335 ****
        x = 1
  
        for i in range(len(entryQueue)):
!         self.ModifyElement(labelQueue[i],Char__x=x,Char__y=1)
!         self.ModifyElement(entryQueue[i],Char__x=x,Char__y=2)
  
          # If label width is larger than entry width, center the entry
!         if entryQueue[i].Char__width < labelQueue[i].Char__width:
!           self.ModifyElement(entryQueue[i],Char__x=entryQueue[i].Char__x + \
!               int((labelQueue[i].Char__width - entryQueue[i].Char__width)/2))
! 
  
          # Calculate the starting x for the next label/entry
!         dx = (entryQueue[i].Char__width < labelQueue[i].Char__width and \
!               labelQueue[i].Char__width or entryQueue[i].Char__width) + 1
  
          # Increase the form width accordingly
          width += dx
!         x = x + dx
  
      # Single Record layout (regardless of label location)
      else:
--- 282,312 ----
        x = 1
  
        for i in range(len(entryQueue)):
!         field = entryQueue[i][0]
!         text = labelQueue[i][0]
!         textLen = len(text)
! 
!         labelQueue[i][1] = x
!         labelQueue[i][2] = 1
!         entryQueue[i][1] = x
!         entryQueue[i][2] = 2
  
          # If label width is larger than entry width, center the entry
!         try:
!           entryWidth = min(field['max_length'],25)
!         except KeyError:
!           entryWidth = 10
!         if entryWidth < textLen:
!           entryQueue[i][1] += int((textLen - entryWidth)/2)
  
          # Calculate the starting x for the next label/entry
!         dx = max(entryWidth, textLen) + 1
!         print dx,
  
          # Increase the form width accordingly
          width += dx
!         x += dx
!         print x
  
      # Single Record layout (regardless of label location)
      else:
***************
*** 350,370 ****
          fx, fy, fdx, fdy = (1, 2, 0, 3)
  
          # Set the form width
!         width = 2 + (largestField > largestLabel and largestField \
!                                or largestLabel)
  
        # Rearrange
        height = fy+2-fdy
        for i in range(len(entryQueue)):
!         self.ModifyElement(labelQueue[i],Char__x=lx,Char__y=ly)
!         self.ModifyElement(entryQueue[i],Char__x=fx,Char__y=fy)
          ly = ly + ldy
          lx = lx + ldx
          fy = fy + fdy
          fx = fx + fdx
          height += fdy
  
!     self.ModifyElement(layout, Char__width=width, Char__height=height)
  
      # That's it... we're done.
      return 1
--- 327,392 ----
          fx, fy, fdx, fdy = (1, 2, 0, 3)
  
          # Set the form width
!         width = 2 + max(largestField, largestLabel)
  
        # Rearrange
        height = fy+2-fdy
        for i in range(len(entryQueue)):
!         labelQueue[i][1] = lx
!         labelQueue[i][2] = ly
!         entryQueue[i][1] = fx
!         entryQueue[i][2] = fy
! 
          ly = ly + ldy
          lx = lx + ldx
          fy = fy + fdy
          fx = fx + fdx
          height += fdy
  
!     #
!     # Resize the layout screen to fit our form
!     #
!     layout['Char:width'] = width
!     layout['Char:height'] = height
! 
! 
!     #
!     # Finally, add the visual elements...
!     #
!     for i in range(len(entryQueue)):
! 
!       #
!       # First, the label
!       #
!       text, x, y = labelQueue[i]
!       self.AddElement( 'label', page,
!                   {'Char:x': x,
!                    'Char:y': y,
!                    'name': "lbl%s" % fieldKey,
!                    'text': text,
!                    'Char:width': len(text)})
! 
!       #
!       # And the entry...
!       #
!       field, x, y = entryQueue[i]
!       attrs={'name': "ent%s" % field['name'][3:],
!              'field': field['name'],
!              'block': block['name'],
!              'Char:x': x,
!              'Char:y': y,
!              'Char:width': 10 }
! 
!       # If we have a length for the field, use this as the max_length
!       # for the entry. Also, adjust the display width if necessary.
!       try:
!         attrs['Char:width'] = min(field['max_length'], 25)
!       except KeyError:
!         pass
! 
!       # Create the entry element
!       self.AddElement('entry', page, attrs)
! 
  
      # That's it... we're done.
      return 1
***************
*** 375,386 ****
  #
  # Basic information about this template
  #
  TemplateInformation = {
      'Product': 'forms',
      'BaseClass' : SimpleFormTemplate,
      'Name' : 'Simple form wizard',
      'Description' : 'Creates a simple single-source entry table.',
!     'Version' : '0.0.1',
      'Author' : 'The GNUe Designer Team',
      'Behavior': WIZARD
  }
--- 397,410 ----
  #
  # Basic information about this template
  #
+ from gnue.designer import VERSION
+ 
  TemplateInformation = {
      'Product': 'forms',
      'BaseClass' : SimpleFormTemplate,
      'Name' : 'Simple form wizard',
      'Description' : 'Creates a simple single-source entry table.',
!     'Version' : VERSION,
      'Author' : 'The GNUe Designer Team',
      'Behavior': WIZARD
  }
Index: gnue/forms/src/GFObjects/GFBlock.py
diff -c gnue/forms/src/GFObjects/GFBlock.py:1.71 
gnue/forms/src/GFObjects/GFBlock.py:1.72
*** gnue/forms/src/GFObjects/GFBlock.py:1.71    Thu Dec 12 21:56:10 2002
--- gnue/forms/src/GFObjects/GFBlock.py Sun Dec 22 20:31:38 2002
***************
*** 124,142 ****
  
      self._triggerProperties={'parent':  {'get':self.getParent}}
  
!   def __getitem__(self, index):
! 
!     cnt = self._resultSet.getRecordCount() - 1
!     if index > cnt:
!       raise IndexError
! 
!     self.jumpRecord(index)
! 
!     if cnt == index and self.isEmpty():
!       print "Bad, bad, bad"
!       raise IndexError
! 
!     return self
  
    def _buildObject(self):
  
--- 124,142 ----
  
      self._triggerProperties={'parent':  {'get':self.getParent}}
  
! ##  def __getitem__(self, index):
! ##
! ##    cnt = self._resultSet.getRecordCount() - 1
! ##    if index > cnt:
! ##      raise IndexError
! ##
! ##    self.jumpRecord(index)
! ##
! ##    if cnt == index and self.isEmpty():
! ##      print "Bad, bad, bad"
! ##      raise IndexError
! ##
! ##    return self
  
    def _buildObject(self):
  



reply via email to

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