Kaydet (Commit) ae2bc91d authored tarafından Javier Fernandez's avatar Javier Fernandez

PyWebWizard: Fixing bugs and implementation of mising features.

Correct implementation of the WebConfigSet class.

Change-Id: I28160008cb9b8f96cd0619c70f573520ba9fa595
üst cb25d58d
...@@ -34,63 +34,45 @@ class WebConfigSet(ConfigGroup): ...@@ -34,63 +34,45 @@ class WebConfigSet(ConfigGroup):
''' '''
def __init__(self, childType): def __init__(self, childType):
print ("DEBUG !!! childType: ", childType)
self.childClass = childType self.childClass = childType
self.childrenMap = {} self.childrenMap = {}
self.childrenList = [] self.childrenList = []
self.noNulls = False self.noNulls = True
self.listenerList = None self.listenerList = None
def add(self, name, o): def add(self, name, o):
print ("DEBUG !!! WebConfigSet.add -- name: ", name)
if (o is None):
print ("DEBUG !!! WebConfigSet.add -- Received None object as argument.")
oldO = None oldO = None
if (name in self.childrenMap): if (name in self.childrenMap):
oldO = self.childrenMap[name] oldO = self.childrenMap[name]
self.childrenMap[name] = o self.childrenMap[name] = o
try: try:
i = int(name) i = int(name)
print ("DEBUG !!! WebConfigSet.add -- name IS an integer.")
self.childrenList.insert(i, o) self.childrenList.insert(i, o)
self.fireListDataListenerIntervalAdded(i, i); self.fireListDataListenerIntervalAdded(i, i);
except Exception: except ValueError:
print ("DEBUG !!! WebConfigSet.add -- name IS NOT an integer.") if (hasattr(o, "cp_Index")):
try:
i = o.cp_Index i = o.cp_Index
print ("DEBUG !!! WebConfigSet.add -- index: ", i)
oldSize = self.getSize() oldSize = self.getSize()
print ("DEBUG !!! WebConfigSet.add -- oldSize: ", oldSize) while (self.getSize() <= i):
if oldSize < i: self.childrenList.append(None)
newSize = i - oldSize self.childrenList[i] = o
self.childrenList += [None] * newSize
self.noNulls |= True
else:
self.noNulls |= False
print ("DEBUG !!! WebConfigSet.add -- inserting object o: ", o)
self.childrenList.insert(i, o)
if oldSize > i: if oldSize > i:
oldSize = i oldSize = i
self.fireListDataListenerIntervalAdded(oldSize, i); self.fireListDataListenerIntervalAdded(oldSize, i);
except Exception: else:
if (oldO is not None): if (oldO is not None):
print ("DEBUG !!! WebConfigSet.add -- No cp_Index attribute, but element already present, so replace it.")
i = self.childrenList.index(oldO) i = self.childrenList.index(oldO)
self.childrenList[i] = o self.childrenList[i] = o
else: else:
print ("DEBUG !!! WebConfigSet.add -- No cp_Index attribute, so just append it.")
self.childrenList.append(o) self.childrenList.append(o)
self.fireListDataListenerIntervalAdded(self.getSize() - 1, self.getSize() - 1); self.fireListDataListenerIntervalAdded(self.getSize() - 1, self.getSize() - 1);
def writeConfiguration(self, configView, param): def writeConfiguration(self, configView, param):
print ("DEBUG !!! writeConfiguration --")
names = self.childrenMap.keys() names = self.childrenMap.keys()
#first I remove all the children from the configuration. #first I remove all the children from the configuration.
children = configView.ElementNames children = configView.ElementNames
print ("DEBUG !!! writeConfiguration -- children length: ", len(children))
if children: if children:
print ("DEBUG !!! writeConfiguration -- removing childrens.")
for i in children: for i in children:
try: try:
Configuration.removeNode(configView, i) Configuration.removeNode(configView, i)
...@@ -110,10 +92,9 @@ class WebConfigSet(ConfigGroup): ...@@ -110,10 +92,9 @@ class WebConfigSet(ConfigGroup):
names = configurationView.ElementNames names = configurationView.ElementNames
if names: if names:
for i in names: for i in names:
print ("DEBUG !!! readConfiguration -- name: ", i)
try: try:
child = self.childClass() child = self.childClass()
child.root = self.root child.setRoot(self.root)
child.readConfiguration( child.readConfiguration(
configurationView.getByName(i), param) configurationView.getByName(i), param)
self.add(i, child) self.add(i, child)
...@@ -128,16 +109,16 @@ class WebConfigSet(ConfigGroup): ...@@ -128,16 +109,16 @@ class WebConfigSet(ConfigGroup):
i -= 1 i -= 1
i += 1 i += 1
def remove(self, obj): def remove1(self, obj):
key = getKey(obj) key = self.getKey(obj)
self.childrenMap.remove(key) del self.childrenMap[key]
i = self.childrenList.indexOf(obj) i = self.childrenList.index(obj)
self.childrenList.remove(obj) self.childrenList.remove(obj)
self.fireListDataListenerIntervalRemoved(i, i) self.fireListDataListenerIntervalRemoved(i, i)
def remove(self, i): def remove(self, i):
o = getElementAt(i) o = self.getElementAt(i)
remove(o) self.remove1(o)
def clear(self): def clear(self):
self.childrenMap.clear() self.childrenMap.clear()
...@@ -151,9 +132,8 @@ class WebConfigSet(ConfigGroup): ...@@ -151,9 +132,8 @@ class WebConfigSet(ConfigGroup):
i = 0 i = 0
while i < len(items): while i < len(items):
item = items[i] item = items[i]
if isinstance(item, XMLProvider): if hasattr(item, "createDOM"):
item.createDOM(parent) item.createDOM(parent)
i += 1 i += 1
return parent return parent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment