Rapla joins the plugin hype. Version 1.0 comes with its own plugin API. At the moment of writing there are 11 standard plugins in the Rapla-distribution and we've developed some more specific for our university.
We introduced the plugin concept into Rapla, so that other devoloper can extend Rapla for their needs and have the possibility to share their extensions with other users without breaking too much of the Rapla framework.
Most of the concept is "borrowed" from the Eclipse project, they invested a lot in plugin research.
But lets get started in writing a Rapla plugin in Eclipse.
Preparation:
1. Start eclipse and checkout the latest Rapla sources
- see [Building Rapla With Eclipse] and follow step 1-3
2. Checkout the My Rapla project
- open sf-repository and right-click on HEAD/MyRapla
3. Now run Rapla with My Rapla on the classpath
- Rightclick on org.rapla.Main and select Run to Rapla without plugin and to create a run entry
- now close Rapla right click again and select Run As/Run
- Click on the classpath tab than add the My Rapla projects to the User Entries
- Click run to start Rapla with My Rapla on the classpath
4. Enable the plugin
- go to file/adminstrator/preferences/plugins
- Enable My Rapla plugin and restart Rapla (file/adminstrator/restart rapla)
- Now the Plugin is active it adds 3 extensions to Rapla
- It adds an import functionality in the file menu
- It adds an info dialog in the help menu
- It adds an option dialog in the user preferences
How does this work?
The entry point for the Plugin is org.rapla.plugin.demo.MyPlugin. Rapla will discover and start the Plugin if its defined in the file generated-src/META-INF/rapla-plugin.list This file is automaticaly created by the build file in the My Rapla project.
The Plugin class must implement the PluginDescriptor Interface When the Rapla system start it calls all provideService methods of all Plugin Descripors. So this is the place where you tell Rapla what extension the plugin provides.
if ( !config.getAttributeAsBoolean("enabled", false) )
{
return;
}
container.addContainerProvidedComponent(
RaplaExtensionPoints.CLIENT_EXTENSION,
MyPluginInitializer.class.getName(),
PLUGIN_CLASS, config);
container.addContainerProvidedComponent(
RaplaExtensionPoints.USER_OPTION_PANEL_EXTENSION,
MyOption.class.getName(),
PLUGIN_CLASS, config);
The if condition at the beginnig of the provideService method only adds the extensions if the plugin is enabled.
The first extension is a client extension. That means the My Plugin Initializer class will only be instanciated, if a Rapla client application has successfully started and a user has logged in (autologin in standalone counts as login).
The second extension will add an option panel to the user preferences. The My Option class will only be instanciated when the option dialog is called.
Now we take a closer look at the My Plugin Initializer
public MyPluginInitializer(RaplaContext sm) throws RaplaException {
super(sm);
MenuExtensionPoint helpMenu = (MenuExtensionPoint)
getService( RaplaExtensionPoints.HELP_MENU_EXTENSION_POINT);
helpMenu.insert(createInfoMenu() );
MenuExtensionPoint importMenu = (MenuExtensionPoint)
getService( RaplaExtensionPoints.IMPORT_MENU_EXTENSION_POINT);
importMenu.insert( createImportMenu());
}
When the client is started we add the two menu entries: The help menu and the import menu.
That's it, basically.
Now for writing your own plugin:
Now we want to develop our own view-extension. For a list of all possible extensions see extension point list
![(please configure the [header_logo] section in trac.ini)](/chrome/site/rapla.jpg)