controls/SearchResultPanel.py
branchsearch_in_CTN
changeset 2524 c80b0d864475
parent 2456 7373e3048167
child 2525 9812b332f350
--- a/controls/SearchResultPanel.py	Fri Mar 15 14:11:49 2019 +0100
+++ b/controls/SearchResultPanel.py	Wed Mar 20 11:34:41 2019 +0100
@@ -29,6 +29,7 @@
 import wx
 import wx.lib.buttons
 import wx.lib.agw.customtreectrl as CT
+from pprint import pprint
 
 from PLCControler import *
 from util.BitmapLibrary import GetBitmap
@@ -130,7 +131,9 @@
                 ("DATATYPE",       ITEM_DATATYPE),
                 ("ACTION",         "action_block"),
                 ("IL",             "IL"),
-                ("ST",             "ST")]:
+                ("ST",             "ST"),
+                ("FILE",           ITEM_CONFNODE),
+                ]:
             self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname))
 
         for itemtype in ["function", "functionBlock", "program",
@@ -202,7 +205,12 @@
 
                 children = element_infos.setdefault("children", [])
                 for infos, start, end, text in results:
-                    if infos[1] == "name" or element_type == ITEM_DATATYPE:
+                    if len(words) == 1:  # CTN match
+                        child_name = {"body":str(start[0])+":",
+                                      "variable":_("Variable:")}[infos[1]]
+                        child_type = {"body":ITEM_CONFNODE,
+                                      "variable":"var_inout"}[infos[1]]
+                    elif infos[1] == "name" or element_type == ITEM_DATATYPE:
                         child_name = GenerateName(infos[1:])
                         child_type = element_type
                     else:
@@ -232,6 +240,7 @@
                     }
                     children.append(child_infos)
 
+                # not Project node
                 if len(words) > 2:
                     for _element_infos in search_results_tree_children:
                         if _element_infos["name"] == words[1]:
@@ -240,7 +249,7 @@
                             break
                     if element_type == ITEM_RESOURCE:
                         search_results_tree_children.append(element_infos)
-                else:
+                else:  # Project node or CTN
                     search_results_tree_children.append(element_infos)
 
             if matches_number < 2:
@@ -287,6 +296,8 @@
                 self.SearchResultsTree.SetItemImage(root, self.TreeImageDict[infos["type"]])
 
         text = None
+        print("XXXXXXXXXXXXXX")
+        pprint(infos)
         if infos["text"] is not None:
             text = infos["text"]
             start, end = infos["data"][1:3]
@@ -302,7 +313,7 @@
         if text is not None:
             text_ctrl_style = wx.BORDER_NONE | wx.TE_READONLY | wx.TE_RICH2
             if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1:
-                text_ctrl_style |= wx.TE_MULTILINE
+                text_ctrl_style |= wx.TE_MULTILINE | wx.TE_NO_VSCROLL
             text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0),
                                     value=text, style=text_ctrl_style)
             width, height = text_ctrl.GetTextExtent(text)