1 #!/usr/bin/env python |
1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- |
2 # -*- coding: utf-8 -*- |
3 |
3 |
4 #This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
4 # This file is part of Beremiz, a Integrated Development Environment for |
5 #based on the plcopen standard. |
5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
6 # |
6 # |
7 #Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
8 # |
8 # |
9 #See COPYING file for copyrights details. |
9 # See COPYING file for copyrights details. |
10 # |
10 # |
11 #This library is free software; you can redistribute it and/or |
11 # This program is free software; you can redistribute it and/or |
12 #modify it under the terms of the GNU General Public |
12 # modify it under the terms of the GNU General Public License |
13 #License as published by the Free Software Foundation; either |
13 # as published by the Free Software Foundation; either version 2 |
14 #version 2.1 of the License, or (at your option) any later version. |
14 # of the License, or (at your option) any later version. |
15 # |
15 # |
16 #This library is distributed in the hope that it will be useful, |
16 # This program is distributed in the hope that it will be useful, |
17 #but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 #General Public License for more details. |
19 # GNU General Public License for more details. |
20 # |
20 # |
21 #You should have received a copy of the GNU General Public |
21 # You should have received a copy of the GNU General Public License |
22 #License along with this library; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 from types import TupleType |
25 from types import TupleType |
26 |
26 |
27 import wx |
27 import wx |
28 import wx.lib.buttons |
28 import wx.lib.buttons |
230 _element_infos["matches"] += len(children) |
230 _element_infos["matches"] += len(children) |
231 _element_infos["children"].append(element_infos) |
231 _element_infos["children"].append(element_infos) |
232 break |
232 break |
233 if element_type == ITEM_RESOURCE: |
233 if element_type == ITEM_RESOURCE: |
234 search_results_tree_children.append(element_infos) |
234 search_results_tree_children.append(element_infos) |
235 else: |
|
236 _tagname = self.ParentWindow.Controler.ComputePouName(words[1]) |
|
237 _element_type = self.ParentWindow.Controler.GetPouType(words[1]) |
|
238 |
|
239 _element_infos = {"name": words[1], |
|
240 "type": _element_type, |
|
241 "data": _tagname, |
|
242 "text": None, |
|
243 "matches": 1, |
|
244 "children": [element_infos]} |
|
245 |
|
246 search_results_tree_children.append(_element_infos) |
|
247 |
|
248 else: |
235 else: |
249 search_results_tree_children.append(element_infos) |
236 search_results_tree_children.append(element_infos) |
250 |
237 |
251 if matches_number < 2: |
238 if matches_number < 2: |
252 header_format = _("'%s' - %d match in project") |
239 header_format = _("'{a1}' - {a2} match in project") |
253 else: |
240 else: |
254 header_format = _("'%s' - %d matches in project") |
241 header_format = _("'{a1}' - {a2} matches in project") |
255 |
242 |
256 self.HeaderLabel.SetLabel(header_format % (self.Criteria["raw_pattern"], matches_number)) |
243 self.HeaderLabel.SetLabel(header_format.format(a1 = self.Criteria["find_pattern"], a2 = matches_number)) |
257 self.ResetButton.Enable(True) |
244 self.ResetButton.Enable(True) |
258 |
245 |
259 if matches_number > 0: |
246 if matches_number > 0: |
260 root = self.SearchResultsTree.GetRootItem() |
247 root = self.SearchResultsTree.GetRootItem() |
261 if root is None: |
248 if root is None: |
335 data = self.SearchResultsTree.GetPyData(item) |
322 data = self.SearchResultsTree.GetPyData(item) |
336 if isinstance(data, TupleType): |
323 if isinstance(data, TupleType): |
337 search_results = [data] |
324 search_results = [data] |
338 else: |
325 else: |
339 search_results = self.SearchResults.get(data, []) |
326 search_results = self.SearchResults.get(data, []) |
|
327 self.ParentWindow.ClearHighlights(SEARCH_RESULT_HIGHLIGHT) |
340 for infos, start, end, text in search_results: |
328 for infos, start, end, text in search_results: |
341 self.ParentWindow.ShowSearchResult(infos, start, end) |
329 self.ParentWindow.ShowSearchResult(infos, start, end) |
342 |
330 |
343 def OnSearchResultsTreeItemActivated(self, event): |
331 def OnSearchResultsTreeItemActivated(self, event): |
344 self.ShowSearchResults(event.GetItem()) |
332 self.ShowSearchResults(event.GetItem()) |