Implementing pluglets

You can use pluglets to list the contents of a selected class in a model or calculate the fan-in metric for a class.

The Model Enumeration pluglet lists the contents of a selected class in a model. It demonstrates basic model examination. The Model Enumeration function is implemented in the run method of the EnumModel class. In this method, the selected elements are obtained from the model. From a modeling perspective, the UMLModeler class allows you access to a model and its contents. An editing context is established. For each selected element, the contents are iterated using the logObject method. The contents are obtained as a list of EMF EObjects. The objects names are listed using the toString method.

The Fan-In pluglet calculates the fan-in metric for a class. The fan-in metric represents the number of references that a class has when selected in the Model Explorer. The Fan-In pluglet initiates the plugletMain method, which iterates through the user selections. If the selection is an instance of a UML 2.0 class, the calcFanIn method is called. This method accesses the model through the execute method of the ResourceSetReadOperation class. The class references are calculated using the getReferencingClassesByOperation and getReferencingClassesByProperty methods. These two methods use the IEObjectHelper.getReferencers method.

Parent topic: Extending your Java environment with pluglets
Previous topic: Running pluglets

Related concepts
Pluglets

Related reference
Pluglets API

Related information
Tutorial and samples for pluglets

Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.