Plex Tutorial Windows ENU
Plex Tutorial Windows ENU
For your convenience, CA Technologies provides one site where you can access the
information you need for your Home Office, Small Business, and Enterprise CA
Technologies products. At http://ca.com/support, you can access the following:
■ Online and telephone contact information for technical assistance and customer
services
■ Information about user communities and forums
■ Product and documentation downloads
■ CA Support policies and guidelines
■ Other helpful resources appropriate for your product
Contents 5
Opening the Panel Designer................................................................................................................................ 43
Defining a Multi-line Edit Control ....................................................................................................................... 46
Adding Spin Controls ........................................................................................................................................... 50
Regenerating the Function.................................................................................................................................. 51
Chapter Review .......................................................................................................................................................... 53
Index 147
Contents 7
Chapter 1: Introduction
CA Plex is an e-business application development environment that enables teams of
software developers to design and implement business applications.
This tutorial shows you how to create a simple Windows application that accesses data
using open database components (ODBC). CA Plex supports a wide variety of platforms,
but Windows-ODBC was chosen for this tutorial because little or no configuration is
required (see the following requirements).
Requirements
To complete this tutorial you need to install:
■ CA Plex r7.0
■ Microsoft Visual Studio 2005 Standard edition or higher
If you do not have Visual Studio 2005 Standard edition or higher installed, you can still
work through the tutorial but you cannot compile or run the application.
Chapter 1: Introduction 9
Using Online Help
■ To locate a particular topic, click the Index tab, and then specify a text string.
■ To print an individual topic, choose Print from the Options menu of the currently
displayed help topic or the Print toolbar.
■ To print a group of topics from the Help Topics window, select the topic, and click
the Print button.
Note: You can access online help for CA Plex from any CA Plex Help menu or by
pressing F1 while in the CA Plex application.
Chapter 1: Introduction 11
Chapter 2: Your First Application in 20
Minutes
In this tutorial, you create an application that stores information about projects, the
tasks they contain, and the employees assigned to each task.
In this chapter, you define a project, and the information you want to store about each
project. The pattern libraries in CA Plex are used to streamline the process. The Panel
Designer is also used to make some changes to a dialog. Before the end of this chapter
you will have the first part of the application up and running.
What Is CA Plex?
CA Plex is an architected RAD tool that uses patterns to accelerate the design, creation,
and maintenance of software applications.
You can use to implement hierarchical data structures such as a bill of materials, an
organization chart, or a chart of accounts. CA Plex includes libraries of such patterns,
and additional libraries are available from third-party vendors.
Several of the patterns from the CA Plex pattern libraries are shown in this tutorial.
Workgroup Development
CA Plex provides a model-based workgroup environment in which teams of software
developers can collaborate on the design and construction of applications. At the heart
of this environment is a repository whose facilities include:
■ Multiple developer support that enables developers to work offline and then
update their changes to the central repository
■ Built-in configuration management that enables a model to store a single
application design in multiple versions, platforms, and national languages
■ The integration of designs stored across multiple models
For simplicity, this tutorial focuses on a single-user environment. The single-user model,
called a local model, has already been created for you.
Code Generation
Based on the designs held in the repository, CA Plex automatically generates 100% of
the code to implement applications and database objects across a variety of platforms.
Currently supported implementation options include:
■ .NET Server applications generated in C# with Win32, Java or .NET clients.
■ Multi-tiered e-business applications with Java or HTML clients and Java, Windows
or System i (iSeries) servers
■ Multi-tiered client/server applications with Win32 clients and Java, Windows or
System i servers
■ System i 5250 character based-terminals applications
CA constantly improves and expands the available generators to keep pace with
customer demand and advances in technology. Generators insulate you from the
underlying technology and its implementation details—CA Plex users can take
advantage of new platforms simply by regenerating their existing designs.
This tutorial creates a Windows-ODBC application because this is the simplest platform
to set up and configure. The development process is very similar regardless of the
platform for which you are developing.
Here is an entity-relationship diagram of the application created in this tutorial. You will
draw a diagram like this later.
If you have worked with entity-relationship diagrams before, you can see that:
■ A project can have more than one task, but a task can only belong to one project.
■ A task is owned by a project, which means that if you delete a project, you also
want all of its tasks deleted.
■ Employees are assigned to tasks—one employee can be assigned to more than one
task, but each task can only have one employee assigned to it.
■ An employee is not dependent on any particular task, which means that if you
delete a task, you do not necessarily want to delete the employee record too.
You can see all of this without having to look at any code. This diagram shows useful
information, which CA Plex uses to generate the application.
For the purpose of this tutorial, this model is very basic. If you have developed real
project management systems before, you may find parts of the model that you would
design differently.
Even though it is a simple example, the end product is far from simple. In this tutorial,
you create both a wizard and a property sheet to work with the project data. If you have
built these in other design environments, you know that you would not be able to reuse
much code from the wizard when creating the property sheet. However, CA Plex
enables you to create a property sheet using the information you added to create the
wizard, plus a few new lines of code.
By default, when the model opens, a window called the Object Browser appears and the
name of the model appears in the title bar of the main application window.
Note: Save Your Work—If you need to stop working on this tutorial before reaching the
end of a chapter, save your progress by clicking the Save toolbar button. CA Plex also
prompts you to save your changes when you close certain editors after making changes
in them.
In this chapter, you create an entity called Project. The Project entity uses fields to store
information, such as its start and end dates. You inherit functions to enable end users to
create, modify, and delete projects. Entities, fields and functions are all types of CA Plex
objects.
The Object Browser is the bucket that displays all of the objects in a model. In it, you can
see the pattern library objects available, as well as the objects that you define in your
model.
Click the Show/Hide Browsers toolbar button (located on right end of the toolbar) to
show or hide the Object Browser.
You can keep the Object Browser open while you work, and use it as a palette from
which you can drag the objects you need. When it overlaps other CA Plex windows, it
always appears on top.
By default, the Object Browser shows you objects of one type at a time. You can see
other objects if they are scoped by the main object type. For more information, see
More About Scope. Notice that the Object Browser has shortcut buttons for displaying
entities, fields, and functions. Setting the Object Browser to display functions only
displays unscoped functions. Functions that are scoped by another object (such as an
entity or a view) display when the Object Browser is focused on that object type. You
can also select an object type to view from the object list.
You can click the Show/Hide Library Objects toolbar button to show library objects.You
can tell that an object is in a pattern library because, by default, it has the library name
in front of the object name. For instance, the fourth entity in the preceding graphic is
FOUNDATI/Association. This means that the entity Association comes from the
FOUNDATION pattern library.
For example, in this tutorial, you use the following triple to define a unique identifier for
the Project entity:
In this example, Project (an entity) is the source object of the triple, known by (or known
by FLD) is the verb and Project ID (a field) is the target object.
Note: In the CA Plex documentation, verbs are always printed in bold and often with
their source and target object types (ENT known by FLD, for example).
Triples provide a simple, easily understood language for entering information into CA
Plex. Here are some examples of triples that you will enter:
■ Project has FLD Project Description
■ Project Description is a FLD LongDescription
■ Project described by DGM Project Diagram
In this chapter, triples are entered to define fields for the Project entity: an identifier, a
description, and start and end dates for a project.
You use the Model Editor to view, add, edit, and delete triples.
The following is an example of the Model Editor as it appears after you complete this
chapter.
1. Open the Model Editor by choosing Model Editor from the Tools menu, or clicking
the New Model Editor toolbar button.
You can see some triples already entered in the Model Editor.
You just created the triple Project known by Project ID. This triple defines a primary
key for the Project entity.
7. If the Object Browser is not open, click the Show/Hide Browsers toolbar button to
open it.
8. Click the Fields toolbar button on the Object Browser to display field objects.
Notice the Project ID field you just added. All objects you define in a local model
appear at the top of the Object Browser. Pattern library objects appear below the
local objects.
Other fields are already defined: Employee Email Address, Employee Hire Status,
and so on. The Employee entity and its fields are already defined in the model you
are working with, to save time.
9. Project should still appear in the source object box in the Model Editor. Select has
FLD from the verb list (you can click the verb list and then press the h key twice).
10. Enter Project Description in the target object box.
11. Press Enter.
You have created the triple Project has Project Description, which defines the field
Project Description for the Project entity. You use this field to store a description of
the project. This triple, ENT has FLD, creates a non-key attribute. The values in
non-key attributes do not need to be unique to each entity. For instance, you can
have more than one project with the same text in the description field.
12. Repeat Steps 9-11 to create the following triples:
Project has Project Start Date
Project has Project End Date
13. Click the Refresh toolbar button on the Object Browser. The Object Browser shows
the new fields:
Project ID is a FIELDS/Identifier
Project Description is a FIELDS/LongDescription
Project Start Date is a DATE/CheckedDateISO
Project End Date is a DATE/CheckedDateISO
The FIELDS and DATE prefixes indicate that the objects concerned belong to the FIELDS
and DATE pattern libraries, respectively.
The fields you defined in the previous section have two different data types: character
and date. These represent different kinds of fields:
■ The Project ID field holds some sort of code that uniquely identifies a project
■ The description holds text, and the start and end dates hold dates.
Currently, your model only indicates that those fields exist, and that they belong to the
Project entity, but has no information about what type of data they store.
Inheritance is the mechanism that enables an object to adopt the properties of another
more general (or abstract) object.
By inheriting from pattern library fields, you enable your application to:
■ Validate data entered in the fields (ensuring, for example, that an end user does not
accidentally enter February 31)
■ Display data on the screen appropriately (such as displaying dates according to your
Windows settings)
■ Store data appropriately in the database (creating a text field in the database for
the Project Description field, and date fields for the Project Start Date and Project
End Date fields)
5. You just created the triple Project ID is a FIELDS/Identifier. Click the Refresh button
on the Object Browser. Notice that the Project ID field has a plus sign to the left,
indicating that it now has scoped objects.
Values are another type of CA Plex object. You can see that Project ID now has the
value *Blank, but you cannot tell much else about what it inherited from
FIELDS/Identifier.
7. Drag the Project ID field from the Object Browser to the body of the Model Editor.
The body is the bottom part of the editor, where the full triples are displayed.
When you drag one or more objects to the body of the Model Editor, the display
changes to show you only the triples that define those objects. This is called
focusing the Model Editor. When you drag the Project ID field to the Model Editor,
it focuses on this field, showing the triple Project ID is a FIELDS/Identifier. This still
does not tell you much.
8. To see more about what an object inherits from its ancestor objects, click the Two
Levels toolbar button.
Now you can see that Project ID has inherited a data type of character and length of
10, along with the value *Blank (which you saw in the Object Browser in Step 6).
Note: In Step 4, you dragged the library object FIELDS/Identifier from the Object
Browser to the target object box in the Model Editor. You can actually enter the
name of the object into the target object box (without the library name) to
accomplish the same thing. In step 4, you would have entered Identifier.
A word of caution: if you entered a wrong object name, you could create a new
object with the wrong name. If you do this, find the erroneous object in the Object
Browser and delete it.
9. Click the One Level toolbar button to set the Model Editor to show a single level of
information.
10. Reset the Model Editor display by clicking the Clear Focus button. This displays all of
the triples in the model, again:
If your Model Editor displays a lot more triples than shown in the previous graphic,
you have your model set to display library objects. If this is the case, click the
Show/Hide Library Objects toolbar button.
11. Drag the Project Description field from the body of the Model Editor to the source
object box. This field is in the third column of the Project has Project Description
triple.
12. Enter LongDescription in the target object box, and press Enter.
Notice that the Model Editor displays the triple as:
Project Description is a FIELDS/LongDescription
This indicates that you correctly spelled the name of the pattern library field.
Note: If you create a new object for a model, and it happens to share the name of a
library object, you must rename your object or delete it (if you did not intend to
create it).
13. Repeat Steps 2-4 or Steps 11-12 to create the following triples:
Project Start Date is a DATE/CheckedDateISO
Project End Date is a DATE/CheckedDateISO
14. Click the Refresh toolbar button on the main toolbar (not on the Object Browser).
Your Model Editor should look like this:
When your end users enter data, they typically enter data in every field. You can specify
that some fields are mandatory, while others are optional. If you do not specify
optionality, the default is that they are mandatory.
Primary key fields must always be mandatory, so you should leave the Project ID field as
it is. But, your end users can use a Project ID that is descriptive enough that they do not
need to enter any data in the Project Description field. When end users create projects,
they may not have a start or end date yet.
If end users leave a mandatory field blank and then try to close the dialogs, a message
dialog prompts them to enter data for the blank mandatory field, and does not let them
close the dialog until they do. Since this processing is defined as part of the pattern
library and not hard-coded into CA Plex, you can adapt it as required (but this concept is
not explained in this tutorial).
2. Select the Project entity in the Object Browser and click the Inspect toolbar button.
This focuses the Model Editor on the Project entity, showing only the triples that
define that entity.
3. Click in the center of the triple Project has Project Description to select it.
4. Drag it to the source object (top left) box in the Model Editor:
5. Select optionality SYS from the verb (top middle) list, and Optional from the target
object (top right) list.
6. Press Enter.
You have entered the continuation triple:
Project has Project Description
...optionality triples Optional
Note: If you do not see this view, click the One Level toolbar button to set the
Model Editor to show a single level of information.
7. In the same manner, make the Project Start Date and Project End Date fields
optional.
8. Refresh the Model Editor:
You again use inheritance to add this functionality. In fact, you do it with only two
triples:
Project is a FOUNDATI/EditDetail
Project is a STORAGE/RelationalTable
The first inheritance triple gives your entity the ability to display and process a user
interface. The second inheritance triple provides the functionality to read Project
records from, and write Project records to, a relational database.
The step-by-step instructions that follow help you better understand the consequences
of entering these two triples.
Patterns are groups of CA Plex objects that are designed to be reused and customized.
In this tutorial, you inherit from the included pattern libraries. Additional pattern
libraries are available from third-party vendors.
The templates or frameworks supplied by other tools provide some of the benefits of
patterns. Typically, a template provides a means of copying a predefined solution.
Also note that patterns are created with CA Plex rather than being hard-coded into the
tool. You can customize a Pattern Library by creating your own patterns that inherit
from the supplied patterns. Or you can create your own patterns from scratch.
Patterns and components (such as COM and EJB components) are complementary
technologies. CA Plex patterns can be used to combine and implement groups of
components. Components are usually likened to the building blocks of a house.
Extending this metaphor, you can think of patterns as the blueprint or plan for the
house.
Like patterns, components are intended to maximize software reuse. Components are
black-boxes, whereas patterns can be regarded as gray-boxes whose internal structure
can be modified in certain places. Another distinction is that patterns are purely a
design construct whereas components form a part of the running application.
Notice that there is no plus sign to the left of the Project entity. This tells you that
there are no objects scoped to it.
To add these triples, you must first set the source object type in the Model Editor to
Entity. You could change the object type directly. But, when you drag an object
from the Object Browser, it sets the object type and shows all of the triples for that
object.
2. Drag Project from the Object Browser to the body of the Model Editor.
This is similar to using the Inspect toolbar button. It changes the Model Editor so
that it only shows triples related to the Project entity, changes the object type
(assuming it was not already set to Entity), and puts Project in the source object
box. The body of the Model Editor is the area of the Model Editor below the Entry
Bar that displays existing triples.
3. From the verb list, select is a ENT.
Note: The is a verb you use in this step is different from the one that you used to
specify inheritance for Project’s fields. There are several verbs that have the same
name, but which have a different source and target object. CA Plex only lets you
select the verb that matches the target object (in this step, the is a ENT verb). For
more information about the types of is a verbs, search for is in the online help
index.
4. Enter EditDetail in the target object box, and press Enter.
You just created the triple Project is a FOUNDATI/EditDetail. This indicates that
Project inherits the structure and functionality of the EditDetail pattern in the
FOUNDATION Pattern Library. You can find the FOUNDATION/EditDetail pattern in
the Object Browser by making sure that library objects are displayed (by clicking the
Show/Hide Library Objects toolbar button) and scrolling down.
For more information about the EditDetail pattern, select it in the Object Browser
and press SHIFT+F1.
5. In the Object Browser, click the Refresh toolbar button. By inheriting from
EditDetail, the Project entity now has some scoped objects (it has a plus sign next to
it).
For more information about scoped objects, see More About Scope.
6. Click the plus sign to the left of the entity icon to expand Project, and then click the
plus sign next to the Edit function to expand it:
Project inherited one function, Edit, with a scoped panel and a caption, and two
views, Fetch and Update. These objects give Project a user interface, and enable it
to store data to and retrieve data from a database.
Specifically:
■ The Edit function displays the panel scoped by it.
■ The Caption and Panel objects, which are scoped by the Edit function, store the
layout of the Edit Projects panel. To see what this panel looks like, see the
generated application illustration in Running the Project.Edit Function.
■ The Fetch and Update views scope functions that read and write database
records.
Next, you indicate how the Project entity stores information. Your application uses
a relational database, so you need processing that creates and maintains database
tables. You set Project to inherit from STORAGE/RelationalTable for that
functionality.
7. The Model Editor should still have Project in the source object box, and is a ENT
showing in the verb list. Drag STORAGE/RelationalTable from the Object Browser to
the target object box and press Enter to create the following triple:
Project is a STORAGE/RelationalTable
8. Click the Refresh button to see all of the triples that you defined for the Project
entity in the Model Editor.
9. Click the Refresh button on the Object Browser:
Notice that the Project entity inherited an object called Physical Table from
STORAGE/RelationalTable. This defines the table that is created in the database
when you generate the application. The fields you defined for the Project entity are
stored in this table.
A scoped object is an object that belongs to another object. A scoped object cannot exist
independently of the object by which it is scoped. For instance, a panel that is scoped by
a function is deleted when that function is deleted.
Some types of objects are unscoped. This means that they exist independently of all
other objects in the model. For example, entities are typically unscoped. Conversely, a
table is always scoped to an entity. To create a table object, you must specify the entity
to which it belongs.
When you refer to a scoped object, you often need to use its full name to avoid
ambiguities. For example, there is an entity called Project that scopes a function called
Edit. The function’s full name is Project.Edit, which distinguishes it from other Edit
functions such as Employee.Edit that also exist in this model.
The previous steps showed you how scoped objects are usually created when you
inherit from a pattern. You can also create them manually.
After you have generated and built the objects in your model, you will be able to run the
program to see what you have created.
The Generate and Build window appears. The Message Log pops up when you open
the window. From the Options menu, choose Quiet Mode, and then minimize the
window. This keeps the Message Log from popping up every time it has a new
message.
2. If the Generate and Build window shows library objects, click the Show/Hide Library
Objects toolbar button to hide them.
The Generate and Build window now shows the Project and Employee entities
(Employee was already added to your model before you started):
CA Plex expands Project and highlights all of the generatable objects under it. Not
all of the scoped objects are selected.
5. A Confirm Generate dialog appears, indicating the number of objects that are
generated. Click Yes.
CA Plex generates those objects, and then summarizes the generation process.
Note: Three warnings appear in the Message Log during the generation and build
processes. This is expected and not a problem. You can expect one warning
message (BLD9083) to occur during the generation stage. For more information, see
Checking for Errors.
6. When the generation process is complete, the Cancel button becomes an OK
button. Click OK to close the Generation Status dialog.
7. CA Plex prompts you to compile and build the objects. Click Yes.
CA Plex starts Microsoft Visual Studio to compile the generated C++ source files.
Depending on your settings, Visual Studio may start minimized.
At the same time, the database table is sent to the ODBC data source being used for
this tutorial. To make set up easier, CA Plex created this data source automatically
during installation together with the underlying Microsoft Jet database.
Note: You can expect to see two of the three warning messages during the build
process. For more information, see Checking for Errors.
You can tell that your C++ build is done when the label on the Visual Studio taskbar
button changes from the name of the model to Microsoft Visual C++. Or, if you have
opened the Visual Studio window so that you could watch the build, you can tell
that it is finished when the cursor returns to the top of the build summary.
CA Plex generates native C++ that is based on Microsoft Foundation Classes (MFC), a
robust, industry standard C++ class library. Each function in the model is implemented
as a Windows DLL.
If we chose to implement our application in Java, CA Plex would generate 100% pure
Java code based on Sun’s Java 2 platform. Similarly, we could also implement the
application on the IBM System i by generating native RPG and DDS code.
Note: The WinC Build Summary toolbar button may not work if the path to your
generation directory contains embedded spaces.
You are not prompted to review the build summary any more in this tutorial, but if
your application does not run correctly, you should review to see if there were
errors.
2. Click the Save toolbar button to save your model.
3. When you are prompted to choose the data source for your application,
double-click Plex r7.0 Tutorial.dsn.
Your generated application starts. It should look like this:
4. Leave this dialog open. The next steps show you how to add projects to your
database.
Value Enter
Project ID Proj01
Project Description Temporary description.
Project Start Date 12/10/2003
Project End Date 01/01/2004
The area on the right of the dialog should look like this after you enter these values:
For now, you only enter Temporary description. in the Project Description field
because the field extends past the right edge of the dialog, and if you type anything
longer, you will not be able to see what you are typing. Since Project Description
was defined as an optional attribute, you can leave it blank if you prefer.
After you finish entering data, you modify the panel layout so that you can see
more of the description so that it does not run off the right edge.
2. Click the Apply button. The values are posted to the database, and the grid region
on the left of the window shows the new project.
3. Click the Copy toolbar button to create a new project populated with Proj01’s data.
Add the following two projects to the database:
Value Enter
Project ID Proj02
Project Description Temporary description.
Project Start Date 03/01/2001
Value Enter
Project End Date 04/04/2001
Value Enter
Project ID Proj03
Project Description Temporary description.
Project Start Date 05/05/2004
Project End Date 06/05/2004
4. Click the close window button at the upper right corner of the dialog to exit the
application.
Note: None of the panels inherited from the Pattern Libraries have Cancel buttons
on them. If you click the close window button, any pending actions are discarded. If
you click Apply, those changes are completed before the window closes.
Feel free to experiment. Check out referential integrity checking inherited from the
pattern library. For example, you cannot enter the same Project ID for multiple records.
Preserving Data
By default, each time you build your application, CA Plex rebuilds all of the objects you
select in the Generate and Build window, including the tables in your database. Because
rebuilding a database table erases all data in the table, if you leave your local model set
up as it is, you will lose all of the data you just entered the next time you build.
You can prevent losing this data by entering a TBL implement SYS No triple for the table.
This keeps the table from being rebuilt the next time you build the entity to which it is
scoped (in this case, Project). Only set this triple after you have built the table at least
once.
Keep in mind that if you make any changes to an entity that affect its table, such as
adding fields to it, you must set the implement SYS value back to Yes, and regenerate
the table. Any data in it is lost. If you want to preserve data entered after rebuilding,
make sure you reset the implement SYS value to No.
The Panel Designer changes the panel displayed by Project.Edit. You change the size of
the Project Description field and give it a multi-line edit control (so that you can enter
multiple lines of text). Some spin controls are added to the date fields as well.
Remember that this button is not on the toolbar, but rather is on the Object
Browser. Some buttons are on both the Object Browser and the toolbar.
2. If you do not see the Project entity, click the Refresh toolbar button.
3. Expand the Project entity, expand the Edit function, and select Panel:
The Panel Designer appears. You can click the Editor button when you select any
object. CA Plex always opens the appropriate editor.
The Panel Designer is made up of three windows:
■ Design Window
■ Panel Palette
■ Panel Property Sheet
Design Window
The Design Window is the main window in the Panel Designer, and shows you what your
panel looks like. When you change a panel’s properties, you see how the changes affect
what the panel looks like here. You can select, move, and resize buttons, fields, and
other user interface elements using this window. When you make visual changes to the
panel and its elements using the other windows, the changes appear here.
A panel’s elements are grouped into regions (each region has a name). The following
graphic shows the grid and detail regions in the panel displayed by Project.Edit:
Panel Palette
The Panel Palette (left) shows all the elements of the panel, including fields, labels, and
buttons, which are grouped under folders ( ) and regions ( ). Feel free to expand the
folders and regions to see what they contain. Most of the visible elements are contained
in regions. Notice that you can see the five regions of the panel (GridP, DetailP,
GridButtonP, DetailButtonP, and Panel) in the Panel Palette (left).
When a region is expanded, as the DetailP region is in this example, you can see the
elements contained in that region. In the case of the DetailP region, this includes the
Project ID, Project Description, Project Start Date, and Project End Date fields.
When represented on panels, fields typically contain more than one part, usually
including at least one label and a control. Notice on the preceding graphic that the
Project ID field shows both a Left Label and an Edit control. The label indicates whether
it is a Left Label, a Top Label, or a Right Label. The type of label indicates if it appears to
the left or right of the control (left/right label), or as a column heading (top label). The
control is the part that end users interact with. The settings for the control indicate if it
is displayed as an edit box, a list box, a combo box, and so on.
Property Sheet
Every element on a panel has a set of properties associated with it, such as its size,
color, or position. The Property Sheet shows you the properties of the currently selected
element. If no element is selected, the Property Sheet shows you the properties of the
panel as a whole (left).
To see what you can change about an element, select the element in the Design
Window or the Panel Palette, and check its properties on the Property Sheet. The
properties displayed depend on the type of element selected.
For example, you can specify if a button should be included in the tab sequence by
setting its Tab Stop property. However, a field label would not ever be included in a tab
sequence, so if you select a label, the Property Sheet does not display this property.
To modify Project.Edit.Panel:
1. Arrange the Panel Designer windows so that they do not overlap, and you can work
with the contents of each.
You must select an element on a panel to make a change to it. To select only the
element, and not the region it is in, you use the Panel Palette.
2. If it is not already expanded, expand Panel to display the regions on the Edit panel.
3. Expand the DetailP region, and then expand the Project Description field.
The field still extends past the right edge of the panel.
6. In the Property Sheet, click the Size (Col, Row) property.
7. In the edit area at the top of the Property Sheet, change the value to 200, 20, and
then click the check mark button.
The edit control resizes so that it fits within the panel, and the beveled box that
surrounds the fields resizes so that it is just slightly wider than the fields.
8. Now, drag the handle on the bottom center of the edit box to make the box taller.
Make it about three times as tall.
The panel should look something like this:
You have repositioned and resized the Project Description edit box. Next, you set
two properties that enable end users to enter more than one line of text in the edit
box.
9. In the Property Sheet, double-click the Multiline property to change its value from
No to Yes.
10. Select the Scrolling property in the Property Sheet.
Note: If the Scrolling property is not available, make sure that the value of the
Multiline property changed from No to Yes.
Notice that the input area at the top of the Property Sheet changed so that you can
select a value from a list, but you cannot type in a value.
11. Select Vertical from the list.
Setting the Scrolling property to Vertical causes the text in the multi-line edit box to
wrap to the next line when the cursor reaches the right edge. If you did not set this
option, text would continue on the first line off the edge of the field, rather than
wrapping to the next.
When you changed the size and shape of the Project Description edit box, it
covered both the Project Start Date and the Project End date fields. Next, you move
those two fields down.
12. In the Panel Palette, select the Project Start Date field in the DetailP region (without
expanding it).
13. Holding the CTRL key down, select the Project End Date field. This selects both of
the fields (you can see this in the Design Window).
14. In the Design Window, drag the fields so that they are below the bottom of the
Project Description multi-line edit box.
In the Design Window, you can see that the beveled box around the fields resizes to
fit around all of the fields:
3. In the Property Sheet, locate the Spin Control property and set it to Yes.
Notice how you can select multiple elements on a panel and change properties for
all of them.
4. From the File menu, choose Save.
5. Close the Design Window. This closes the whole Panel Designer.
2. Select Project.Edit:
To rebuild a panel, you regenerate and rebuild the function that scopes it. Because
you only modified the Project.Edit.Panel object, you only need to regenerate and
rebuild Project.Edit. If you had made changes that affected the scoped table or
other objects, you would need to regenerate and rebuild those other objects as
well.
3. Click the Generate and Build toolbar button.
4. Click Yes when prompted to generate, and again when prompted to build.
5. When the generate and build process is complete, choose Project.Edit in the
Generate and Build window and click the Run toolbar button.
7. Select the text in the Project Description field for Proj01, and replace it with a
longer description. For example:
Create a database application for the McCready account. Contact is Jim Hauser,
415-555-3146.
8. Click Apply.
Notice that the description has changed in both the grid and detail regions.
9. Select Proj02 and repeat this process to change its description to:
Create an email client for internal support staff.
and change the Proj03 description to:
Convert the ODBC version of the McCready application to a System i version.
10. Close the application.
Chapter Review
In this chapter, you:
■ Learned how to use the Model Editor to add triples
■ Inherited from pattern library objects to define fields, and data access and user
interface functions
■ Generated and built the Project entity’s database table and the inherited functions,
and added some sample data
■ Used the Panel Designer to modify the inherited panel layout
■ Regenerated and rebuilt the affected objects to see your changes
This chapter introduced the following patterns (and their scoped objects):
Pattern Description
Triple Description
ENT known by FLD Defines the primary key of an entity
ENT has FLD Defines a data attribute of an entity and whether it is
...optionality SYS mandatory or optional to provide a value for a field
ENT is a ENT The source entity inherits the properties of the target
entity.
FLD is a FLD The source field inherits the properties of the target field
TBL implement SYS Specifies whether to generate and build a database table
You also define the Task entity and generate and build the Employee entity.
With the project management application you are designing, the real-world entities
map quite easily into database objects. The application tracks projects, the tasks that
make up those projects, and the employees that are assigned to those tasks. Projects,
tasks, and entities are each represented by one entity.
When you have identified the data structures you need, you can represent this
information visually using design diagrams. The CA Plex Diagrammer enables you to
create these diagrams, and define objects and their relationships. When you create
entities and relationships using the Diagrammer, the corresponding triples are
automatically added to your model.
In this chapter, you use the Diagrammer to create a diagram of the data model behind
the sample application (left). In the process, CA Plex creates the Task entity for you,
along with triples representing relationships between the entities.
In CA Plex diagrams, objects are represented by boxes (or other shapes) called nodes. A
relationship between two objects is represented in one of two ways:
Together, two nodes and the link between them, or a node and its sub-node, represent
a triple in an CA Plex model. For example, the diagram of the project application has an
owned by link that relates the Task entity to the Project entity. This corresponds to the
following triple:
When you define and change objects using the Diagrammer, your changes are reflected
everywhere in the model. Similarly, if you delete a triple in the Model Editor, any
corresponding links on diagrams are also removed.
Creating a Diagram
You defined Project in the previous chapter, and Employee was already defined before
you started. In the following steps, you create an entity-relations diagram. On the
diagram, you create the Task entity, and specify the relationships between the different
entities.
The Diagrammer opens, with the Select Diagram Type dialog over it:
7. Drag the Project and Employee entities from the Object Browser to the Diagrammer
window.
The Diagrammer window should look something like this:
8. Drag the Employee node down and to the right, so that it does not overlap the
Project node.
Next, you add the Task entity to the diagram.
9. Right-click below the Project entity.
10. From the pop-up menu, choose Create Node, and then Entity.
CA Plex adds the new node at the point where you clicked the mouse.
The New Node dialog appears:
Note that the title bar on the dialog says Entity. The title bar shows you the type of
node you are defining.
11. Enter Task, and click OK.
12. Position the nodes (by dragging) so that the diagram looks something like this:
In your application, a task is part of a project. Therefore, if you delete a project, you
want all of its tasks to be deleted. Because of this, you define Project as the owner of
Task, so that each task is directly related to the project it is part of. This is known as an
owned by relationship, which is sometimes referred to as a parent-child relationship.
When you define a task that is part of a project, this project management application
requires that you specify an employee who is responsible for completing the task.
Because an employee can be assigned to more than one task, in more than one project,
you do not want to delete the employee record if you delete a task. So, you define a
refers to relationship between the Task and Employee entities.
When you add the triple Task refers to Employee, the Task entity stores the identifier of
the Employee entity, and uses it as a pointer to that entity. The stored value is called a
foreign key.
An employee can be assigned to more than one task, even to more than one task in
more than one project, but a task can have only one employee assigned to it.
You can see the relationships between the entities, but the links look the same,
with no indication of what kinds of relationships they represent. Next, you change
the display so that it shows more information.
7. From the View menu, choose Display Link Labels, and then Link Names. The
Diagrammer window should look something like this:
8. If the link label appears on top of one of the nodes, drag it to a more appropriate
location. When you select a label, the associated link turns red to show you which
link the label goes with.
9. Save your model and close the Diagrammer.
The diagram is automatically synchronized with the model. For example, if you deleted
the Task refers to Employee triple in the Model Editor, the corresponding link would
automatically be removed from the diagram.
Now that you have defined the fields for the Task entity, you need to specify which
patterns you want the Task entity to inherit from.
To specify what pattern library objects the Task entity inherits from:
1. Add the following triples:
Task is a FOUNDATI/EditDetail
Task is a STORAGE/RelationalTable
Task is a FOUNDATI/OwnedCascade
You have already learned about the EditDetail and RelationalTable patterns, but the
OwnedCascade entity is new.
OwnedCascade connects Task with a parent entity so that each record in the Task
entity belongs to a record of the parent entity. When the parent entity that owns
the Task records is deleted, the Task records are deleted as well. This is known as
cascade deletion.
In the diagram, you added the relationship Task owned by Project, so Project is
Task’s parent. The OwnedCascade pattern contains an abstract (placeholder)
parent, called Owner, which you need to replace with a real owner entity.
Next, you replace the placeholder in the FOUNDATI/OwnedCascade pattern with
the Project entity in your model.
2. In the Model Editor, select the Task is a FOUNDATI/OwnedCascade triple (make
sure the whole line is highlighted) and click the Editor toolbar button.
Notice that Task has another view called SuperKeys in addition to the Fetch and
Update views inherited from EditDetail. The SuperKeys view stores the key fields of
the owner of the entity—in this case, Project. Unlike Fetch and Update, SuperKeys
does not have any scoped functions. Views are defined in CA Plex Object Types in
the chapter “Your First CA Plex Application in 20 Minutes.” You learn more about
them later in this chapter.
Now you have defined the Task entity. You have specified what pattern library entities it
should inherit from, defined its fields, and the properties of the fields.
The Employee entity also inherits its user interface from FOUNDATION/EditDetail, and
its database access functions from STORAGE/RelationalTable. It has five fields:
Employee ID, Employee Name, Employee Hire Status, and Employee Email Address.
Employee Hire Status is a status field, which displays as a drop-down list on the
Employee panel.
6. You may notice that the grid on the left does not show the new employees you
have just added. This is the default behavior when adding a series of records using
the Continue New option.
Click the Refresh toolbar button above the grid to show the records.
Chapter Review
In this chapter you:
■ Used the Diagrammer to create a diagram showing the entity relationships in your
application
■ Added new nodes to the diagram for the Task and Employee entities
■ Specified the attributes of the Task entity, and inherited from pattern library fields
to define their properties
■ Inherited from the pattern library entities EditDetail and RelationalTable to provide
database access and user interface functions for Task and Employee
■ Inherited from OwnedCascade for the Task entity to specify that each task record
belongs to a Project record in your database
■ Generated and built the Employee entity’s database table and the inherited
functions, and added some sample data
Pattern Description
Triple Description
ENT described by DGM Associates a diagram object with the source
entity.
ENT owned by ENT Defines a parent/child relationship between
two entities.
ENT refers to ENT Specifies that one entity references
another.
ENT replaces ENT Replaces an abstract entity with a real
...by ENT entity in your application.
By providing a wizard, you give your end users an easy way to define a new project and
all of the information that goes with it.
Some designers might argue that this is not the best use of a wizard. This tutorial
includes it simply as an example to show how quick and easy it is to create sophisticated
user interfaces by inheriting from patterns.
This chapter is your first opportunity to work with the Action Diagrammer, which you
use to modify inherited code.
You create the wizard using a parent function that contains a child site, and two child
functions that display panels inside the child site.
The parent function you create is an unscoped function. This means that it does not
appear under either the Project or Task entities, as Project.Edit and
Task.Edit do. To view unscoped functions in the Object Browser, you click the Functions
toolbar button.
Wizards are linear. In other words, you run each function in a specific order. You should
design the sequence of a wizard before creating its parts. After you determine the order
of the parts, you use FNC comprises FNC triples to set up the order. This wizard uses the
Edit functions you already have for the Project and Task entities, and uses them as the
parts of the wizard.
After you define the wizard functions, the user interface looks like this:
Note: Remember to select Function in the Object Browser if you are dragging and
dropping.
The Project.Update view can be found by expanding the Project entity in the Object
Browser.
When you inherit from FrameChild, the panel scoped to your function becomes a
child panel, which you can display in a child site on the parent panel of the wizard.
The UISTYLE/EditInsert pattern provides a dialog that lets you enter a record, which
is then validated before insertion in the database.
The previous replaces VW triple specifies which view is used by the Add Project
function to display and update records. Note that there are a number of replaces
verbs available for functions—make sure you select replaces VW.
4. To define the second function in the wizard sequence, add the following triple:
Task.Edit is a FNC UISTYLE/FrameChild
Note: To get the Task.Edit function into the source object box, drag it from the
Object Browser.
You created the Task.Edit function in the previous chapter, "Modeling Entity
Relationships." Adding the is a triple modifies the function so that it can run as part
of wizard.
5. In the Model Editor, set the object type to Function.
6. Add the following triples:
Project Wizard is a FNC UISTYLE/FrameWizard
Project Wizard comprises Project.Add Project
Project Wizard comprises Task.Edit
Since you last built the model, you defined two new functions, Project Wizard and
Project.AddUpdate. You also modified the function Task.Edit to inherit from
UISTYLE/FrameChild. You have not yet generated and built the Task entity.
4. Generate and build these objects. For more information on generating and building,
see Generating and Building in the chapter “Your First CA Plex Application in 20
Minutes.”
3. When prompted for a data source, select Plex r7.0 Tutorial.dsn and click OK.
The first part of the wizard appears:
You determine the size that the child site in a wizard needs to be by opening each of the
panels that are displayed in the site, and noting their size. You record the largest height
and width of the child panels, and set the child site to those dimensions.
The child site defined on the panel is too small to hold the panel scoped by Task.Edit,
which measures 454 by 311 pixels (you find a panel’s size by opening the panel and
looking in the Property Sheet). Also, the child site extends to the bottom of the panel,
which means that the child panels overlap the buttons unless you move the button
region.
3. In the Property Sheet, change the Size property to 475,400 to make the whole
panel bigger.
4. In the Panel Palette, expand Panel and select the ChildSiteP region.
This is the child site region, where the child panels appear.
5. In the Property Sheet, change the Size property to 454,311.
Action Diagrammer
CA Plex functions are objects that perform the activities, processes, and procedures that
constitute the functionality of an application. Functions can:
■ Display panels and control how end users interact with the user interface
■ Create, read, update, and delete records in the database
■ Perform calculations
Associated with each function is an action diagram, which contains the code that
specifies what the function does. The Action Diagrammer is used to edit a function’s
action diagram. This editor consists of three windows:
■ Action Diagram window, where you enter instructions
■ Action Diagram Palette, where you select Action Diagram syntax
■ Variable Palette, which displays the variables for the function and their contents
The Action Diagram Palette displays the instructions you use to create function logic. It
is organized in folders containing statements that are grouped based on the types of
actions they perform. You can enter new instructions by typing them in the input line or
dragging them to the input line from the Action Diagram Palette.
Variable Palette
The Variable Palette toolbar button is used to hide or show the Variable Palette. The
Variable Palette lets you view and edit the variables available to a function. Variables in
CA Plex are different from variables in other programming languages. A variable in CA
Plex is a container for one or more fields. A field must be added to a variable before you
can reference it in action diagram code. This is equivalent to declaring variables or fields
in many programming languages.
The Variable Palette displays variables in folders, known as variable groups. Each group
contains one or more variables. Notice that the icon for a variable looks like three field
objects on top of each other.
Refresh and notice that the variable now contains the Project ID field. This adds the
following triples to the model:
Project.Add Project local Project ID
...for UIBASIC/SharedData
The Project ID could have been added to the SharedData variable by entering these
triples in the Model Editor using drag and drop in the Variable Palette. The result is
the same whichever method you use.
7. Keep the Action Diagrammer open for the next section.
The Insert Inserted Pre Point corresponds to the point at which a new Project
record was successfully inserted into the database.
4. Copy the data from the Project ID field in the InsertP region (located in Panel,
Project.AddProject in the Variable Palette) into the SharedData variable so that the
next part of the wizard can use it.
5. In the input line in the Action Diagrammer, enter the following statement and then
press Enter.
Set SharedData<Project ID> = InsertP<Project ID>
This statement copies the data from the Project ID field in the InsertP region into
the SharedData variable, so that the next wizard part can use it. Instead of typing
the entire statement you could have constructed it using drag and drop techniques,
as explained in the next step.
A variable is a list of fields. Each function has its own set of variables that are used to:
■ Pass values between the function and panels, reports, views and other functions
■ Temporarily store interim values during processing
When you perform operations on fields in an action diagram you always specify the
variable to which the field belongs. The same field can (and typically does) appear in
more than one variable. Consider the statement you just entered. The Project ID field
appears in both the InsertP and SharedData variables. Each instance of the field can
store a different value.
To specify the variable to which a field belongs you use the syntax:
variable <field>
For example, this refers to the instance of Project ID in the InsertP variable:
InsertP<Project ID>
As a general rule, the values stored in action diagram fields are local to the function
concerned. Updating the value of a field in one function does not change the value in
another function, unless the field concerned is explicitly passed as an input or output
parameter on a function call.
This type of global data storage is provided by the SharedData variable. The Pattern
Library provides additional processing (in the Get SharedData Values and Set
SharedData Values subroutines) that maintains the values of the fields concerned in an
area of memory that is available to all the functions in a single Windows client
application.
The Next button is needed to trigger an event in a different function. Fortunately, the
wizard patterns provide the entire infrastructure required—only a few lines of code
need to be added.
When the Next button is clicked, it triggers an event in the Add Project function causing
the Add Project panel to be hidden (and then the Task.Edit panel to be shown in its
place). The Add Project function has edit/collection points (inherited from
UISTYLE/FrameChild) that enable us to intervene in this processing:
1. Enter Set release control flag in the input line in the Action Diagrammer, and press
F4.
2. The Action Diagrammer moves to the Pre Point before the Set Release Control Flag
Edit Point.
Select the Post Point following this Edit Point and expand it by pressing the space
bar.
This Post Point corresponds to when end users click the Next or Back buttons to
move to a different part of the wizard. At that stage, this you want to create a
Project record using the values entered by the user. All the processing required to
validate the entered values and then create the record is provided in a subroutine
called Process Insert. You simply need to call this subroutine using a Go Sub
statement.
3. Enter the following statement into the input line and press Enter:
Go Sub Process Insert
There is one further refinement required. The creation of the record may fail for a
variety of reasons. For example, the user may not have entered all the required
values or they might try to create a record using the key of an existing record. In
these circumstances, you need to prevent the wizard moving to the next screen.
There is a simple flag you can set to control this—the ReleaseControl field.
There are a set of fields, Environment fields that indicate whether the creation of a
record was successful. The following If instruction uses a compound condition
separated by OR operators to test these fields.
Because this instruction is quite long, it is shown on three lines, but you need to
enter the entire instruction on one line. You can type the entire line or drag or drop
the required objects from the Variable Palette (see the following example).
4. Enter the following instruction immediately after the previous Go Sub statement:
If Environment<*Validation> IS <*Validation.*Abnormal>
OR Environment<*Returned status> IS <*Returned status.*Abnormal>
OR Environment<*Call status> IS <*Call status.*Abnormal>
Note: It is often easier to enter long action diagram statements by dragging the
necessary parts from the palettes rather than typing them. In this example, the
state *Validation.*Abnormal was dragged from the Variable Palette to the input
line.
5. Enter the following statement inside the If construct you created in the previous
step:
Set FrameChildL<ReleaseControl> = <ReleaseControl.No>
This statement prevents the wizard from moving to the second part if the creation
of the Project record fails.
Note: You can find the FrameChildL variable in the Local variable group in the
Variable Palette.
2. From the View menu, choose Show Full Logic CTRL+SHIFT+F. This resets the display
of the Action Diagrammer.
3. Keep the Add Project action diagram open for a later section.
In this section, you modified the behavior of inherited action diagrams by entering code
into its Pre, Edit, or Post Points. These three types of construct are known collectively in
the CA Plex documentation as edit/collection points. Edit/collection points are placed in
Pattern Library action diagrams at strategic points where the developer of the pattern
expects that you will need to make modifications. In team-based development, this
approach gives pattern developers control over how their patterns are used.
Conversely, it guides developers who use a pattern to the best places to make
modifications.
Edit/collection points always appear as a group of three constructs; an Edit Point with a
Pre and Post Point before and after.
Always enter your code into either a Pre Point or a Post Point. Edit Points are provided
for backwards compatibility with earlier versions of CA Plex and should be avoided (see
the online help for a full explanation).
Always use a Post Point to enter changes unless you have a particular reason to use the
corresponding Pre Point. In Updating the shared data we told you to use the Pre Point.
This was because there was code in the Post Point that needed to be executed after the
code we added.
In this tutorial, we are making things easier for you by specifying exactly which Pre or
Post Point to use. In practice, it takes a little time to become familiar with the flow of
each Pattern Library function. After you learn the action diagram syntax, you can
examine the inherited code to understand how it works. The shipped CA Plex Pattern
Libraries are also supplied with extensive online help that includes function flow
diagrams for many of the major functions.
Note: To get help for a Pattern Library object, select it in the Object Browser and press
SHIFT+F1.
You should have the Add Project action diagram open. Here is a quick way to switch to
the panel associated with an action diagram:
1. From the View menu, choose Edit Panel (F11).
The Add Project panel design appears as a white box without the usual title bar and
border. This is because this panel is a Child Panel that can only be run within a site
on another panel.
2. On the Design window select the Apply button. Click the right-mouse button and
set the Visible property to No using the pop-up menu. This is an alternative to
setting the property on the Property Sheet.
3. Change the Project Description edit control into a multi-line edit control and add a
spin control to the date fields. You made these same changes to the Project.Edit
panel previously. For more information, see Defining a Multi-Line Edit Control and
Adding Spin Controls in the chapter "Your First CA Plex Application in 20 Minutes."
4. That completes the changes to the Add Project function and its panel. Close the
Action Diagrammer and the Panel Designer and save your changes.
4. Expand the Local variable group and then expand the DetailKey variable. Note that
the Project ID field is available in this variable.
5. Drag and drop the Project ID field from DetailKey to the Restrict variable. Then drag
and drop it again to the SharedData:
You have now added the Project ID field to the SharedData and Restrict variables.
This adds the following triples to the model:
Task.Edit local Project ID
...for STORAGE/Restrict
Task.Edit local Project ID
...for UIBASIC/SharedData
Note: For this exercise, Project ID is dragged from the DetailKey variable. This was
just for convenience—it could have also been dragged from the Object Browser and
the result would have been the same.
The functionality you set up to accomplish this is called restrictor processing because it
restricts database access functions so they only display the records associated with a
particular key value—in this case, the primary key of the project.
Next, you add action diagram statements to restrict the display of tasks on the second
part of the wizard. The first step is to put the Project ID field into the Restrict variable.
4. Scroll down and select the End Show Panel Post Point, then click OK. This is Post
Point that immediately follows the End Show Panel Post Point:
The Select Edit Point dialog provides a conventional way to locate and focus on a
particular Pre or Post Point.
5. Inside the End Show Panel Post Point, enter the following lines of code:
The Reload Grid subroutine reads the database to retrieve rows to display on the
grid. Because you use the Restrict variable to read only the tasks for a single
project, the grid only shows those rows. Adding the Project ID field to the Restrict
variable, and then setting its value, is like setting up a display filter.
6. Save your model and close the Action Diagrammer.
You can define your wizard so that it remembers what end users enter, but does not
write anything until they complete the process. In database terms, you commit the
changes when you are ready to write the records (the end users click Finish). The
opposite of commit is rollback, which lets you cancel any changes in memory without
making any changes to the database. You can use this when end users click Cancel.
2. Drag the Project Wizard function from the Object Browser to the body of the Model
Editor, and then add the following triple:
Project Wizard commit SYS Parent
This enables the Project Wizard function to commit and rollback the database.
3. In the Object Browser, select Project Wizard and click the Editor button.
The Action Diagrammer appears, with the Select Edit Point dialog over the Action
Diagram window:
4. Select the Post Point that follows the Process Finish Request Edit Point, and click
OK.
The Process Finish Request Edit Point corresponds with the end user clicking the
Finish button.
The Action Diagrammer appears with the Post Point highlighted:
5. In the input line of the window, enter Commit and press Enter.
The statement is added to the body of the window:
In Step 2 you added the triple Project Wizard commit Parent. This indicated that
you want to do commit/rollback processing. Adding the Commit statement
indicates when you want the transaction committed.
6. Double-click the up arrow ( ) next to the Post Point name in the action diagram.
7. Enter Start cancel request in the input line, and press F4.
The Action Diagrammer moves to the Pre Point before the Start Cancel Request Edit
Point. This Edit Point corresponds to the end user clicking Cancel on the wizard.
8. Double-click the Post Point after the Edit Point.
9. Add the statement Rollback.
10. Save your model and close the Action Diagrammer.
Now, when end users cancel out of the wizard, no records are written to the
database, and when the end users click Finish, the records are written to the
database. In the next section, you generate, build, and test the wizard.
Note: Remember that when you change a panel, you must generate and build the
function that scopes it before you can see the change. You do not generate or build
panels directly.
1. On the Generate and Build window, select the functions Project.Add Project,
Task.Edit, and Project Wizard.
For best results, make sure you have entered some Employee records into the database
before you test the wizard. For more information, see Adding Employee Records in the
Chapter "Modeling Entity Relationships."
3. When you are prompted to select a data source, select Plex r7.0 Tutorial.dsn and
click OK.
The wizard appears:
In the next step, you create a new project by entering a Project ID and a
description.
Note: You made all of the fields except Project ID (the key field) optional, so you do
not have to enter a project start and end date.
4. Enter Proj04 in the Project ID field.
5. Enter the following text in the Project Description field:
Port client to Java, to enable staff to view email from a browser.
6. Click Next.
The second part of the wizard appears. Notice that the Project ID field is already
filled in for you.
10. Select an employee from the grid on the left, and click Select.
11. On the wizard, click Apply.
At this stage, you can enter more tasks if you want.
12. Click Finish.
This is an excellent example of the power that comes from combining model-based
development, patterns and code generation. Because the model records the
relationship between Task and Employee (Task refers to Employee), CA Plex is able to
automatically generate the implied referential integrity and selection processing based
on definitions inherited from patterns.
Chapter Review
In this chapter, you:
■ Created a two-part wizard for adding a new project and defining the tasks that are
part of that project
■ Used the Action Diagrammer to modify the logic of an inherited function
■ Learned that Pre and Post Points are the places in an action diagram where you can
make changes
■ Enabled commit and rollback to control when records are written to the database
■ Enabled the wizard functions to share data so that you can supply the key of the
new Project record when you define Task records
Pattern Description
Triple Description
FNC is a FNC The source function inherits the properties of the
target function.
ENT function FNC Creates a function scoped by the source entity.
FNC comprises FNC Connects the target function to the source function,
without scoping one to the other.
FNC replaces VW Replaces an abstract template view with a view in
...by VW your application.
FNC replaces FNC Replaces references to one function with references
...by FNC to a different one.
In this chapter, you create a property sheet. Like the wizard, the property sheet uses
panel frames to host child functions within a parent function. It enables end users to
maintain employees, projects, and tasks.
The tabs that you see on property sheets are provided by an ActiveX control that has
been integrated with CA Plex patterns.
In this chapter, you create a property sheet that enables end users to maintain
employees and the projects that they defined using the wizard.
When you are done, the two tabs of your property sheet will look like this:
As with the function Project Wizard, you create the function Project Property Sheet
as an unscoped function.
2. Add the following triple:
Employee.Edit is a FNC UISTYLE/FrameChild
This triple enables you to use the edit function scoped to Employee on a tab of the
property sheet. It turns the scoped panel into a child panel.
3. Add the following triple:
This triple associates Employee.Edit with the first tab on the property sheet. Later in
this chapter, you will associate a function that displays both projects and tasks with
the second tab.
To make this work, you create a new function that shows both project and task data.
The panel scoped to the function has a grid on the top that displays projects, and a
section at the bottom that displays tasks. When end users select a project at the top,
only the tasks that belong to that project are displayed in the bottom.
This function comprises the second tab of the property sheet. When you have added
this function to the property sheet, the property sheet looks like this:
This defines a new function scoped to the Project entity. You customize this
function to work with projects and tasks.
2. Double-click Project.Maintain Projects in the body of the Model Editor to focus on
the triples for that object. (The body of the Model Editor actually clears, as there
are no triples defined for Maintain Projects function, yet.)
3. Add the following triple:
You inherit from Grid2 because EditDetail.Edit already has a region called GridP,
and you want two grid regions in the new function. You must inherit from Grid2 to
get a separate Grid2P region; otherwise, with two functions both having GridP
regions, they would become a single one in the new function.
To call the correct database access functions, you need to replace the pattern views
that the original function expects with the Fetch and Update views scoped to your
Task entity.
Because you are replacing views, use the verb replaces VW in the next step.
5. Add the following triples:
Project.Maintain Projects replaces VW FOUNDATION/EditDetail.Fetch
...by VW Task.Fetch
Project.Maintain Projects replaces VW FOUNDATION/EditDetail.Update
...by VW Task.Update
Before you add the replacement triples, Maintain Projects calls the abstract
functions scoped to EditDetail.Fetch and EditDetail.Update.
After you add the replacement triples, Maintain Projects calls the functions scoped
to Task.Fetch and Task.Update.
Inheriting from Grid2 provides the parts needed to work with projects: a grid to
display them on the panel, and calls to template database access functions to read
the records to display.
Next, you replace the abstract view Grid2 with the Fetch view from Project, so that
the BlockFetch function reads the right records to display on the Project grid.
Note: In the next step, after dragging Project.Maintain Projects to the source object
box of the Model Editor, you must change the Object Browser to show entities to
find UIBasic.Grid2.
6. Refresh your Model Editor, and then add the following view replacement triple:
Project.Maintain Projects replaces VW UIBasic.Grid2
...by VW Project.Fetch
In the chapter "Creating a Wizard", you modified Task.Edit so that it would use
BlockFetchSet instead of BlockFetch to retrieve only the tasks for the project you
specify. You do that again for Project.Maintain Projects, so that the task grid only
loads the records that match the selected project.
7. Add the following function replacement triple:
Project.Maintain Projects replaces FNC EditDetail.Fetch.BlockFetch
...by FNC Task.Fetch.BlockFetchSet
8. Refresh the Model Editor to see the triples you defined for Project.Maintain
Projects:
You can only add code at the end of a Pre or Post Point, below any statements that
are already there.
5. Click just below the Go Sub Reload Grid line, and enter the following statement:
Go Sub Reload Grid2
This statement loads the project grid when the panel is initialized.
6. In the Variable Palette, expand the Local variable group.
7. Drag the Project ID field from the Object Browser to Position Grid2.
8. Navigate to the End Initialize Grid2 Post Point.
9. Inside the End Initialize Grid2 Post Point, enter the following statement:
Set PositionGrid2<Project ID> = <Project ID.*Blank>
Note: You can find the PositionGrid2 variable in the Local variable group.
This statement tells the function to read the database starting with the first project.
If you did not add this statement, the function that reloads the grid would start
wherever it stopped the last time it read projects.
10. In the Variable Palette, expand the Local variable group.
11. Drag the Project ID field from the Object Browser to the Restrict variable.
12. Navigate to the Post Point below the Process Selected Grid2 Row Edit Point.
13. Enter the following statements:
This sets the values of the fields in Restrict variable equal to the corresponding
fields in the currently selected row in the project grid. This means that you only get
a list of the tasks for that project from the database, and then it reloads the project
grid. Remember, when the function loads the task grid, it uses the BlockFetchSet
function, which checks the Restrict variable to determine which tasks to load.
14. Navigate to the Post Point below the End Reload Grid2 Edit Point.
15. Enter the following statement:
For Each Selected Grid2P
These statements display the tasks associated with any selected projects in the
Grid2P region.
17. To check that you entered all the required code, choose Show Local Modifications
from the View menu. Use the space bar to expand each construct.
Your action diagram should look like the following example. This example includes
extra comments in the code:
18. Reset the action diagram display by choosing Show Full Logic from the View menu.
19. Save your model and close the action diagram.
Because you made it a child panel, you have no title bar or dialog frame. You can
see the panel elements that it inherited from Task.Edit.Panel, but you cannot yet
see the elements inherited from Grid2.Panel.
2. In the Design Window, drag the bottom edge of the dialog to make it about twice as
tall.
3. In the Panel Palette, select DetailP, GridP, GridButtonP, DetailButtonP, and Panel:
4. In the Design Window, drag the selected elements to the bottom of the panel.
Note: There is a second grid region—it was behind the one you just moved down.
Your panel should look like this.
5. In the Panel Palette, expand Grid2P, and then select the Project Description field.
6. Open the Properties icon. Change the Width property of this field to 400.
7. Widen the entire dialog so that there is some space between the detail region at
the bottom and the right edge.
8. Widen the grid at the top of the dialog so that it is about as wide as the bottom
section.
9. In the Panel Palette, expand the GridP region and select the Project Id field.
Right-click and use the pop-up menu to set the Visible property to No. It is not
necessary to display the Project Id in the grid since we are restricting the grid to the
tasks for a single project.
10. In the Panel Palette, select Panel at the top.
11. Note the size of the panel (it should be roughly 460, 540). You will need this
information later.
12. Save your model and close the panel.
This adds the Maintain Projects function to the property sheet. The order of the
comprises triples is important. The first comprises triple sets the function that
displays the first tab, and the second one sets the function for the second tab.
If the Project.Maintain Projects function is the target of the first triple, then do the
following steps.
2. Click the middle column of the Project Property Sheet comprises Project.Maintain
Projects triple to select the entire triple.
3. Drag the triple onto the Project Property Sheet comprises Employee.Edit triple.
This reorders the triples.
Next, you modify the parent panel so that the child site is large enough to display both
the employee tab and the project/task tab.
The child site now extends past the right and bottom edges of the dialog.
4. In the Design Window, drag the right edge of the dialog so that it is a little wider
than the child site. Then drag the bottom edge so that it extends enough below the
bottom edge of the child site to display the OK, Cancel, and Apply buttons.
The buttons are currently hidden behind the child site. The panel should look like
this:
To override this and specify tab labels yourself, you can add FNC name NME triples to
specify the text to display on that function’s tab in the property sheet.
When you generate and build the property sheet function, the first tab will read
Employees and the second tab will read Projects and Tasks:
For more information on generating and building, see the section Generating and
Building in the chapter "Your First CA Plex Application in 20 Minutes."
2. Select Plex r7.0 Tutorial.dsn from the Select Data Source dialog.
The Maintain Employees, Projects, and Tasks property sheet appears.
There are two Apply buttons:
■ One on the Employee tab—Detail region applies a new or changed employee record
■ One at the bottom of the property sheet—Processes all of the action diagram code
that clicking the OK button processes, but does not close the property sheet
Value Enter
Task ID Task01
Task Description Design the server functionality
Employee ID Emp03
Chapter Review
In this chapter you:
■ Created a property sheet using the FrameProperty and FrameChild patterns
■ Changed the size of the panels of all of the child functions to fit on the parent
function’s panel
■ Defined a new function by combining two pattern functions to create a region with
a grid listing projects and a region with both a grid listing tasks and an editing region
■ Replaced inherited template views with actual views in your model
■ Modified inherited action diagrams so that they only list the tasks that belong to
the selected project
■ Specified the text to display on each tab of the property sheet
■ Generated and built your property sheet and tested it
Pattern Description
Triple Description
FNC name NME Specifies a name to use for a function on panels; in
this case, as the text for a property sheet tab.
The property sheet was created by defining a new function with combined patterns
from the UIBASIC, UISTYLE, and FOUNDATION Pattern Libraries. Creating a property
sheet is much like creating a wizard.
In this chapter, you will define a top-level interface from which you can create a new
project, using the wizard, and maintain employees and projects using the property
sheet.
In this chapter, you create a simple function that calls the wizard and property sheet.
You start with UIBASIC/UIBasicShell, which has a panel and a caption, but no associated
processing.
Next, you modify the panel for your function by adding three buttons to it, which let
users open the property sheet and the wizard:
You also specify a recognizable file name for the application, so that when you create an
executable file (.EXE), its name makes sense.
Now, when you build your application, CA Plex gives it the name Projects.exe.
2. Right-click the top left corner of the panel and choose Create Push Button.
A button is added to your panel, with the button text selected.
3. Enter &Create New Project to change the text, and press Enter.
The & in the text indicates that the letter that follows appears as an underlined
access key on the screen.
The new button you created shows up in the Panel Palette under the Controls
folder:
4. On the panel, click below the Create New Project button to clear it.
5. Repeat Steps 2-4 to create two more buttons below the Create New Project button,
with the captions Maintain &Projects and Maintain &Employees.
6. Resize and arrange the panel and its buttons so that it looks like this:
Use logical events to link actions end users take to code in an action diagram. In the
following steps, you create logical events that are triggered when your end users click
each of the three buttons.
After you define these events, you modify the Project Manager function to call the
wizard and property sheet functions when each logical event is triggered.
Now, when end users click the Create New Project button, the Create New Project
logical event is triggered. Later, you add action diagram code to call the Project
Wizard function when this event is triggered.
6. Click OK.
7. Repeat Steps 2-6 to create logical events called Maintain Projects and Maintain
Employees. Associate the logical events with the Pressed physical events for the
corresponding buttons.
8. Save your changes but keep the Panel Designer open.
To do this, add an Event construct specifying what should happen when the Create New
Project event is triggered.
To add action diagram code for the Create New Project event:
1. Choose Edit Scoping Function F11 from the View menu to switch to the action
diagram for the Project Manager function.
2. In the Select Edit Point dialog, select the Events Post Point, and click OK:
3. In the Action Diagram Palette (not the Variable Palette), expand the Events folder.
Note that the three logical events you created are listed in the Events folder:
4. Drag the Create New Project event to the input line of the Action Diagrammer, and
press Enter.
This adds an Event construct:
This tells the function to display the wizard when the Create New Project button is
pressed.
At this point, you will only map the one event. Before you can map the other two
events to call the property sheet, you must make a small change to the property
sheet function.
7. Save your model and keep the action diagram open for later.
Now, any function that calls the Project Property Sheet function has to pass in a
value for this field. Next, you add a statement to use that value to determine which
tab to display.
7. Navigate to the Pre Point before the End Initialize Edit Point.
There is already code in the Pre Point. The statement you add goes at the end, after
what is already there.
8. Add the following statement:
Set TabStripL<SelectedTab> = Input<Tab>
This sets the displayed tab to the one indicated in the input variable. The action
diagram should look like this:
This creates a variable called Tab Number in the Local variable group. Next, you add
a field to the variable.
6. In the Variable Palette, expand the Local variable group.
CA Plex provides a field called Int in the FIELDS Pattern Library that stores literal
values for integers. Use the field in this function to specify the tabs in the property
sheet by their number (Tab 1 and Tab 2).
7. Set the Object Browser to display fields, make sure library objects are showing, and
drag the FIELDS/Int field from the Object Browser to the Tab Number variable:
Next, tell the Project Manager function what to do when the Maintain Projects and
Maintain Employees buttons are clicked.
8. In the Action Diagram Palette, expand the Events folder.
9. Drag the Maintain Projects logical event from the Action Diagram Palette to the
input line of the Action Diagrammer, and press Enter.
10. Drag the Project Property Sheet function from the Object Browser to the input line
of the Action Diagrammer, and press Enter. Notice that CA Plex automatically
assumes you are entering a Call statement.
The Parameter Mapping dialog appears. Next, tell the Project Manager function
what value to pass to the Project Property Sheet function. The Project Property
Sheet function uses that value to determine which tab to display.
11. Click Map Parameter.
The Select Field dialog appears:
Notice that both the Tab Number variable and the Int field you added to it are
displayed.
12. Expand the Int field.
13. Select the value 2 and click OK.
This tells the property sheet to open the Projects and Tasks tab when it is called.
Next, you tell the Project Manager function to open the property sheet when the
Maintain Employees button is clicked. But this time, you make the Employees tab
show.
14. Click OK to close the Parameter Mapping dialog.
15. Click below the Maintain Projects Event construct in the action diagram.
16. Clear the input line of the Action Diagrammer.
17. Drag the Maintain Employees logical event from the Action Diagram Palette to the
input line of the Action Diagrammer, and press Enter.
This adds another Event construct to the action diagram.
18. Repeat Steps 8-14 to call the Project Property Sheet function for the Maintain
Employees logical event, but instead of mapping to <Int.2>, map it to <Int.*One>.
The action diagram should now look like this.
For full instructions on generating and building, see Generating and Building in the
chapter "Your First CA Plex Application in 20 Minutes."
Remember that earlier in this chapter, you added the triple Project Manager file
name Projects. The Create Exe process uses that triple to determine the filename to
create.
3. When prompted to build the .exe file, click Yes.
4. Switch from CA Plex to Windows Explorer, and locate the directory in which your
compiled files reside.
Note: By default this directory is C:\Program Files\CA\CA Plex
r6.0\Tutorial\Gen\Release.
5. Double-click the file Projects.exe to start the application.
The Project Manager dialog appears:
[ODBC Settings]
SAVE DSN=False
DSN=Plex r7.0 Tutorial.dsn
Userid=
Password=
Database=
Errorlog=
Default Connect=True
Value Enter
Employee ID Emp04
Employee Name Bob Strudwick
Employee Hire Status Full-time
Employee Email [email protected]
Value Enter
Task ID DBImport
Task Description Use db imp
Employee ID Emp04
Value Enter
Task ID Transport
Task Description Transport
Employee ID Emp02
At this point, you can no longer test the property sheet by running it directly from the
Generate and Build window. You can only run the property sheet from the Project
Manager function, because you specified an input parameter to tell the property sheet
which tab to display.
Chapter Review
In this chapter, you:
■ Defined a new function, inheriting from UIBasicShell, to serve as an entry point for
your application
■ Created push buttons and linked them to logical events on the panel of your new
function
■ Defined three Event constructs in the action diagram to enable the push buttons, so
that:
– Clicking Create New Project calls the wizard function you defined in the chapter
"Creating a Wizard"
– Clicking Maintain Projects calls the property sheet function you defined in the
chapter "Creating a Property Sheet" with the Projects tab selected
– Clicking Maintain Employees calls the property sheet function with the
Employees tab selected
■ Generated and built the changed functions and tested your application
Pattern Description
Triple Description
FNC file name NME Specifies a name to assign to the file
generated for the source function.
FNC input FLD Defines an input parameter for a function.
...for VAR
You started with an empty model with no local objects in it. In addition to that empty
model, CA Plex comes with a completed version of the tutorial model, known as the
tutorial reference model.
If you would like to see what the completed model looks like, you can review the
tutorial reference model at any time. This model contains all of the information that you
add as you go through the tutorial, plus comments in the functions’ action diagrams.
The model uses its own data source, and that data source has a corresponding
database. So, you can work with the tutorial reference model without conflicting with
the tutorial model, or its data.
Because it is separate from the tutorial model, you can also use the reference tutorial
model to experiment with. As you read about functionality in the online help, you can
use the tutorial reference model to try out CA Plex features. Before experimenting with
this model, make a backup copy of it, so that you can revert to the shipped version.
The three entities have relationships with each other. The Project entity owns the Task
entity; when you delete a project, all of its tasks are deleted as well. The Task entity
refers to Employee. This enables you to assign employees to tasks, but when tasks are
deleted, the employees are not deleted.
The following shows the entity-relations diagram you created in the tutorial:
End users add new tasks and maintain existing tasks in the property sheet (already
shown), and add tasks in the second part of the wizard:
End users add and maintain employees with the property sheet:
7. In the Generate and Build window, right click the Project Manager function.
8. Choose Create Exe from the pop up menu.
9. Visual Studio creates an executable file for the function.
10. Switch to Windows Explorer, find the directory that stores your compiled files, and
double click Projects.exe. The default location for the compiled files is:
PlexInstallationDirectory/Tutrefer/Gen/Release
Index 147
hiding/showing • 18 U
represented in diagrams • 55
types • 17 unscoped functions • 68
ODBC (open database components ) • 9 unscoped functions, displaying • 18
open database components (ODBC) • 9
optionality • 29
V
views • 17, 61
P adding SuperKeys to Task • 61
Panel Designer • 43, 45, 46 definition • 17
the Design Window • 43
the Panel Palette • 45
the Property Sheet • 46
panels • 17
panels, defining simple • 121, 122
pattens • 13
preserving data • 41
Project entity • 19, 31, 33, 36
defining • 19, 31
generating and building • 36
specifying database functionality • 33
R
RelationalTable entity. See STORAGE/RelationalTable
• 33
requirements • 9
S
saving the tutorial model • 16
scoped objects • 35, 68
defining • 68
deleting • 35
STORAGE/, RelationalTable • 33
T
tables • 17, 41
definition • 17
saving data in • 41
TBL, implement SYS • 41, 64
triples • 19, 29, 112
adding • 19
continuation • 29
deleting • 19
editing • 19
parts • 19
reordering • 112
significance of order • 112
tutorial model, explanation • 15