Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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 (http://wiki.pentaho.com/display/ServerDoc2x/The+Pentaho+XUL+Framework+Developer's+Guide). They can also provide whole new areas of funtionality to Spoon through the concept of a Spoon Perspective, which is not limited to XUL.

Attached to this wiki is a zip file containing an example Spoon Plugin, some of which you'll see below. In addition to a simple Hello World example, it also contains a more complex document-based Spoon Perspective.

Current Spoon Plugin Doc:

Developing Spoon Perspectives

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.

...

Code Block
titleSample Annotated Class

<?xml version='1.0'
encoding='UTF-8'?>
@SpoonPlugin(id = "SpoonExample", image = "")
@SpoonPluginCategories({"spoon"})
public class HelloWorldSpoonPlugin implements SpoonPluginInterface {
....
}

...

Code Block
titleExample 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());
    }
  }

Plugin Area

Category ID

Spoon Menusystem and toolbar

"spoon"

Database Explorer Dialog

"database_dialog"

Job Toolbar

"job-graph"

Transformation Toolbar

"trans-graph"

Repository Explorer

"repository-explorer"

Providing New Prespectives to Spoon

...

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

Code Block
titleExample SpoonPerspective

public class HelloWorldSwtPerspective implements SpoonPerspective {
  private Composite comp;
  private static HelloWorldSwtPerspective instance = new HelloWorldSwtPerspective();

  private HelloWorldSwtPerspective(){
    createUI();
  }

  private void createUI(){
    comp = new Composite(((Spoon) SpoonFactory.getInstance()).getShell(), SWT.BORDER);
    comp.setLayout(new GridLayout());
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lbl = new Label(comp, SWT.CENTER);
    lbl.setLayoutData(new GridData(GridData.FILL_BOTH));
    lbl.setText("This perspective has added two menu-items to the Spoon menu-system. One is under " +
        "Tools->\"Spoon Plugin Example\", the other is only visible when the perspective is active: " +
        "Edit->\"Perspective Only Action\"");
  }

  public static HelloWorldSwtPerspective getInstance(){
    return instance;
  }

  public void setActive(boolean b) {
  }

  public List<XulOverlay> getOverlays() {
    return Collections.singletonList((XulOverlay) new DefaultXulOverlay("org/pentaho/di/plugins/examples/helloworld/res/spoon_perspective_overlay.xul"));
  }

  public List<XulEventHandler> getEventHandlers() {
    return Collections.singletonList((XulEventHandler) new HelloWorldPerspectiveHandler());
  }

  public void addPerspectiveListener(SpoonPerspectiveListener spoonPerspectiveListener) {
  }

  public String getId() {
    return "helloWorld";
  }

  // Whatever you pass out will be reparented. Don't construct the UI in this method as it may be called more than once.
  public Composite getUI() {
    return comp;
  }

  public String getDisplayName(Locale locale) {
    return "Spoon Example";
  }

  public InputStream getPerspectiveIcon() {
    ClassLoader loader = getClass().getClassLoader();
    return loader.getResourceAsStream("org/pentaho/di/plugins/examples/helloworld/res/blueprint.png");
  }

  /**
   * This perspective is not Document based, therefore there is no EngineMeta to save/open.
   */
  public EngineMetaInterface getActiveMeta() {
    return null;
  }
}