18 from io
import StringIO
19 from ..pluginapi
import Plugin, TreeAwarePluginMixin
20 from ..action
import ActionInfo
21 from ..publish
import (RideTreeSelection, RideNotebookTabChanged, RideTestCaseAdded, RideUserKeywordAdded)
22 from ..robotapi
import TestCase, UserKeyword
23 from ..widgets
import ButtonWithHandler, Font
24 from ..utils
import Printing
32 Plugin.__init__(self, application, default_settings={
'format':
'HTML'})
38 doc=
'Show preview of the current file',
64 self.
_panel_panel.tree_node_selected(message.item)
71 self.
_panel_panel.update_preview()
78 _formats = [
'HTML',
'Text (Spaces)',
'Text (Pipes)']
81 wx.Panel.__init__(self, notebook)
83 main_sizer = wx.BoxSizer(wx.VERTICAL)
84 self.SetSizer(main_sizer)
88 box = wx.BoxSizer(wx.HORIZONTAL)
90 if wx.VERSION < (4, 1, 0):
91 box.Add(self.
_print_button_print_button(), 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
95 notebook.AddPage(self,
"Preview")
101 _file_format = property
104 if self.
_format_format ==
'HTML':
109 _pipe_separated = property
112 return 'Pipes' in self.
_format_format
115 chooser = wx.RadioBox(self, label=
'Format', choices=self.
_formats_formats)
116 chooser.SetStringSelection(self.
_format_format)
117 self.Bind(wx.EVT_RADIOBOX, self.
OnTypeChangedOnTypeChanged, chooser)
121 return ButtonWithHandler(self,
'Print')
128 if isinstance(self.
__view__view, view_class):
136 self.Sizer.Remove(self.
__view__view)
137 self.
__view__view.Destroy()
140 view = view_class(self)
141 self.Sizer.Add(view, 1, wx.EXPAND|wx.ALL, border=8)
153 datafile = self.
_parent_parent.datafile
162 txt_separating_spaces=self.
_parent_parent.global_settings[
'txt number of spaces']
164 except Exception
as e:
165 return "Creating preview of '%s' failed: %s" % (datafile.name, e)
167 return output.getvalue()
170 self.
_format_format = event.String
178 wx.html.HtmlWindow.__init__(self, parent)
179 self.SetStandardFonts()
182 self.SetPage(content)
186 if self.HasAnchor(anchor):
187 self.ScrollToAnchor(anchor)
193 if isinstance(data, UserKeyword):
194 return 'keyword_%s' % data.name
195 if isinstance(data, TestCase):
196 return 'test_%s' % data.name
203 wx.TextCtrl.__init__(self, parent, style=wx.TE_MULTILINE|wx.TE_NOHIDESEL)
204 self.SetEditable(
False)
205 self.SetFont(Font().fixed)
208 self.SetValue(content)
Used to create menu entries, keyboard shortcuts and/or toolbar buttons.
Entry point to RIDE plugin API – all plugins must extend this class.
def delete_tab(self, tab)
Deletes the tab added using add_tab.
def get_selected_datafile(self)
Returns the data file that is currently selected in the tree.
def subscribe(self, listener, *topics)
Start to listen to messages with the given topics.
def unsubscribe_all(self)
Stops to listen to all messages this plugin has subscribed to.
def register_action(self, action_info)
Registers a menu entry and optionally a shortcut and a toolbar icon.
def unregister_actions(self)
Unregisters all actions registered by this plugin.
def show_tab(self, tab)
Makes the tab added using add_tab visible.
def tab_is_visible(self, tab)
Returns is the tab added using add_tab visible or not.
Mixin to help solve if tree aware plugin has focus.
def add_self_as_tree_aware_plugin(self)
def remove_self_from_tree_aware_plugins(self)
def set_content(self, content)
def _get_anchor(self, data)
def __init__(self, parent)
def scroll_to_subitem(self, item)
def __init__(self, parent, notebook)
def _pipe_separated(self)
def OnTypeChanged(self, event)
def tree_node_selected(self, item)
def _create_view(self, view_class)
def _remove_current_view(self)
Provides preview of the test data in HTML, TSV and TXT formats.
def disable(self)
Called by RIDE when the plugin is disabled.
def enable(self)
This method is called by RIDE when the plugin is enabled.
def _update_preview(self, message)
def OnTreeSelection(self, message)
def __init__(self, application)
def OnTabChanged(self, message)
def OnShowPreview(self, event)
def set_content(self, content)
def scroll_to_subitem(self, item)
def __init__(self, parent)