Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

PDI Spoon Plugin Development

Spoon plugins provide developers the ability to add new or modify existing functionality of the Spoon UI. A Spoon plugin can modify any area that's been written in Pentaho XUL Xul Developer's Guide. Below is a current list of areas written in XUL that can be modified:

  • Menu system
  • Toolbars
  • Agile BI
  • Database Explorer Dialog

Plugins can also provide whole new areas of funtionality to Spoon through the concept of a Spoon Perspective.

Common Use Cases

The most common use case is to add new functionality to Spoon. However, user interface elements can be hidden, rearranged or have their behaviors changed by Spoon Plugins.

Spoon Plugin Structure

Spoon Plugins are packaged as a folder under the $SPOON_HOME/plugins/spoon folder. They contain a plugin.xml file which contains a list of Plugin class names, and a lib directory where the plugin jar and all needed dependent jars are located. Spoon Plugins can also be supplied using annotated classes

Example plugin.xml
<?xml version='1.0' encoding='UTF-8'?>
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

  <bean id="YOUR_BEAN_ID" class="org.sample.YourSpoonPluginClass"></bean>
</beans>
Sample Annotated Class
<?xml version='1.0' encoding='UTF-8'?>
@SpoonPlugin(id = "SpoonExample", image = "")
@SpoonPluginCategories({"spoon"})
public class HelloWorldSpoonPlugin implements SpoonPluginInterface {
....
}

Spoon Plugin Implementations

Spoon Plugins don't tell Spoon where they're to be applied. Instead the control is inverted and every Spoon Plugin registered will be asked to apply itself to a given area (category) when that area is loaded. For instance when the Database Explorer dialog is created all plugins will be given the chance to make their customizations.

Example modifying the menusystem of spoon
  public void applyToContainer(String category, XulDomContainer container) throws XulException {
    container.registerClassLoader(getClass().getClassLoader());
    if(category.equals("spoon")){
      container.loadOverlay("org/pentaho/di/plugins/examples/helloworld/res/spoon_overlay.xul");
      container.addEventHandler(new HelloWorldPerspectiveHandler());
    }
  }

Providing New Prespectives to Spoon

Perspectives are wholly distinct area of functionality. Spoon ships with several, from ETL to Agile BI, Scheduling, etc. Most are XUL-based, but you can implement them is pure SWT as well.

Perspectives are supplied through Spoon Plugins. Simply implement the following:

  public SpoonPerspective getPerspective() {
    return HelloWorldSwtPerspective.getInstance();
  }

Perspectives must implement several methods which provide Spoon with what it needs to manage their presentation and by which it can notify the perspective when it's become active.

Method

Description

getId()

Unique ID

getUI()

Return the Composite panel

getDisplayName(Locale l)

Localized name

getPerspectiveIcon()

Icon to be showed in the toolbar

setActive(boolean active)

Notification when active state changes

getOverlays()

Return a list of XulOverlays to apply when your perspective is activated

getEventHandlers()

Return a list of XulEventHandlers to be added to Spoon

addPerspectiveListener(...listener)

Allows outside code to register to for activation events for this perspective

getActiveMeta()

Return the active EngineMeta in the case of perspectives with save-able content

  • No labels