Tigerstripe M0 Plugin Tutorial

From Eclipsepedia

Jump to: navigation, search

< To: Tigerstripe_Tutorials

Using "standard" generators, Tigerstripe allows you to create output based on the classes that are in your model. In some areas this is known as an "M1" model.

An "M0" model is a set of instances, and in Tigerstripe these are captured in a instance Diagram. By writing an "M0 generator", you can create output files based on the content of instance diagrams.

M1 vs M0 generator

The general process for creating M0 generators is exactly the same as for M1 generators. You specify properties and rules as before, and the deploy phase is exactly the same. The only major differences are :

Triggering a rule

Once deployed, an M0 generator needs to be enabled in the "Generator settings" tab of the Tigerstripe descriptor editor for the project where your instance diagram lives. Here you specify the property values required by your plugin.

Once enabled, open your instance diagram, right click and select the "Generate.." option. This pops up a dialog giving you a couple of options, hit Generator, and the plugin will run over the options you have chosen (typically "This diagram only". The output should appear in the tigerstripe.gen folder as per a standard plugin.

Context contents

In an instance generator rule context, there are a few additional entries that are of interest(the same basic "class based" collections are still populated). There are 3 new collections of interest, identified by the following keys :

  • classInstances
  • associationInstances
  • artifactInstances - a superset of the above two collections.

The contents of these collections are (at this stage) internal representations of instances, and there is a very poor interface. In a template rule, you can use the access methods listed below, but in a Runnable rule, you will almost certainly end up using java reflection to get access to the instance properties

Template methods:

  • $instance.InstanceName
  • $instance.Artifact -> returns the Artifact Class of which this is an instance
  • $instance.Variables -> returns a set of Variables that contain any values you have set against this instance - use $variable.name, $ variable.type to get the details, and $variable.value to get the set of values this will need to be further split to get the individual values.