objdictgen/nodemanager.py
changeset 242 4864f7f01e1d
parent 239 f45fd4cd3832
child 244 da4245399655
equal deleted inserted replaced
241:4ecc2f3690f4 242:4864f7f01e1d
   225                 elif option == "SaveConfig":
   225                 elif option == "SaveConfig":
   226                     AddIndexList.extend([0x1010, 0x1011, 0x1020])
   226                     AddIndexList.extend([0x1010, 0x1011, 0x1020])
   227                 elif option == "StoreEDS":
   227                 elif option == "StoreEDS":
   228                     AddIndexList.extend([0x1021, 0x1022])
   228                     AddIndexList.extend([0x1021, 0x1022])
   229             # Add a new buffer 
   229             # Add a new buffer 
   230             index = self.AddNodeBuffer()
   230             index = self.AddNodeBuffer(self.CurrentNode.Copy(), False)
   231             self.SetCurrentFilePath("")
   231             self.SetCurrentFilePath("")
   232             # Add Mandatory indexes
   232             # Add Mandatory indexes
   233             self.ManageEntriesOfCurrent(AddIndexList, [])
   233             self.ManageEntriesOfCurrent(AddIndexList, [])
   234             return index
   234             return index
   235         else:
   235         else:
   304     def ImportCurrentFromEDSFile(self, filepath):
   304     def ImportCurrentFromEDSFile(self, filepath):
   305         # Generate node from definition in a xml file
   305         # Generate node from definition in a xml file
   306         result = eds_utils.GenerateNode(filepath, self.ScriptDirectory)
   306         result = eds_utils.GenerateNode(filepath, self.ScriptDirectory)
   307         if isinstance(result, Node):
   307         if isinstance(result, Node):
   308             self.CurrentNode = result
   308             self.CurrentNode = result
   309             index = self.AddNodeBuffer()
   309             index = self.AddNodeBuffer(self.CurrentNode.Copy(), False)
   310             self.SetCurrentFilePath("")
   310             self.SetCurrentFilePath("")
   311             self.BufferCurrentNode()
       
   312             return index
   311             return index
   313         else:
   312         else:
   314             return result
   313             return result
   315     
   314     
   316     """
   315     """
   594             entry_infos = self.GetEntryInfos(index)
   593             entry_infos = self.GetEntryInfos(index)
   595             if "callback" not in entry_infos:
   594             if "callback" not in entry_infos:
   596                 self.CurrentNode.SetParamsEntry(index, None, callback = value)
   595                 self.CurrentNode.SetParamsEntry(index, None, callback = value)
   597                 self.BufferCurrentNode()
   596                 self.BufferCurrentNode()
   598 
   597 
   599     def ResetCurrentDefaultValue(self, index, subIndex):
       
   600         subentry_infos = self.GetSubentryInfos(index, subIndex)
       
   601         if "default" in subentry_infos:
       
   602             default = subentry_infos["default"]
       
   603         else:
       
   604             default = self.GetTypeDefaultValue(subentry_infos["type"])
       
   605         self.CurrentNode.SetEntry(index, subIndex, default)
       
   606         
       
   607 
       
   608     def SetCurrentEntry(self, index, subIndex, value, name, editor):
   598     def SetCurrentEntry(self, index, subIndex, value, name, editor):
   609         if self.CurrentNode and self.CurrentNode.IsEntry(index):
   599         if self.CurrentNode and self.CurrentNode.IsEntry(index):
   610             if name == "value":
   600             if name == "value":
   611                 if editor == None:
   601                 if editor == "map":
   612                     self.CurrentNode.SetEntry(index, subIndex, value)
       
   613                 elif editor == "map":
       
   614                     value = self.CurrentNode.GetMapValue(value)
   602                     value = self.CurrentNode.GetMapValue(value)
   615                     if value:
   603                     if value:
   616                         self.CurrentNode.SetEntry(index, subIndex, value)
   604                         self.CurrentNode.SetEntry(index, subIndex, value)
   617                 elif editor == "bool":
   605                 elif editor == "bool":
   618                     value = value == "True"
   606                     value = value == "True"
   750         self.FilePaths.pop(index)
   738         self.FilePaths.pop(index)
   751         self.FileNames.pop(index)
   739         self.FileNames.pop(index)
   752     
   740     
   753     def GetCurrentNodeIndex(self):
   741     def GetCurrentNodeIndex(self):
   754         return self.NodeIndex
   742         return self.NodeIndex
   755     
       
   756     def GetCurrentNode(self):
       
   757         if self.NodeIndex:
       
   758             return self.CurrentNode
       
   759         return None
       
   760     
   743     
   761     def GetCurrentFilename(self):
   744     def GetCurrentFilename(self):
   762         return self.GetFilename(self.NodeIndex)
   745         return self.GetFilename(self.NodeIndex)
   763     
   746     
   764     def GetAllFilenames(self):
   747     def GetAllFilenames(self):