Exemplo n.º 1
0
    def fromXml(self,obj,root):
	if hasattr(obj,'__dict__'):
	    name = str(obj.__class__)
	    if root.getName() == name:
		xe = root
	    else:
		tw = TreeWalker(root)
		xe = tw.getNextElement(name)
		if xe == None: raise "No matching object named %s under %s"%(name,str(obj))
	    namedict = obj.__dict__
	    for key in namedict.keys():
		field = obj.__dict__[key]
		if hasattr(field,'__dict__'):
		    tw = TreeWalker(xe)
		    self.fromXml(field,obj,root)
		else:
		    str = xe.getAttribute(key)
		    if type(field) == types.IntType:
			field = int(str)
		    elif type(field) == types.FloatType:
			field = float(str)
		    else:
			field = str
		obj.__dict__[key] = field
	else:
	    raise "No __dict__ for object: " + str(obj)
Exemplo n.º 2
0
 def fromXml(self, obj, root):
     if hasattr(obj, '__dict__'):
         name = str(obj.__class__)
         if root.getName() == name:
             xe = root
         else:
             tw = TreeWalker(root)
             xe = tw.getNextElement(name)
             if xe == None:
                 raise "No matching object named %s under %s" % (name,
                                                                 str(obj))
         namedict = obj.__dict__
         for key in namedict.keys():
             field = obj.__dict__[key]
             if hasattr(field, '__dict__'):
                 tw = TreeWalker(xe)
                 self.fromXml(field, obj, root)
             else:
                 str = xe.getAttribute(key)
                 if type(field) == types.IntType:
                     field = int(str)
                 elif type(field) == types.FloatType:
                     field = float(str)
                 else:
                     field = str
             obj.__dict__[key] = field
     else:
         raise "No __dict__ for object: " + str(obj)
Exemplo n.º 3
0
 def valueChanged(self,evt):
   tnode = evt.getPath().getLastPathComponent()
   xnode_name = tnode.getUserObject()
   tw=TreeWalker(self.xroot)
   xnode=tw.getNextElement(xnode_name)
   if not xnode: return
   if isinstance(xnode,ElementNode):
     headerSorter = TableSorter(NodeTableModel(xnode))
   else:
     headerSorter = TableSorter(DefaultTableModel())
   headerSorter.addMouseListenerToHeaderInTable(self.jtb)
   self.jtb.setModel(headerSorter)
   #self.sizeColumns()
   self.jtb.sizeColumnsToFit(-1)