Skip to content

ExtensionPoint

UrsZeidler edited this page Mar 13, 2017 · 9 revisions

generation and launch config extension point

With the 1.1.0 release two extension points are introduced to register your own model to text transformation and provide a launch configuration for it.

This way it is possible to add your own acceleo transformation to the generation process.

The de.urszeidler.eclipse.solidity.um2solidity.m2t extension point let you register an acceleo generator to be a part of the uml2solidity generation process.

Configuration Markup:

<!ELEMENT extension (acceleo_generator)*>
<!ATTLIST extension
point CDATA #REQUIRED
id    CDATA #IMPLIED
name  CDATA #IMPLIED>

<!ELEMENT acceleo_generator EMPTY>
<!ATTLIST acceleo_generator
generator_id          CDATA #REQUIRED
generator_name        CDATA #REQUIRED
generator_description CDATA #IMPLIED
generator_target      CDATA #REQUIRED
generator_class       CDATA #REQUIRED
estimated_work        CDATA #IMPLIED>
  • generator_id - The generator_id is used identify the generator also it is the constance for the preferences for checking if the generator is used in the running generation process.
  • generator_name - The name of the transformation.
  • generator_description - A small description.
  • generator_target - The generation_target is used to get the preference for the target folder where the generated files should be stored.
  • generator_class - The class of the acceleo generator which provides the model to text transformation.
  • estimated_work - An optional integer to indicate the work which is needed for the generator, it is used for the progress monitor. The default value is 10.

The de.urszeidler.eclipse.solidity.um2solidity.m2t.laucherTab let you register a launch configuration used to configure the model to text transformation.

Configuration Markup:

<!ELEMENT extension (uml2solidityLauchTab*)>
<!ATTLIST extension
point CDATA #REQUIRED
id    CDATA #IMPLIED
name  CDATA #IMPLIED>

<!ELEMENT uml2solidityLauchTab EMPTY>
<!ATTLIST uml2solidityLauchTab
id        CDATA #REQUIRED
tab_class CDATA #REQUIRED
tab_order CDATA #IMPLIED>

This extension point adds launcher tabs to the uml2solidity laucher configuration. There are used to controll the generation process and provide the parameters for a transformation.

  • id -
  • tab_class - The tab must extends the AbstractUml2SolidityLaunchConfigurationTab the tab must provide at least a boolean field to en/disable the generation and the tab configuration name must correspond to the id of the registered accele_generator.
  • tab_order - The position the tab should be placed, when left out 10 is used. Choose a number higher as 10 as the first are reserved.

There is a simple example project to illustrate the usage. See registering the transformation and the launch config in the plugin.xml.

Register a transformation:

   <extension
         point="de.urszeidler.eclipse.solidity.um2solidity.m2t">
      <acceleo_generator
            generator_class="de.urszeidler.eclipse.solidity.generation.example.template.GenerateUseCasesDoc"
            generator_id="de.urszeidler.eclipse.solidity.generation.example.useCaseDoc"
            generator_name="generate usecase doc"
            generator_target="de.urszeidler.eclipse.solidity.generation.example.usecaseDocTarget">
      </acceleo_generator>
   </extension>

Besides the Generator class the important attributes are the generator_id and the generator_target. Both must correspond to attributes in the launch config. The generator class is generated by acceleo when the transformation contains a [comment @main/] tag. The acceleo file is here.

Note that we include two other transformations uml2service and generateMarkDown the uml2service gives you access to the launch configuration parameters while generateMarkDown contains some helper functions for text generation.

Register a launch config tab:

   <extension
         point="de.urszeidler.eclipse.solidity.um2solidity.m2t.laucherTab">
      <uml2solidityLauchTab
            id="de.urszeidler.eclipse.solidity.generation.example.uml2solidityLauchTab1"
            tab_class="de.urszeidler.eclipse.solidity.generation.example.launch.UmlDocLaunchConfigurationTab">
      </uml2solidityLauchTab>
   </extension>

Here the tab_class is the important attributes. It defines a tab for the launch configuration. This tab is used to define the parameters for your model to text transformation.

There are at least two parameters the launch config must provide, a boolean value defining if the transformation should run and a string value defining the target of the generation. These two parameters are defines by the de.urszeidler.eclipse.solidity.um2solidity.m2t extensions point. The value of the generator_id defines the name of the boolean parameter and the value id the generator_target attributes the name of the target folder parameter.

public class UmlDocLaunchConfigurationTab extends AbstractUml2SolidityLaunchConfigurationTab {
	private static final String GENERATE_UML_DOC_TARGET = "de.urszeidler.eclipse.solidity.generation.example.usecaseDocTarget";
	private static final String GENERATE_UML_DOC = "de.urszeidler.eclipse.solidity.generation.example.useCaseDoc";

....

	@Override
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
		configuration.setAttribute(GENERATE_UML_DOC, false);
		configuration.setAttribute(GENERATE_UML_DOC_TARGET, "doc");
	}

	@Override
	public void initializeFrom(ILaunchConfiguration configuration) {
		try {
			btnGenerateUmlDoc.setSelection(configuration.getAttribute(GENERATE_UML_DOC, false));
			text.setText(configuration.getAttribute(GENERATE_UML_DOC_TARGET, "doc"));
		} catch (CoreException e) {
			Activator.logError("Error while initalize launch config.", e);
		}
	}
Clone this wiki locally