Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

Commit

Permalink
Eclipse documentation with screenshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed Apr 12, 2017
1 parent ad5fe1a commit 1798737
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 78 deletions.
77 changes: 1 addition & 76 deletions README.md
@@ -1,89 +1,14 @@
# ECore Code Generation

Those working with Eclipse EMF Ecore models are familiar with the Ecore code generation editors and process:

* The Ecore model contains the model definition - packages, classifiers, structural features, operations, etc.
* The generator model contains additional information required for code generation - java package names, names of base classes, ...
* There are four "generation targets"
* Model
* Edit support
* Editor
* Tests

The goal of this project is to extend the code generation concepts in the following ways:

* Allow users to select a sub-set of model elements for which to generate code.
* Generation targets can be contributed to the UI through the Eclipse extensions mechanism and a set of generation targets of interest is selected by a user at the generator model creation time.

## Usage scenarios

### Web UI generation

A server application is using a domain model stored in CDO repository. There is a need to create a web page (e.g. a single-page application) dealing with a particular aspect of the model.
For example, display a list of customer accounts with balances in a table.

In this case a developer would create a generator model with the application domain model as input and Web UI generation target.
Then they would select domain model elements which participate in the user story they are implementing - display a list of customer accounts.
In essence, they would define a bounded context for their "micro-app".

After that they would configure Web UI generation for selected domain elements, e.g. select whether to use a drop-down or radio-buttons for value selection.

Once everything is configured the developer would validate the generator model and then generate code for selected targets.

## Concepts

* Code generator model
* Root element - keeps a list of EPackages included in the model and a list of generation targets.
* Model elements - reference Ecore model elements - packages, classifiers, ... Generator model elements keep track of element Ecore model elements selection and contain configuration elements for the model element.
* Generator target is an extension point which defines a name of the target and an implementation class which performs actual generation.
* The target generator class has a method which creates configuration elements contained in the generation model.
* The target generator also has a method selecting model elements supported by the target. Only model elements supported by at least one target are displayed in the tree view.
* Configuration elements are displayed in the tab view in the right bottom of the editor.

![Sketch](sketch.jpg)


## Creating a model

A model is created with a wizard. User selects EPackages and generation targets.

## Editing the model

* Select Ecore elements to be included in the generation process.
* Fill out configuration forms for elements.
* Validate the model.

## Generating code

* Right-click on the model root or other model element and select "Generate". Or click on the generator icon in the form editor.
* Enter values for unbound properties to a dialog when requested.

If the project containing the generation model is a Java project, then Java classes defined in the project or referenced by the project are available in the generators context class loader.

## API Documentation

* [Model](http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore/apidocs/)
* [Edit](http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore.edit/apidocs/)
* [Editor](http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore.editor/apidocs/)
[Online documentation](org.nasdanika.codegen.ecore.editor/doc/ecore.md).

## P2 Repository

* ``http://www.nasdanika.org/products/codegen-ecore/repository``
* [Archived](http://www.nasdanika.org/products/codegen-ecore/org.nasdanika.codegen.ecore.repository-0.1.0-SNAPSHOT.zip)

## Examples

* https://github.com/Nasdanika/codegen-examples

## Roadmap

* Generation target definition
* Interface
* Extension point
* Modify the model wizard
* Select source EPackages - from the registered packages, target platform, workspace packages, URL's
* Select generation targets - from extension points
* Integrate EMF Forms, customize to display context help for form elements generated from model documentation annotations.
* Code generation dialog - selection of targets, remembering last using targets in the model.

## How to contribute
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions org.nasdanika.codegen.ecore.editor/doc/ecore.html
Expand Up @@ -5,5 +5,101 @@
</head>
<body>
<h1 id="ecore-code-generation">Ecore Code Generation</h1>
<p>Those working with Eclipse EMF Ecore models are familiar with the Ecore code generation editors and process:</p>
<ul>
<li>The Ecore model contains the model definition - packages, classifiers, structural features, operations, etc.</li>
<li>The generator model contains additional information required for code generation - java package names, names of base classes, ...</li>
<li>There are four "generation targets"</li>
<li>Model</li>
<li>Edit support</li>
<li>Editor</li>
<li>Tests</li>
</ul>
<p>Nasdanika Ecore Code Generation extends the code generation concepts in the following ways:</p>
<ul>
<li>Allows users to select a sub-set of model elements for which to generate code.</li>
<li>Generation targets can be contributed to the UI through the Eclipse extensions mechanism and a set of generation targets of interest is selected by a user at the generator model creation time. </li>
</ul>
<h2 id="concepts">Concepts</h2>
<ul>
<li>Code generator model</li>
<li>Root element - keeps a list of EPackages included in the model and a list of generation targets.</li>
<li>Model elements - reference Ecore model elements - packages, classifiers, ... Generator model elements keep track of element Ecore model elements selection and contain configuration elements for the model element.</li>
<li>Generator target is an extension point which defines a name of the target and an implementation class which performs actual generation.</li>
<li>The target generator class has a method which creates configuration elements contained in the generation model.</li>
<li>The target generator also has a method selecting model elements supported by the target. Only model elements supported by at least one target are displayed in the tree view.
<br/>
</li>
<li>Configuration elements are displayed in the tab view in the right bottom of the editor.</li>
</ul>
<h2 id="creating-a-model">Creating a model</h2>
<p>Select "File &gt; New &gt; Other" and then "Nasdanika / Ecore Code Generation Model":</p>
<p>
<img alt="select-wizard.png" border="0" src="select-wizard.png"/>
</p>
<p>Click "Next" and select parent folder and file name:</p>
<p>
<img alt="create-model.png" border="0" src="create-model.png"/>
</p>
<p>Click "Next" and select source EPackages:</p>
<p>
<img alt="select-packages.png" border="0" src="select-packages.png"/>
</p>
<p>
<img alt="load-resource.png" border="0" src="load-resource.png"/>
</p>
<p>
<img alt="file-selection.png" border="0" src="file-selection.png"/>
</p>
<p>
<img alt="selected-package.png" border="0" src="selected-package.png"/>
</p>
<p>Click "Next" and select generation targets:</p>
<p>
<img alt="select-generation-targets.png" border="0" src="select-generation-targets.png"/>
</p>
<p>Click "Finish".
<br/>
</p>
<h2 id="editing-the-model">Editing the model</h2>
<ul>
<li>Select Ecore elements to be included in the generation process.</li>
<li>Fill out configuration forms for elements.</li>
</ul>
<p>
<img alt="ledger-ui-model.png" border="0" src="ledger-ui-model.png"/>
</p>
<p>Configuration forms perform live validation of input. Also the model is validated before generation.</p>
<h2 id="generating-code">Generating code</h2>
<ul>
<li>Select the model root in the tree. </li>
<li>Click the cog icon in the top right cornder of the editor.</li>
</ul>
<h2 id="usage-scenario">Usage scenario</h2>
<h3 id="web-ui-generation">Web UI generation</h3>
<p>This scenario is shown in the screenshots above.</p>
<p>A server application is using a domain model stored in CDO repository. There is a need to create a set of web pages dealing with a particular aspect of the model. </p>
<p>In this case a developer would create a generator model with the application domain model as input and Web UI generation target.
Then they would select domain model elements which participate in the user stories they are implementing.
In essence, they would define a bounded context for their application. </p>
<p>After that they would configure Web UI generation for selected domain elements, e.g. select whether to use a select or radio-buttons for value selection.</p>
<p>Once everything is configured the developer would generate code for selected targets.</p>
<h2 id="api-documentation">API Documentation</h2>
<ul>
<li>
<a href="http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore/apidocs/">Model</a>
</li>
<li>
<a href="http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore.edit/apidocs/">Edit</a>
</li>
<li>
<a href="http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore.editor/apidocs/">Editor</a>
</li>
</ul>
<h2 id="example">Example</h2>
<p>
<code>Ledger.nsd_ecore_gen</code> in
<a href="https://github.com/Nasdanika/ledger/tree/master/org.nasdanika.ledger.app">Nasdanika Leder App Project</a>.
</p>
</body>
</html>
95 changes: 94 additions & 1 deletion org.nasdanika.codegen.ecore.editor/doc/ecore.md
@@ -1 +1,94 @@
# Ecore Code Generation
# Ecore Code Generation

Those working with Eclipse EMF Ecore models are familiar with the Ecore code generation editors and process:

* The Ecore model contains the model definition - packages, classifiers, structural features, operations, etc.
* The generator model contains additional information required for code generation - java package names, names of base classes, ...
* There are four "generation targets"
* Model
* Edit support
* Editor
* Tests

Nasdanika Ecore Code Generation extends the code generation concepts in the following ways:

* Allows users to select a sub-set of model elements for which to generate code.
* Generation targets can be contributed to the UI through the Eclipse extensions mechanism and a set of generation targets of interest is selected by a user at the generator model creation time.

## Concepts

* Code generator model
* Root element - keeps a list of EPackages included in the model and a list of generation targets.
* Model elements - reference Ecore model elements - packages, classifiers, ... Generator model elements keep track of element Ecore model elements selection and contain configuration elements for the model element.
* Generator target is an extension point which defines a name of the target and an implementation class which performs actual generation.
* The target generator class has a method which creates configuration elements contained in the generation model.
* The target generator also has a method selecting model elements supported by the target. Only model elements supported by at least one target are displayed in the tree view.
* Configuration elements are displayed in the tab view in the right bottom of the editor.

## Creating a model

Select "File > New > Other" and then "Nasdanika / Ecore Code Generation Model":

![select-wizard.png](select-wizard.png)

Click "Next" and select parent folder and file name:

![create-model.png](create-model.png)

Click "Next" and select source EPackages:

![select-packages.png](select-packages.png)

![load-resource.png](load-resource.png)

![file-selection.png](file-selection.png)

![selected-package.png](selected-package.png)

Click "Next" and select generation targets:

![select-generation-targets.png](select-generation-targets.png)

Click "Finish".

## Editing the model

* Select Ecore elements to be included in the generation process.
* Fill out configuration forms for elements.

![ledger-ui-model.png](ledger-ui-model.png)


Configuration forms perform live validation of input. Also the model is validated before generation.

## Generating code

* Select the model root in the tree.
* Click the cog icon in the top right cornder of the editor.


## Usage scenario

### Web UI generation

This scenario is shown in the screenshots above.

A server application is using a domain model stored in CDO repository. There is a need to create a set of web pages dealing with a particular aspect of the model.

In this case a developer would create a generator model with the application domain model as input and Web UI generation target.
Then they would select domain model elements which participate in the user stories they are implementing.
In essence, they would define a bounded context for their application.

After that they would configure Web UI generation for selected domain elements, e.g. select whether to use a select or radio-buttons for value selection.

Once everything is configured the developer would generate code for selected targets.

## API Documentation

* [Model](http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore/apidocs/)
* [Edit](http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore.edit/apidocs/)
* [Editor](http://www.nasdanika.org/products/codegen-ecore/apidocs/org.nasdanika.codegen.ecore.editor/apidocs/)

## Example

``Ledger.nsd_ecore_gen`` in [Nasdanika Leder App Project](https://github.com/Nasdanika/ledger/tree/master/org.nasdanika.ledger.app).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -5,5 +5,6 @@
</head>
<body>
<h1 id="generation-targets">Generation Targets</h1>
<p>Generation targets perform actual code generation using selected model elements and their configuration as input.</p>
</body>
</html>
4 changes: 3 additions & 1 deletion org.nasdanika.codegen.ecore.editor/doc/generation_targets.md
@@ -1 +1,3 @@
# Generation Targets
# Generation Targets

Generation targets perform actual code generation using selected model elements and their configuration as input.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed sketch.jpg
Binary file not shown.

0 comments on commit 1798737

Please sign in to comment.