SearchResultPanel.py
changeset 576 3f2024f30553
parent 574 8c525217ef1f
child 581 c2d96ea9c14a
equal deleted inserted replaced
575:a7c706b9492e 576:3f2024f30553
    30 from PLCControler import *
    30 from PLCControler import *
    31 
    31 
    32 CWD = os.path.split(os.path.realpath(__file__))[0]
    32 CWD = os.path.split(os.path.realpath(__file__))[0]
    33 
    33 
    34 def GenerateName(infos):
    34 def GenerateName(infos):
    35     if infos[0] in ["input", "output"]:
    35     if infos[0] in ["input", "output", "value"]:
    36         return "%s %d:" % (infos[0], infos[1])
    36         return "%s %d:" % (infos[0], infos[1])
       
    37     elif infos[0] == "range":
       
    38         return "%s %d %s" % (infos[0], infos[1], infos[2])
       
    39     elif infos[0] == "struct":
       
    40         return "element %d %s" % (infos[1], infos[2])
    37     return "%s:" % infos[0]
    41     return "%s:" % infos[0]
    38 
    42 
    39 #-------------------------------------------------------------------------------
    43 #-------------------------------------------------------------------------------
    40 #                            Search Result Panel
    44 #                            Search Result Panel
    41 #-------------------------------------------------------------------------------
    45 #-------------------------------------------------------------------------------
   189                                  "text": None,
   193                                  "text": None,
   190                                  "matches": len(results)}
   194                                  "matches": len(results)}
   191                 
   195                 
   192                 children = element_infos.setdefault("children", [])
   196                 children = element_infos.setdefault("children", [])
   193                 for infos, start, end, text in results:
   197                 for infos, start, end, text in results:
   194                     child_type = infos[1]
   198                     if element_type == ITEM_DATATYPE:
   195                     if child_type == "body":
   199                         child_name = GenerateName(infos[1:])
   196                         child_name = "body"
   200                         child_type = element_type
   197                         if element_type == ITEM_TRANSITION:
   201                     else:
   198                             child_type = self.ParentWindow.Controler.GetTransitionBodyType(words[1], words[2])
   202                         child_type = infos[1]
   199                         elif element_type == ITEM_ACTION:
   203                         if child_type == "body":
   200                             child_type = self.ParentWindow.Controler.GetActionBodyType(words[1], words[2])
   204                             child_name = "body"
       
   205                             if element_type == ITEM_TRANSITION:
       
   206                                 child_type = self.ParentWindow.Controler.GetTransitionBodyType(words[1], words[2])
       
   207                             elif element_type == ITEM_ACTION:
       
   208                                 child_type = self.ParentWindow.Controler.GetActionBodyType(words[1], words[2])
       
   209                             else:
       
   210                                 child_type = self.ParentWindow.Controler.GetPouBodyType(words[1])
   201                         else:
   211                         else:
   202                             child_type = self.ParentWindow.Controler.GetPouBodyType(words[1])
   212                             child_name = GenerateName(infos[3:])
   203                     else:
       
   204                         child_name = GenerateName(infos[3:])
       
   205                     child_infos = {"name": child_name,
   213                     child_infos = {"name": child_name,
   206                                    "type": child_type,
   214                                    "type": child_type,
   207                                    "data": (infos, start, end ,None),
   215                                    "data": (infos, start, end ,None),
   208                                    "text": text,
   216                                    "text": text,
   209                                    "matches": 1,
   217                                    "matches": 1,