I install Papyrus at here. So how to generate code using Papyrus ?
In order to generate any text artifacts from UML models in the Eclipse Modelling Environment (i.e. Papyrus, TopCased, etc.) you should use Acceleo which is an eclipse implementation of the MOF models to text transformation language, the OMG standard language for models to text transformations. It is a very well made technology but it could take some time to become familiar with it especially if you do not know MOF and the Model Driven Architecture.
QVT is another OMG language but its aim is models to models transformations (not models to text). It is therefore not the right answer to your question.
To generate the java code from UML you can follow the below steps.
- New Project->EMF Project Press Next
- give the project name
- In Model Importer page select UML model and press Next
- Select UML model which is created by using Papyrus.Press next
- In Package selection page select all the root packages
- click finish, it will generate genmodel.
- Use the genmodel to generate Java code.
I hope this information helps.
These can help you.
Papyrus is an Eclipse lugin for modeling, you need to use additional Eclipse plugin to do model transformations. In the other answer you can find link to tutorials. First of them indicates you should use QVTo.
Resources:
To generate code from a UML diagram created with Papyrus must create a run configuration for Papyrus.
More information and a demo video at the following links.
You need to install Papyrus Java Classes Generator.
- Help --> install new software
- work with : http://download.eclipse.org/modeling/mdt/papyrus/updates/releases/mars
- Check group items by category
- Check show only the latest version of available software
- Check Papyrus Java
- Next --> accept terms and conditions
- finish
Now, in your model.di : right click on your class --> Java --> Generate java code. And you're done !
It doesn't work with Java because even if you get a code from a class diagram then this code is so dirty that it is totally unusable.
It seems that this tool has been written by modelers who have never done any java codding :-)
来源:https://stackoverflow.com/questions/7130937/how-to-generate-code-by-papyrus-on-eclipse