diff --git a/ParameterCatalogs.html b/ParameterCatalogs.html index 4b1ace44bbe61ac1c625be05995973071b510c65..b7d97db685c26f913c3e375f0cc3b5628a5bb768 100644 --- a/ParameterCatalogs.html +++ b/ParameterCatalogs.html @@ -484,14 +484,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
This work by Kai-Holger Brassel, Hamburg, is licensed under CC BY-NC-ND 4.0 +
This work by Kai-Holger Brassel, Hamburg, is licensed under CC BY-NC-ND 4.0
Version: October 19th, 2020.
+Version: November 9th, 2020.
For now, you can dismiss the welcome screen. It can be opened anytime by executing Help → Welcome
For now, you can dismiss the welcome screen. It can be opened anytime by executing Help → Welcome
.
+Now you should see the initial layout of Eclipse with Model Explorer and Outline on the left and a big empty editing area to the right with a Properties view below.
+-+Now you should see the initial layout of Eclipse with Model Explorer and Outline on the left and a big empty editing area with Properties view below to the right.
+There are two hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.
+
Since we will use Ecore diagrams for data modeling, create your first Ecore modeling project now:
+It takes time and effort to come along with good names for model entities, projects, files, and so on. +Also, specific naming conventions are in place to enhance readability of models and program code. +Since it is not always clear where names provided during modeling are used later, I compiled a list of names important in Ecore projects and added examples and comments to elucidate their meaning and naming conventions.
+Name | +Demo Catalog Example | +Real World Expample | +
---|---|---|
Namespace URI |
++ | + |
Namespace Prefix |
+democat |
+buildphys |
+
Base Package (reverse domain)[8] |
+org.example |
+hft-stuttgart.de |
+
Main Package |
+democatalog |
+buildingphysics |
+
Eclipse Project[9] |
+org.example.democatalog |
+de.hft-stuttgart.buildingphysics |
+
Class Prefix |
+Democatalog |
+Buildingphysics |
+
XML File Suffix |
+democatalog |
+buildingphysics |
+
Classes |
+e.g. SolarPanel |
+e.g. WindowType |
+
Attributes |
+e.g. nominalPower |
+e.g. id |
+
Associations |
+e.g. solarPanels |
+e.g. windowTypes |
+
Classes are written in Camel case notation starting with an upper case letter. Associations and attributes are written the same way, but starting with a lower case letter.
+All other names should be derived from the globally unique name space of the project, in our example: example.org/democatalog
.
+It consists of a global unique domain name and a path to the project, unique within that domain.
Use the names of example Demo Catalog to create your first Ecore modeling project:
Execute File → New → Ecore Modeling Project
from main menu — not Modeling Project
!
Name it demo.catalog
and click Next >
Name the project org.example.democatalog
and uncheck Use default location
so that the new project is not stored in workspace but a different directory you create/choose, then click Next >
Uncheck Use Default Location
so that the new project is not stored in workspace, but a different directory you create/choose, then click Next >
Provide democatalog
as main Java package name, uncheck Use default namespace parameter
and provide http://example.org/democatalog
as Ns URI and democat
as Ns prefix
Provide democatalog
as main Java package name and click Finish
.
Click Finish
.
Note that class names — despite the fact that they model a set of similar objects — are always written in singular! They are written in Camel case notation starting with an upper case letter. Associations and attributes are written the same way, but starting with a lower case letter. Names for list-like associations and attributes usually are written in plural form.
+Note that class names — despite the fact that they model a set of similar objects — are always written in singular! +Names for list-like associations and attributes usually are written in plural form.
In our example above, common to all four energy components are attributes modelName
and revisionYear
, thus these are modeled by class EnergyComponent
that is directly or indirectly a super class of Boiler, CombinedHeatPower, SolarPanel, and Inverter.
-Similar, Boiler and CombinedHeatPower share attribute installedThermalPower
factored out by class ChemicalEnergyDevice.
installedThermalPower
factored out by class ChemicalDevice.
+SolarPanel and Inverter share attribute nominalPower
modeled in abstract class ElectricalDevice.
Make sure all files are saved (File → Save All
)
Execute Generate → Model Code
from context menu over democatalog.ecore
Execute Generate → Model Code
from the context menu of Ecore editor democatalog
Execute Generate → Edit Code
from context menu over democatalog.ecore
Execute Generate → Edit Code
from the same context menu
This would create code for a simple user interface, but we use more advanced EMF Forms for that later.
-If, by mistake, project demo.catalog.editor
was created, just delete it from Model Explorer and do not forget to check Delete project contents on disk
in confirmation dialog.
org.example.democatalog.editor
was created, just delete it from Model Explorer and do not forget to check Delete project contents on disk
in confirmation dialog.
demo.catalog.editor
was created, just delet
Generate → Model Code
creates classes that represent the modeled data in code. These classes are located in three packages under directory src-gen
in demo.catalog
.
Generate → Model Code
creates classes that represent the modeled data in code. These classes are located in three packages under directory src-gen
in org.example.democatalog
.
Generate → Edit Code
creates a whole new Eclipse project named demo.catalog.edit
, again with generated classes under directory src-gen
.
Generate → Edit Code
creates a whole new Eclipse project named org.example.democatalog.edit
, again with generated classes under directory src-gen
.
You may have a look at some Java classes for curiosity by double clicking at them in Model Explorer. There is no point in trying to understand the code in detail, but observe token @generated
present in the comments of all classes, fields and methods. Classes, fields and methods marked with this token are (re)generated whenever above commands are executed.
From context menu over democatalog.ecore
execute EMF Forms → Create View Model Project
In the Model Explorer execute EMF Forms → Create View Model Project
from context menu over democatalog.ecore
Leave project name demo.catalog.viewmodel
as is but uncheck Use default location
— as we always do — and browse to the directory containing demo.catalog
Leave project name org.example.democatalog.viewmodel
as is but uncheck Use default location
— as we always do — and browse to the directory containing org.example.democatalog
Click Next >
and select EnergyComponentsCatalog
as data element we want to create a user interface for
According to these inputs a new project is created with file EnergyComponentsCatalog.view
under directory view models
.
+
According to these inputs a new project is created with file EnergyComponentsCatalog.view
under directory viewmodels
.
This file opens automatically in a special View Editor.
Of course, such automatic approach has its limits. -In our case, to have a long list of lists is not very user-friendly, because one has to scroll up and down to find a specific list. +In our case, a long list of lists is not very user-friendly, because one has to scroll up and down to find a specific list. Also, no specific object data are shown in the list and data can only be edited in a pop-up form (no inline editing).
High time to introduce a master-detail view that presents categories of object types in a master view and, after one is selected, the according object table as detail.
+High time to introduce a master-detail view that presents categories of object types in a master view and, after one is selected, the according object table in the detail view.
Be aware that in some cases the view model must adapt to changes in the data model, e.g. a new leaf category and table component has to be created for a new catalog object type. -Other changes are automatically reflected in the generated UI, at least for default forms and other UI elements. +
Be aware that in some cases the view model must adapt to changes in data model, e.g. a new leaf category and table component must be created for a new catalog object type. +Other changes are automatically reflected in the generated UI, at least for default forms and default table columns. To our convenience, view model specifications incompatible with data model are indicated by error badges in the View Editor.
We created a graphical Ecore data model with a catalog class and five classes/types of objects therein. -Classes have been defined by name, attributes, and relations between, often with cardinalities. +Classes have been defined by name, attributes, and relations between them, often with cardinalities. Whenever classes shared some attributes or references we factored these out into super classes. -An enumeration introduced a new attribute type from a set of named values.
+An enumeration introduced a new attribute type as a set of named values.From this data model, we issued commands to create matching Java code for representing the data in memory as well as to store and retrieve them on and from disk. Methods to create, read, update and delete data objects (CRUD) were generated, too.
+From this data model, we issued commands to create Java code for representing the data in memory as well as to store and retrieve them on and from disk. Methods to create, read, update and delete data objects (CRUD) were generated, too.
Lastly, we thought about a good user interface for this data and used EMF Forms to model and prototype it.
+Lastly, we thought about a good user interface for this data and used EMF Forms to model it resulting in a full functional prototype.
Window →
7. Please stay away from version 2020-03 and 2020-06 of Eclipse Modeling Tools, since these came with a bug preventing the user from editing data in table cells within the generated UI.
+
+
diff --git a/ParameterCatalogs.pdf b/ParameterCatalogs.pdf
deleted file mode 100644
index 0bc31317b1e5f85b0e9d507f3a7b1903c078331b..0000000000000000000000000000000000000000
Binary files a/ParameterCatalogs.pdf and /dev/null differ