16 from functools
import (total_ordering, cmp_to_key)
21 from ..utils
import overrides
22 from ..widgets
import (RIDEDialog, VerticalSizer, VirtualList, Label,
23 HelpLabel, ImageProvider)
24 from ..widgets.list
import ListModel
29 def __init__(self, fuzzy_search_handler, tag_search_handler, add_to_selected_handler):
34 title =
"Search Tests"
35 RIDEDialog.__init__(self, title=title, size=(800, 400))
37 self.SetLayoutDirection(wx.Layout_LeftToRight)
38 self.SetBackgroundColour(Colour(self.color_background))
39 self.SetForegroundColour(Colour(self.color_foreground))
40 self.SetSizer(VerticalSizer())
41 self.Sizer.Add(self.
_create_notebook_create_notebook(), 1, wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, 3)
44 self.
_notebook_notebook = wx.Notebook(self, wx.ID_ANY, style=wx.NB_TOP)
45 self.
_notebook_notebook.SetBackgroundColour(Colour(self.color_background))
46 self.
_notebook_notebook.SetForegroundColour(Colour(self.color_foreground))
52 self.
_notebook_notebook.ChangeSelection(page)
56 panel.SetSizer(VerticalSizer())
59 self.
tests_listtests_list = VirtualList(panel, [
'Test',
'Tags',
'Source'], self.
teststests)
60 self.
tests_listtests_list.SetBackgroundColour(Colour(self.color_secondary_background))
61 self.
tests_listtests_list.SetForegroundColour(Colour(self.color_secondary_foreground))
63 panel.Sizer.add_expanding(self.
tests_listtests_list)
70 panel.SetSizer(VerticalSizer())
71 tags_controls_sizer = VerticalSizer()
75 controls_sizer.Add(tags_controls_sizer)
79 panel.Sizer.Add(controls_sizer)
80 panel.Sizer.Add(self.
_add_info_text_add_info_text(panel,
"Find matches using tag patterns. See RF User "
81 "Guide or 'robot --help' for more information.")
85 self.
_tags_list_tags_list.SetBackgroundColour(Colour(self.color_secondary_background))
86 self.
_tags_list_tags_list.SetForegroundColour(Colour(self.color_secondary_foreground))
88 panel.Sizer.add_expanding(self.
_tags_list_tags_list)
95 include_line.Add(Label(panel, label=
'Include', size=(80, -1)))
97 style=wx.TE_PROCESS_ENTER|wx.TE_NOHIDESEL)
98 self.
_tags_to_include_text_tags_to_include_text.SetBackgroundColour(Colour(self.color_secondary_background))
99 self.
_tags_to_include_text_tags_to_include_text.SetForegroundColour(Colour(self.color_secondary_foreground))
106 img = ImageProvider().SWITCH_FIELDS_ICON
107 button = wx.BitmapButton(panel, -1, img, pos=(10, 20))
108 button.SetBackgroundColour(Colour(self.color_secondary_background))
109 button.SetForegroundColour(Colour(self.color_secondary_foreground))
110 self.Bind(wx.EVT_BUTTON, self.
OnSwitchFieldsOnSwitchFields, button)
116 exclude_line.Add(Label(panel, label=
'Exclude', size=(80, -1)))
118 style=wx.TE_PROCESS_ENTER|wx.TE_NOHIDESEL)
119 self.
_tags_to_exclude_text_tags_to_exclude_text.SetBackgroundColour(Colour(self.color_secondary_background))
120 self.
_tags_to_exclude_text_tags_to_exclude_text.SetForegroundColour(Colour(self.color_secondary_foreground))
126 button = wx.Button(panel, label=
'Search')
127 button.SetBackgroundColour(Colour(self.color_secondary_background))
128 button.SetForegroundColour(Colour(self.color_secondary_foreground))
129 button.Bind(wx.EVT_BUTTON, self.
OnSearchTagsOnSearchTags)
137 button = wx.Button(panel, label=
'Add all to selected')
138 button.SetBackgroundColour(Colour(self.color_secondary_background))
139 button.SetForegroundColour(Colour(self.color_secondary_foreground))
150 results = list(results)
153 self.
teststests._tests = results
157 results = list(results)
167 if list.GetItemCount():
168 list._inform_listeners(0)
172 infopanel.Add(HelpLabel(panel,
"Info. " + text))
176 panel.SetSizer(VerticalSizer())
179 fuzzy_search_button = wx.Button(panel, label=
'Search')
180 fuzzy_search_button.SetBackgroundColour(Colour(self.color_secondary_background))
181 fuzzy_search_button.SetForegroundColour(Colour(self.color_secondary_foreground))
182 fuzzy_search_button.Bind(wx.EVT_BUTTON, self.
OnSearchTestsOnSearchTests)
183 line1.Add(fuzzy_search_button, 0, wx.ALL | wx.EXPAND, 3)
184 add_to_selection_button = wx.Button(panel, label=
'Add all to selected')
185 add_to_selection_button.SetBackgroundColour(Colour(self.color_secondary_background))
186 add_to_selection_button.SetForegroundColour(Colour(self.color_secondary_foreground))
187 add_to_selection_button.Bind(wx.EVT_BUTTON, self.
OnAddToSelectedOnAddToSelected)
188 line1.Add(add_to_selection_button, 0, wx.ALL | wx.EXPAND, 3)
189 panel.Sizer.Add(line1, 0, wx.ALL, 3)
190 panel.Sizer.Add(self.
_add_info_text_add_info_text(panel,
"Find matches by test name, "
191 "documentation and/or tag."), 0, wx.ALL, 3)
195 return wx.BoxSizer(wx.HORIZONTAL)
198 return wx.BoxSizer(wx.VERTICAL)
202 style=wx.TE_PROCESS_ENTER)
203 self.
_search_control_search_control.SetBackgroundColour(Colour(self.color_secondary_background))
204 self.
_search_control_search_control.SetForegroundColour(Colour(self.color_secondary_foreground))
213 listener(self.
teststests[idx])
233 if self.
_notebook_notebook.GetSelection() == 0:
239 if self.
_notebook_notebook.GetSelection() == 0:
240 return [t
for t, _
in self.
teststests._tests]
242 return [test
for test, _
in self.
_tags_results_tags_results._tests]
245 if self.
teststests.count:
262 if len(include_txt.strip()) > 0
or len(exclude_txt.strip()) > 0:
272 self.
_tests_tests = sorted(tests, key=cmp_to_key(
lambda x, y: self.
m_cmpm_cmp(x[1], y[1])))
275 @overrides(ListModel)
279 return len(self.
_tests_tests)
282 return self.
_tests_tests[item]
285 test, match = self.
_tests_tests[row]
289 return u', '.join(str(t)
for t
in test.tags)
290 return test.datafile_controller.longname
294 return (a > b) - (a < b)
297 return self.__class__.__name__.lower() == other.name.lower()
300 return hash(repr(self))
303 return self.__class__.__name__.lower() < other.name.lower()
def _select_text_search_result(self, idx)
def _create_include_line(self, panel)
def _get_current_tests(self)
def _select_page(self, page=0)
def __init__(self, fuzzy_search_handler, tag_search_handler, add_to_selected_handler)
def _set_focus_to_default_location_in_text_search(self, selected)
def _create_add_to_selected_button(self, panel)
def set_search_model(self, search_text, results)
def _text_search_panel(self)
def add_selection_listener(self, listener)
def OnSwitchFields(self, event)
def set_tag_search_model(self, include_text, exclude_text, results)
def _vertical_sizer(self)
def _create_tag_search_button(self, panel)
def OnAddToSelected(self, event)
def _set_focus_to_default_location_in_tag_search(self, selected)
def _add_search_control(self, panel)
def _select_tag_search_result(self, idx)
def _create_notebook(self)
def _create_switch_button(self, panel)
def OnSearchTests(self, event)
def _find_index_in_list(self, item, list)
def _create_exclude_line(self, panel)
def _horizontal_sizer(self)
def _add_info_text(self, panel, text="")
def OnSearchTags(self, event)
def _refresh_list(self, list)
def _add_pattern_filter(self, sizer, parent)
def _tag_pattern_search_panel(self)
def set_focus_to_default_location(self, selected=None)
def __getitem__(self, item)
def item_text(self, row, col)
def __init__(self, tests)