author | Laurent Bessard |
Wed, 18 Jul 2012 01:02:08 +0200 | |
changeset 728 | ce36d704184b |
parent 714 | 131ea7f237b9 |
child 737 | 85a4bc7dc31e |
permissions | -rw-r--r-- |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
3 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
5 |
#based on the plcopen standard. |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
6 |
# |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
8 |
# |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
9 |
#See COPYING file for copyrights details. |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
10 |
# |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
11 |
#This library is free software; you can redistribute it and/or |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
12 |
#modify it under the terms of the GNU General Public |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
13 |
#License as published by the Free Software Foundation; either |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
15 |
# |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
16 |
#This library is distributed in the hope that it will be useful, |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
19 |
#General Public License for more details. |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
20 |
# |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
21 |
#You should have received a copy of the GNU General Public |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
22 |
#License along with this library; if not, write to the Free Software |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
24 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
25 |
import re |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
26 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
27 |
import wx |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
28 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
29 |
RE_ESCAPED_CHARACTERS = ".*+()[]?:|{}^$<>=-," |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
30 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
31 |
def EscapeText(text): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
32 |
text = text.replace('\\', '\\\\') |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
33 |
for c in RE_ESCAPED_CHARACTERS: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
34 |
text = text.replace(c, '\\' + c) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
35 |
return text |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
36 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
37 |
#------------------------------------------------------------------------------- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
38 |
# Search In Project Dialog |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
39 |
#------------------------------------------------------------------------------- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
40 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
41 |
def GetElementsChoices(): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
42 |
_ = lambda x: x |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
43 |
return [("datatype", _("Data Type")), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
44 |
("function", _("Function")), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
45 |
("functionBlock", _("Function Block")), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
46 |
("program", _("Program")), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
47 |
("configuration", _("Configuration"))] |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
48 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
49 |
class SearchInProjectDialog(wx.Dialog): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
50 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
51 |
def __init__(self, parent): |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
52 |
wx.Dialog.__init__(self, parent, title=_('Search in Project'), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
53 |
size=wx.Size(600, 300), style=wx.DEFAULT_DIALOG_STYLE| |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
54 |
wx.RESIZE_BORDER) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
55 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
56 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
57 |
main_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
58 |
main_sizer.AddGrowableRow(1) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
59 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
60 |
pattern_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
61 |
pattern_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
62 |
main_sizer.AddSizer(pattern_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
63 |
flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
64 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
65 |
pattern_label = wx.StaticText(self, label=_('Pattern to search:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
66 |
pattern_sizer.AddWindow(pattern_label, flag=wx.ALIGN_BOTTOM) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
67 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
68 |
self.CaseSensitive = wx.CheckBox(self, label=_('Case sensitive')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
69 |
pattern_sizer.AddWindow(self.CaseSensitive, flag=wx.GROW) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
70 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
71 |
self.Pattern = wx.TextCtrl(self, size=wx.Size(0, 24)) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
72 |
pattern_sizer.AddWindow(self.Pattern, flag=wx.GROW) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
73 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
74 |
self.RegularExpression = wx.CheckBox(self, label=_('Regular expression')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
75 |
pattern_sizer.AddWindow(self.RegularExpression, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
76 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
77 |
scope_staticbox = wx.StaticBox(self, label=_('Scope')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
78 |
scope_sizer = wx.StaticBoxSizer(scope_staticbox, wx.HORIZONTAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
79 |
main_sizer.AddSizer(scope_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
80 |
flag=wx.GROW|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
81 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
82 |
scope_selection_sizer = wx.BoxSizer(wx.VERTICAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
83 |
scope_sizer.AddSizer(scope_selection_sizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
84 |
flag=wx.GROW|wx.TOP|wx.LEFT|wx.BOTTOM) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
85 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
86 |
self.WholeProject = wx.RadioButton(self, label=_('Whole Project'), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
87 |
size=wx.Size(0, 24), style=wx.RB_GROUP) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
88 |
self.WholeProject.SetValue(True) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
89 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, self.WholeProject) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
90 |
scope_selection_sizer.AddWindow(self.WholeProject, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
91 |
flag=wx.GROW|wx.BOTTOM) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
92 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
93 |
self.OnlyElements = wx.RadioButton(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
94 |
label=_('Only Elements'), size=wx.Size(0, 24)) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
95 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, self.OnlyElements) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
96 |
self.OnlyElements.SetValue(False) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
97 |
scope_selection_sizer.AddWindow(self.OnlyElements, flag=wx.GROW) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
98 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
99 |
self.ElementsList = wx.CheckListBox(self) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
100 |
self.ElementsList.Enable(False) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
101 |
scope_sizer.AddWindow(self.ElementsList, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
102 |
flag=wx.GROW|wx.TOP|wx.RIGHT|wx.BOTTOM) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
103 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
104 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
105 |
ok_button = self.ButtonSizer.GetAffirmativeButton() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
106 |
ok_button.SetLabel(_('Search')) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
107 |
self.Bind(wx.EVT_BUTTON, self.OnOK, ok_button) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
108 |
main_sizer.AddSizer(self.ButtonSizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
109 |
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
110 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
111 |
self.SetSizer(main_sizer) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
112 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
113 |
for name, label in GetElementsChoices(): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
114 |
self.ElementsList.Append(_(label)) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
571
diff
changeset
|
115 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
571
diff
changeset
|
116 |
self.Pattern.SetFocus() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
117 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
118 |
def GetCriteria(self): |
571 | 119 |
raw_pattern = pattern = self.Pattern.GetValue() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
120 |
if not self.CaseSensitive.GetValue(): |
571 | 121 |
pattern = pattern.upper() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
122 |
if not self.RegularExpression.GetValue(): |
571 | 123 |
pattern = EscapeText(pattern) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
124 |
criteria = { |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
125 |
"raw_pattern": raw_pattern, |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
126 |
"pattern": re.compile(pattern), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
127 |
"case_sensitive": self.CaseSensitive.GetValue(), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
128 |
"regular_expression": self.RegularExpression.GetValue(), |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
129 |
} |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
130 |
if self.WholeProject.GetValue(): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
131 |
criteria["filter"] = "all" |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
132 |
elif self.OnlyElements.GetValue(): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
133 |
criteria["filter"] = [] |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
134 |
for index, (name, label) in enumerate(GetElementsChoices()): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
135 |
if self.ElementsList.IsChecked(index): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
136 |
criteria["filter"].append(name) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
137 |
return criteria |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
138 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
139 |
def OnScopeChanged(self, event): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
140 |
self.ElementsList.Enable(self.OnlyElements.GetValue()) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
141 |
event.Skip() |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
142 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
143 |
def OnOK(self, event): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
144 |
if self.Pattern.GetValue() == "": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
145 |
message = _("Form isn't complete. Pattern to search must be filled!") |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
146 |
else: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
147 |
wrong_pattern = False |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
148 |
if self.RegularExpression.GetValue(): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
149 |
try: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
150 |
re.compile(self.Pattern.GetValue()) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
151 |
except: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
152 |
wrong_pattern = True |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
diff
changeset
|
153 |
if wrong_pattern: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
154 |
message = _("Syntax error in regular expression of pattern to search!") |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
155 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
156 |
if message is not None: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
157 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
158 |
dialog.ShowModal() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
159 |
dialog.Destroy() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
160 |
else: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
161 |
self.EndModal(wx.ID_OK) |