commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/definitions/GObjects.py designe...


From: Jason Cater
Subject: gnue common/src/definitions/GObjects.py designe...
Date: Mon, 09 Jun 2003 11:54:32 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Branch:         
Changes by:     Jason Cater <address@hidden>    03/06/09 11:54:32

Modified files:
        common/src/definitions: GObjects.py 
        designer/src/base/tools: PropertyEditor.py 

Log message:
        Fixed the OnModified code for the Property Editor so that when an 
object is modified, the editor is updated and not recreated from scratch.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/definitions/GObjects.py.diff?tr1=1.59&tr2=1.60&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/tools/PropertyEditor.py.diff?tr1=1.45&tr2=1.46&r1=text&r2=text

Patches:
Index: gnue/common/src/definitions/GObjects.py
diff -c gnue/common/src/definitions/GObjects.py:1.59 
gnue/common/src/definitions/GObjects.py:1.60
*** gnue/common/src/definitions/GObjects.py:1.59        Thu May  1 12:21:37 2003
--- gnue/common/src/definitions/GObjects.py     Mon Jun  9 11:54:32 2003
***************
*** 47,53 ****
    def __init__(self, *args, **parms):
      GTriggerCore.__init__(self)
      ParserObj.__init__(self, *args, **parms)
! 
  
    # This is a convenience function for applications
    # NOT using GParser to load an object tree.
--- 47,53 ----
    def __init__(self, *args, **parms):
      GTriggerCore.__init__(self)
      ParserObj.__init__(self, *args, **parms)
!     self.__properties__ = {}
  
    # This is a convenience function for applications
    # NOT using GParser to load an object tree.
***************
*** 69,75 ****
      print " " * indent * 2, self
      for child in self._children:
        child.printTree(indent+1)
!                 
    #
    # phaseInit
    #
--- 69,75 ----
      print " " * indent * 2, self
      for child in self._children:
        child.printTree(indent+1)
! 
    #
    # phaseInit
    #
***************
*** 100,112 ****
        inits[phase]()
  
      for child in self._children:
!       try: 
          initter = child._phaseInit
!       except AttributeError: 
          continue
        initter(phase)
  
!       
    # This function is called after the parsers have completely
    # constructed. All children should be in place and
    # attributes and content should be set at this point.
--- 100,112 ----
        inits[phase]()
  
      for child in self._children:
!       try:
          initter = child._phaseInit
!       except AttributeError:
          continue
        initter(phase)
  
! 
    # This function is called after the parsers have completely
    # constructed. All children should be in place and
    # attributes and content should be set at this point.
***************
*** 203,209 ****
        if self._xmlchildnamespaces:
          for abbrev in self._xmlchildnamespaces.keys():
            xmlnsdef += ' xmlns:%s="%s"' % 
(abbrev,self._xmlchildnamespaces[abbrev])
!     except AttributeError: 
        pass
  
      xmlEntity = self.getXmlTag()
--- 203,209 ----
        if self._xmlchildnamespaces:
          for abbrev in self._xmlchildnamespaces.keys():
            xmlnsdef += ' xmlns:%s="%s"' % 
(abbrev,self._xmlchildnamespaces[abbrev])
!     except AttributeError:
        pass
  
      xmlEntity = self.getXmlTag()
***************
*** 387,399 ****
  
    # 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
--- 387,396 ----
  
    # Hooks
    def __getitem__(self, key):
!     return self.__dict__[key.replace(':','__')]
  
    def __setitem__(self, key, value):
!     return self._setItemHook(key.replace(':','__'),value)
  
    def _setItemHook(self, key, value):
      self.__dict__[key] = value
***************
*** 402,443 ****
  #
  # ParserMultiplexor
  #
! # When a GParser's BaseClass needs to be dependent upon 
  # an attribute, the tool can use a customized ParserMultiplexor,
! # overwriting the getClass method. 
  #
! # e.g., assume we have an xml tag 'goblin', that 
! # corresponds to a GObj-based class Goblin.  However, 
  # if <goblin style="boo"> we really need a BooGoblin
  # object or if <goblin style="foo"> then we need a
! # FooBoblin object, then the a GoblinPlexor would 
! # define getClass as: 
  #
! # def getClass(self): 
! #   if self.style == 'boo': 
  #     return BooGoblin
! #   elif self.style == 'foo': 
  #     return FooGoblin
! #   else: 
  #     return Goblin
  #
! class ParserMultiplexor(ParserObj): 
!   
!   def _buildObject(self): 
      newObj = self.getClass()(None)
!     for attr, value in self.__dict__.items(): 
!       if attr not in ('_buildObject','getClass') and attr[:2] != '__': 
          newObj.__dict__[attr] = value
!         
!     if self._parent: 
        self._parent._children[self._parent._children.find(self)] = newObj
      return newObj._buildObject(self)
!       
!         
    # This should return a GObj-based class
!   def getClass(self): 
      raise "Virtual method not implemented"
!     
  
  # This is down here to avoid recursive importing
  from gnue.common.definitions.GBinary import GBinary
--- 399,440 ----
  #
  # ParserMultiplexor
  #
! # When a GParser's BaseClass needs to be dependent upon
  # an attribute, the tool can use a customized ParserMultiplexor,
! # overwriting the getClass method.
  #
! # e.g., assume we have an xml tag 'goblin', that
! # corresponds to a GObj-based class Goblin.  However,
  # if <goblin style="boo"> we really need a BooGoblin
  # object or if <goblin style="foo"> then we need a
! # FooBoblin object, then the a GoblinPlexor would
! # define getClass as:
  #
! # def getClass(self):
! #   if self.style == 'boo':
  #     return BooGoblin
! #   elif self.style == 'foo':
  #     return FooGoblin
! #   else:
  #     return Goblin
  #
! class ParserMultiplexor(ParserObj):
! 
!   def _buildObject(self):
      newObj = self.getClass()(None)
!     for attr, value in self.__dict__.items():
!       if attr not in ('_buildObject','getClass') and attr[:2] != '__':
          newObj.__dict__[attr] = value
! 
!     if self._parent:
        self._parent._children[self._parent._children.find(self)] = newObj
      return newObj._buildObject(self)
! 
! 
    # This should return a GObj-based class
!   def getClass(self):
      raise "Virtual method not implemented"
! 
  
  # This is down here to avoid recursive importing
  from gnue.common.definitions.GBinary import GBinary
Index: gnue/designer/src/base/tools/PropertyEditor.py
diff -c gnue/designer/src/base/tools/PropertyEditor.py:1.45 
gnue/designer/src/base/tools/PropertyEditor.py:1.46
*** gnue/designer/src/base/tools/PropertyEditor.py:1.45 Fri Jun  6 22:18:24 2003
--- gnue/designer/src/base/tools/PropertyEditor.py      Mon Jun  9 11:54:32 2003
***************
*** 96,110 ****
      object = event.object
      handler = event.originator
  
- 
    def onModifyObject (self, event):
      object = event.object
-     handler = event.originator
      if object == None:
        return
-     if handler != __name__ and self.object == object:
-       self.setCurrent(object)
  
  
    def onDeleteObject (self, event):
      object = event.object
--- 96,109 ----
      object = event.object
      handler = event.originator
  
    def onModifyObject (self, event):
      object = event.object
      if object == None:
        return
  
+     if event.originator != __name__:
+       for page in [self.main] + self.supplemental:
+         page.resetValues(object)
  
    def onDeleteObject (self, event):
      object = event.object
***************
*** 249,254 ****
--- 248,264 ----
        self.maxy = y
        self.maxLabel = maxLabel
        self.__onSize(None)
+ 
+   # Reset the values displayed based on the values on the object
+   def resetValues(self, object):
+     for i in range(len(self.fields)):
+       xkey = self.rowList[i].replace(':','__')
+       field = self.fields[i]
+       # Set the initial value of the cells to the current property values
+       if hasattr(object, xkey):
+         field.SetValue(object.__dict__[xkey])
+       else:
+         field.Clear()
  
    def getPageText(self):
      return self.object._type[2:]




reply via email to

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