Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Papyrus/Papyrus Developer Guide/Papyrus diagram generation"

(New page: == How to generate a diagram for Papyrus == Papyrus editor add some new features to GMF, and needs specific generation. TODO == How to add your own template to the custom Papyrus gene...)
 
(How to generate a diagram for Papyrus)
Line 1: Line 1:
 +
Papyrus editor add some new features to GMF, and needs specific generation.
 +
Here is a little guide explaining how to deal with the Papyrus generation stuff.
 +
 
== How to generate a diagram for Papyrus ==
 
== How to generate a diagram for Papyrus ==
  
Papyrus editor add some new features to GMF, and needs specific generation.  
+
The generation has to be run in a runtime application.
 +
 
 +
=== Setup your runtime application ===
 +
It is strongly recommended to setup your runtime application before running a generation in order to avoid Java Heap Space error.
 +
 
 +
=== Import the required project ===
 +
You will need to import from your workspace the following project into your runtime application (do not copy them) :
 +
* org.eclipse.papyrus.codegen
 +
* org.eclipse.papyrus.def
 +
* the plugin of the diagram you will generate (like org.eclipse.papyrus.diagram.clazz)
 +
 
 +
=== Update the GMFGen ===
 +
 
 +
In your GMFGen, you have to update two properties to take into account the specific Papyrus templates.  
 +
In the node ''GenEditor'' of your gmfgen files, you have to setup the following properties :<br/>
 +
'''Dynamic Templates''' to ''true''<br/>
 +
'''Template Directory''' to ''/org.eclipse.papyrus.def/dynamic-templates3.5/codegen''<br/>
 +
 
 +
=== Run the generation ===
  
TODO
+
To run the transformation, rigth click on your gmfgen file and select the menu '''Generate Papyrus Diagram'''.
  
 
== How to add your own template to the custom Papyrus generator ==  
 
== How to add your own template to the custom Papyrus generator ==  

Revision as of 09:20, 26 June 2009

Papyrus editor add some new features to GMF, and needs specific generation. Here is a little guide explaining how to deal with the Papyrus generation stuff.

How to generate a diagram for Papyrus

The generation has to be run in a runtime application.

Setup your runtime application

It is strongly recommended to setup your runtime application before running a generation in order to avoid Java Heap Space error.

Import the required project

You will need to import from your workspace the following project into your runtime application (do not copy them) :

  • org.eclipse.papyrus.codegen
  • org.eclipse.papyrus.def
  • the plugin of the diagram you will generate (like org.eclipse.papyrus.diagram.clazz)

Update the GMFGen

In your GMFGen, you have to update two properties to take into account the specific Papyrus templates. In the node GenEditor of your gmfgen files, you have to setup the following properties :
Dynamic Templates to true
Template Directory to /org.eclipse.papyrus.def/dynamic-templates3.5/codegen

Run the generation

To run the transformation, rigth click on your gmfgen file and select the menu Generate Papyrus Diagram.

How to add your own template to the custom Papyrus generator

To add a new template to the mechanism of generation, you have to :

  1. Add your template xpt to the plugin org.eclipse.papyrus.def under a subfolder of "dynamic-templates3.5/codegen/xpt"
  2. In the plugin org.eclipse.papyrus.codegen, edit the class org.eclipse.papyrus.codegen.PapyrusCodegenEmitters by adding a get method for your template :
public TextEmitter getyourTemplateNameEmitter() {
   return newXpandEmitter("xpt::yourTemplatePath::yourTemplateName::yourStartingDefine"); //$NON-NLS-1$
}

where
yourTemplateName is the name of your template
yourTemplatePath is the path to access to your template from the folder xpt. Subfolder has to be separated by ::
yourStartingDefine the define that will start the generation

  1. Edit the class org.eclipse.papyrus.codegen.PapyrusGenerator
    1. Add a method generateXXXPage() :
    private void generateDiagramPreferencePage() throws InterruptedException, UnexpectedBehaviourException {
     doGenerateJavaClass(emitters.getyourTemplateNameEmitter(), PackageName,
     ClassName, Input);
    }
    

    where
    getyourTemplateNameEmitter() : is the new TextEmitter defined before
    PackageName : is the name of the package the class will be contained in. It has to match with the one specified in the template.
    ClassName : is the name of the class. It has to match with the one defined in the template.
    Input : is the input element. It has to match with the type defined with FOR in your first xpt define.

    1. Call this method in the method customRun().


You just now have to run your transformation as explained before in this page. Be careful to refresh your projects in your runtime application if you generate in this mode.

How to overwrite existing GMF template

TODO

Back to the top