Delphi 2006 - ECO Child's Play Tutorial
Basic One-to-Many Relationship
This is ridiculous - the highly touted
BDNtv: ECO is Child's Play
demo looks easy ... but how do you start?
That's right - there are no written instructions.
This page supplies the MISSING written instructions so that you to can execute the demo.
I have renamed a few of the components to clarify the example and have removed a few
actions that don't appear to be needed. At any rate,
I have tested these instructions with both C# and Delphi.NET, and,
except for the file sizes, only the tab names are slightly different.
Language | exe | Source | Model Support
|
C# | 36 KB | 62 KB (100 KB on Disk) | 4 KB (16 KB on disk)
|
Delphi.NET | 53 KB | 212 KB (260 KB on Disk) | 5 KB (24 KB on disk)
|
To get these steps, I had to watch the demo many times and,
in some cases, advance it only a few frames at a time to determine
what was actually happening.
One reason that this was so difficult is that the demo is too large
(1024 x 768 plus status bar, control bar, and other stuff) for my screen (1280 x 800) ...
as a result, I can not see both the top and the bottom of the demo at the same time.
Other issues include
- Clicking on icons without saying so
- Double clicking tree nodes without saying so
- Important actions are obscured by the "live" video in the upper left hand corner
(It barely fit on a 1280 x 1024 screen used for part of the analysis.)
Overview
| Starting the Application
| UML Data Model
| WinForm
| Persistence
| Execute
| Debug
| Notes on the Demo
Overview
ECO allows you to design a database application by
- Defining the tables via a UML diagram
- Defining how the data is physically stored via an EcoSpace PresistenceMapper
- Displaying the data via a WinForm
The steps below will show you ONE way to do this.
Starting the Application
- In the main BDS window, click New Project (the button should be in the upper middle of the screen)
- Select C# Projects / ECO WinForms Application and give the project a name
(This creates 8 files in the selected directory - 4 C#, 3 xml, 1 empty)
In actuality, you can use either C# or Delphi.NET to start an ECO WinForms Application.
UML Data Model
- In the upper right hand part of the screen (above the component panel), there is a
panel with 3 tabs ... select the middle tab - Model View
- In the Model View, there are 2 entries - your project and some references.
Open the first (project) tree node and double click the Package_1 node.
(There is a second Package_1 node under the first.)
Double clicking the Package_1 node creates a UML ECO Class Diagram -
this critical step is not explained in the demo.
- Create 2 ECO Class - name them Teachers and Assignments
(Note: in the demo, these names are singular)
The are several ways to add ECO Classes (which are used to define tables) to the UML Diagram
- With the Package_1 node highlighted, right click in the Model View tree diagram and select Add / ECO Class
- Right click on the Package_1 [diagram] sheet and select Add / ECO Class
- In the Tool Palette, select the ECO Class component and place one on the model diagram
- The 2 tables need fields - create these by right clicking anywhere in the associated ECO Classes
and selecting Add / Attribute - the field names and types can be typed directly in the
ECO Classes if they are separated by colons (extra spaces are ignored) - Name:string - otherwise,
you can use the Object Inspector and set the Name and Type for each attribute.
ECO Class (Table)
| Attribute (Field) | Data Type
|
---|
Teachers
| Name | String
|
Subject | String
|
Assignments
| DateSet | DateTime
|
DateDue | DateTime
|
Title | String
|
- Create the 1-M (one-to many) link by selecting Association from the
UML ECO Class Diagram palette and then clicking on the 2 classes (tables)
- Configure the Association object to associate 1 Teacher with zero or more Assignments.
Using the Object Inspector configure End1 and End2 by setting
the Multiplicity properties to
Teachers End | 1 | For each Teacher
|
Assignments End | 0..* | Allow zero or more Assignments
|
Notice that Effective Name tells which end is connected to which table.
Also notice the an extra *s* is added to Assignments when the
Multiplicity is changed to 0..*.
- Click on the Teachers table
and set the Default String Representation to
self.Name
(Click the 3 dots to open a dialog box, click Attributes / Name)
BTW, there is no online (F1) help on this property - apparently,
this defines what is shown as link field, however, some hidden unique value is actually used to link
the 2 tables
- Click the Regenerate ECO Source Code button (at the top of Model View)
(this is done in the demo without comment)
- From the menu, select Project / Build all projects
(I think that this just verifies that there are no errors)
WinForm
This creates a simple user interface.
- Select the WinForm.cs tab (just WinForm if Delphi.NET is used)
- Add an expressionHandle nonvisual component - on the Tool Palette, click the funnel
(filter) icon and type *ex* to locate Enterprise Core Objects / ExpressionHandle and set the
following properties
Property | Value | Comment
|
---|
Name | Teachers_UIExpressionHandle | In the demo, the
name is just Teachers - however, this is a very bad name because it does not
indicate the object type - in my opinion, Teachers_UIExpressionHandle is much better
|
RootHandle | rhRoot |
|
Expression | Teachers.allInstances
| The exact details are not visible because the
video covers the results - click the 3-dot button,
double click Classes / Teachers that creates the OCL Operations
tree node. Double click OCL Operations and .allInstances ... then
click ok.
|
- Add 2 DataGrids, 3 Buttons, and a few other components to the form
and set the following properties (in the following order).
The demo does this by clicking on the tool palette filter icon (funnel),
and typing the first few letters of the desired component.
Component
| Property | Value
|
---|
DataGrid
| DataSource | Teachers_UIExpressionHandle
|
Button
| EcoListAction on EcoListActions | Add
|
RootHandle on EcoListActions | Teachers_UIExpressionHandle
|
currencyManagerHandle
| Name | Teacher_UICurrencyManagerHandle
|
RootHandle | Teachers_UIExpressionHandle
|
BindingContext | DataGrid1
|
expressionHandle
| Name | Assignments_UIExpressionHandle
|
RootHandle | Teacher_UICurrencyManagerHandle
|
Expression | self.Assignmentss
Double click Roles / Assignmentss (notice 2 s's)
|
DataGrid
| DataSource | Assignments_UIExpressionHandle
|
Button
| EcoListAction on EcoListActions | Add
|
RootHandle on EcoListActions | Assignments_UIExpressionHandle
|
Button
| EcoListAction on EcoGlobalActions | UpdateDatabase
|
Persistence
Create something for the UpdateDatabase button to work with
- Select the EcoSpace.cs tab (ProjectNameEcoSpace in Delphi.NET)
- Add the following component
Component
| Property | Value
|
---|
persistenceMapperXml
| FileName | c:\path\file.xml
|
Execute
Execute the project and it should work.
- Use the first button to Add data to the first (Teachers) DataGrid
- Then use the second button to add data to the second (Assignments) DataGrid
- The 3rd button creates an XML file that stores the data
- When you stop and restart the program, you will see that the data is still available
Debug
The first time I ran the application ... it failed with
Can not find any binding context.
There is absolutely NO local (F1) or online help for this error ... I was on my own.
It turned out that I forgot to set
Teachers_UIExpressionHandle.BindingContext ...
notice that the property name does NOT contain a space and that the error message does.
This is the full message ... notice that there is nothing to indicate which component had the problem.
Project Two Table Demo.exe encountered unhandled exception class System.InvalidOperationException with message 'Can not find any binding context'.
After about 4 hours searching, I found something via google that eventually indicated where the problem might be.
Notes on the Demo
- In the demo, the Model View was selected by default ...
this indicates that the demo was practiced and, therefore, the instructions
to select this tab were missing.
- The demo does things very quickly ... but without much explanation.
For instance, how do you know what field types are available?
The available options are under Object Inspector / Type -
it would make more sense if the IDE prompted you with a list of available types.
- In the demo, the table names are singular - in my opinion, they should be plural
because the tables contain many Teachers and Assignments.
- Apparently, the Association object automatically adds an *s* to the end of the table
names under certain situations ... such as Assignmentss, which looks pretty bad. This is ridiculous.
Other times (in another demo), these names are editable -
but I don't understand the difference.
- Setting the Default String Representation was very confusing - it is extremely difficult to
determine what is selected and the results of double clicking are covered by the
video window in the upper left hand corner of the display.
- In the DataGrids, the order of the field names in the demo is reverse from what I got.
I do not know why and I can not control the order.
- This is a good demo ... I recommend it.
Author: Robert Clemenzi -
clemenzi@cpcug.org