128 ("CONFIGURATION", ITEM_CONFIGURATION), |
128 ("CONFIGURATION", ITEM_CONFIGURATION), |
129 ("RESOURCE", ITEM_RESOURCE), |
129 ("RESOURCE", ITEM_RESOURCE), |
130 ("DATATYPE", ITEM_DATATYPE), |
130 ("DATATYPE", ITEM_DATATYPE), |
131 ("ACTION", "action_block"), |
131 ("ACTION", "action_block"), |
132 ("IL", "IL"), |
132 ("IL", "IL"), |
133 ("ST", "ST")]: |
133 ("ST", "ST"), |
|
134 ("FILE", ITEM_CONFNODE), |
|
135 ]: |
134 self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
136 self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
135 |
137 |
136 for itemtype in ["function", "functionBlock", "program", |
138 for itemtype in ["function", "functionBlock", "program", |
137 "comment", "block", "io_variable", |
139 "comment", "block", "io_variable", |
138 "connector", "contact", "coil", |
140 "connector", "contact", "coil", |
200 "text": None, |
202 "text": None, |
201 "matches": len(results)} |
203 "matches": len(results)} |
202 |
204 |
203 children = element_infos.setdefault("children", []) |
205 children = element_infos.setdefault("children", []) |
204 for infos, start, end, text in results: |
206 for infos, start, end, text in results: |
205 if infos[1] == "name" or element_type == ITEM_DATATYPE: |
207 if len(words) == 1: # CTN match |
|
208 child_name = {"body":str(start[0])+":", |
|
209 "var_inout":_("Variable:")}[infos[1]] |
|
210 child_type = {"body":ITEM_CONFNODE, |
|
211 "var_inout":"var_inout"}[infos[1]] |
|
212 elif infos[1] == "name" or element_type == ITEM_DATATYPE: |
206 child_name = GenerateName(infos[1:]) |
213 child_name = GenerateName(infos[1:]) |
207 child_type = element_type |
214 child_type = element_type |
208 else: |
215 else: |
209 if element_type == ITEM_RESOURCE: |
216 if element_type == ITEM_RESOURCE: |
210 child_type = element_type |
217 child_type = element_type |
230 "matches": 1, |
237 "matches": 1, |
231 "children": [], |
238 "children": [], |
232 } |
239 } |
233 children.append(child_infos) |
240 children.append(child_infos) |
234 |
241 |
|
242 # not Project node |
235 if len(words) > 2: |
243 if len(words) > 2: |
236 for _element_infos in search_results_tree_children: |
244 for _element_infos in search_results_tree_children: |
237 if _element_infos["name"] == words[1]: |
245 if _element_infos["name"] == words[1]: |
238 _element_infos["matches"] += len(children) |
246 _element_infos["matches"] += len(children) |
239 _element_infos["children"].append(element_infos) |
247 _element_infos["children"].append(element_infos) |
240 break |
248 break |
241 if element_type == ITEM_RESOURCE: |
249 if element_type == ITEM_RESOURCE: |
242 search_results_tree_children.append(element_infos) |
250 search_results_tree_children.append(element_infos) |
243 else: |
251 else: # Project node or CTN |
244 search_results_tree_children.append(element_infos) |
252 search_results_tree_children.append(element_infos) |
245 |
253 |
246 if matches_number < 2: |
254 if matches_number < 2: |
247 header_format = _("'{a1}' - {a2} match in project") |
255 header_format = _("'{a1}' - {a2} match in project") |
248 else: |
256 else: |
300 style = wx.TextAttr(wx.Colour(0, 127, 174)) |
308 style = wx.TextAttr(wx.Colour(0, 127, 174)) |
301 |
309 |
302 if text is not None: |
310 if text is not None: |
303 text_ctrl_style = wx.BORDER_NONE | wx.TE_READONLY | wx.TE_RICH2 |
311 text_ctrl_style = wx.BORDER_NONE | wx.TE_READONLY | wx.TE_RICH2 |
304 if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1: |
312 if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1: |
305 text_ctrl_style |= wx.TE_MULTILINE |
313 text_ctrl_style |= wx.TE_MULTILINE | wx.TE_NO_VSCROLL |
306 text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), |
314 text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), |
307 value=text, style=text_ctrl_style) |
315 value=text, style=text_ctrl_style) |
308 width, height = text_ctrl.GetTextExtent(text) |
316 width, height = text_ctrl.GetTextExtent(text) |
309 text_ctrl.SetClientSize(wx.Size(width + 1, height)) |
317 text_ctrl.SetClientSize(wx.Size(width + 1, height)) |
310 text_ctrl.SetBackgroundColour(self.SearchResultsTree.GetBackgroundColour()) |
318 text_ctrl.SetBackgroundColour(self.SearchResultsTree.GetBackgroundColour()) |