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 "Java Code Generation"

m (Installation Instructions)
(Replaced content with "= Page has moved to [https://gitlab.eclipse.org/eclipse/papyrus/org.eclipse.papyrus-designer/-/wikis/Java_code_generation gitlab] =")
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The Java code generation is available in the extra plugins of Papyrus. It can be used by installing the latest version of Papyrus. It allows to create Java source code from a class diagram.
+
= Page has moved to [https://gitlab.eclipse.org/eclipse/papyrus/org.eclipse.papyrus-designer/-/wikis/Java_code_generation gitlab] =
 
+
== Installation Instructions==
+
The Java Generator will be available as a Papyrus extra plugin.
+
 
+
You can install it by using the Papyrus Software Designer update-site:
+
* http://download.eclipse.org/modeling/mdt/papyrus/components/designer/
+
Or you can use the nightly build update site (paste following url in eclipse update site):
+
* https://hudson.eclipse.org/papyrus/view/Designer/job/papyrus-designer-neon-papyrusnightly/ws/releng/org.eclipse.papyrus.designer.p2/target/repository/
+
 
+
Then select "Papyrus Java profile, library and code generation (Incubation)" feature. You need JDT installed (which comes with most Eclipse packages).
+
 
+
== Code generation from UML elements ==
+
 
+
You can generate code for a specific classifier or package in your UML model. To generate code, do the following:
+
 
+
* Right click on classifier or package, either in a diagram or in the model explorer
+
* Designer > Generate Java code
+
* Follow the JDT dialogs that let you create a new JDT project in Eclipse, where code will be generated, if there is no JDT project associated with your model (e.g. the first time you generate code from your model)
+
 
+
When you generate code from a classifier, its required classifiers are also generated. Required classifiers are classifiers related for the generated classifier, e.g. typing one of its attributes, inheritance relationship, dependency relationship. When you generate code from a package (e.g. the root of your model), all of its classifiers, and their required classifiers, will be generated.
+
 
+
[[Image:GenerateJavaCode.jpg]]
+
 
+
== Change generation preferences ==
+
You can change the generation preferences using the eclipse preferences menu, and choose Papyrus -> Java classes Generation.
+
Available options are:
+
 
+
*stop generation on first error (enabled by default),   
+
*implement methods of inheres interfaces and abstract class (enabled by default),   
+
*generate getters & setters (enabled by default), 
+
*manage packages to not include into generation,   
+
*choose the generic classe to use for association (java.util.List by default). 
+
 
+
== Change project name for generation ==
+
 
+
=== By Using Stereotype ===
+
By default, the generator use the name of the model as Java project name for generation. To change the default project name, you can use the profiles system. 
+
First, add the java profile to your model:
+
 
+
*click on your model (on the Model Explorer view),
+
*in the Properties view, choose the Profile tab,
+
*click on Apply registered profile,
+
[[File:applyRegisteredProfile.jpg]]
+
*into the opened pop-up, choose Java
+
[[File:javaRegisteredProfile.jpg]]
+
 
+
You now can change the default project name by adding a profile into your model
+
 
+
*on Properties View, Profile tab, click on Apply stereotypes,
+
*on the opened pop-up choose JavaSrcFolder, and add it into Applied Stereotypes, and close the pop-up by clicking on Ok button.
+
[[File:JavaSrcFolder.jpg]]
+
*you now can change the project name into the JavaSrcFolder stereotype
+
[[File:changeProjectName.jpg]]
+
 
+
 
+
=== From Eclipse Preferences ===
+
Papyrus provides eclipse preferences to change the default source folder name. This preferences  value is used for all generation, if nothing is provided by a stereotype:
+
*Open Eclipse preferences,
+
*Search for ''Papyrus'' section,
+
*Choose ''Java Classes Generation'' sub-section,
+
*Change ''default source folder name value''
+
 
+
[[Image:JavaCodeGenerationEclipsePreferencesDefaultSourceFolderName.png]]
+
 
+
[[Category:Modeling]]
+
[[Category:Papyrus]]
+
[[Category:Papyrus-Designer]]
+

Latest revision as of 05:10, 18 March 2024

Page has moved to gitlab

Copyright © Eclipse Foundation, Inc. All Rights Reserved.