Code Example DisplayShape Pluglet
DisplayShape Code Example
You can create pluglets to handle routine tasks and use their functionality to explore and learn the application programming interfaces (API) of the workbench platform and other product extensions.
- Pluglet source file is no different from any other Java source file. Pluglet writers can specify what Eclipse plug-ins their pluglets require, and this controls the pluglet class path, both at compile and at runtime.
This Code Example shows how to write a pluglet that adds geometric shapes to a package and displays them on a diagram, using IBM Rational Software Architect (RSA), IBM Rational Software Modeler (RSM) or IBM Rational® Systems Developer (RSD).
This sample might require some optionally installable components. If you encounter errors or cannot find user interface options when you run the sample, ensure that you installed the appropriate optional components.
The pluglet provided in this Code Example shows a full example that creates a rectangle on a class diagram. It performs the following actions:
- It operates on all open models
- It creates a package
- It creates a diagram
- It inserts the rectangle on it
- Start Rational Software Architect (or RSM, or RSD) on a new Workspace.
- Create a new UML Modeling project containing a test model that the pluglet will iterate through
- Select File -> New -> Pluglets Project.
- Select File -> New -> Pluglet.
- Choose the type: UML Modeler -> Model Enumeration.
- Choose the package: com.ibm.rational.support.
- Choose the name: DisplayShape.
- Replace the template code with the Code Template listed, or Import the DisplayShape.zip into your pluglet project.
- Open and select the model
Run the Pluglet from: Run -> Internal Tools -> DisplayShape (visible in Modeling perspective).
Note that the pluglet operates on all open models, so you do not need to select a model before running the pluglet.
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- Pluglets Developer Guide
InfoCenter: Rational Pluglets Developer Guide
- Extending Rational Software Architect Functionality -> Extending your Java Environment with Pluglets
- Extending Rational Software Architect Functionality -> Reference for extending the modeling environment
- How to create and display geometric shapes on diagrams programmatically with a pluglet
- Eclipse: https://www.ibm.com/developerworks/mydeveloperworks/wikis/form/anonymous/api/library/b7da455c-5c51-4706-91c9-dcca9923c303/document/765ac084-bb0f-4626-9e10-cf2ac011ddca/attachment/24203ee9-8be0-4f29-bef6-f00e0555eee7/media/DisplayShape.zip
- OnLine(DisplayShape.java file)
Mariana Alupului is an Information Developer for IBM Rational Software.
You can reach Mariana at email@example.com