Difference between revisions of "Papyrus/Papyrus Developer Guide/Papyrus diagram generation"
m (String with VM args is added, it will allow the user just copy and paste in into Run Configuration) |
(Create the part Papyrus Extension Root Node Description and add the description of the Label Role Node) |
||
Line 1: | Line 1: | ||
− | Papyrus editor add some new features to GMF, and needs specific generation. | + | 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. |
− | 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 == |
The generation has to be run in a runtime application. | The generation has to be run in a runtime application. | ||
− | === Setup your 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. | |
− | + | ||
− | + | ||
− | + | In the ''Run configuration'' menu, you can | |
− | + | ||
− | === | + | *Add specific vm arguments (''-Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256M -Xms40m -Xmx512m -XX:PermSize=64M''): |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | [[Image:Capture-Run Configurations.gif|400px]] | |
− | + | *Use the arguments define in a *.ini file (for instance the eclipse.ini of your Eclipse) | |
− | + | ||
− | + | ||
− | + | ||
− | + | [[Image:Capture-Run Configurations Configuration.gif|400px]] | |
− | + | === Import the required project === | |
− | == How to add your own template to the custom Papyrus generator == | + | 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 === | ||
+ | |||
+ | 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 : | ||
+ | |||
+ | #Add your template xpt to the plugin org.eclipse.papyrus.def under a subfolder of "dynamic-templates3.5/codegen/xpt" | ||
+ | #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 get'''yourTemplateName'''Emitter() { | public TextEmitter get'''yourTemplateName'''Emitter() { | ||
− | + | return newXpandEmitter("xpt::'''yourTemplatePath'''::'''yourTemplateName'''::'''yourStartingDefine'''"); //$NON-NLS-1$ | |
} | } | ||
− | where <br | + | |
− | '''yourTemplateName''' is the name of your template <br | + | where <br> '''yourTemplateName''' is the name of your template <br> '''yourTemplatePath''' is the path to access to your template from the folder xpt. Subfolder has to be separated by '''::''' <br> '''yourStartingDefine''' the define that will start the generation |
− | '''yourTemplatePath''' is the path to access to your template from the folder xpt. Subfolder has to be separated by '''::''' <br | + | |
− | '''yourStartingDefine''' the define that will start the generation | + | #Edit the class org.eclipse.papyrus.codegen.PapyrusGenerator |
− | + | #Add a method generateXXXPage() : | |
− | + | ||
− | + | ||
− | Add a method generateXXXPage() : | + | |
private void generateDiagramPreferencePage() throws InterruptedException, UnexpectedBehaviourException { | private void generateDiagramPreferencePage() throws InterruptedException, UnexpectedBehaviourException { | ||
− | + | doGenerateJavaClass(emitters.'''getyourTemplateNameEmitter()''', '''PackageName''', | |
− | + | '''ClassName''', '''Input'''); | |
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | <br | + | where <br> '''getyourTemplateNameEmitter()''' : is the new TextEmitter defined before <br> '''PackageName''' : is the name of the package the class will be contained in. It has to match with the one specified in the template. <br> '''ClassName''' : is the name of the class. It has to match with the one defined in the template. <br> '''Input''' : is the input element. It has to match with the type defined with '''FOR''' in your first xpt define. <br> |
+ | |||
+ | #Call this method in the method customRun(). | ||
+ | |||
+ | <br>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. <br> | ||
+ | |||
+ | == Papyrus Extension Root Node Description == | ||
+ | |||
+ | TODO | ||
+ | |||
+ | <br> | ||
+ | |||
+ | === Label Role (Coming soon) === | ||
+ | |||
+ | Description : This extension is used to define the role of the labels (Connection Labels and External Node Labels). The informations provide by this node are used in two ways : | ||
+ | |||
+ | *Define which label should be hidden after the element creation (Preference) | ||
+ | *Provide the role of the label in the Manage Labels dialog. | ||
+ | |||
+ | Fields for this node: | ||
+ | |||
+ | *'''Comment''' : a comment | ||
+ | *'''External Node Label''' : the list of the external node labels which have the specified role | ||
+ | *'''Icon Path Role''' : an icon to illustrate the role of the label | ||
+ | *'''Link Labels''' : the list of the link labels which have the specified role | ||
+ | *'''Role''' : the role of the referenced labels | ||
+ | *'''Visible By Default''' : true or false, allow to define the preference for the labels | ||
+ | |||
+ | <br> | ||
+ | |||
+ | '''Required EditPolicy : ''' | ||
+ | |||
+ | //TODO | ||
+ | |||
+ | '''Warning :''' if you have a node representation and a link representation for the same element (for example, AssociationNodeEditPart and AssociationEditPart), | ||
+ | |||
+ | when you define the Metamodel Type or the Specialization Type of the element, you can't specify the same "Display Name" for each EditPart. | ||
+ | |||
+ | This "Display Name" is used to generate the Preferences Pages. So, before you had one Preference Page by Element (I think) and after you get 2 Preferences Pages : | ||
+ | |||
+ | Before : | ||
+ | |||
+ | *AssociationPreferencePage | ||
+ | |||
+ | <br> | ||
+ | |||
+ | After : | ||
+ | |||
+ | *AssociationNodePreferencePage | ||
+ | |||
+ | *AssociationLinkPreferencePage | ||
+ | *(you should destroy AssociationPreferencePage) | ||
+ | |||
+ | <br> | ||
+ | |||
+ | I you don't use this node : | ||
+ | |||
+ | *you can't manage the display of the labels in the preferences pages | ||
+ | |||
+ | *the dialog to manage the labels works, but it don't display the role. | ||
+ | |||
+ | Examples of usage: | ||
+ | |||
+ | * Labels Preferences for Association | ||
+ | [[Image:AssociationLinkLabelPreference.png|Label Preferences for Association]] | ||
+ | |||
+ | * Labels Manager | ||
+ | [[Image:LabelManager.png|LabelManager]] | ||
− | == How to overwrite existing GMF template == | + | == How to overwrite existing GMF template == |
TODO | TODO |
Revision as of 10:22, 14 April 2011
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.
Contents
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.
In the Run configuration menu, you can
- Add specific vm arguments (-Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256M -Xms40m -Xmx512m -XX:PermSize=64M):
- Use the arguments define in a *.ini file (for instance the eclipse.ini of your Eclipse)
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 :
- Add your template xpt to the plugin org.eclipse.papyrus.def under a subfolder of "dynamic-templates3.5/codegen/xpt"
- 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
- Edit the class org.eclipse.papyrus.codegen.PapyrusGenerator
- 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.
- 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.
Papyrus Extension Root Node Description
TODO
Label Role (Coming soon)
Description : This extension is used to define the role of the labels (Connection Labels and External Node Labels). The informations provide by this node are used in two ways :
- Define which label should be hidden after the element creation (Preference)
- Provide the role of the label in the Manage Labels dialog.
Fields for this node:
- Comment : a comment
- External Node Label : the list of the external node labels which have the specified role
- Icon Path Role : an icon to illustrate the role of the label
- Link Labels : the list of the link labels which have the specified role
- Role : the role of the referenced labels
- Visible By Default : true or false, allow to define the preference for the labels
Required EditPolicy :
//TODO
Warning : if you have a node representation and a link representation for the same element (for example, AssociationNodeEditPart and AssociationEditPart),
when you define the Metamodel Type or the Specialization Type of the element, you can't specify the same "Display Name" for each EditPart.
This "Display Name" is used to generate the Preferences Pages. So, before you had one Preference Page by Element (I think) and after you get 2 Preferences Pages :
Before :
- AssociationPreferencePage
After :
- AssociationNodePreferencePage
- AssociationLinkPreferencePage
- (you should destroy AssociationPreferencePage)
I you don't use this node :
- you can't manage the display of the labels in the preferences pages
- the dialog to manage the labels works, but it don't display the role.
Examples of usage:
- Labels Preferences for Association
- Labels Manager
How to overwrite existing GMF template
TODO