/[papo]/gnue/designer/src/Incubator.py
ViewVC logotype

Diff of /gnue/designer/src/Incubator.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by charlie, Tue Aug 27 18:15:52 2002 UTC revision 1.4 by styxman, Fri Nov 8 16:46:03 2002 UTC
# Line 1  Line 1 
1  #  #
 # Copyright 2001 Free Software Foundation  
 #  
2  # This file is part of GNU Enterprise.  # This file is part of GNU Enterprise.
3  #  #
4  # GNU Enterprise is free software; you can redistribute it  # GNU Enterprise is free software; you can redistribute it
# Line 18  Line 16 
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19    # Copyright 2001-2002 Free Software Foundation
20    #
21  # FILE:  # FILE:
22  # Incubator.py  # Incubator.py
23  #  #
24  # DESCRIPTION:  # DESCRIPTION:
25  # Creates objects to be added to the form  # Creates objects to be added to the object
26  #  #
27  # NOTES:  # NOTES:
28  #  #
29    
30  from gnue.common import GDebug  from gnue.common import GDebug
 from gnue.forms import GFParser, GFForm  
   
 def createObject(instance, form, tag, type=None, parent=None,  
          parentHint=None, attributes={}):  
   
   
   GDebug.printMesg(3,'Creating a "%s" object' % tag)  
   GDebug.printMesg(6,"Object's parent is %s" % parentHint)  
   
   try:  
     name = attributes['name']  
   except KeyError:  
     name = instance.getNextGenericName(tag)  
   
   try:  
     objclass = elements[tag]['BaseClass']  
     if elements[tag].has_key('Attributes'):  
       attrs = elements[tag]['Attributes']  
     else:  
       attrs = {}  
   except KeyError:  
     GDebug.printMesg(1, "Attempted to create a '%s', "  
                         "but I don't know what to do!" % tag)  
     return  
   
   
   if tag == 'trigger':  
     if not attributes.has_key('type'):  
       attributes['type'] = 'NAMED'  
     if attributes['type'] == 'NAMED':  
       parent = form  
     else:  
       parent = parent or parentHint  
   elif tag in ('page','datasource','import'):  
     parent = form  
   
   o = objclass(parent or parentHint)  
   
   # Pull default values for any attributes not supplied  
   for attr in attrs.keys():  
     if not attributes.has_key(attr):  
       if attrs[attr].has_key('Default'):  
         attributes[attr] = attrs[attr]['Typecast'](attrs[attr]['Default'])  
       elif attr in ('x','y',):  
         attributes[attr] = 0  
       elif attr in ('height',):  
         if tag in ('box','scrollbar'):  
           attributes[attr] = 4  
         else:  
           attributes[attr] = 1  
       elif attr == 'width':  
         if tag in ('scrollbar',):  
           attributes[attr] = 1  
         else:  
           attributes[attr] = 10  
       elif attr in ('text','label'):  
         attributes[attr] = name  
   
   for attr in attributes.keys():  
     if attrs.has_key(attr):  
       o.__dict__[attr] = attributes[attr]  
   o.name = name  
   instance.nameMappings[o.name] = o  
   o._buildObject()  
   instance.onCreateObject(o, __name__)  
   instance.onSetCurrentObject(o, __name__)  
   return o  
   
31    
32  def reparentObject(instance, form, object, newParent):  def calcDependencies(elements, elementMapping):
   if object._parent == newParent:  
     return  
33    
   # TODO  
   pass  
   
   
 def deleteObject(instance, form, object, newCurrentObject=None, firstRun=1):  
   
   if firstRun:  
     newCurrentObject = object._parent  
     parent = object._parent  
   
   for child in object._children:  
     child.deleteObject(instance, form, child, firstRun=0)  
   
   instance.onDeleteObject(object, __name__)  
   
   if firstRun:  
     o = parent  
     while not isinstance(o, GFForm.GFForm):  
       o._buildObject()  
       o = o._parent  
         
     if newCurrentObject:  
       instance.onSetCurrentObject(newCurrentObject, __name__)  
   
   
   
 #  
 # Figure out GFParser's dependencies  
 #  
 elements = None  
 elementMapping = {}  
 def calcDependencies():  
   
   global elements  
   global elementMapping  
   
   elements = GFParser.getXMLelements()  
34    for tag in elements.keys():    for tag in elements.keys():
35      t = elements[tag]      t = elements[tag]
36    
# Line 158  def calcDependencies(): Line 51  def calcDependencies():
51          else:          else:
52            elementMapping[parent] = [tag]            elementMapping[parent] = [tag]
53    
   
 calcDependencies()  
   

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26