def __init__(self, application): Plugin.__init__(self, application) self._tab = None self._grid_popup_creator = PopupCreator() self._creator = EditorCreator(self.register_editor) self._editor = None
class EditorPlugin(Plugin, TreeAwarePluginMixin): """The default editor plugin. This plugin implements editors for the various items of Robot Framework test data. """ def __init__(self, application): Plugin.__init__(self, application) self._tab = None self._grid_popup_creator = PopupCreator() self._creator = EditorCreator(self.register_editor) self._editor = None def enable(self): self._creator.register_editors() self._show_editor() self.register_actions(ActionInfoCollection(_EDIT, self._tab, self._tab)) self.subscribe(self.OnTreeItemSelected, RideTreeSelection) self.subscribe(self.OnTabChanged, RideNotebookTabChanged) self.subscribe(self.OnTabChanging, RideNotebookTabChanging) self.subscribe(self.OnSaveToModel, RideSaving) self.add_self_as_tree_aware_plugin() def disable(self): self.remove_self_from_tree_aware_plugins() self.unregister_actions() self.unsubscribe_all() self.delete_tab(self._tab) self._tab = None def is_focused(self): return self.tab_is_visible(self._tab) def highlight_cell(self, obj, row, column): self.show() self._editor.highlight_cell(obj, row, column) def highlight(self, text): self.show() self._editor.highlight(text) def show(self): self.show_tab(self._tab) def register_context_menu_hook_to_grid(self, hook): """ Used to register own items to grid's right click context menu hook is called with current selection (list of list containing values) and it is expected to return list of PopupMenuItem. If user selects one of the returned PopupMenuItem, related function is called with one argument, the wx event. """ self._grid_popup_creator.add_hook(hook) def unregister_context_menu_hook_to_grid(self, hook): self._grid_popup_creator.remove_hook(hook) def _show_editor(self): if not self._tab: self._tab = _EditorTab(self) self.add_tab(self._tab, 'Edit', allow_closing=False) if self.is_focused(): self._editor = self._create_editor() self._tab.show_editor(self._editor) def _create_editor(self): return self._creator.editor_for(self, self._tab, self.tree) def OnTreeItemSelected(self, message=None): self._show_editor() if not self.is_focused() and \ not self.is_focus_on_tree_aware_plugin() and \ (not message or not message.silent): self._editor = self._create_editor() self._tab.show_editor(self._editor) self.show() if self._editor: self._editor.tree_item_selected(message.item) def OnOpenEditor(self, event): self._show_editor() def OnTabChanged(self, event): self._show_editor() def OnTabChanging(self, message): if 'Edit' in message.oldtab: self._tab.save() def OnSaveToModel(self, message): if self._tab: self._tab.save()
class EditorPlugin(Plugin, TreeAwarePluginMixin): """The default editor plugin. This plugin implements editors for the various items of Robot Framework test data. """ def __init__(self, application): Plugin.__init__(self, application) self._tab = None self._grid_popup_creator = PopupCreator() self._creator = EditorCreator(self.register_editor) self._editor = None def enable(self): self._creator.register_editors() self._show_editor() self.register_actions(ActionInfoCollection(_EDIT, self._tab, self._tab)) self.subscribe(self.OnTreeItemSelected, RideTreeSelection) self.subscribe(self.OnTabChanged, RideNotebookTabChanged) self.subscribe(self.OnTabChanging, RideNotebookTabChanging) self.subscribe(self.OnSaveToModel, RideSaving) self.subscribe(self.OnFileDeleted, RideDataFileRemoved) self.add_self_as_tree_aware_plugin() def disable(self): self.remove_self_from_tree_aware_plugins() self.unregister_actions() self.unsubscribe_all() self.delete_tab(self._tab) self._tab = None def is_focused(self): return self.tab_is_visible(self._tab) def highlight_cell(self, obj, row, column): self.show() self._editor.highlight_cell(obj, row, column) def highlight(self, text): self.show() self._editor.highlight(text) def show(self): self.show_tab(self._tab) def register_context_menu_hook_to_grid(self, hook): """ Used to register own items to grid's right click context menu hook is called with current selection (list of list containing values) and it is expected to return list of PopupMenuItem. If user selects one of the returned PopupMenuItem, related function is called with one argument, the wx event. """ self._grid_popup_creator.add_hook(hook) def unregister_context_menu_hook_to_grid(self, hook): self._grid_popup_creator.remove_hook(hook) def _show_editor(self): if not self._tab: self._tab = _EditorTab(self) self.add_tab(self._tab, 'Edit', allow_closing=False) if self.is_focused(): self._editor = self._create_editor() self._tab.show_editor(self._editor) def _create_editor(self): return self._creator.editor_for(self, self._tab, self.tree) def OnTreeItemSelected(self, message=None): self._show_editor() if not self.is_focused() and \ not self.is_focus_on_tree_aware_plugin() and \ (not message or not message.silent): self._editor = self._create_editor() self._tab.show_editor(self._editor) self.show() if self._editor: self._editor.tree_item_selected(message.item) @overrides(Plugin) def get_selected_datafile(self): if self._editor and self._editor.controller: return self._editor.controller.datafile return Plugin.get_selected_datafile(self) def OnOpenEditor(self, event): self._show_editor() def OnTabChanged(self, event): self._show_editor() def OnTabChanging(self, message): if 'Edit' in message.oldtab: self._tab.save() def OnSaveToModel(self, message): if self._tab: self._tab.save() def OnFileDeleted(self, message): self._create_editor()