Plugin.pm - Base Class For GEM Plugins
This Document Describes how plugins work and how to write them.
Plugins are the objects within the generic enterprise manager that perform all the functionality. This class provides core functionality and is inheirited by .pm files that reside in the plugins subdirectory. This is the documentation on how to write a plugin.
Generic Enterprise Manager plugins are written to provide users features through the GEM. A plugin is a perl module (extension .pm) that inheirits from the base class Plugin. The .pm file and a .xml file which identifies associated data (author, copyright notice...) are placed in the plugins subdirecory of the application where they will automatically be loaded at run time. Plugins should conform to this specification. If a plugin does not compile, it not loaded at run time ( you will see error messages ). Plugins are called by and run from the PluginManager module.
It is recommended that the top of a plugin file named xyz follow the following template:
package xyz;
@ISA = qw(Plugin);
use strict;
use vars qw($VERSION);
$VERSION = ".01";
As with all perl modules, the plugin must return a 1 and of course you are encouraged to embed embed perldoc documentation after that line.
1; __END__
=head1 NAME
eventviewer.pm - Module for viewing events
=head2 DESCRIPTION
The event viewer can be viewed as an example plugin. etc...
After that, the plugin should contain subroutines that override the
subroutines in its parent Plugin.pm. These will be used to define user interface elements and to
handle functionality. You can create and paint a notebook tab if you wish to use one.
You can create explorer buttons (lower left side), bitmaps for the upper left side, can
add items to the main explorer tree, and
can create the functionality that occurs when you right click items on an element of that tree.
You can also create menu items for the menu bar. The heirarchy is that the explorer
buttons, when clicked, will populate the explorer tree. The tree is painted and right click items
added to elements. When a user selects
an element on this tree, selects a menu item, or right clicks on one of the right click items, a call back to
event_handler() will be performed.
This section lists functions that your plugin must NOT override. These are automatically called from GEM. In other words... theses functions should not be defined by the plugin.
The following functions are available to you to use in your plugin:
messageBox($str)
DialogBox(@_) using normal DialogBox argumentsmake_button()clear_tab($tabname)
$current_main_frame = $package->clear_tab($tabname);
Clears the notebook tab named by $tabname. The cleared frame is then raised and returned to the calling program and can be used as a base frame.
global_data()global_data() to get/set values from the gem.xml configuration file
show_html()unimplemented()write_XMLDATA()globaldata() if needed
get_last_event_info()ignore_events()browse()get_CONFIG()
You also have 3 print functions.
statusmsg(@msg)notifymsg(@msg)debugmsg(@msg)The following example line will set the statusbar and print to stdout
$package->statusmsg( "[navigator.pm] menuclick($menuitem)\n" );
The callbacks define the look and feel of the application. The buttons on the lower left side determines which tree is selected in the explorer type menu above it. This function returns an array of buttons to place in that corner.
init()event_handler()
<TABLE>
<TR><TH>EVENT TYPE</TH><TH>ARGUMENT</TH></TR>
<TR><TD>menu</TD><TD>
-menuitem</TD></TR>
<TR><TD>tabchange</TD><TD>
-oldtab<br>
-curtab</TD></TR>
<TR><TD>pagechange</TD><TD>
-oldpage<br>
-newpage</TD></TR>
<TR><TD>treebrowse</TD><TD>
-entrypath<br>
-curtab1</TD></TR>
<TR><TD>treertclick</TD><TD>
-entrypath<br>
-clicktext</TD></TR>
<TR><TD>expbutton</TD><TD>
-context</TD></TR>
<TR><TD>imgbutton</TD><TD>
-text</TD></TR></TABLE>
=item * $package->getExplorerButtons()
return a hash of buttons that will go in the lower left corner.
getMenuItems()getPluginPanes($package)menuclick($package,$Frame,$entryPath)getTreeColorFunc($package,$curTreeType)getTreeItems($package,$curTreeType)getBitMaps($package)bitmapclick($package,$Frame,$entryPath)getTreeRtclk($package,$curTreeType,$treeitmptr)
Plugin documentation is contained in an xml file in the plugins directory that has the same root name as the .pm file. I suggest you browse a few of them for functionality.
<package name="MDA_tables" version=".01"> <copyright type="gpl" key="" expires="never" notice="copyright (c) 2005 by edward barlow" /> <help_url>http://www.edbarlow.com/plugins/MDA_tables.html</help_url> <long_description>Monitoring Table Viewer</long_description> <short_description>Monitoring Table Viewer</short_description> <author_name>Edward Barlow</author_name> <author_mail>barlowedward@hotmail.com</author_mail> </package>
GEM communicates with the plugins using the function $pluginname->send_event(%args). This function sends
the event to each event_handler() function in loaded plugins. These functions, on a plugin by plugin basis,
will handle the event.
Clicking on the buttons in the lower left corner will always redraw_tree() in addition to
anything else you want it to do.