Robot Framework Integrated Development Environment (RIDE)
robotide.pluginapi.plugin.Plugin Class Reference

Entry point to RIDE plugin API – all plugins must extend this class. More...

Inheritance diagram for robotide.pluginapi.plugin.Plugin:
robotide.postinstall.desktopshortcut.ShortcutPlugin robotide.recentfiles.recentfiles.RecentFilesPlugin robotide.run.runanything.RunAnything robotide.searchtests.searchtests.TestSearchPlugin robotide.spec.specimporter.SpecImporterPlugin robotide.ui.fileexplorerplugin.FileExplorerPlugin robotide.ui.keywordsearch.KeywordSearch robotide.ui.preview.PreviewPlugin robotide.ui.treeplugin.TreePlugin

Public Member Functions

def __getattr__ (self, name)
 Provides convenient attribute access to saved settings. More...
 
def __init__ (self, application, name=None, doc=None, metadata=None, default_settings=None, initially_enabled=True)
 Initialize the plugin with the provided data. More...
 
def add_tab (self, tab, title, allow_closing=True)
 Adds the tab with the title to the tabbed notebook and shows it. More...
 
def all_testcases (self)
 Returns all test cases from all suites in one, unsorted list. More...
 
def allow_tab_closing (self, tab)
 Allows closing a tab that has been created using allow_closing=False. More...
 
def config_panel (self, parent)
 Called by RIDE to get the plugin configuration panel. More...
 
def content_assist_values (self, value='')
 Returns content assist values for currently selected item. More...
 
def delete_tab (self, tab)
 Deletes the tab added using add_tab. More...
 
def disable (self)
 Called by RIDE when the plugin is disabled. More...
 
def disallow_tab_closing (self, tab)
 Disallows closing a tab by use. More...
 
def enable (self)
 This method is called by RIDE when the plugin is enabled. More...
 
def get_editor (self, item_class)
 Return the current editor class for the given model item class. More...
 
def get_editors (self, item_class)
 Return all registered editors for the given model item class. More...
 
def get_keyword (self, name)
 Returns the keyword object with the given name or None. More...
 
def get_keyword_details (self, name)
 Returns details (documentation, source) of keyword with name name. More...
 
def get_plugins (self)
 Returns list containing plugin wrapper for every loaded plugin. More...
 
def get_selected_datafile (self)
 Returns the data file that is currently selected in the tree. More...
 
def get_selected_item (self)
 Returns the item that is currently selected in the tree. More...
 
def get_user_keyword (self, name)
 Returns user keyword instance whose name is name or None. More...
 
def highlight (self, data, text)
 Highlight a specific text of a given data's edito. More...
 
def highlight_cell (self, tcuk, obj=None, row=-1, column=-1)
 Highlight a specific row/column of a test case or user keyword. More...
 
def is_library_keyword (self, name)
 Returns whether name is a keyword imported by current datafile. More...
 
def is_unsaved_changes (self)
 Returns True if there is any unsaved changes, otherwise False. More...
 
def is_user_keyword (self, name)
 Returns whether name is a user keyword of current datafile. More...
 
def new_suite_can_be_opened (self)
 Checks are there modified files and asks user what to do if there are. More...
 
def open_suite (self, path)
 Opens a test suite specified by the path. More...
 
def publish (self, topic, data)
 Publishes a message with given topic and client data. More...
 
def register_action (self, action_info)
 Registers a menu entry and optionally a shortcut and a toolbar icon. More...
 
def register_actions (self, action_infos)
 Registers multiple menu entries and shortcuts/icons. More...
 
def register_content_assist_hook (self, hook)
 Allows plugin to insert values in content assist dialog. More...
 
def register_editor (self, item_class, editor_class, activate=True)
 Register editor_class as an editor class for model items of type item_class More...
 
def register_search_action (self, description, handler, icon, default=False)
 
def register_shortcut (self, shortcut, callback)
 
def save_all_unsaved_changes (self)
 Saves all the data files that are modified. More...
 
def save_selected_datafile (self)
 Saves the data file that is currently selected in the tree. More...
 
def save_setting (self, name, value, override=True, delay=0)
 Saves the specified setting into the RIDE configuration file. More...
 
def select_user_keyword_node (self, uk)
 Selects node containing the given uk in the tree. More...
 
def set_active_editor (self, item_class, editor_class)
 Activates the specified editor to be used with the specified model item. More...
 
def show_tab (self, tab)
 Makes the tab added using add_tab visible. More...
 
def subscribe (self, listener, *topics)
 Start to listen to messages with the given topics. More...
 
def tab_is_visible (self, tab)
 Returns is the tab added using add_tab visible or not. More...
 
def unregister_actions (self)
 Unregisters all actions registered by this plugin. More...
 
def unregister_editor (self, item_class, editor_class)
 Unregisters editor_class as an editor class for model items of type item_class More...
 
def unsubscribe (self, listener, *topics)
 Stops listening to messages with the given topics. More...
 
def unsubscribe_all (self)
 Stops to listen to all messages this plugin has subscribed to. More...
 

Public Attributes

 doc
 
 initially_enabled
 
 metadata
 
 name
 

Properties

 datafile
 
 filemgr
 
 frame
 
 global_settings
 
 menubar
 
 model
 
 notebook
 
 toolbar
 
 tree
 

Private Member Functions

def _delay_saving (self, delay)
 
def _get_doc (self, given_doc)
 
def _save_setting_after_delay (self)
 

Private Attributes

 __actions
 
 __app
 
 __doc__
 
 __frame
 
 __namespace
 
 __settings
 
 _save_timer
 

Detailed Description

Entry point to RIDE plugin API – all plugins must extend this class.

Plugins can use the helper methods implemented in this class to interact
with the core application. The methods and their arguments are kept stable
across the different RIDE releases to the extent that it is possible.

If the provided methods are not enough, plugins can also interact with the
core directly using properties `tree`, `menubar`, `toolbar`, `notebook` and
`model`. Although these attributes themselves are stable, the functionality
behind them may still change between releases. Users are thus recommended
to propose new helper methods, preferably with patches, for often needed
functionality that is only available through these properties.

:IVariables:
  name
    Plugin name. Set in `__init__` based on the given name or the class name.
  doc
    Plugin documentation. Set in `__init__` based on the given doc or
    the class docstring.
  metadata
    Plugin metadata. Set in `__init__` based on the given metadata.
  initially_enabled
    Specifies should the plugin be enabled when first loaded.
    Set in `__init__`.

Definition at line 50 of file plugin.py.

Constructor & Destructor Documentation

◆ __init__()

def robotide.pluginapi.plugin.Plugin.__init__ (   self,
  application,
  name = None,
  doc = None,
  metadata = None,
  default_settings = None,
  initially_enabled = True 
)

Initialize the plugin with the provided data.

    The provided information is mainly used by the plugin manager. Simple
    plugins are often fine with the defaults. If this method is overridden,
    the plugin must call it explicitly::

        from robotide.pluginapi import Plugin

        class MyCoolPluginExample(Plugin):
            \"\"\"This extra cool docstring is used as the plugin doc.\"\"\"
            def __init__(self, application):
                Plugin.__init__(self, application, metadata={'version': '0.1'},
                                default_settings={'color': 'red', 'x': 42})

    Plugins should not create any user interface elements at this point but
    wait until the `enable` method is called.

    :Parameters:
      application
        RIDE application reference.
      name
        Name of the plugin. If not specified, the name is got from the
        plugin class name dropping possible ``Plugin`` from the end.
      doc
        Plugin documentation. If not specified, the doc is got from the
        plugin class docstring.
      metadata
        A dictionary of free metadata shown on the plugin manager. Values
        containing URLs will be shown as links.
      default_settings
        A dictionary of settings and their default values. Settings are
        automatically stored onto RIDE configuration file, can be
        accessed using direct attribute access via `__getattr__`, and new
        settings can be saved using `save_setting`.
      initially_enabled
        Specifies should the plugin be enabled when loaded for the first
        time. Users can change the status later from the plugin manager.

Definition at line 108 of file plugin.py.

Member Function Documentation

◆ __getattr__()

def robotide.pluginapi.plugin.Plugin.__getattr__ (   self,
  name 
)

Provides convenient attribute access to saved settings.

    For example, setting ``color`` can be accessed directly like
    ``self.color``.

Definition at line 134 of file plugin.py.

◆ _delay_saving()

def robotide.pluginapi.plugin.Plugin._delay_saving (   self,
  delay 
)
private

Definition at line 152 of file plugin.py.

◆ _get_doc()

def robotide.pluginapi.plugin.Plugin._get_doc (   self,
  given_doc 
)
private

Definition at line 122 of file plugin.py.

◆ _save_setting_after_delay()

def robotide.pluginapi.plugin.Plugin._save_setting_after_delay (   self)
private

Definition at line 161 of file plugin.py.

◆ add_tab()

def robotide.pluginapi.plugin.Plugin.add_tab (   self,
  tab,
  title,
  allow_closing = True 
)

Adds the tab with the title to the tabbed notebook and shows it.

    The ``tab`` can be any wxPython container. ``allow_closing`` defines
    can users close the tab while the plugin is enabled.

Definition at line 240 of file plugin.py.

◆ all_testcases()

def robotide.pluginapi.plugin.Plugin.all_testcases (   self)

Returns all test cases from all suites in one, unsorted list.

Definition at line 358 of file plugin.py.

◆ allow_tab_closing()

def robotide.pluginapi.plugin.Plugin.allow_tab_closing (   self,
  tab 
)

Allows closing a tab that has been created using allow_closing=False.

Definition at line 252 of file plugin.py.

◆ config_panel()

def robotide.pluginapi.plugin.Plugin.config_panel (   self,
  parent 
)

Called by RIDE to get the plugin configuration panel.

    The panel returned will be integrated into the plugin manager UI, and
    can be used e.g. to display configurable settings.

    By default there is no configuration panel.

Definition at line 187 of file plugin.py.

◆ content_assist_values()

def robotide.pluginapi.plugin.Plugin.content_assist_values (   self,
  value = '' 
)

Returns content assist values for currently selected item.

Definition at line 321 of file plugin.py.

◆ delete_tab()

def robotide.pluginapi.plugin.Plugin.delete_tab (   self,
  tab 
)

Deletes the tab added using add_tab.

Definition at line 248 of file plugin.py.

◆ disable()

◆ disallow_tab_closing()

def robotide.pluginapi.plugin.Plugin.disallow_tab_closing (   self,
  tab 
)

Disallows closing a tab by use.

Definition at line 256 of file plugin.py.

◆ enable()

def robotide.pluginapi.plugin.Plugin.enable (   self)

◆ get_editor()

def robotide.pluginapi.plugin.Plugin.get_editor (   self,
  item_class 
)

Return the current editor class for the given model item class.

Definition at line 441 of file plugin.py.

◆ get_editors()

def robotide.pluginapi.plugin.Plugin.get_editors (   self,
  item_class 
)

Return all registered editors for the given model item class.

    The last editor in the list is the currently active editor.

Definition at line 437 of file plugin.py.

◆ get_keyword()

def robotide.pluginapi.plugin.Plugin.get_keyword (   self,
  name 
)

Returns the keyword object with the given name or None.

Definition at line 336 of file plugin.py.

◆ get_keyword_details()

def robotide.pluginapi.plugin.Plugin.get_keyword_details (   self,
  name 
)

Returns details (documentation, source) of keyword with name name.

    Returns None if no matching keyword is found.

Definition at line 343 of file plugin.py.

◆ get_plugins()

def robotide.pluginapi.plugin.Plugin.get_plugins (   self)

Returns list containing plugin wrapper for every loaded plugin.

    Wrapper is an instance of `PluginConnector` if the plugin has loaded
    successfully, otherwise it's an instance of `BrokenPlugin`.

Definition at line 375 of file plugin.py.

◆ get_selected_datafile()

def robotide.pluginapi.plugin.Plugin.get_selected_datafile (   self)

Returns the data file that is currently selected in the tree.

    If a test case or a keyword is selected, the data file containing the
    selected item is returned.

    :rtype:
        `InitFile`, `TestCaseFile` or `ResourceFile`

Definition at line 286 of file plugin.py.

◆ get_selected_item()

def robotide.pluginapi.plugin.Plugin.get_selected_item (   self)

Returns the item that is currently selected in the tree.

    The item can be a test suite, a resource file, a test case or a keyword.

    :rtype:
        `InitFile`, `TestCaseFile`, `ResourceFile`, `TestCase` or `UserKeyword`

Definition at line 315 of file plugin.py.

◆ get_user_keyword()

def robotide.pluginapi.plugin.Plugin.get_user_keyword (   self,
  name 
)

Returns user keyword instance whose name is name or None.

Definition at line 325 of file plugin.py.

◆ highlight()

def robotide.pluginapi.plugin.Plugin.highlight (   self,
  data,
  text 
)

Highlight a specific text of a given data's edito.

Definition at line 452 of file plugin.py.

◆ highlight_cell()

def robotide.pluginapi.plugin.Plugin.highlight_cell (   self,
  tcuk,
  obj = None,
  row = -1,
  column = -1 
)

Highlight a specific row/column of a test case or user keyword.

Definition at line 445 of file plugin.py.

◆ is_library_keyword()

def robotide.pluginapi.plugin.Plugin.is_library_keyword (   self,
  name 
)

Returns whether name is a keyword imported by current datafile.

Definition at line 354 of file plugin.py.

◆ is_unsaved_changes()

def robotide.pluginapi.plugin.Plugin.is_unsaved_changes (   self)

Returns True if there is any unsaved changes, otherwise False.

Definition at line 300 of file plugin.py.

◆ is_user_keyword()

def robotide.pluginapi.plugin.Plugin.is_user_keyword (   self,
  name 
)

Returns whether name is a user keyword of current datafile.

    Checks both the datafile's own and imported user keywords for match.

Definition at line 350 of file plugin.py.

◆ new_suite_can_be_opened()

def robotide.pluginapi.plugin.Plugin.new_suite_can_be_opened (   self)

Checks are there modified files and asks user what to do if there are.

    Returns False if there were modified files and user canceled the dialog,
    otherwise returns True.

Definition at line 268 of file plugin.py.

◆ open_suite()

def robotide.pluginapi.plugin.Plugin.open_suite (   self,
  path 
)

Opens a test suite specified by the path.

    No suite is opened if parsing the suite fails.

Definition at line 275 of file plugin.py.

◆ publish()

def robotide.pluginapi.plugin.Plugin.publish (   self,
  topic,
  data 
)

Publishes a message with given topic and client data.

    Purpose of this method is to support inter-plugin communication which
    is not possible to achieve using custom message classes.

    `data` will be passed as an argument to registered listener methods.

Definition at line 385 of file plugin.py.

◆ register_action()

def robotide.pluginapi.plugin.Plugin.register_action (   self,
  action_info 
)

Registers a menu entry and optionally a shortcut and a toolbar icon.

    ``action_info`` is an instance of `ActionInfo` class containing needed
    information to create menu entry, keyboard shortcut and/or toolbar
    button for the action.

    All registered actions can be un-registered using the
    `unregister_actions` method.

    If register action is used in menu event handler and it modifies the
    menu that triggered the event, it is safest to wrap register action
    call inside wx.CallAfter function.

    Returns created `Action` object.

Definition at line 205 of file plugin.py.

◆ register_actions()

def robotide.pluginapi.plugin.Plugin.register_actions (   self,
  action_infos 
)

Registers multiple menu entries and shortcuts/icons.

    ``action_infos`` is a list of same `ActionInfo` objects that
    `register_action` method accepts.

    Returns list of created `Action` objects.

Definition at line 223 of file plugin.py.

◆ register_content_assist_hook()

def robotide.pluginapi.plugin.Plugin.register_content_assist_hook (   self,
  hook 
)

Allows plugin to insert values in content assist dialog.

    ``hook`` must be a callable, which should take two arguments and
    return a list of instances of `ItemInfo` class. When content
    assist is requested by user, ``hook`` will be called with the current
    dataitem and current value of cell as parameters.

Definition at line 368 of file plugin.py.

◆ register_editor()

def robotide.pluginapi.plugin.Plugin.register_editor (   self,
  item_class,
  editor_class,
  activate = True 
)

Register editor_class as an editor class for model items of type item_class

    If ``activate`` is True, the given editor is automatically activated
    using `set_active_editor`.

Definition at line 419 of file plugin.py.

◆ register_search_action()

def robotide.pluginapi.plugin.Plugin.register_search_action (   self,
  description,
  handler,
  icon,
  default = False 
)

Definition at line 226 of file plugin.py.

◆ register_shortcut()

def robotide.pluginapi.plugin.Plugin.register_shortcut (   self,
  shortcut,
  callback 
)

Definition at line 210 of file plugin.py.

◆ save_all_unsaved_changes()

def robotide.pluginapi.plugin.Plugin.save_all_unsaved_changes (   self)

Saves all the data files that are modified.

Definition at line 304 of file plugin.py.

◆ save_selected_datafile()

def robotide.pluginapi.plugin.Plugin.save_selected_datafile (   self)

Saves the data file that is currently selected in the tree.

    If a test case or a keyword is selected, the data file containing the
    selected item is saved.

Definition at line 296 of file plugin.py.

◆ save_setting()

def robotide.pluginapi.plugin.Plugin.save_setting (   self,
  name,
  value,
  override = True,
  delay = 0 
)

Saves the specified setting into the RIDE configuration file.

    ``override`` controls whether a possibly already existing value is
    overridden or not. Saved settings can be accessed using direct attribute
    access via `__getattr__`.
    ``delay`` is number defining how many seconds is waited before setting
    is saved. This can be used to prevent saving the value while user is
    typing it.

Definition at line 148 of file plugin.py.

◆ select_user_keyword_node()

def robotide.pluginapi.plugin.Plugin.select_user_keyword_node (   self,
  uk 
)

Selects node containing the given uk in the tree.

Definition at line 330 of file plugin.py.

◆ set_active_editor()

def robotide.pluginapi.plugin.Plugin.set_active_editor (   self,
  item_class,
  editor_class 
)

Activates the specified editor to be used with the specified model item.

    The editor must have been registered first by using `register_editor`.

Definition at line 430 of file plugin.py.

◆ show_tab()

def robotide.pluginapi.plugin.Plugin.show_tab (   self,
  tab 
)

Makes the tab added using add_tab visible.

Definition at line 244 of file plugin.py.

◆ subscribe()

def robotide.pluginapi.plugin.Plugin.subscribe (   self,
  listener,
topics 
)

Start to listen to messages with the given topics.

    See the documentation of the `robotide.publish` module for more
    information about subscribing to messages and the messaging system

    `unsubscribe` and `unsubscribe_all` can be used to stop listening to
    certain or all messages.

Definition at line 396 of file plugin.py.

◆ tab_is_visible()

def robotide.pluginapi.plugin.Plugin.tab_is_visible (   self,
  tab 
)

Returns is the tab added using add_tab visible or not.

Definition at line 260 of file plugin.py.

◆ unregister_actions()

def robotide.pluginapi.plugin.Plugin.unregister_actions (   self)

Unregisters all actions registered by this plugin.

Definition at line 230 of file plugin.py.

◆ unregister_editor()

def robotide.pluginapi.plugin.Plugin.unregister_editor (   self,
  item_class,
  editor_class 
)

Unregisters editor_class as an editor class for model items of type item_class

Definition at line 423 of file plugin.py.

◆ unsubscribe()

def robotide.pluginapi.plugin.Plugin.unsubscribe (   self,
  listener,
topics 
)

Stops listening to messages with the given topics.

    ``listener`` and ``topics`` have the same meaning as in `subscribe`
    and a listener/topic combination is unsubscribed only when both of them
    match.

Definition at line 406 of file plugin.py.

◆ unsubscribe_all()

def robotide.pluginapi.plugin.Plugin.unsubscribe_all (   self)

Stops to listen to all messages this plugin has subscribed to.

Definition at line 411 of file plugin.py.

Member Data Documentation

◆ __actions

robotide.pluginapi.plugin.Plugin.__actions
private

Definition at line 120 of file plugin.py.

◆ __app

robotide.pluginapi.plugin.Plugin.__app
private

Definition at line 115 of file plugin.py.

◆ __doc__

robotide.pluginapi.plugin.Plugin.__doc__
private

Definition at line 125 of file plugin.py.

◆ __frame

robotide.pluginapi.plugin.Plugin.__frame
private

Definition at line 116 of file plugin.py.

◆ __namespace

robotide.pluginapi.plugin.Plugin.__namespace
private

Definition at line 117 of file plugin.py.

◆ __settings

robotide.pluginapi.plugin.Plugin.__settings
private

Definition at line 118 of file plugin.py.

◆ _save_timer

robotide.pluginapi.plugin.Plugin._save_timer
private

Definition at line 114 of file plugin.py.

◆ doc

robotide.pluginapi.plugin.Plugin.doc

Definition at line 111 of file plugin.py.

◆ initially_enabled

robotide.pluginapi.plugin.Plugin.initially_enabled

Definition at line 113 of file plugin.py.

◆ metadata

robotide.pluginapi.plugin.Plugin.metadata

Definition at line 112 of file plugin.py.

◆ name

robotide.pluginapi.plugin.Plugin.name

Definition at line 110 of file plugin.py.

Property Documentation

◆ datafile

robotide.pluginapi.plugin.Plugin.datafile
static
Initial value:
= property(lambda self: self.get_selected_datafile(),
doc='Currently selected datafile')

Definition at line 65 of file plugin.py.

◆ filemgr

robotide.pluginapi.plugin.Plugin.filemgr
static
Initial value:
= property(lambda self: self.__frame.filemgr,
doc='Provides access to the files and folders explorer')

Definition at line 53 of file plugin.py.

◆ frame

robotide.pluginapi.plugin.Plugin.frame
static
Initial value:
= property(lambda self: self.__frame,
doc='Reference to the RIDE main frame')

Definition at line 63 of file plugin.py.

◆ global_settings

robotide.pluginapi.plugin.Plugin.global_settings
static
Initial value:
= property(lambda self: self.__app.settings,
doc='Settings read from settings.cfg')

Definition at line 67 of file plugin.py.

◆ menubar

robotide.pluginapi.plugin.Plugin.menubar
static
Initial value:
= property(lambda self: self.__frame.GetMenuBar(),
doc='Provides access to the application menubar')

Definition at line 55 of file plugin.py.

◆ model

robotide.pluginapi.plugin.Plugin.model
static
Initial value:
= property(lambda self: self.__app.model,
doc='Provides access to the data model')

Definition at line 61 of file plugin.py.

◆ notebook

robotide.pluginapi.plugin.Plugin.notebook
static
Initial value:
= property(lambda self: self.__frame.notebook,
doc='Provides access to the tabbed notebook')

Definition at line 59 of file plugin.py.

◆ toolbar

robotide.pluginapi.plugin.Plugin.toolbar
static
Initial value:
= property(lambda self: self.__frame.GetToolBar(),
doc='Provides access to the application toolbar')

Definition at line 57 of file plugin.py.

◆ tree

robotide.pluginapi.plugin.Plugin.tree
static
Initial value:
= property(lambda self: self.__frame.tree,
doc='Provides access to the suite and resource tree')

Definition at line 51 of file plugin.py.


The documentation for this class was generated from the following file: