Robot Framework Integrated Development Environment (RIDE)
settingeditors.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 import wx
17 from wx import Colour
18 
19 from .editordialogs import EditorDialog, DocumentationDialog, MetadataDialog, \
20  ScalarVariableDialog, ListVariableDialog, DictionaryVariableDialog, LibraryDialog, \
21  ResourceDialog, VariablesDialog
22 from .formatters import ListToStringFormatter
23 from .gridcolorizer import ColorizationSettings
24 from .listeditor import ListEditor
25 from .popupwindow import HtmlPopupWindow
26 from .tags import TagsDisplay
27 from .. import context
28 from .. import utils
29 from ..controller import ctrlcommands
30 # import UpdateVariable, UpdateDocumentation, SetValues, AddLibrary, AddResource, AddVariablesFileImport, ClearSetting
31 from ..editor.listeditor import ListEditorBase
32 from ..publish import PUBLISHER
33 from ..publish.messages import (RideImportSetting, RideOpenVariableDialog, RideExecuteSpecXmlImport, RideSaving,
34  RideVariableAdded, RideVariableUpdated, RideVariableRemoved)
35 from ..utils import overrides
36 from ..utils.highlightmatcher import highlight_matcher
37 from ..widgets import ButtonWithHandler, Label, HtmlWindow, PopupMenu, PopupMenuItems, HtmlDialog
38 
39 
40 class SettingEditor(wx.Panel):
41 
42  def __init__(self, parent, controller, plugin, tree):
43  wx.Panel.__init__(self, parent)
44  from ..preferences import RideSettings
45 
48  _settings = RideSettings()
49  self.general_settingsgeneral_settings = _settings['General']
50  self.color_backgroundcolor_background = self.general_settingsgeneral_settings.get('background', 'light grey')
51  self.color_foregroundcolor_foreground = self.general_settingsgeneral_settings.get('foreground', 'black')
52  self.color_secondary_backgroundcolor_secondary_background = self.general_settingsgeneral_settings.get('secondary background', 'light grey')
53  self.color_secondary_foregroundcolor_secondary_foreground = self.general_settingsgeneral_settings.get('secondary foreground', 'black')
54  self.color_background_helpcolor_background_help = self.general_settingsgeneral_settings.get('background help', (240, 242, 80))
55  self.color_foreground_textcolor_foreground_text = self.general_settingsgeneral_settings.get('foreground text', (7, 0, 70))
56  self.font_facefont_face = self.general_settingsgeneral_settings.get('font face', '')
57  self.font_sizefont_size = self.general_settingsgeneral_settings.get('font size', 11)
58  self.SetBackgroundColour(Colour(self.color_backgroundcolor_background))
59  self.SetOwnBackgroundColour(Colour(self.color_backgroundcolor_background))
60  self.SetForegroundColour(Colour(self.color_foregroundcolor_foreground))
61  self.SetOwnForegroundColour(Colour(self.color_foregroundcolor_foreground))
62  self._controller_controller = controller
63  self.pluginplugin = plugin
64  self._datafile_datafile = controller.datafile
65  self._create_controls_create_controls()
66  self._tree_tree = tree
67  self._editing_editing = False
68  self.fontfont = self._tree_tree.GetFont()
69  self.fontfont.SetFaceName(self.font_facefont_face)
70  self.fontfont.SetPointSize(self.font_sizefont_size)
71  self._tree_tree.SetFont(self.fontfont)
72  self._tree_tree.Refresh()
73  self.pluginplugin.subscribe(self._ps_on_update_value_ps_on_update_value, RideImportSetting)
74 
75  def _create_controls(self):
76  sizer = wx.BoxSizer(wx.HORIZONTAL)
77  sizer.Add((5, 0))
78  sizer.Add(Label(
79  self, label=self._controller_controller.label,
80  size=(context.SETTING_LABEL_WIDTH, context.SETTING_ROW_HEIGHT)))
81  self._value_display_value_display = self._create_value_display_create_value_display()
82  self.update_valueupdate_value()
83  self._tooltip_tooltip = self._get_tooltip_get_tooltip()
84  sizer.Add(self._value_display_value_display, 1, wx.EXPAND)
85  self._add_edit_add_edit(sizer)
86  sizer.Add(ButtonWithHandler(self, 'Clear', color_secondary_foreground=self.color_secondary_foregroundcolor_secondary_foreground,
87  color_secondary_background=self.color_secondary_backgroundcolor_secondary_background))
88  sizer.Layout()
89  self.SetSizer(sizer)
90 
91  def _add_edit(self, sizer):
92  sizer.Add(
93  ButtonWithHandler(self, 'Edit', color_secondary_foreground=self.color_secondary_foregroundcolor_secondary_foreground,
94  color_secondary_background=self.color_secondary_backgroundcolor_secondary_background),
95  flag=wx.LEFT | wx.RIGHT, border=5)
96 
98  display = self._value_display_control_value_display_control()
99  display.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindowOnEnterWindow)
100  display.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindowOnLeaveWindow)
101  display.Bind(wx.EVT_WINDOW_DESTROY, self.OnWindowDestroyOnWindowDestroy)
102  display.Bind(wx.EVT_MOTION, self.OnDisplayMotionOnDisplayMotion)
103  return display
104 
106  ctrl = SettingValueDisplay(self)
107  ctrl.Bind(wx.EVT_LEFT_UP, self.OnLeftUpOnLeftUp)
108  ctrl.Bind(wx.EVT_KEY_DOWN, self.OnKeyOnKey)
109  return ctrl
110 
111  def _get_tooltip(self):
112  return HtmlPopupWindow(self, (500, 350))
113 
114  def OnKey(self, event):
115  try:
116  self._tooltip_tooltip.hide()
117  except AttributeError:
118  pass
119  event.Skip()
120 
121  def OnDisplayMotion(self, event):
122  try:
123  self._tooltip_tooltip.hide()
124  except AttributeError:
125  pass
126 
127  def refresh(self, controller):
128  self._controller_controller = controller
129  self.update_valueupdate_value()
130 
131  def refresh_datafile(self, item, event):
132  self._tree_tree.refresh_datafile(item, event)
133 
134  def OnEdit(self, event=None):
135  self._hide_tooltip_hide_tooltip()
136  self._editing_editing = True
137  dlg = self._create_editor_dialog_create_editor_dialog()
138  if dlg.ShowModal() == wx.ID_OK:
139  self._set_value_set_value(dlg.get_value(), dlg.get_comment())
140  self._update_and_notify_update_and_notify()
141  dlg.Destroy()
142  self._editing_editing = False
143 
145  dlg_class = EditorDialog(self._controller_controller)
146  return dlg_class(self._datafile_datafile, self._controller_controller, self.pluginplugin)
147 
148  def _set_value(self, value_list, comment):
149  self._controller_controller.execute(ctrlcommands.SetValues(value_list, comment))
150 
151  def _hide_tooltip(self):
152  self._stop_popup_timer_stop_popup_timer()
153  try:
154  self._tooltip_tooltip.hide()
155  except AttributeError:
156  pass
157 
158  def _stop_popup_timer(self):
159  if hasattr(self, 'popup_timer'):
160  self.popup_timerpopup_timer.Stop()
161 
162  def OnEnterWindow(self, event):
163  if self._mainframe_has_focus_mainframe_has_focus():
164  self.popup_timerpopup_timer = wx.CallLater(500, self.OnPopupTimerOnPopupTimer, event)
165 
167  return wx.GetTopLevelParent(self.FindFocus()) == \
168  wx.GetTopLevelParent(self)
169 
170  def OnWindowDestroy(self, event):
171  self._stop_popup_timer_stop_popup_timer()
172  try:
173  self._tooltip_tooltip.hide()
174  except AttributeError:
175  pass
176  event.Skip()
177 
178  def OnLeaveWindow(self, event):
179  self._stop_popup_timer_stop_popup_timer()
180  try:
181  self._tooltip_tooltip.hide()
182  except AttributeError:
183  pass
184  event.Skip()
185 
186  def OnPopupTimer(self, event):
187 
190  _tooltipallowed = False
191  # TODO This prevents tool tip for ex. Template edit field in wxPhoenix
192  try:
193 
196  _tooltipallowed = self.Parent.tooltip_allowed(self._tooltip_tooltip)
197  except AttributeError:
198  # print("DEBUG: There was an attempt to show a Tool Tip.\n")
199  pass
200  if _tooltipallowed:
201  details, title = self._get_details_for_tooltip_get_details_for_tooltip()
202  if details:
203  self._tooltip_tooltip.set_content(details, title)
204  self._tooltip_tooltip.show_at(self._tooltip_position_tooltip_position())
205 
207  kw = self._controller_controller.keyword_name
208  return self.pluginplugin.get_keyword_details(kw), kw
209 
210  def _tooltip_position(self):
211  ms = wx.GetMouseState()
212  # ensure that the popup gets focus immediately
213  return ms.x-3, ms.y-3
214 
215  def OnLeftUp(self, event):
216  if event.ControlDown() or event.CmdDown():
217  self._navigate_to_user_keyword_navigate_to_user_keyword()
218  else:
219  if self._has_selected_area_has_selected_area() and not self._editing_editing:
220  wx.CallAfter(self.OnEditOnEdit, event)
221  event.Skip()
222 
224  selection = self._value_display_value_display.GetSelection()
225  if selection is None:
226  return False
227  return selection[0] == selection[1]
228 
230  uk = self.pluginplugin.get_user_keyword(self._controller_controller.keyword_name)
231  if uk:
232  self._tree_tree.select_user_keyword_node(uk)
233 
235  self.update_valueupdate_value()
236 
237  def OnClear(self, event):
238  self._controller_controller.execute(ctrlcommands.ClearSetting())
239  self._update_and_notify_update_and_notify()
240 
241  def _ps_on_update_value(self, message):
242  self.update_valueupdate_value()
243 
244  def update_value(self):
245  if self._controller_controller is None:
246  return
247  if self._controller_controller.is_set:
248  self._value_display_value_display.set_value(self._controller_controller, self.pluginplugin)
249  else:
250  self._value_display_value_display.clear()
251 
253  return self._controller_controller.datafile_controller
254 
255  def close(self):
256  self._controller_controller = None
257  self.pluginplugin.unsubscribe(self._ps_on_update_value_ps_on_update_value, RideImportSetting)
258 
259  def highlight(self, text):
260  return self._value_display_value_display.highlight(text)
261 
262  def clear_highlight(self):
263  return self._value_display_value_display.clear_highlight()
264 
265  def contains(self, text):
266  return self._value_display_value_display.contains(text)
267 
268 
269 class SettingValueDisplay(wx.TextCtrl):
270 
271  def __init__(self, parent):
272  wx.TextCtrl.__init__(
273  self, parent, size=(-1, context.SETTING_ROW_HEIGHT),
274  style=wx.TE_RICH | wx.TE_MULTILINE | wx.TE_NOHIDESEL)
275  """
276  self.SetBackgroundColour(Colour(200, 222, 40))
277  self.SetOwnBackgroundColour(Colour(200, 222, 40))
278  self.SetForegroundColour(Colour(7, 0, 70))
279  self.SetOwnForegroundColour(Colour(7, 0, 70))
280  """
281  self.color_secondary_backgroundcolor_secondary_background = parent.color_secondary_background
282  self.SetBackgroundColour(Colour(self.color_secondary_backgroundcolor_secondary_background))
283  self.SetEditable(False)
284  self._colour_provider_colour_provider = ColorizationSettings(
285  parent.plugin.global_settings['Grid'])
286  self._empty_values_empty_values()
287 
288  def _empty_values(self):
289  self._value_value = None
290  self._is_user_keyword_is_user_keyword = False
291 
292  def set_value(self, controller, plugin):
293  self._value_value = controller.display_value
294  self._keyword_name_keyword_name = controller.keyword_name
295  try:
296  self._is_user_keyword_is_user_keyword = plugin.is_user_keyword(self._keyword_name_keyword_name)
297  except AttributeError:
298  self._is_user_keyword_is_user_keyword = False
299  self.SetValue(self._value_value)
300  self._colorize_data_colorize_data()
301 
302  def _colorize_data(self, match=None):
303  self._colorize_background_colorize_background(match)
304  self._colorize_possible_user_keyword_colorize_possible_user_keyword()
305 
306  def _colorize_background(self, match=None):
307  self.SetBackgroundColour(self._get_background_colour_get_background_colour(match))
308 
309  def _get_background_colour(self, match=None):
310  if self._value_value is None:
311  return Colour(self.color_secondary_backgroundcolor_secondary_background)
312  if match is not None and self.containscontains(match):
313  return self._colour_provider_colour_provider.get_highlight_color()
314  return Colour(self.color_secondary_backgroundcolor_secondary_background) # 'white' # Colour(200, 222, 40)
315 
317  if not self._is_user_keyword_is_user_keyword:
318  return
319  font = self.GetFont()
320  font.SetUnderlined(True)
321  user_kw_color = self._colour_provider_colour_provider.get_text_color('user keyword')
322  self.SetStyle(0, len(self._keyword_name_keyword_name),
323  wx.TextAttr(user_kw_color, self._get_background_colour_get_background_colour(), font))
324 
325  def clear(self):
326  self.Clear()
327  self._empty_values_empty_values()
328  self._colorize_background_colorize_background()
329 
330  def contains(self, text):
331  if self._value_value is None:
332  return False
333  return [item for item in self._value_value.split(' | ')
334  if highlight_matcher(text, item)] != []
335 
336  def highlight(self, text):
337  self._colorize_data_colorize_data(match=text)
338 
339  def clear_highlight(self):
340  self._colorize_data_colorize_data()
341 
342 
344 
345  def __init__(self, parent, controller, plugin, tree):
346  # print(f"DEBUG: DocumentationEditor parent={parent} controller={controller}")
347  SettingEditor.__init__(self, parent, controller, plugin, tree)
348 
350  ctrl = HtmlWindow(self, (-1, 100), color_background=self.color_secondary_backgroundcolor_secondary_background,
351  color_foreground=self.color_secondary_foregroundcolor_secondary_foreground)
352  ctrl.SetBackgroundColour(Colour(self.color_secondary_backgroundcolor_secondary_background))
353  ctrl.SetForegroundColour(Colour(self.color_secondary_foregroundcolor_secondary_foreground))
354  ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnEditOnEdit)
355  return ctrl
356 
357  def update_value(self):
358  if self._controller_controller:
359  self._value_display_value_display.set_content(self._controller_controller.visible_value)
360 
361  """
362  def _get_tooltip(self):
363  return HtmlPopupWindow(self, (500, 350), detachable=False)
364 
365  def _get_details_for_tooltip(self):
366  return self._controller.visible_value, None
367  """
368 
369  def OnKey(self, event):
370  event.Skip()
371 
372  def OnDisplayMotion(self, event):
373  pass
374 
375  def _hide_tooltip(self):
376  pass
377 
379  return DocumentationDialog(self._datafile,
380  self._controller.editable_value)
381 
382  def _set_value(self, value_list, comment):
383  if value_list:
384  self._controller_controller.execute(ctrlcommands.UpdateDocumentation(value_list[0]))
385 
386  def contains(self, text):
387  return False
388 
389  def highlight(self, text):
390  pass
391 
392  def clear_highlight(self):
393  pass
394 
395 
396 class TagsEditor(SettingEditor):
397 
398  def __init__(self, parent, controller, plugin, tree):
399  SettingEditor.__init__(self, parent, controller, plugin, tree)
400  self.pluginplugin.subscribe(self._saving_saving, RideSaving)
401 
402  def _saving(self, message):
403  self._tags_display_tags_display.saving()
404 
406  self._tags_display_tags_display = TagsDisplay(self, self._controller_controller)
407  self._tags_display_tags_display.Bind(wx.EVT_LEFT_UP, self.OnLeftUpOnLeftUp)
408  self._tags_display_tags_display.Bind(wx.EVT_KEY_DOWN, self.OnKeyOnKey)
409  return self._tags_display_tags_display
410 
411  def contains(self, text):
412  return False
413 
414  def highlight(self, text):
415  pass
416 
417  def clear_highlight(self):
418  pass
419 
420  def close(self):
421  self._tags_display.close()
422  self.plugin.unsubscribe(self._saving, RideSaving)
423  SettingEditor.close(self)
424 
425 
427 
428  def __init__(self, parent, tree, controller):
429  ListEditor.__init__(self, parent, self._titles, controller)
430  self._datafile_datafile = controller.datafile
431  self._tree_tree = tree
432 
434  return self._controller_controller.datafile_controller
435 
436  def refresh_datafile(self, item, event):
437  self._tree_tree.refresh_datafile(item, event)
438 
439  def update_data(self):
440  ListEditor.update_data(self)
441 
442  def update_value(self):
443  pass
444 
445  def close(self):
446  pass
447 
448  def highlight(self, text, expand=False):
449  pass
450 
451 
452 class VariablesListEditor(_AbstractListEditor):
453 
456  _titles = ['Variable', 'Value', 'Comment']
457 
460  _buttons = ['Add Scalar', 'Add List', 'Add Dict']
461 
462  def __init__(self, parent, tree, controller):
463  PUBLISHER.subscribe(
464  self._update_vars_update_vars, RideVariableAdded)
465  PUBLISHER.subscribe(
466  self._update_vars_update_vars, RideVariableUpdated)
467  PUBLISHER.subscribe(
468  self._update_vars_update_vars, RideVariableRemoved)
469  PUBLISHER.subscribe(self._open_variable_dialog_open_variable_dialog, RideOpenVariableDialog)
470  _AbstractListEditor.__init__(self, parent, tree, controller)
471 
472  def _update_vars(self, message):
473  ListEditor.update_data(self)
474 
475  def get_column_values(self, item):
476  return [item.name, item.value
477  if isinstance(item.value, str)
478  else ' | '.join(item.value),
479  ListToStringFormatter(item.comment).value]
480 
481  def OnMoveUp(self, event):
482  _AbstractListEditor.OnMoveUp(self, event)
483  self._list_list.SetFocus()
484 
485  def OnMoveDown(self, event):
486  _AbstractListEditor.OnMoveDown(self, event)
487  self._list_list.SetFocus()
488 
489  def OnAddScalar(self, event):
490  self._show_dialog_show_dialog(
491  ScalarVariableDialog(self._controller_controller))
492 
493  def OnAddList(self, event):
494  self._show_dialog_show_dialog(
495  ListVariableDialog(self._controller_controller, plugin=self.Parent.plugin))
496 
497  def OnAddDict(self, event):
498  self._show_dialog_show_dialog(
499  DictionaryVariableDialog(self._controller_controller,
500  plugin=self.Parent.plugin))
501 
502  def _show_dialog(self, dlg):
503  if dlg.ShowModal() == wx.ID_OK:
504  ctrl = self._controller_controller.add_variable(*dlg.get_value())
505  ctrl.set_comment(dlg.get_comment())
506  self.update_dataupdate_dataupdate_data()
507  dlg.Destroy()
508 
509  def OnEdit(self, event):
510  var = self._controller_controller[self._selection_selection]
511  self._open_var_dialog_open_var_dialog(var)
512 
513  def _open_variable_dialog(self, message):
514  # Prevent opening a dialog if self has been destroyed
515  if self:
516  self._open_var_dialog_open_var_dialog(message.controller)
517 
518  def _open_var_dialog(self, var):
519  var_name = var.name.lower()
520  dlg = None
521  if var_name.startswith('${'):
522  dlg = ScalarVariableDialog(self._controller_controller, item=var)
523  elif var_name.startswith('@{'):
524  dlg = ListVariableDialog(self._controller_controller, item=var,
525  plugin=self.Parent.plugin)
526  elif var_name.startswith('&{'):
527  dlg = DictionaryVariableDialog(self._controller_controller, item=var,
528  plugin=self.Parent.plugin)
529  if dlg: # DEBUG robot accepts % variable definition
530  if dlg.ShowModal() == wx.ID_OK:
531  name, value = dlg.get_value()
532  var.execute(ctrlcommands.UpdateVariable(name, value, dlg.get_comment()))
533  self.update_dataupdate_dataupdate_data()
534  dlg.Destroy()
535 
536  def close(self):
537  PUBLISHER.unsubscribe_all(self)
538 
539 
541 
544  _titles = ['Import', 'Name / Path', 'Arguments', 'Comment']
545 
548  _buttons = ['Library', 'Resource', 'Variables', 'Import Failed Help']
549 
550  def __init__(self, parent, tree, controller):
551  self._import_failed_shown_import_failed_shown = False
552  _AbstractListEditor.__init__(self, parent, tree, controller)
553  self.SetBackgroundColour(Colour(self.color_backgroundcolor_background))
554  self.SetOwnBackgroundColour(Colour(self.color_backgroundcolor_background))
555  self.SetForegroundColour(Colour(self.color_foregroundcolor_foreground))
556  self.SetOwnForegroundColour(Colour(self.color_foregroundcolor_foreground))
557 
558  @overrides(ListEditorBase)
559  def _create_buttons(self):
560  sizer = wx.BoxSizer(wx.VERTICAL)
561  sizer.Add(Label(
562  self, label='Add Import', size=wx.Size(120, 20),
563  style=wx.ALIGN_CENTER))
564  for label in self._buttons_buttons_buttons:
565  sizer.Add(ButtonWithHandler(self, label, width=120,
566  color_secondary_foreground=self.color_secondary_foregroundcolor_secondary_foreground,
567  color_secondary_background=self.color_secondary_backgroundcolor_secondary_background), 0, wx.ALL, 1)
568  return sizer
569 
570  def OnLeftClick(self, event):
571  if not self.is_selectedis_selectedis_selected:
572  return
573  if wx.GetMouseState().ControlDown() or wx.GetMouseState().CmdDown():
574  self.navigate_to_treenavigate_to_tree()
575 
576  def navigate_to_tree(self):
577  setting = self._get_setting_get_setting()
578  if self.has_link_targethas_link_targethas_link_target(setting):
579  self._tree_tree.select_node_by_data(setting.get_imported_controller())
580 
581  def has_link_target(self, controller):
582  return controller.is_resource and controller.get_imported_controller()
583 
584  @overrides(ListEditorBase)
585  def has_error(self, controller):
586  return controller.has_error()
587 
588  @overrides(ListEditorBase)
589  def OnRightClick(self, event):
590  PopupMenu(self, PopupMenuItems(self, self._create_item_menu_create_item_menu()))
591 
592  def _create_item_menu(self):
593  menu = self._menu_menu
594  item = self._controller_controller[self._selection_selection]
595  if item.has_error() and item.type == 'Library':
596  menu = menu[:] + ['Import Library Spec XML']
597  return menu
598 
599  def OnImportLibrarySpecXml(self, event):
600  RideExecuteSpecXmlImport().publish()
601 
602  def OnEdit(self, event):
603  setting = self._get_setting_get_setting()
604  self._show_import_editor_dialog_show_import_editor_dialog(
605  EditorDialog(setting),
606  lambda v, c: setting.execute(ctrlcommands.SetValues(v, c)),
607  setting, on_empty=self._delete_selected_delete_selected)
608 
609  def OnLibrary(self, event):
610  self._show_import_editor_dialog_show_import_editor_dialog(
611  LibraryDialog,
612  lambda v, c: self._controller_controller.execute(ctrlcommands.AddLibrary(v, c)))
613 
614  def OnResource(self, event):
615  self._show_import_editor_dialog_show_import_editor_dialog(
616  ResourceDialog,
617  lambda v, c: self._controller_controller.execute(ctrlcommands.AddResource(v, c)))
618 
619  def OnVariables(self, event):
620  self._show_import_editor_dialog_show_import_editor_dialog(
621  VariablesDialog,
622  lambda v, c:
623  self._controller_controller.execute(ctrlcommands.AddVariablesFileImport(v, c)))
624 
625  def OnImportFailedHelp(self, event):
626  if self._import_failed_shown_import_failed_shown:
627  return
628  dialog = HtmlDialog('Import failure handling', '''
629  <br>Possible corrections and notes:<br>
630  <ul>
631  <li>Import failure is shown with red color.</li>
632  <li>See Tools / View RIDE Log for detailed information about the failure.</li>
633  <li>If the import contains a variable that RIDE has not initialized, consider adding the variable
634  to variable table with a default value.</li>
635  <li>For library import failure: Consider importing library spec XML (Tools / Import Library Spec XML or by
636  adding the XML file with the correct name to PYTHONPATH) to enable keyword completion
637  for example for Java libraries.
638  Library spec XML can be created using libdoc tool from Robot Framework.
639  For more information see <a href="https://github.com/robotframework/RIDE/wiki/Keyword-Completion#wiki-using-library-specs">wiki</a>.
640  </li>
641  </ul>''')
642  dialog.Bind(wx.EVT_CLOSE, self._import_failed_help_closed_import_failed_help_closed)
643  dialog.Show()
644  self._import_failed_shown_import_failed_shown = True
645 
646  def _import_failed_help_closed(self, event):
647  self._import_failed_shown_import_failed_shown = False
648  event.Skip()
649 
650  def _get_setting(self):
651  return self._controller_controller[self._selection_selection]
652 
654  self, dialog, creator_or_setter, item=None, on_empty=None):
655  dlg = dialog(self._controller_controller, item=item)
656  if dlg.ShowModal() == wx.ID_OK:
657  value = dlg.get_value()
658  if not self._empty_name_empty_name(value):
659  creator_or_setter(value, dlg.get_comment())
660  elif on_empty:
661  on_empty()
662  self.update_dataupdate_dataupdate_data()
663  dlg.Destroy()
664 
665  def _empty_name(self, value):
666  return not value[0]
667 
668  def get_column_values(self, item):
669  return [item.type, item.name, item.display_value,
670  ListToStringFormatter(item.comment).value]
671 
672 
674 
677  _titles = ['Metadata', 'Value', 'Comment']
678 
681  _buttons = ['Add Metadata']
682 
685  _sortable = False
686 
687  def OnEdit(self, event):
688  meta = self._controller_controller[self._selection_selection]
689  dlg = MetadataDialog(self._controller_controller.datafile, item=meta)
690  if dlg.ShowModal() == wx.ID_OK:
691  meta.set_value(*dlg.get_value())
692  meta.set_comment(dlg.get_comment())
693  self.update_dataupdate_dataupdate_data()
694  dlg.Destroy()
695 
696  def OnAddMetadata(self, event):
697  dlg = MetadataDialog(self._controller_controller.datafile)
698  if dlg.ShowModal() == wx.ID_OK:
699  ctrl = self._controller_controller.add_metadata(*dlg.get_value())
700  ctrl.set_comment(dlg.get_comment())
701  self.update_dataupdate_dataupdate_data()
702  dlg.Destroy()
703 
704  def get_column_values(self, item):
705  return [item.name, utils.html_escape(item.value),
706  ListToStringFormatter(item.comment).value]
def __init__(self, parent, controller, plugin, tree)
def _show_import_editor_dialog(self, dialog, creator_or_setter, item=None, on_empty=None)
def __init__(self, parent, tree, controller)
def _set_value(self, value_list, comment)
def __init__(self, parent, controller, plugin, tree)
def __init__(self, parent, controller, plugin, tree)
def __init__(self, parent, tree, controller)
def __init__(self, parent, tree, controller)
Sent whenever spec xml import is requested.
Definition: messages.py:178
def highlight_matcher(value, content)