Extending using pluglets

Pluglets enable the automation of repetitive tasks using Java. A benefit of pluglets over plug-ins is that they can be executed within the same workbench session they are authored. One limitation is that pluglets do not offer debugging support. Also, pluglets do not support the creation of extensions to extension-points.

Creating a pluglet

Pluglets need to be created within a Pluglets Project. Such a project can contain many pluglets. Creating a Pluglets Project is accomplished by using the New Pluglets Project wizard accessible from File > New > Project..., within the Pluglets category.

New Pluglets Projects Wizard

Selecting Pluglets Project and selecting Next will make the Pluglet Projects page appear.

New Pluglets Projects Wizard, Pluglet Projects Page

Entering the new project's name and selecting Finish will create a new project.

Changing the perspective to the Java Perspective using Window > Open Perspective > java will present a better view of the pluglet within the Package Explorer.

Creating a new Pluglet is accomplished by selecting the newly created Pluglets Project and selecting File > New > Pluglet. The New Pluglet wizard will appear.

New Pluglet Wizard

Selecting the UML Modeler category, selecting the Model Enumeration template, and selecting Next will make the Pluglet page appear.

New Pluglet Wizard, Pluglet Page

Entering the pluglet's Java package name, the pluglet's main class name and selecting Finish will create a pluglet Java file and open its editor. Because the Model Enumeration template is chosen, the pluglet includes code to enumerate the content of the selected model element on the console. It also adds a dependency from the Pluglets project to the com.ibm.xtools.modeler.ui plug-in as can be appreciated from the pluglets.xml file also included in the project.

<?xml version="1.0" encoding="UTF-8"?>
      <import plugin="com.ibm.xtools.pluglets"/>
      <import plugin="com.ibm.xtools.modeler.ui"/>

At this point, the pluglet code can be replaced to reflect the desired behaviour. Should a dependency to another plug-in be required, its name should be added to the list of dependent plugins found in pluglets.xml .

Running a pluglet

To run the pluglet, precondition required by the pluglet such as having a proper element selected should be performed, then selecting Run > Internal Tools and the desired pluglet should execute it.

It is possible to deploy a pluglet within a plugin, more information can be found in the description of the com.ibm.xtools.pluglets.ui.samplePluglet extension-point of the Rational Pluglets Developer Guide.

Legal notices