Eclipse Manual

icons1 icons1

Manual Actifsource User Manual
Notation ↪ To do
ⓘ Information
Bold: Terms from actifsource or other technologies and tools
Bold underlined: actifsource Resources
Monospaced: User input
Italics: Important terms in current situation
Disclaimer The authors do not accept any liability arising out of the application or use of any information or equipment described herein. The information contained within this document is by its very nature incomplete. Therefore the authors accept no responsibility for the precise accuracy of the documentation contained herein. It should be used rather as a guide and starting point.
Contact Actifsource AG
Täfernstrasse 37
5405 Baden-Dättwil
Switzerland
www.actifsource.com
Trademark Actifsource is a registered trademark of Actifsource AG in Switzerland, the EU, USA, and China. other names appearing on the site may be trademarks of their respective owners.

actifsource-point-large actifsource-point-large

Subsections of Eclipse Manual

Overview

Working with models

Actifsource is a comprehensive design and code generator tool, covering all aspects of domain-driven software development from domain analysis through to the design models, code generating, testing, refactoring and maintenance.

Actifsource allows you to define your domain-specific software specification.

image5 image5

This software specification is also called domain model, or specific model. The domain model shall be independent from any used technology (i.e. programming language, operating system, etc.).

image6 image6

As the domain model is domain-specific by definition, we need to specify the structure for every domain. This task is done in the so called meta-model.

image7 image7

The meta-model is built upon concepts of the Actifsource core model (aka Meta Meta-Model). Note that the core model is self-describing, i.e., it is the meta-model of itself.

image8 image8

To find an adequate meta-model, you need to analyze your business domain. If you like to create a Service Oriented Architecture (SAO), your meta-model might will contain services. If you like to model state machines, your meta-model will define states, event and transitions.

Note that the Meta-Model is an abstraction of your business domain, and defines the business classes and their relationships.

As we do not know your meta-model in advance, we cannot generate any suitable code for you. This means, that you have to define your own code templates according to the meta-model. Defining code templates is as easy as writing normal code.

image9 image9

Since everything depends on the meta-model you have to start by analyzing your business domain. Once the meta-model is defined, you are able to enter you domain specific software specification accordingly. Also template code is written along the meta-model. From this three models (meta-model, domain model, code template) your code is generated by the Actifsource code generator.

image10 image10

Resource

Every model consists of so called resources. A resource is like an object and the most abstract entity from the Actifsource core model. In fact, every model element is a resource.

Every resource is identified by a globally unique identifier (GUID) which is automatically assigned, if you create a new resource. Therefore changing resource names never affects any relation between resources.

Getting started

To get started with Actifsource, we suggest our tutorials on the Actifsource web site. Please visit www.actifsource.com/tutorials.

image11 image11

Actifsource Environment

Actifsource Eclipse Plugin

Actifsource is shipped as Eclipse Plugin. Please make sure to install Eclipse first. Choose Help/Install new Software… to install Actifsource from one of the following Eclipse Update Sites:

If you are not familiar with the Eclipse environment, please consult the Installing Actifsource.

Memory Usage

The Actifsource technology allows you to track any keystroke in real-time. As a result of this feature the memory consumption might be quite high for larger models. Make sure to adopt the memory given to Eclipse if necessary in the eclipse.ini file in the Eclipse directory. We suggest at least 4 GB of ram.

image12 image12

To observe the memory while working with Actifsource enable Window/Preferences/General/Show heap status.

image13 image13

Make sure to enable Show Max Heap to track the maximum memory usage by using the context menu on the heap status display.

image14 image14

Perspectives

Since Eclipse is a general software development tool, you must be able to select different perspectives. Make sure that the Actifsource Perspective is selected when working with Actifsource.

image15 image15

Actifsource Preferences

The preferences dialog (Window/Preferences/Actifsource) provides the following configuration options.

Statistics

Selecting the Actifsource menu shows a statistic of the resources.

image16 image16

  • Reources The number of resources in the project.
  • RootResources The number of root resources in the project. A root resource is a non-aggregated resource.
  • Statements The number of statements in the project. The statement declares three resources as follows: Subject-Predicate-Object.

Generator

image17 image17

  • Always clear generator console before generate Actifsource cleans the console output before generating code. This makes it easier to scroll to the top of the output to find error messages.

Style Configuration

The style configuration let you define your own colors.

image18 image18

  • Profile Shows all built-in and user-defined profiles.
  • Edit Edit user-defined profiles. Note that you cannot edit built-in profiles.
  • Copy Copy built-in or user-defined profiles. Use copy on a built-in profile to create a user-defined profile.
  • Remove Removes user-defined profiles. Note that you cannot remove built-in profiles.

Validator

image19 image19

  • Revalidation Delay (ms) Actifsource validates every keystroke. The validation might lead to a high CPU load for large models. For this reason you can configure the delay between validations.

Project Wizard

The project wizard allows you to create a new Actifsource project from scratch. Select File/new/Actifsource Project.

Project Name and Location

image20 image20

  • Project name This is the name of the new project. We suggest that the project name is given in the eclipse-like manner: com.company.project.subproject. Note that the dotted name automatically leads to a corresponding package structure. image21 image21
  • Location This is the location of the project. The default location is in the workspace.
  • Working Set You might add the project to an existing working set. A working set is a dedicated view to the projects of the workspace.

Resource Paths

image22 image22

All Actifsource resources are saved in Resource Files with the ending .asr in an xml format. The resource path defines where to find the model resources.

  • Add Resource Path Adds a new resource path to the project.
  • Edit… Edits an existing resource path.
  • Remove Removes an existing resource path.
  • Generate javamodel Actifsource builds internal Java classes to handle your model. Do not switch off this option unless you know exactly what you do.

Target Folder

Generated code is written to target folders. You might specify any existing or new folder in your project as a target folder.

image23 image23

  • Add Target Folder… Adds a new target folder to your project.

  • Add Build Config Adds a new build configuration to your target folder.
    A build configuration is kind of a make file that tells actifsource which templates to build. If no build configuration is defined, Actifsource automatically generates code for all templates from the current project, combined with all matching resources from the current project (see Build Config, see Template Editor).

  • Add Package… Adds a new package to your build configuration. Code is only generated for matching resources found in the specified packages.

    • com.actifsource.statemachine.specific.* (all resources in the package)
    • com.actifsource.statemachine.specific.** (all resources in the package and its subpackages)

    If no package is defined, Actifsource generates code for all matching resources found in all packages of the current project.

Info

Note that you need to reference packages from other projects explicitly. Set the project dependencies first accordingly.

  • Add Resource… Adds a single resource to your build configuration. If no resource is defined, Actifsource generates code for all matching resources found in all packages of the current project.
Info

Note that you need to reference resources from other project explicitly. Set the project dependencies first (see Chapter 2.5.5 Project Dependencies).

  • Edit… Edits the current entry.
  • Remove Removes the current entry.
  • Ignore Whitespaces Actifsource calculates a checksum (MD5 hash) for every generated file.
    If this option is checked, Actifsource will ignore whitespaces when calculating the checksum.
  • Execute Save Actions Eclipse supports so called Save Actions after a file has been saved (i.e. code formatting). If this option is checked, save actions are executed after generating the files.

Template Folders

image24 image24

This feature is for beta users and developers only and might be used to reference folders for templates of third party products.

Project Dependencies

image25 image25

Use the project dependencies if you like to split your model in different Actifsource projects. Note that you have to set the project dependencies, before you might reference packages and resources from other projects in the target folder.

  • Add Project Adds a new project dependency.
  • Edit… Edits the current project dependency.
  • Remove Removes the current project dependency.

Built-in Dependencies

image26 image26

Use the built-in dependencies to reference any Actifsource built-in models.

Built-In Description
CORE The Actifsource core model (do not remove)
DIAGRAM Domain Diagram
CIP Embedded real-time state engine
DEC Modelling I/O connection and scheduling for embedded systems
OCUMENTATION_METAMODEL Creates meta-model documentation from class diagrams
JAVAMODEL Creates Java classes for model access (shipped with Core built-in)
GRAPHVIZ Generator for graphviz
WORKSPACE File/folder operations and generating Eclipse projects
DATATYPE Common data type meta-model
UML UML state engine and code generator
ECORE ECore meta-model
MODVIS Visualization and animation of domain diagrams in the web browser
FREEMARKER Generator for freemarker templates
XPAND Generator for xpand templates
  • Add Builtin Adds a new built-in project dependency.
  • Edit… Edits the current built-in project dependency.
  • Remove Removes the current built-in project dependency.

Project Properties

All settings shown in Chapter 2.5 Project Wizard can be found in Project/Properties/Actifsource.

image27 image27

Standard Package Structure

We suggest the following package structure.

image28 image28

  • Generic The generic package contains the meta-model.
  • Specific The specific package contains the domain model.
  • Template The template package contains the code templates.

Project Menu

Use the project menu to control the build system of Eclipse and Actifsource.

image29 image29

  • Build Automatically If Build Automatically is switched on, Eclipse will build the project automatically after changed files have been saved.

    Actifsource also generates Java classes for internal use. Generating these internal classes is also switched off by Build Automatically and you can’t expect Actifsource to work correctly. Therefore, please make sure that Build Automatically is switched on.

    Please make yourself familiar with the Eclipse Builder concept. See Project/Properties/Builders to see the active builders for your project and their execution order (see Chapter 7.7 Eclipse Builder).

image30 image30

  • Generate Automatically If Generate Automatically is switched on, Actifsource will generate code after saving changed files. If Generate Automically is not switched on, you have to trigger code generation manually (Right-click on the Eclipse project and select Generate Code).

    Actifsource also generates Java classes for internal use. Generating these internal classes is not switched off by Generate Automatically.

  • Enable External Builder This feature is for beta users and developers only. Since Actifsource is developed by Actifsource, we must be able to build ourselves with the current version. The external builder is compiled at development time and ensures that every change in the Actifsource workspace affects the next code generation run.

Toolbar

The Actifsource toolbar provides you with two important tools.

  • New Actifsource Resource image31 image31 The new resource tool lets you create a new Actifsource resource in the selected package. The new resource tool only allows creating so called root classes.

  • Open Actifsource Resource image32 image32 This tool shows all resources and allows filtering by name. Please note that this operation might be slow for a large amount of resources.

Project Explorer

The project explorer let you access your resource files. Resources are stored as xml files and named by the GUID (Globally Unique Identifier) of the resource. Since this format is incomprehensible for humans, the Project Explorer shows the name for named resources.

image33 image33

Switch on the option Link with Editor to synchronize the project explorer with the currently active editor.

Actifsource Presentation

Actifsource allows you to show aggregated resources sorted by relation or just by their occurrence in the containing class.

  • Group Aggregation By Relation switched on

    image34 image34

  • Group Aggregation By Relation switched off

    image35 image35

Package Presentation

image36 image36

  • Flat Package Presentation Using the flat package presentation, all packages are shown as a flat list.

    image37 image37

  • Hierarchical Package Presentation Using the hierarchical package presentation, the hierarchy is preserved. Note that folders which do not contain files are shown flat anyhow. This might lead to problems if you like to add new files or folders in a collapsed package. Just switch to the flat package presentation to solve this problem.

    image38 image38

Drag and Drop

Use drag and drop to move resources between packages. All references to the resource are kept automatically.

image39 image39

Project Explorer Context Menu

The context menu of the project explorer supports several important operations on packages and resources.

New Dialog

The new/Actifsource dialog creates different types of actifsource files. For some types of resources, you can create new resources based on existing resources.

  • New Actifsource Project Creates a new Actifsource project in the current workspace with the project wizard, as shown in Chapter 2.5 Project Wizard.
  • New BuildConfig Creates a new BuildConfig which can be referenced in target folders (see Chapter 2.5.3 Target Folder and Chapter 7 Build Config).
  • New Class Diagram Creates a new class diagram for UML-like Meta-Model design. The class diagram is the easiest way to create Meta-Models.
  • New Diagram Type Creates a new diagram type which defines a user specific domain diagram. Creating a new diagram type on an existing class preselects this class as the RootClass.
  • New Domain Diagram Creates a new domain diagram. Domain diagrams are based on diagram types.Creating a domain diagram on an existing resource preselects this resource as the singleRoot. The diagram type is automatically selected by the type of the singleRoot. If no singleRoot is defined, it is created automatically with the type defined by the diagram type.
  • New FunctionSpace Creates a new function space (see Chapter 9.2 Function Space).
  • New Package Creates a new package.
  • New Resource Creates a new resource of any type.
  • New Resource Folder Creates a new resource folder (see Chapter 2.5.2 Resource Paths).
  • New Template Creates a new code template (see Chapter Template Editor). Creating a new template on an existing class preselects this class as the base type.

Open with

The Open with dialog forces eclipse to open files with a specific editor. The first element in the Open With list is the default editor. Once opened with another than the default editor Eclipse reminds this setting when double clicking the file to open. Just select Open With/Default Editor to restore the settings.

image40 image40

Actifsource supports the following editor types:

  • Resource Editor The Actifsource Resource Editor is the standard editor which opens all types of Actifsource resources.
  • Class Diagram Editor The Actifsource Class Diagram Editor opens resources of type ClassDiagram.
  • Domain Diagram Editor The Actifsource Domain Diagram Editor opens resources of type DomainDiagram.
  • Template Editor The Actifsource Template Editor opens resources of type Template.

Rename Resources and Packages

image41 image41

You may rename any resource or package via the context menu/rename or by pressing F2 (Windows).

Generic Refactoring

If you change your meta-model, any depending domain model might become invalid. Actifsource lets you register a piece of Java code, which transforms all existing domain models to fit the new meta-model.

Actifsource also uses this feature intensely if there are changes in the core model (meta meta-model). Please make sure to check the release notes to see if you need to run a Generic Refactoring after updating to a new Actifsource Version.

image42 image42

Compare With

image43 image43

Working together in a team, you might have collisions when checking Actifsource resource files (.asr) into your version control system (i.e. CVS, SVN, GIT etc.).

Actifsource lets you compare resources and resolve conflicts in the compare view of the Resource Editor.

Show Resource Dependencies

In the context menu of the selected resource you will find the following commands to show specific dependencies.

  • Show Instances image44 image44 Shows all instances of the selected resource. Note that a resource must be of type Class to have instances. See also Chapter 2.12.2.
  • Show Types image45 image45 Shows all types of the selected resource (typeof statement). See also Chapter 2.12.2.
  • Show Subclasses image46 image46 Shows all sub classes of the selected resource (extend statement). Note that a resource must be of type Class to have sub classes. See also Chapter 2.12.2.
  • Show Superclasses image47 image47 Shows all super classes of the selected resource (extend statement). Note that a resource must be of type Class to have super classes. See also Chapter 2.12.2.
  • Show References image48 image48 Shows all resources that are referencing the selected resource. See also Chapter 2.12.6.
  • Sot Property image49 image49 Sorts resources referenced by a relation. Note that you can sort according to any literal attribute (i.e. name).

image50 image50

Info

Note that you have to switch on Group Aggregation By Relation (see Chapter 2.10.2 Actifsource Presentation) to see the relations.

Actifsource Views

AQL Query

image51 image51

The Actifsource Query Language let you query the model.

Hierarchy

image52 image52

Shows the hierarchy between resources.

Model Inconsistencies

image53 image53

Shows all model inconsistencies calculated by the validator. Make sure that this view is always visible to check whether your model is valid or not. Note that the code generator could throw an exception if your model is invalid.

Model Navigator

image54 image54

The model navigator shows all resources sorted by projects, packages and types. Use the model navigator to find classes outside your project.

Protected Regions

image55 image55

Shows all protected regions from a generated file. Click on the entry to navigate to the protected region in the selected file.

References

image56 image56

Shows all references to a specific resource in the form Subject-Predicate-Object while object is the referenced resource.

Resource Editor

Overview

The Actifsource Resource Editor allows you to view and/or edit any Actifsource resource. Since everything is a resource in Actifsource this is the most important editor.

The Actifsource Resource Editor shows resources as tree (similar to the Windows Explorer).

image57 image57

Aggregated vs. Referenced Resource

Actifsource distinguish between aggregated and referenced resources. An aggregated resource lives in the context of the parent resource. Deleting the parent resource will delete all aggregated resources.

Referenced resource may live anywhere in the model and are just referenced. Delete the referencing class will not affect the lifetime of the referenced resource.

Property

All information is grouped by properties (see also Chapter Property). Actifsource distinguish the following property types.

image58 image58

Class Meaning
Property Base class for all properties
Relation Base class for all relations
Composition Leads to aggregated resources (UML: Aggregation, Composition)
UseRelation Leads to referenced resources (UML: Association)
Attribute Primitive literals (String, Boolean, Integer, etc.)

Open/Close Folding

To work with large resources efficiently, Actifsource can expand or collapse aggregated resources.

image59 image59

Use the following possibilities to expand/collapse resources.

Device Action
Mouse Klick the [+] [-] sign\ DoubleClick the property
Context menu Open/Close Folding
Keyboard Enter (Open/Close Folding)\ Backspace (Close Folding)

The typeOf Statement

The typeOf statement of a resource shows the instantiation relation and declares the type of this resource.

image60 image60

Actifsource only allows a typeOf relation to resources of type Class.

image61 image61

Read Only View

image62 image62

Deploying Actifsource Models as an Eclipse Plugin (see Chapter 15 Plugin Project) leads to a read only view of the models. Models that are read-only are displayed in gray colors.

Info

Note that the Actifsource Core Model is read-only for you.

The breadcrumb helps you navigating large resources.

image63 image63

Clicking on the arrow in the breadcrumb allows you navigating all resources from the same property.

image64 image64

Focusing aggregated resources

Clicking on a resource in the breadcrumb allows you to focus only on this aggregated resource. Use this feature to work with large resource files.

image65 image65

Browse resource

Actifsource allows you to browse any resource in any editor.

image66 image66

To browse any resources in actifsource use the following possibilities.

Device Action
Mouse Ctrl+LeftClick
Context menu Browse Into
Keyboard F3

Insert resource

Insert on the empty line

Actifsource shows an empty line for all properties which might have another instance (depends on the subject cardinality; see Chapter 4.4.1 Property).

image67 image67

To insert a resources on the empty line use the following possibilities.

Device Action
Mouse Ctrl+DoubleLeftClick on the property
Context menu Insert here
Keyboard Enter

Insert before or after properties

Actifsource allows inserting resources before or after existing properties.

image68 image68

To insert an aggregated resource before or after an existing resource use the following possibilities.

Device Action
Mouse Ctrl+DoubleLeftClick to insert after the current resource\ Ctrl+Shift+DoubleLeftClick to before after the current resource
Context menu Insert after to insert after the current resource\ Insert before to insert before the current resource
Keyboard Ctrl+Enter to insert after the current resource\ Ctrl+Shift+Enter to insert before the current resource

Reference resource

image69 image69

To reference any resource use the content assist.

Device Action
Context menu Open Content Assist
Keyboard Ctrl+Space

You may also type some letters to filter the resources.

Info

Note that Actifsource supports content assist in many different situations. Just try Ctrl+Space to activate content assist via keyboard

image70 image70

New referenced resource

You are able to create new referenced resources just by typing the named and select new from the content assist.

image71 image71

The place where the resource is created depends on the UseRangeRestrictionAspect (see Chapter 4.4.4 UseRelation). If there is no UseRangeRestrictionAspect defined, the new resource is created in the same package as the referencing resource.

Move resource

If you need to change the order you can simple move resources up and down within the same property.

image72 image72

To move resources up and down use the following possibilities.

Device Action
Context menu Move Down\ Move Up
Keyboard Alt+CursorDown\ Alt+CursorUp

Sort property

Actifsource lets you sort all resources of the same property by any literal (i.e. name property).

image73 image73

Info

Note that Actifsource supports content assist in many different situations. Just try Ctrl+Space to activate content assist via keyboard

Quick Assist

Sometimes Actifsource offers a quick assist to fix common issues. Hoover the mouse pointer over the light bulb symbol image74 image74 to get a tooltip with a short description of the problem.

image75 image75

Click on the bulb symbol to get the possible solutions.

image76 image76

Device Action
Mouse Click on the bulb symbol
Keyboard Ctrl+1

Core Model Meta Meta-Model

Overview Core Model

Every meta-model is based on the Actifsource Core Model. Make sure that you understand the concepts of Resource, Class and Property before you start creating your own meta-model.

image77 image77

Resource

In Actifsource everything is a Resource. That means that every Resource you create extends the Resource. Even Resource extends Resource, so that the core model can describe itself.

image78 image78

If the Resource shall has a name you can extend from NamedResource.

image79 image79

Class

Creating your own meta-model you have to specify a set of classes and their relationships. The Core Model therefore provides you a NamedResource called Class. Class is the only Resource in Actifsource that can be instantiated where in this context we mean by instantiate that there is a typeOf relation. For that reason Resource is of type Class and Class extends NamedResource.

This recursive definition becomes necessary as the Actifsource core model has to describe itself. You can say that the Actifsource core model is meta-model of itself.

image80 image80

Property

Any information is modelled by a property. Specifying your own class therefore also means specifying all properties of this class.

image81 image81

There are different types of properties.

image82 image82

Property

The property acts as an abstract base class. Please note that properties are fully typed. In Actifsource the type of a property is named range.

image83 image83

Every resource that can be referenced by a range has to be of type AbstractType. One abstract type you already know by now is Class.

image84 image84

  • SubjectCardinality The Property defines the subject cardinality which determines how many resources of type B can be referenced by a resource of type A via relation b.
    image85 image85
    You may choose one of the following predefined cardinality instances.
    image86 image86
    It is also possible to define any other cardinality just by specifying minCardinality and maxCardinality.
    image87 image87

  • Relation The relation acts as an abstract base class for any relation property between classes.

  • Extends The relation extends allows you to define sub-properties of existing properties in a super class.
    image88 image88
    ASub.bSub extends A.b in the following example. That means that instances of ASub can have only references to resources of type BSub while it is still possible to access the ASub.bSub resources via A.b as type of B
    image89 image89
    It is also possible to have more than one sub-property that extends the same super-property, as long as the sum of cardinalities of the sub-properties complies with the cardinality of the super-property.
    image90 image90
    Please note that is it only allowed to extend a property of the same type (i.e. UseRelation extends UseRelation, Composition extends Composition).

  • ObjectCardinality The Relation defines the object cardinality which determines how many resources of type A can reference a resource of type B via relation b
    image91 image91
    You may choose one of the following predefined cardinality instances.
    image92 image92

UseRelation

The UseRelation (UML: Association) references another resource without affecting the lifetime of this resource. Deleting the referencing resource will not delete the referenced resource.

image93 image93

The range of UseRelation is AbstractType.

image94 image94

  • UseRangeRestrictionAspect You may want to restrict resources that can be referenced by a UseRelation depending on their context. Consider a state machine where only target states of the own state machine shall be selected.
    image95 image95
    Let’s define a UseRangeRestriction aspect for Transition.state that allows only states of the own state machine. Select the ResourceSelectorAspectImplementation for the easy to use Selector-Syntax (see Chapter 9.3.2 SelectorFunction) or the JavaAspectImplementation for a powerful Java implementation.
    image96 image96
    Starting from Transition navigating backwards via transition and state (note the minus sign for backward navigation) to Statemachine where navigating forward to all States.

Composition

The Composition (UML: Aggregation, Composition) aggregates another resource. Deleting the aggregating resource of type A will delete the referenced resources of type B

image97 image97

Please note that you have to adjust the ObjectCardinality if B may be owned either from A1 or A2

image98 image98

The range of Composition is Class.

image99 image99

DecoratingRelation

Combining two existing models together is a very important task. Sometimes this is done by so called model transformation. Actifsource chooses another way, because model transformation often only works in one direction. Actifsource allows decorating existing resources with other ones. That means that we can add any auxiliary information to already existing information. You will find out that this is a very powerful concept.

The DecoratingRelation allows building a homomorphism. A homomorphism is a structure-preserving map between two structures. The word homomorphism comes from the ancient Greek language: ὁμός (homos) meaning "same" and μορφή (morphe) meaning "shape".

Consider a resource A1 with a list b1 of resources of type B1 Consider a second List A2 that has a reference a1 to a resource of type A1 The decorating relation A2.b2 shall have 0..1 resources of type B2 for any resources reached via A2.a1.b1

image100 image100

The decorating relation A2.b2 needs a decorating aspect which defines where to find the resources that shall be decorated.

image101 image101

Let us create a resource TestA1 of type A1 first.

image102 image102

Now let us create a resource TestA2 of type A2 with a reference to TestA1 Please note that A2.b2 is now decorating A2.a1.b1 what is indicated by the brackets (i.e. b1[B1_1]).

image103 image103

Creating a decorated resource will automatically fill in the target property b1

image104 image104

Please note that the decorating relation needs a subclass of type Decorator.

image105 image105

If your decorating relation does not point to a resource which fits the requirements Actifsource comes up with a quick assist (see also Chapter 3.10 Quick Assist).

image106 image106

The quick assist extends the range of the decorating relation from Decorator and adds a sub relation to Decorator.target with type of the target of your decorating aspect.

image107 image107

SelectorRelation

[TBD]

Attribute

The Attribute allows creating simple literals. There are some predefined literal instances that you might use. Please note that the range of an attribute is Literal where Literal is also an AbstractType as already seen for Class (see Chapter 4.4.1 Property).

image108 image108

  • BooleanLiteral The Boolean literal allows the values true or false only.
  • DoubleLiteral The double literal is a 64 bit floating point value.
  • IntegerLiteral The integer literal is a 32 bit integral value.
  • LongLiteral The long literal is a 64 bit integral value.
  • StringLiteral The string literal is a single-line string value.
  • TextLiteral The text literal is a multi-line string value.
  • ScopePathLiteral The scope literal allows referencing any file in the current project.
  • JavaTypeLiteral The Java type literal allows referencing a Java class or interface.
  • JavaClassLiteral The Java type literal allows referencing a Java class.
  • JavaInterfaceLiteral The Java type literal allows referencing a Java interface.

AbstractType

image109 image109

As we have seen before, Class and Literal both extend AbstractType. Furthermore, AbstractLiteral is of type Literal and Resource is of type Class. To complete this picture, we can add Any which is of type AbstractType.

Core Resources

The Actifsource Core provides a set of resources that allows you to build your own meta-model. The most important resources are Class with its Properties and Enum.

ch.actifsource.core.Class

image110 image110

  • typeOf To act as a class a resource has to be of type Class. To be type something of means to be an instance of something.
  • comment The comment text literal let you comment your classes and literals. Comments are shown in tooltips when hovering the mouse pointer over class and property names.
Info

Note that the comment property is inherited by extending from Commentable. Extending from Commentable allows writing comment for any resource and activates the tooltip functionality.

  • aspect[InitializationAspect] The initialization aspect initializes a resource during creation. To be provided as Java class.
  • aspect[ResourceValidationAspect] The resource validation aspect defines specific validation rules for a resource. To be provided as Java class.
  • aspect[NameAspect] The name aspect defines the name of a resource. To be provided as Java class or in the simple selector syntax.
Info

Note that you might define a selector aspect pointing to a TemplateFunction (see Chapter 9.3.6 TemplateFunction) or a TemplateLineFunction (see Chapter 9.3.7 TemplateLineFunction).

  • extends Defines the base class and inherits all properties when instantiating.
  • modifier The modifier defines if a class can be instantiated or sub classed.\
Modifier Description
Abstract No instance allowed of this class.
Final No subclass allowed of this class.
  • property Defines the property of this class. Properties carry the data when instantiating the class. Choose the property type you need (see also Chapter Property).

    image111 image111

  • definesAspect Defines aspects for instances of this class (see also aspect[InitializationAspect], aspect[ResourceValidationAspect], aspect\NameAspect] which are defined in the aspect property of the class Class.

  • allowRoot A Class is a root class if it is not aggregated exclusively (that mean owned by an ownRelation with ObjectCardinality1_1). Set this flag to true or false if you want to overwrite the Actifsource logic.
    Please note that only root classes can be created directly via the New Actifsource Resource Tool (see Chapter 2.9.1 New Actifsource Resource).

  • classIcon Sets an icon for this class and all instances. You can select an icon project by using content assist to browse the current project. The icon size shall be 16 x 16 pixels.

  • lineColor Deprecated.

  • fillColor Deprecated.

  • shape Deprecated.

ch.actifsource.core.Enum

The enum is a class with a set of values.

image112 image112

  • Value Technically the value is an instance of the enum and therefore fully typed.
Info

Note that you might define properties in your enum which are than accessible in the values.

image113 image113

Diagram Editor

Overview

Actifsource offers graphical editors to view and edit the meta-model and model. For editing the model it is possible to define domain-specific editors.

Class Diagram Editor

The class diagram editor allows you to create new meta-models based on Actifsource classes.

New Class Diagram

You can create a new class diagram via context menu in the project explorer or File/New.

image114 image114

Preselecting a package will directly fill in the resource path and package in the wizard.

image115 image115

Palette

Use the palette to edit your diagram.

image116 image116

  • Select Selects one or many classes from the diagram. Use Ctrl+Click for multi select.

  • Marquee Selects classes from the diagram within a rectangle.

  • Extension Derives a class from another class by adding a Class.extend statement in the sub class.

    image117 image117

    Inserting an extends-relation from MySubClass to MyClass would add an extends-relation from MySubClass to MyClass as expected. At the same time the extends-relation from MySubSubClass to NamedResource is removed because MyClass already extends NamedResource.
    The same rule also applies when extending from Resource.

Info

Note that are special rules for your convenience. Consider creating two new Classes MyClass and MySubClass Both are extending NamedResource by default.

image118 image118

  • Relation Inserts a relation from a class to another. Select one of the relation types or a base relation. Selecting a base relation automatically selects the relation type needed (see Chapter Property).

image119 image119

  • Note Connects class to any note. See also New Note.
  • New Class Inserts a new class on the diagram and in the model. Note that the preselected namespace (package and/or containing resource) is the same as the package of the class diagram.
Info

Note that you can directly select the super class in this dialog. While NamedResource is the default you may select**Resource** to create an unnamed resource, or any other Class. For other properties see also Chapter 4.6.1 ch.actifsource.core.Class.

image120 image120

  • New Enum Inserts a new enum on the diagram and in the model. For other properties see also Chapter 4.6.2 ch.actifsource.core.Enum.
  • New Note Inserts a new note on the diagram. Click on the first text line of the note to enter the edit mode.

image121 image121

Drag and Drop

Use the drag and drop feature from the project explorer to add an existing class to your diagram.

image122 image122

Context Menu

Use the context menu on the diagram background.

image123 image123

  • Show Shows any existing resource in the scope of your project. Use this feature to insert resources from third party or Actifsource models to your diagram (i.e. Actifsource Core Model).

Class Context Menu

Use the content menu on any class.

image124 image124

  • Delete from Diagram Deletes this class from the diagram only but not from the model. Use Delete on the keyboard to delete selected classes from the diagram.
  • Delete from Model Deletes this class from the diagram and from the model. Use Shift+Delete on the keyboard to delete selected classes from the diagram and from the model.
  • Show Attributes Shows attributes (literals) in an UML-like style.

image125 image125

  • Hide Attributes Hides shown attribute (see also Show Attributes).

  • Instances Inserts instances of a specific class on the diagram.

    image126 image126

  • Types Shows the types (Class.typeOf statement) of a specific class.

  • Super Class Shows the superclass (Class.extend statement) of a specific class. You this feature repeatedly to show the inheritance hierarchy.

Browse Resource

Open any class in the resource editor by Ctrl+Click on the class name.

image127 image127

Domain Diagram Editor

The domain diagram editor allows you to create new models based on your meta-model.

New Domain Diagram

You can create a new class diagram via context menu in the project explorer or File/New.

image128 image128

Preselecting a package will directly fill in the resource path and package in the wizard.

image129 image129

  • Name The name of the domain diagram.
  • Diagram Type Every domain uses its own diagram styles. The DiagramType lets you define your domain-specific domain diagrams (see Chapter 6 Domain Diagram Type).
    If there is no diagram type defined, the diagram editor has a default behavior and shows resources and their relationships (use and own relation, dependencies).

image130 image130

As a very simple example, let us define a diagram type for a state machine meta-model.

image131 image131

As the root class (see also Single Root) we choose Statemachine. This means that we can only edit elements that are part of the state machine.

The allowed class is State since we like to edit states. Between states there are transitions. A Transition is an indirect relation from State via Transition to State.

image132 image132

The minimal diagram type shown above leads to a domain specific state event diagram.

image133 image133

  • SingleRoot If there is a single root defined, every resource is created in the context of the single root. If no single root is defined, resources are created in the same package as the domain diagram.
Info

Note that defining a rootClass in the DiagramType demands for a singleRoot in the domain diagram.

New Domain Diagram for Resource

image134 image134

You can create a new domain diagram for a single root directly by calling New/Domain Diagram on a resource.

image135 image135

Info

Note that the single root is preselected in the wizard and the diagram type is automatically detected if there is a diagram type which has a root class of the same type as the chosen single root.

Palette

Use the palette to edit the domain diagram.

image136 image136

  • Select Selects one or many classes from the diagram. Use Ctrl+Click for multi select.
  • Edit Edits figures with a FigureEditableLabelSelector.
Info

Note that you can also enter the edit mode with the Select tool. Click on the text to alter – wait for one second until the cursor changes to text mode – and click again.

  • Marquee Selects classes from the diagram within a rectangle.
  • Relation Inserts a relation from a resource to another.
  • Resources Inserts a new resource on the diagram and in the model.
Info

Note that you control the palette by AllowedClass.paletteEntry in your diagram type. image137 image137

  • Search Searches allowed classes with a defined search path.\

Drag and Drop

Use the drag and drop feature from the project explorer to add an existing resource to your diagram.

image138 image138

Context Menu

image139 image139

  • Delete from Model Deletes this resource from the diagram and from the model. Use Shift+Delete on the keyboard to delete selected resources from the diagram and from the model.

  • Hide Resource Deletes this resource from the diagram but not from the model. Use Delete on the keyboard to hide selected resources from the diagram.

  • Show Resource Shows any hidden resource in the scope of the selected resource. If this action is called on the background of the diagram, the scope is your single root.

  • Show/Hide Resource Part Shows or hides aggregated parts (see Chapter 4.4.5 Composition).

    image140 image140

    image141 image141

  • Router Selects between different routing algorithms.\

    Router Description Image
    Default Manual routing by dragging image142 image142
    Manhatten Lines are routed with 90° image143 image143
    NoIntersection As few intersections as image144 image144

Browse Resource

Open any class in the resource editor by Ctrl+Click on the class name.

image145 image145

Browse Diagram

Actifsource automatically detects resources that are also shown on other diagrams. Simply click on the diagram symbol to list and browse the other diagrams.

image146 image146

Domain Diagram Type

Overview

Domain diagrams are domain-specific by definition. This means that you can define your own domain-specific diagrams.

Shape

Figure

Build Config

Overview

The Actifsource BuildConfig acts like a make file. It tells Actifsource which build tasks shall be executed. The most important build task for code generation is the TemplateGeneratorTask.

New BuildConfig

You can create a new build configuration via context menu in the project explorer or File/New.

image147 image147

Actifsource suggests adding templates to the build configuration which are not assigned to any other build configuration yet.

image148 image148

For every selected template, Actifsource creates a so called a TemplateGeneratorTask as shown below.

image149 image149

BuildConfig and TargetFolder

Build configurations have to be registered with target folders to take any effect (see also Chapter 2.5.3 Target Folder and Chapter 2.6 Project Properties).

image150 image150

Output Encoding

For every build configuration you may select the output encoding.

image151 image151

If no output encoding has been set, the one from the parent build configuration (see also Chapter 7.6.2 NestedBuildConfigGeneratorTask), folder, parent folder, project, or workspace is taken (in this order).

Check Properties/Resource/Text file encoding on folder or project.

image152 image152

Check Window/Preferences/General/Workspace/Text file encoding on workspace.

image153 image153

Line Break

For every build configuration you may select the line break style.

image154 image154

If no line break has been set, the one from the parent build configuration (see also Chapter 7.6.2 NestedBuildConfigGeneratorTask), project, or workspace is taken.

image155 image155

BuildTask

The build configuration lists all build tasks. Build tasks are executed in the order as listed. There are different types of build tasks. The most important one is the TemplateGeneratorTask.

Template Generator Task

The template generator task defines which templates have to be built.

image156 image156

  • Template References the template.

  • Omit File Id Actifsource normally inserts an id at the end of every generated file. This file id helps identify and track generated code.

    image157 image157

    The Actifsource ID is assembled as follows.
    /* Actifsource ID=\[TemplateGUID,SuperContextGUID\*,BaseContextGUID,MD5Hash\] */

    Element Descriptiom
    Comment Tags The comment tags (i.e. /* */) are given by the language
    Actifsource ID Static identifier
    TemplateGUID GUID of the template which created this file
    SuperContextGUID GUID of the resources which contains the base resource
    BaseContextGUID GUID of the base resources of this file
    MD5Hash A hash code over the generated code but not including protected regions to detect if the generated code has been changed manually. To ignore white spaces when building the MD5 hash check Chapter 2.5.3 Target Folder.
Info

Note that you can open the resource for any GUID in an Eclipse text editor or in the Eclipse console by Ctrl+Click on the GUID.

image158 image158

NestedBuildConfigGeneratorTask

The nested build configurator task let you reference and execute existing build configurations.

image159 image159

  • Build Config References any existing build configuration.
  • Target Sub Path Defines a sub path to the target folder (see also Chapter 2.5.3 Target Folder).

CopyTask

Copies a file or a folder to a specified target path. Please note that this tasks needs a built-in dependency to WORKSPACE (see Chapter 2.5.6 Built-in Dependencies).

image160 image160

  • Resource The file or folder to copy. There are different resource types.\
Resource Type Description
BundleResource File or folders found in a bundle (plugin project).
OutputScopeResource File or folders found in the target folder.
TemplateScopeResource File or folders found in the template folder.
WorkspaceResource File or folders found in the workspace.
  • Recursive All subfolders are copied if set to true.
  • Merge Duplicate Folders When enabled, the generator allows merging content from different folders into one folder. Otherwise an error will occur.
  • Target The target to copy the files or folders. There are different target types.\
Target Type Description
ResourcePathTarget Target path relative to copied resources.
ZipTarget File and folders are copied into a zip file.

DeleteFolderTask

Deletes the specified folders relative to the target folder. Please note that this tasks needs a built-in dependency to WORKSPACE (see Chapter 2.5.6 Built-in Dependencies).

image161 image161

  • Path A path relative to the target folder.

ExecuteProcessBuildTask

Executes any process on your operating system. Please note that this tasks needs a built-in dependency to WORKSPACE (see also Chapter 2.5.6 Built-in Dependencies).

To execute a shell command on windows, choose cmd as shell command, /c as first argument, and your shell command and parameters as subsequent arguments.

image162 image162

  • Directory Directory to execute the process relative to the target project.
  • Command The command (without arguments) to execute.
  • Argument The arguments of the command.

GraphvizBuiltTask

Runs the graphviz dot command on all .dot files in the target folder. Please note that this tasks needs a built-in dependency to GRAPHVIZ (see also Chapter 2.5.6 Built-in Dependencies).

Make sure that you have graphviz installed (see www.graphviz.org) and reachable in your path.

image163 image163

  • Styleheet A css stylesheet if needed.

  • Adapt Size If set to true, the generated diagram's width is set to 100%.

Eclipse Builder

Eclipse supports so called Builders to build anything. In C/C++ there is the CDT Builder to build executables and libraries from header and source files. In Java there is the Java Builder to build .class files from .java files.

In Actifsource there is the Actifsource Builder to generate code from the model (.asr files).

Make sure that the builders are arranged in the correct order. You will find the settings in Project/Properties/Builder.

image164 image164

Template Editor

Overview

As already seen in Chapter 1.1 Working with models, the Actifsource Template Editor allows you to write meta-code based on the meta-model. Writing meta-code means to write code along the structures which are given by the meta-model without knowing the specific domain model.

image165 image165

New Template

A template is either based on a type (Class, Enum) or not.

Template Type Description
Based on types Based on a type means that the Template is applied for every instance of that type. The result is one file per instance.
Build once Build once means that the Template is applied exactly once. The result is one file.

Create a template based on type

Creating a template based on a specific type (Class) is the normal case. Consider a nested Parent-Child structure with the following meta-model.

image166 image166

For every specific parent-child structure there is at least a resource of type Parent to start with. So let’s start writing meta-code based on the class Parent

To create a template based on the class Parent simply choose New/Template from the context menu of the class Parent

image167 image167

The New Template Wizard helps to configure the template settings.

image168 image168

Set the options as needed.

Option Description
Resource Path The resource path where the template is located (see Chapter 18 resource-paths) Resource Paths). This option is automatically filled in.
Package The package where the template is located. The package is derived from the location where the context menu was called.
Template Name The name of the template. The template name is automatically derived from the Base Type.
BuildConfig The build configuration where this template is referenced (see Chapter 7 Build Config).
MetaModel Make sure to choose Actifsource unless you know exactly what you do.
Base Type The base type is derived from the location where the context menu was called.

Please note that there is a short way for choosing the package. Just type the first few letters of a package followed by a dot. Using content assist (Ctrl+Space) shows the matching packages.

image169 image169

Creating a template based on a type (i.e. class Parent opens an editor with a predefined selector Build.allParent. This means that this template is executed for all resources of type Parent

image170 image170

Create a Build.once Template

To create a Build.once template simply choose New/Template from the context menu of a package. Please note that the template is created in the chosen package.

image171 image171

The New Template Wizard asks for the template name and even allows you to add a base type afterwards using the content assist (Ctrl+Space). Adding a base type leads to a template based on a type (see Chapter 8.2.1 Create a template based on type).

image172 image172

Creating a Build.once template opens an editor with a predefined selector Build.once@BuiltIn. That means that this template is executed only once.

image173 image173

Writing template code

Writing template code is nearly as easy as writing common code – thanks to the Actifsource Template Editor.

Base Context

The Actifsource Template Editor lets you write code in the context of the meta-model.

image174 image174

The orange bar on the left is the context you are in. Creating a template for the class Parent lets you work in the context of this class.

The context derived from the base type (see Chapter 8.2.1 Create a template based on type) is called base context.

File Line

First of all you have to specify a proper name. Since we want to generate a file for any instance of the class Parent, we have to specify a file name that is unique for every Parent instance.

image175 image175

The name of the generated files is derived from the specific resource instance for which code is generated. Use content assist (Ctrl+Space) to access the properties of the class which is bound to the base context by the Selector.

image176 image176

The following file name will create files named Parent.name while Parent.name is replaced by the name of the specific instance of class Parent Text elements referring to the model are called links and displayed underlined.

Please note that the file extension .hpp automatically selects the Language C++ (see Chapter 8.3.3 Language Line and Chapter 8.4 Declaring a Programming Language).

image177 image177

It is also possible to define a folder structure in the file line. The generated files will be placed in the defined folders.

image178 image178

Language Line

The language line defines the programming language for

  • Syntax Highlighting
  • Comment Style
  • String Style including escape rules

Actifsource defines the most common languages. If you are using a language which is not defined by default (see Chapter 8.4.1 Supported Programming Languages), do not hesitate to create one by your own (see Chapter 8.4 Declaring a Programming Language).

You may change the language at any time by using the content assist (Ctrl+Space) on the language line.

image179 image179

Selecting or changing a file extension in the file line (see Chapter 8.3.2 File Line) automatically selects the corresponding language.

image180 image180

Use Ctrl+Click on the language to show the underlying language model (see Chapter 8.4 Declaring a Programming Language).

image181 image181

File Tab

There are always situations where two or more files belong to each other (i.e. hpp/cpp in C++). Actifsource therefore supports file tabs.

Just press the [+] button right next to the file tabs to add a new file tab.

Info

Note that files tabs are always automatically named the same as the file extension.

image182 image182

Press the X button to delete the active file tab.

image183 image183

Press Ctrl+Tab to select next tab from within the code section.

SuperContext

Let’s assume that we want to generate a file for every Child instance.

image184 image184

For that reason we create a template with Child as base type.

image185 image185

Since Child is owned by Parent.child, Actifsource automatically provides you with a super context of type Parent

image186 image186

Please note that the base context (i.e. Child in this example) is the widest bar ( image187 image187 ).

image188 image188

Writing Code

Let’s start writing code. First we write a C++ class named Parent.name while Parent.name is replaced by the name of the specific instance of class Parent

Info

Note that the keyword class is bold and has a special color as defined in the language C++ (see Chapter 8.4 Declaring a Programming Language).

To insert a reference to the meta-model just use content assist (Ctrl+Space) at any time.

image189 image189

Underlined words are so called links which are directly linked with your model.

Info

Note that renaming resources in the meta-model automatically renames all links in the template synchronously.

image190 image190

You can always navigate to the corresponding resource in the model by using Ctrl+Click on the links as shown below or the image191 image191 tool from the toolbar.

image192 image192

Saving the above template leads to one file for every resource of type Parent in your project.

image193 image193

A build config is needed to work with resources from other projects (see Chapter 7 Build Config).

Using type names in the template code

Please note that you might insert type names directly in the template code by using the content assist (Ctrl+Space). If the desired type name is not available, press Ctrl+Space again to get all available type names.

image194 image194

The type name is inserted just as given. The advantage of using type names in the template is the automatic renaming if the name of the type is changed.

image195 image195

You can always open a resource link in the template editor.

image196 image196

  • Open Link with Default Editor Use one of the following methods to open a link in the default editor (see Chapter 2.11.2 Open with).
Action Opens Description
Ctrl+Click Default Editor Press Ctrl+Click on the link to open the resource
F3 Default Editor Press F3 on the current cursor position to open the resource
image197 image197 Default Editor Click Open Link in ResourceEditor from toolbar on the current cursor position to open the resource \

To open a function link in the function editor use the default editor. To open the function model use the resource editor (see below).

  • Open Link with Resource Editor Use one of the following methods to open a link in the resource editor (see Chapter 2.11.2 Open with).
Action Opens Description
Ctrl+Alt+Click Resource Editor Press Ctrl+Click on the link to open the Editor resource
Alt+F3 Resource Editor Press F3 on the current cursor position to open Editor the resource
image191 image191 Resource Editor Click Open Link in ResourceEditor from the toolbar on the current cursor position to open the resource

Line Context, Column Context, Protected Context

Actifsource knows three different types of contexts.

  • Line Context The line context consists of one or more lines in a file. The text in the line context is repeated for any resource reached by the selector (see chapter 8.3.10 Working with Context). To insert a line context use the Insert LineContext tool image198 image198 from the toolbar or press Alt+Insert. image199 image199
  • Column Context The column context consists of one or more columns of a line. The text in the column context is repeated for any resource reached by the selector (see Chapter 8.3.10 Working with Context). To insert a column context use the Insert ColumnContext tool image200 image200 from the toolbar or press Alt+Shift+Insert.
    image201 image201
  • Protected Context The protected context allows inserting so called protected regions into the generated files.
    image202 image202

The content of the Protected Regions is saved before regenerating and inserted in the newly generated file. Use Protected Regions to insert handwritten code into generated files.

Info

Note that Protected Regions are identified by the GUID of the resource of the current context. Use Ctrl+Click on the GUID to navigate to the corresponding resource.

image203 image203

The protected context consists of one or more lines in a file. The text in the protected context is repeated for any resource reached by the selector (see Chapter 8.3.10 Working with Context) and generated. To insert a protected context use the Insert ProtectedContext tool image204 image204 from the toolbar.

image205 image205

Info

Note that you can control the GUIDs that identify the protected regions by checking the resources in the context path. Just make sure that the resulting set of GUIDs is unique in your generated file. You might also define a name for the Protected Region.

image206 image206

Please note that changing the name of the Protected Region or the involved resources leads to new Protected Regions while the old once are moved to the end of the file.

Working with Contexts

Adding and removing a context is one of the most important operations when working with the Template Editor.

Use the Template Editor Toolbar to add, remove or navigate contexts.

image207 image207

Context Operation Icon Shortcut Description
Select TopContext image208 image208 Alt+Home Selects the top context
Select image209 image209 Alt+PgUp Selects the parent context from the actual context
Select image210 image210 Alt+PgDown Selects the child context from the actual context
Select image211 image211 Alt+End Selects the bottom context
Insert LineContext image198 image198 Alt+Insert Inserts a line context in the actual context
Insert image200 image200 Alt+Shift+Insert Inserts a column context in the actual context
Insert image204 image204 Inserts a protected context in the actual contextt
Delete Context image212 image212 Alt+Delete Delete the actual context
  • Navigate Context via Select Tools Using the Context Select Tools in the Toolbar you might change the selection of the context from parent to child and vice versa.
    image213 image213

  • Navigate Context via Breadcrumb A context can be selected by clicking on the Breadcrumb.
    image214 image214

  • Navigate Context via Context Bar A context can also be selected by clicking on the context bar.
    image215 image215

  • Add Context A new context is always added after the actually selected context. Navigate to a certain context before inserting a new context as shown above.
    Let’s assume that we want create a function identifyChild.name for every child in the parent context. For that reason we insert a new context using the Insert LineContext tool image198 image198 from the toolbar.
    image216 image216

As a second step you have to declare a selector (see Chapter 8.3.12 Selector) to define the context.

Since our base context is Parent we have to traverse the relation Parent.child to reach all children from parent.

image217 image217

Choose the relation Parent.child for the selector using content assist (Ctrl+Space).

image218 image218

Using content assist in the new context you are now able to use links on resources of type Child

image219 image219

To complete the task from above insert a function named identifyChild.name

image220 image220

Line 4 is now repeated for any resource of type Child reached by the relation Parent.child

image221 image221

  • Add Context via Quick-Assist Using the quick assist is the most efficient way to add a new context.

To create a new context with the selector Parent.child just insert the link Parent.child using context assist (Ctrl+Space). A light bulb image222?classes=inline image222?classes=inline indicates that there is a quick assist available. Click on the light bulb or press Ctrl+1 to open the quick assist.

image223 image223

You are now allowed to create a line context or a column context directly with Parent.child as the selector.

image224 image224

A new context is inserted with the desired selector. Parent.child is automatically replaced by Child which is the result of the selector. image225 image225

  • Automatic Context growth Adding new lines (pressing return) automatically lets the context grow.

image226 image226

  • Add Content between existing Contexts

Consider two contexts that follow each other (line 4 and 5 in the following example). How to insert new content between line 4 and line but in the base context?

image227 image227

Place the cursor on the end of line 4 as shown above and press cursor right. The cursor will still remain at the same position but the context selection will change to the parent context.

image228 image228

Entering a new line is done in the selected parent context and results in a new line between the existing contexts.

image229 image229

Copy/Paste

Copy (Ctrl+C) and Paste (Ctrl+V) in the Template Editor has some special features to work with links and contexts.

  • Copy/Paste with Link Links can be easily copied like text.

image230 image230

  • Copy/Paste with Context The Copy action takes care on all nested contexts in the current context. The following situation won’t copy the selected line context C on line 2 but the nested column context D

image231 image231

If you have to copy the line context C on line 2 just navigate to the base context (see Chapter 8.3.10 Working with Contexts) what makes the line context a nested context.

image232 image232

There is also a command Copy with Context in the context menu which allows to specify the position from which context are copied. The following situation shows a selection on line 2 where the copy operation allows to copy with context C or B

image233 image233

Please note that it makes no sense to copy the base context (see Chapter 8.3.1 Base Context) or even the super context (see Chapter 8.3.5 SuperContext) because they are part of the whole template.

Selector

The selector allows navigating the meta-model and is extremely powerful. Please consult Chapter 9.3.2 SelectorFunction for details.

Use the Switch to Selector tool from the tool bar or Alt+Enter to navigate from the code to the selector. Use Enter in the selector to jump back to the code.

image234 image234

  • Break Flag Consider the following situation:

image235 image235

The subsequent template iterates over Container.element and prints the name of every element.

image236 image236

Let’s assume that we write template code that shall produce different code depending whether Container.element is of type ElementA ElementB or ElementC

A straightforward solution is introducing a context with a type cast for type in the inheritance hierarchy.

image237 image237

The problem is that a resource type of ElementC is also of type ElementB and ElementA Therefore the above template prints lines 2, 3 and 4 for resources f type ElementC But the intention is that only line 2 is printed.

Use the break flag in the selector for the desired behavior. If the break flag is set all subsequent context of the same level are skipped. Users familiar with programming language C or C++ can think of the switch/case/break statement.

The following template prints line 2 for resource types of ElementC and then breaks the current iteration to continue with the next resource for Container.element

image238 image238

Info

Please note that a context with a break flag is displayed with a ground beam. image239 image239

Line Attributes

Use line attributes on a line context to control the output specific positions of a resource in a list. Place the cursor on the desired line to apply a line attribute.

image240 image240

There are five different types of line attributes which might be applied to a line context.

Context Operation Icon Shortcut Description
First image241 image241 Alt+1 The first element of the iteration
Not First image242 image242 Alt+2 All elements of the iteration except the first
Not Last image243 image243 Alt+3 All elements of the iteration except the last
Last image244 image244 Alt+4 The last element of the iteration
Empty image245 image245 Alt+5 For empty iterations

The following template prints the comment on line 7 only for the first element of the iteration over the list Parent.child Please note that line 7 is not printed if Parent.child is empty.

image246 image246

The following example prints a comment on line 8 if Parent.child is empty.

image247 image247

Column Attributes

Use column attributes on a column context to control the output specific positions of a resource in a list. Select the desired characters to apply a line attribute.

image248 image248

There are five different types of column attributes which might be applied to a column context.

Context Operation Icon Shortcut Description
First image249 image249 Alt+1 The first element of the iteration
Not First image250 image250 Alt+2 All elements of the iteration except the first
Not Last image251 image251 Alt+3 All elements of the iteration except the last
Last image252 image252 Alt+4 The last element of the iteration
Empty image253 image253 Alt+5 For empty iterations

The following example prints the comma after Param.name for all elements of the iteration except the last.

image254 image254

The next example prints void on line 7 if Parent.child is empty.

image255 image255

FunctionSpace

As shown in Chapter 9.2 Function Space the Template acts as a Functions Space. Therefore functions might be placed directly in the template (see Chapter 9 Functions for details).

image256 image256

Function calls are displayed in italic. In the subsequent example there is a call to Parent.className where className is the function.

image257 image257

To see the model of a function within a template just open the folding image258 image258 on the template.

image259 image259

If a function is placed in a function space other than the own template the function call is displayed with the name of the function space after the @ sign. Parent.className@MyFunctionSpace indicates a function call where the function className is located in the function space MyFunctionSpace

image260 image260

Extract Function

The Actifsource Template Editor allows you to extract selected expressions as functions. Please consider extracting complex expression if you use them more than once.

image261 image261

Selecting an expression which might also contain links leads to a image74 image74 light bulb on the left side which indicates that there is a Quick Assist available. Click on the light bulb or press Ctrl+1 to open the Quick Assist.

image262 image262

Context Path

The path from the outermost to the innermost context is called Context Path. Actifsource uses the Context Path to determine the parameters of a function (see Chapter 9.2.1 Function Parameters).

Consider the following meta-model:

image263 image263

The subsequent template shows nested contexts based on the above meta-model. Please note that the breadcrumb displays the context path for the actual cursor position.

image264 image264

The template shows the following context paths.

Line Context Path
ine 1 A
Line 2 A, B
Line 3 A, B, C
Line 4 A, B, C, D

Calling a function with parameters is only allowed if the context path is matching.

The following function fD C B A is based on Class D and declaring the parameters c of type C b of type B and a of type A

image265 image265

Calling fD C B A is only allowed if the context path contains at least A B C, and D in the given order.

image266 image266

Consider a function fD A which is based on Class D and declaring a parameter a of type A It is allowed to call this function on the context path A B C, and D because it contains A and D in the correct order.

image267 image267

Declaring a Programming Language

The Actifsource Template editor does syntax highlighting for keywords, comments, and strings. The actual selected language is determined by the Language Line (see Chapter 8.3.3 Language Line).

Supported Programming Languages

Currently Actifsource supports syntax highlighting for the following programming, script, markup, or domain languages.

Programming Language Description File Name Extension
Ada ada
C c, h
C# Microsoft C Sharp cs
C++ cpp, hpp
Cobol cob
Css Cascading Style Sheet css
D d
Delphi dfm
Eiffel e
Erlang erl, hrl
GraphViz www.graphviz.org dot
Groovy groovy
Haskell hs
Html Hyper Text Markup Language html, xtml
Java java
JavaScript js
Modula2 mod
Oberon pas
OmgIdl www.omg.org idl
Pascal pas
Perl pl
Php php
Python py
Ruby rb
Scala scala
Sql Structured Query Language for RDBMS sql
StructuredText see wikipedia st
Svg Scalable Vector Graphics svg
Text Plain text txt
VisualBasic Microsoft Visual Basic vb, vba
Xml Extensible Markup Language xml

TemplateLanguage Model

To create your own template language model just instantiate the class TemplateLanguage.

image268 image268

  • fileNameExtension The file name extension of the template language is used to automatically select the language line (see Chapter 8.3.3 Language Line) from the file extension in the file line (see Chapter 8.3.2 File Line).

  • keywordStyle A list of keywords including the syntax style (color, font modifier)
    image269 image269

  • stringStyle A declaration of start and end tag for strings including the syntax style (color, font modifier)
    image270 image270

  • singleLineComment A declaration of the start tag for single-line comments including the syntax style (color, font modifier)
    image271 image271

  • mutliLineComment A declaration of start and end tag for multi-line comments including the syntax style (color, font modifier)
    image272 image272

File Extension Priority Rules

You might define your own template language defining the same file name extension as a built-in language. Actifsource will handle user-defined template languages with higher priority so that you can overwrite the standard.

Functions

Table of Contents

Overview

Actifsource functions might be called from templates (see ChapterTemplate Editor), from other functions, or from selector relations (see Chapter 4.4.7 SelectorRelation). There are different supported types of functions (see Chapter 9.3 Function types).

Function Space

The function space is the resource where functions are living. We know two different types of functions spaces, both derived from AbstractFunctionSpace.

FunctionSpace is the place where you can place any function. Template is a code template where you can place functions in the scope of the template.

image256 image256

Functions are grouped by a FunctionContext. By the typeRef, the FunctionContext is bound to a Class or an Enum. Functions in the function context are applicable on instances of types referenced by typeRef.

image273 image273

Info

Note that Actifsource prohibits more than one function context with the same typeRef in the same function space.

Function Parameters

A function might define a set of parameters. If calling a function from a template, Actifsource automatically tries to match with the context path (see Chapter 8.3.17).

Function parameters are defined in the model of the specific function type (see Chapter 9.3 Function types).

image265 image265

Using function parameters in a template function (see Chapter 9.3.6 TemplateFunction) leads to the corresponding super contexts (see Chapter 8.3.5 SuperContext).

image274 image274

Using function parameters in a java function (see Chapter 9.3.3 SelectorFunction)

Selector functions allow you to navigate the model by using the selector syntax. Starting from a Class defined by FunctionContext.typeRef you may navigate via the resource properties.

Selectors might be used in Templates to select a context. But selectors might also be called from within selectors – even recursively.

  • Forward navigation Consider the following meta-model.

    image275 image275

    We like to define a selector function named getSubChild on Parent which returns all sub-children in all children of the parent. The return type when navigating along a property is given by the range of the property, i.e, in our example the expected return type is a list of elements of type SubChild To navigate from Parent via child to subChild just assemble a selector Parent.child.subChild Make sure to use content assist (Ctrl+Space) when writing selector functions.

image276 image276

This is what a selector function could look like.

image277 image277

  • Backward navigation Consider the following meta-model.

image275 image275

To get the Parent instance for a SubChild instance we have to navigate backwards via the subChild and child relation. The selector allows backward navigation via the minus relation.

image278 image278

  • List operators Actifsource provides you with the following operators which are defined on lists (where the lists are given by Selector expressions):\
Operator Description
A union B The result is the concatenation of the two lists A and B. For example, [a1,a2] union [a3,a1] is equal to [a1,a2,a3,a1].
A intersect B Only elements found in A and in B where duplicates are preserved and the resulting order is given by A. For example, [a1,a1,a2,a2] intersect [a2,a1,a1] is equal to [a1,a1,a2].
A except B For all elements b in B, the first occurrence of b in A is removed from A. For example, [a2,a1,a3,a2,a1] except [a1,a2,a1] is equal to [a3,a2]
A else B All elements in A if a is empty, otherwise all elements in B. For example, [a1, a2] else [b1,b2] is equal to [a1,a2] and [] else [b1,b2] is equal to [b1,b2].
A then B All element in B if A is not empty else empty list (i.e (A then B else C)).
A excludefilterA.c All elements from the set A with the exception of the elements for which A.c is evaluated to empty or boolean true.
A includefilterA.c where the expression A.c must be evaluated as not empty or Boolean true.
A getindexi Selects the element at position i ($i \in \mathbb{Z}_{0}^{+}$) from the list of elements of A. For example [a2,a1,a3,a2,a1] getindex 2 selects a3.
Info

Note that you can use brackets to control precedence (i.e. (A.x union A.y) intersect A.z). The result type of the union, intersect and else operator is the most concrete supertype of the type of the two operands (e.g. if A is of type NamedResource and B is of type Resource, then A intersect B A union B and A else B are all of type Resource). After brackets you can continue the selector (i.e (A.x union A.y).typeOf).

  • Down Cast Consider the following meta-model.
    image279 image279

If you only like to get Leaf components from the Client, just use the type cast operator (colon).

image280 image280

  • Up Cast It is always possible to use an upcast to a base class (i.e. Resource or NamedResource) if needed.

  • Self Cast If your selector has to return the typeRef instance itself, use the self-cast. Consider the following selector function for Component returning the component instance itself.

image281 image281

  • Recursive navigation The diagram below shows a composite pattern as presented in the book Design Patterns from Erich Gamma et al. The composite pattern allows you to recursively instantiate Composite instances, which might aggregate other components of type Leaf or again – of type Composite.

image282 image282

There is an easy way to find the Client of this recursive model using selectors. First, we collect all components including the own component and all parent components.

For that reason we write a selector function for Component which returns the component itself and also all parent components which are reachable by going backwards via the component relation.

image283 image283

To get the Client which is parent of all component just collect all component first by using the above selector functions. From all this components in the collected set there is only one instance aggregated by Client. Let’s write a selector function for that.

Please take extra care because there are two relations named component. One is Composite.component the other one is Client.component Make sure to use Composite.component in allComponent and Client.component in getClient

image284 image284

  • Calling selectors with parameters

[TBD]

JavaFunction

leads to the corresponding java function arguments.

image285 image285

Polymorphic calls

Function calls are polymorphic if a function has the same name, the same parameters and a typeRef to a sub class.

image286 image286

In the following example, the function identify is defined for MyClass and MySubClass. There will be a polymorphic call to MyClass.identify dependent on the type of the instance.

image287 image287

Non-Polymorphic calls

There are situations where polymorphic calls are not desired. You have to disable polymorphic calls on every caller. Use the context menu Change to non-virtual call on the function.

image288 image288

A small arrow indicates the non-polymorphic call.

image289 image289

Extends

Polymorphic calls are supported in the same function space by default. Extending another function space enables polymorphic calls over functions spaces.

image290 image290

Function types

Actifsource supports different types of functions.

image291 image291

Abstract Function

Abstract functions shall only be defined on types with an abstract modifier (see Chapter 4.6.1 ch.actifsource.core.Class).

For an abstract function, there must be non-abstract function for any non-abstract subclass in the same function space or in a function space that extends it.

image292 image292

SelectorFunction

Selector functions allow you to navigate the model by using the selector syntax. Starting from a Class defined by FunctionContext.typeRef you may navigate via the resource properties.

Selectors might be used in Templates to select a context. But selectors might also be called from within selectors – even recursively.

  • Forward navigation Consider the following meta-model.
    image275 image275

We like to define a selector function named getSubChild on Parent which returns all sub-children in all children of the parent. The return type when navigating along a property is given by the range of the property, i.e, in our example the expected return type is a list of elements of type SubChild

To navigate from Parent via child to subChild just assemble a selector Parent.child.subChild Make sure to use content assist (Ctrl+Space) when writing selector functions.

image276 image276

This is what a selector function could look like.

image277 image277

  • Backward navigation Consider the following meta-model.

image275 image275

To get the Parent instance for a SubChild instance we have to navigate backwards via the subChild and child relation. The selector allows backward navigation via the minus relation.

image278 image278

  • List operators Actifsource provides you with the following operators which are defined on lists (where the lists are given by Selector expressions):
Operator Description
A union B The result is the concatenation of the two lists A and B. For example, [a1,a2] union [a3,a1] is equal to [a1,a2,a3,a1].
A intersect B Only elements found in A and in B where duplicates are preserved and the resulting order is given by A. For example, [a1,a1,a2,a2] intersect [a2,a1,a1] is equal to [a1,a1,a2].
A except B For all elements b in B, the first occurrence of b in A is removed from A. For example, [a2,a1,a3,a2,a1] except [a1,a2,a1] is equal to [a3,a2]
A else B All elements in A if a is not empty, otherwise all elements in B. For example, [a1, a2] else [b1,b2] is equal to [a1,a2] and [] else [b1,b2] is equal to [b1,b2].
A then B All element in B if A is not empty else empty list (i.e (A then B else C)).
Info

Note that you can use brackets to control precedence (i.e. (A.x union A.y) intersect A.z). The result type of the union, intersect and else operator is the most concrete supertype of the type of the two operands (e.g. if A is of type NamedResource and B is of type Resource, then A intersect B A union B and A else B are all of type Resource).

  • Down Cast Consider the following meta-model.

image279 image279

If you only like to get Leaf components from the Client, just use the type cast operator (colon).

image280 image280

  • Up Cast It is always possible to use an upcast to a base class (i.e. Resource or NamedResource) if needed.

  • Self Cast If your selector has to return the typeRef instance itself, use the self-cast. Consider the following selector function for Component returning the component instance itself.

image281 image281

  • Recursive navigation The diagram below shows a composite pattern as presented in the book Design Patterns from Erich Gamma et al. The composite pattern allows you to recursively instantiate Composite instances, which might aggregate other components of type Leaf or again – of type Composite.

image282 image282

There is an easy way to find the Client of this recursive model using selectors. First, we collect all components including the own component and all parent components.

For that reason we write a selector function for Component which returns the component itself and also all parent components which are reachable by going backwards via the component relation. $

image283 image283

To get the Client which is parent of all component just collect all component first by using the above selector functions. From all this components in the collected set there is only one instance aggregate by Client. Let’s write a selector function for that.

Please take extra care because there are two relations named component. One is Composite.component the other one is Client.component Make sure to use Composite.component in allComponent and Client.component in getClient

image284 image284

  • Calling selectors with parameters

[TBD]

JavaFunction

Actifsource supports user-implemented Java functions that make use of the very powerful Javamodel to access the Actifsource models from Java code (see also Section 9.5).

image293 image293

When you declare a Java function, Actifsource automatically generates a function skeleton in a file with the same name as your function space found in the folder src-gen.

image294 image294

You should only modify generated files within protected regions (see Chapter 2.12.5 Protected Regions). Take extra care that import statements are placed within the protected regions – especially if inserted automatically by the Java content assist.

image295 image295

As function arguments, an instance of type FunctionContext.typeRef and all parameters are passed. Use the Java content assist (Ctrl+Space) to display available functions. To access properties choose myClass.selectMyProperty(). For more information on how to access the Javamodel see Chapter 9.5.

  • Return Types
    image296 image296

A Java function has a return type which is either a Type or a TypeReference.

A Type is either a SimpleType or a ListType. A SimpleType can, in particular, be a ClassType, which references any Class, or a LiteralType, which references any Literal. For a LiteralType the return type of the generated Java function is the Java class given by the return value of the method getValueType() of the ILiteralAspect (e.g. in the example above the LiteralAspect of StringLiterals (ch.actifsource.core.model.aspects.impl.String.StringLiteralAspect) defines that java.lang.String represents StringLiterals and, therefore, the the return type of identify is java.lang.String). A ListType references either a Class or a Literal (more precisely, it actually references an AbstractType). The return type of the generated Java function is then a java.util.List<Class>, where Class is the Java class that corresponds to the Literal or the Class. Note that in the latter case the Java class is the wrapper Java class that corresponds to the Actifsource Class and is provided by the Javamodel (see also Chapter 2 and Section 9.5).

A TypeReference is either a GenericContextType or a GenericContextListType. In the first case, the return type of the generated Java function is <T extends C T where C is the Java class corresponding to the type of the element the function is called on (the this-instance). In the second case, the return type of the generated Java function is a <T extends C> java.util.List<T> where T is defined as before (see examples below).

Info

Note that function with a return type of GenericContextType or a GenericContextListType can be applied to elements of any sub-type of the type given by typeRef of the FunctionContext, i.e., the this-parameter of the generated Java function is <T extends Class> T where Class is the Java wrapper class corresponding to the typeRef of the FunctionContext.

image297 image297

image298 image298

image299 image299

image300 image300

image301 image301

JavaListFunction

Java list functions can be applied to a list of elements defined by a Selector expression, e.g. in the Selector expression Parent.child.myFunction@ChildFunctionSpace the function myFunction is called on the list of all Children reachable from Parent via the relation child (see example in Section 9.3.2). The this-parameter of the generated Java function is then of type java.util.List<\> where C is the Java class corresponding to the typeRef of the FunctionContext (respectively java.util.List<T extends C> if the returnType of the Java list function is GenericContext(List)Type). Consider the following example that is based on the meta-model from Section 9.3.5:

image302 image302

image303 image303

The return types of JavaListFunctions are determined in the same way as for JavaFunctions (see Section 9.3.3). A list of built-in (Java) list functions is presented in Section Fehler! Verweisquelle konnte nicht gefunden werden..

Consider an extended meta-model where Parent can be referenced by a ParentContainer via a relation parent:

image304 image304

In this case, the selector ParentContainer.parent.child.myFunction@MyFunctionSpace constructs for each Parent the list of Children reachable from this Parent and then applies the function myFunction to each of these lists. If the function should be applied to the list of Children reachable indirectly via parent we can write a (Selector)Function that returns a list of all these Children e.g. ParentContainer.getAllChildren@MyFunctionSpace where getAllChildren is a SelectorFunction with the selector ParentContainer.parent.child In the selector ParentContainer.getAllChildren@MyFunctionSpace.myFunction@MyFunctionSpace the function myFunction is only called once on the list of all Children reachable from ParentContainer.

JavaAspectFunction

[TBD]

TemplateFunction

A template function behaves in the same way as a template, but there are no files generated from a template function. Just think of a template function as a sub template which can be expanded in a template or in another template function (also recursively).

Consider the following meta-model:

image305 image305

Let us now write a template function for a component which writes the name and type of the component and, if the given component is a composite, also does the same recursively for all subcomponents.

First of all we have to define the template function in the model.

image306 image306

To open the template function with the template editor, just double click in the Project Explorer. Use the Link with Editor tool (see Chapter 2.10.1 Link with Editor) to easily locate the template function in the project explorer.

image307 image307

In line 1 we write out the component name and its type name. In line 2 we iterate over all aggregated components, but only if the component is of type Composite (type cast). In this context we call the template function asText recursively for all aggregated component.

Info

Note the indention of two spaces on line 2. Actifsource takes care of the indentions so that the whole content of the template function is indented.

image308 image308

We can now call our template function from a template. If there is a call to a function from another function space, the function space is explicitly stated using the notation myFunction@MyFunctionSpace.

image309 image309

Next, we create an instance of type Client containing composites and leaves. The output from the above template might look as follows.

Info

Note that the indention is applied recursively.

image310 image310

TemplateLineFunction

The template line function behaves like a template but without the possibility to set contexts (see Chapter 8.3.9 Line Context, Column Context, Protected Context). The template line allows you to create simple single line texts as for name aspects (see Chapter 4.6.1 ch.actifsource.core.Class).

Consider a resource Person with two string literals firstName and LastName

image311 image311

Write a template function for person, which prints out the person's last name and first name.

image312 image312

Simply use the template line function as name aspect in the class Person.

image313 image313

Please not that it is also possible that the selector of the name aspect can be used directly as template line.

image314 image314

Info

Note that Person is only a Resource but not a NamedResource. The attributes firstName and lastName are therefore just normal properties.

image315 image315

Defining the name aspect as seen above synthesizes the name.

image316 image316

Built-in functions

Actifsource provides lots of useful built-in functions.

Built-in functions on Any

Actifsource provides the following built-in functions on Any.

Function Return type Description
guid Literal Gets the unique identifier of any Resource or Literal. (For Resources it is a GUID, for Literals it is the Literal itself.)

Built-in functions on Any List

Actifsource provides the following built-in functions on List of Any.

Function Return type Description
count IntegerLiteral Counts the number of elements in the list
isEmpty BooleanLiteral Returns true if and only if the list is empty.
isSet BooleanLiteral Returns true if and only if the list contains no duplicates.
first T Returns the first element in the list.
last T Returns the last element in the list.
count IntegerLiteral Counts the number of elements in the list.
reverse List of T Reverses the elements in the list.
distinct List of T Remove duplicates from a list, first to last.

Built-in functions on Resource

Actifsource provides the following built-in functions on Resource.

Function Return type Description
package String Returns the package of the resource as string.
guid String Returns the GUID of the resource as string.
simpleName String Returns the Resource’s name as defined by its NameAspect. If the resource extends NamedResource, the NameAspect returns the value of the name attribute. If no NameAspect is defined, the GUID of the resource is returned.

Built-in functions on List of Resource

Actifsource provides the following built-in functions on List of Resource.

Function Return type Description
sortByGuid List of T Sorts the list of resources by their GUIDs.
sortBySimpleName List of T Sorts the list of resources by their names.

Built-in functions on Literal

Actifsource provides the following built-in functions on Literal.

Function Return type Description
guid T Gets the identifier of the Literal value.

Built-in functions on IntegerLiteral

Actifsource provides the following built-in functions on IntegerLiteral.

Function Return type Description
increment Integer Increments an integer number.
decrement Integer Decrements an integer number.
notZero Integer Returns the number unless it is zero.

Built-in functions on IntegerLiteralList

Actifsource provides the following built-in functions on List of IntegerLiteral.

Function Return type Description
sum Integer Calculates the sum of a list of integer numbers.
minimum Integer Returns the minimum integer in a list.
maximum Integer Returns the maximum integer in a list.

Built-in functions on BooleanLiteral

Actifsource provides the following built-in functions on BooleanLiteral.

Function Return type Description
isFalse Boolean Returns true if the Boolean value is false.

Built-in functions on List of Character

Actifsource provides the following built-in functions on List of Character.

Function Return type Description
string Boolean Builds a string from characters.

Built-in functions on List of Letter

Actifsource provides the following built-in functions on List of Letter.

Function Return type Description
string Word Builds a word from letters.

Built-in functions on TextLiteral

Actifsource provides the following built-in functions on TextLiteral.

Function Return type Description
suppressIndent Text Sets the current intent mode to ‘suppress indent’: All lines after the first line start at the very beginning of the line. If applied in a template function, the setting of the outer template is not affected. The return value is the text itself.
indent Text Sets the indent mode to ‘indent’ (=default). All lines will start at the same position as the first line. (The preceding characters in the first line are copied, non-whitespace characters replaced by whitespaces.) If applied in a template function, the setting of the outer template is not affected. The return value is the text itself.
prefix Text Sets the indent mode to ‘prefix’. All lines will repeat the preceding characters in of the first line. If applied in a template function, the setting of the outer template is not affected. The return value is the text itself.
splitLines List<String> Splits text at line breaks into a list of strings.
split80 List<String> Splits text into a list of strings of maximum 80 characters. Words are considered atomic, if possible.
split100 List<String> Splits text into a list of strings of maximum 100 characters. Words are considered atomic, if possible.
escapedString String Escapes the text such that it can be embedded into C, C++ or Java source code. Escaping for C/C++ only works for ASCII characters.
notEmpty Text Returns the text unless it is empty.

Built-in functions on StringLiteral

Actifsource provides the following built-in functions on StringLiteral.

Function Return type Description
character List of Character Gets the characters in the string.
length Integer Gets the number of characters in the string.
toFirstUpper String Gets the same string with capital first letter.
toFirstLower String Gets the same string with small first letter.
toAllUpper String Gets the string in all capital letters.
toAllLower String Gets the string in all small letters.
camelcapToUnderscore String Inserts an underscore before every uppercase letter unless it is the first letter in the string.
whitespaceToCamelcap String Replaces letters behind one or many whitespace characters by their uppercase counterparts, replacing those whitespace
characters.
whitespaceToUnderscore String Replaces all whitespace characters by underscore characters.
split80 List of String Splits the string into a list of strings of maximally 80 characters.
split100 List of String Splits the string into a list of strings of maximally 100 characters.
packageToDirectory String Replaces '.' by '/'.
isNotEmpty Boolean Returns true if and only if the string is not an empty string.
escapedString String Escapes the string such that it can be embedded into C, C++ or Java source code. Escaping for C/C++ only works for ASCII characters.
part List of Literal Parses the string into words, natural numbers and special characters, removing whitespaces.

Built-in functions on Word

Actifsource provides the following built-in functions on Build.

Function Return type Description
character Letter Gets the letters in the word.

Built-in functions on Guid

Actifsource provides the following built-in functions on Build.

Function Return type Description
timestamp Long Returns the GUID's timestamp in nanoseconds starting from Oct 15, 1582.
time Time Returns the GUID's time.
identify Resource Returns the Resource identified by the GUID.

Built-in functions on Build

Actifsource provides the following built-in functions on Build.

Function Return type Description
once Build Used in the selector of the template. Build.once means a template is not based on a resource but only built once.

Built-in functions on LinkSelector

Actifsource provides the following built-in functions on LinkSelector.

Function Return type Description
selectorText String Converts a selector to simple text string.
selectorResultType AbstractType Calculates a selectors result type.

Built-in functions on File

Actifsource provides the following built-in functions on File.

Function Return type Description
contents Text Returns a file's contents.

Accessing the model from within Java function

It is possible to access the model, other functions (see chapter 9.3 Function types), or even built-in functions (see chapter Fehler! Verweisquelle konnte nicht gefunden werden. Fehler! Verweisquelle konnte nicht gefunden werden.) from within Java functions.

Consider the following meta-model for the subsequent examples:

image317 image317

Model forward access

Let’s write a Java Function for Parent which returns only instances of type Child with names beginning with “A”.

Start by declaring a Java Function named filterChild as seen in Chapter 9.3.3.

image318 image318

For the model forward access use the selectProperty() function on the given resource where property is the property to select.

The subsequent filter function iterates over the relation Parent.child in the for-Statement via parent.selectChild(). Then we check if Child.name starts with “A” via child.selectName(). If the condition is fulfilled we add the filtered child to the child list. At the end we return the child list with the filtered children.

image319 image319

You might use the filter function in the selector of a template or in any other function. The following template only prints children with names starting with “A”.

image320 image320

Model backward access

Using the selector syntax accessing the model backwards is quite easy (see chapter 9.3.2 SelectorFunction) by the minus sign. Accessing the model backwards is also possible in the Java code.

For the model backward access use the static function selectToMeProperty() on the class which defines the relation.

Since we want to access the relation Parent.child backwards we have to choose the static method Parent.selectToMeChild() providing the actual child as parameter. As a result we get the parent of the given child.

image321 image321

Function access

Use the extension mechanism to access any of your functions from within Java Code.

Info

Note that the extension mechanism also supports polymorphic calls (see chapter Fehler! Verweisquelle konnte nicht gefunden werden. Fehler! Verweisquelle konnte nicht gefunden werden.).

Let’s assume that we have a function filterChild as shown in chapter 9.5.1 Model forward access. Let’s write a Java function filterChildReverse which returns a reverse list of the filtered children based on filterChild.

For the function access use the extension() function on the given resource with FunctionSpace.ITypeRefFunctions.class as parameter. FunctionSpace is the function space where your function is defined. TypeRef is FunctionContext.typeRef. The static property .class is given from Java and represents a class as an object.

image322 image322

Built-in function access

Use the extension mechanism to access built-in functions on resources (see chapter 9.4.1 Built-in functions on Any

Actifsource provides the following built-in functions on Any.

Function Return type Description
guid Literal Gets the unique identifier of any Resource or Literal. (For Resources it is a GUID, for Literals it is the Literal itself.)

Built-in functions on Any List

Actifsource provides the following built-in functions on List of Any.

Function Return type Description
count IntegerLiteral Counts the number of elements in the list.
isEmpty BooleanLiteral Returns true if and only if the list is empty.
isSet BooleanLiteral Returns true if and only if the list contains no duplicates.
first T Returns the first element in the list.
last T Returns the last element in the list.
count IntegerLiteral Counts the number of elements in the list.
reverse List of T Reverses the elements in the list.
distinct List of T Remove duplicates from a list, first to last.

Built-in functions on Resource) from within Java Code. Accessing built-in functions is done the same way as seen in the above chapter 9.5.3 Function access.

To write a function which returns the package and the simpleName of a child we can reuse the built-in functions package() and simpleName() For the built-in function access use the extension() function on the given resource with BuiltinResourceFunctions.class as parameter.

image323 image323

Info

Note that you cannot access built-in functions for literals via the extension mechanism.

Code Snippets

Overview

Actifsource supports a special editor, the so-called Code Snippet editor, which allows the user to insert Actifsource resources as variables or functions into snippets of source code. Such a snippet of code is essentially a list of statements written in C-, where C- is a subset of the programming language ANSI C. A more precise definition of C- will be given below. Actifsource then provides the possibility to generate code in an arbitrary target language from these code snippets. This is achieved by parsing the input code according to the grammar of C- and applying either built-in or user-provided templates to the resulting parse tree. This parse tree is actually a model composed of temporary (i.e. non-persistent) resources. The following example shows a code snippet here the underlined identifiers are resources used as variables and functions:

image324 image324

Defining Code Snippet Relations

First, we will show how to add a code snippet relation to a class and define all the necessary properties of this relation. Such a relation enables the code snippet editor on instances of this class and allows a user to add code written in the chosen input language to the resource. Most of the examples and screenshots in the following are taken from the Code Snippet tutorial available at http://www.actifsource.com/tutorials/index.html. This tutorial is based on the following meta-model for statemachines and shows how to add code snippets for conditions on transitions and for actions taken when a condition is executed.

image325 image325

To add code snippets to resources of type MyClass, you have to edit MyClass in the resource editor, add a new property and choose the type StructuredCodeSnippetRelation for the relation in the Type Selection dialog:

image326 image326

In the resulting property, you have to create the following statements: subjectObjectCardinality, objectCardinality and name as for Own- or Association (see Section 4.3).

Additionally, we define the CodeSnippetRelationAspect as shown below with the class

ch.actifsource.codesnippet.metamodel.aspect.impl.StructuredCodeSnippetRelationAspect.

image327 image327

Language

Next, we choose an input language for the code snippet.

image328 image328

The input language is used to check the input code syntactically and to highlight keywords of the language. Furthermore, the input language defines which parser will be applied to the input code when generating output code from the code snippet. See Section 10.3 for a description of the available input languages.

Tokens

Finally, we need to define which resources will be available as functions and variables in the code snippet editor. This is done by creating one or more token statements referring to a RelationTokenProvider. The RelationTokenProvider allows the user to define a selector (cf. Section 8.3.12) which defines a list of resources. Additionally, it allows you to choose a tokenType which is either

  • ch.actifsource.codesnippet.metamodel.TokenType.Variable for variables or
  • ch.actifsource.codesnippet.metamodel.TokenType.Function for functions.

image329 image329

For variables you can define sub-tokens. The definition of sub-tokens instructs the Content Assist to propose all resources defined by the selector of the sub-token when you insert a '.' after a token. This means that sub-tokens can be used to insert resources as identifiers of fields in structs where the token corresponds to the struct and the sub-token to the field (for details see Section 0 below).

Input Languages

At the moment, the following languages are available: C-, CMinusCondition and Text.

C-

The language C- is a (proper) subset of the language ANSI C. It has the following restrictions:

  1. C- supports no declarations (of variables, functions or types)

  2. C- does not support the use of pointers and addresses

  3. C- does not support type casts

  4. C- does not support conditional statements (Expression ? Expression : Expression). However, they can easily be replaced by equivalent if-statements.

  5. The comma operators is not supported, i.e., expressions such as

    • X = 2, z = 42
    • Foo(x,(y=2,y)) are not valid.
  6. Postfix and prefix increment and decrement operators (++,--) are not supported.

C- supports access to fields of structs. As identifiers for fields either variables or arbitrary identifiers are valid. The Content Assist provides proposals for fields of structs if the variable definitions are created accordingly (see Section 10.4.1 ).

C- knows the following list of keywords: break, else, switch, return, continue, for, default, do, if, while, until, case.

Furthermore, the language knows the following operators:

  • Infix-Operators { ||,  &&|^&==!=<><=, >=<<>>, +-*,  /, %}
  • Prefix-Operators { !, ~, +, -}
  • Assignment-Operators {=, *=, /= , %=, +=, -= , <<= , >>= , &=, ^= , |=}

CminusCondition

A code snippet with CMinusCondition allows the user to input a conditional expression as in ANSI C (e.g. a relational or equality expression) while the same restrictions apply as for C- (details see Section 10.3.1). Such an expression can then be used for example as the condition in an if-statement.

Text

Text allows the user to insert arbitrary text with resources added as either variables or functions. This language should only be used if C- is too restrictive and validation of the input code is not required. The input code is syntactically not validated[^1] and the resulting parse tree is very simple:

image330 image330

Code Snippet Editor

The code snippet editor is available in the resource editor for any property of type StructuredCodeSnippetRelation. The editor supports multi-line input. It highlights keywords and comments according to the language property of the StructureCodeSnippetRelation. You can inspect the definition of the input language by CTRL+Left-Click on the chosen language:

image331 image331

This opens the chosen language in the resource editor and allows you to browse the properties such as keywords and style of comments of the language:

image332 image332

Content Assist

By using CTRL+Space in the code snippet editor you can as usual call the Content Assist. The Content Assist will show you all available resources to insert as functions and variables. The set of available resources is defined by the property token on the corresponding StructuredCodeSnippetRelation (see Section10.2). Inserted resources are underlined with blue color.

  • Structures The StructuredCodeSnippetRelation supports the definition of complex and nested data types such as structs by defining a set of subtokens for a token. After inserting an instance of a token into the code snippet editor followed by a '.' (struct field access in C-), the Content Assist will propose the list of all resources defined by the selectors of its sub-tokens.

Consider for example the following meta-model:

image333 image333

Furthermore, we consider a StructuredCodeSnippetRelation on class A with the following definition of tokens:

image334 image334

We can now create a resource a1 of type A and insert code into the code snippet editor. When calling the Content Assist after inserting b1 it proposes the list c1, c2 (available through the Selector B.c) and d1 (available through the Selector B.d). See first screenshot below.

Info

Note that it is also syntactically correct to insert arbitrary strings as identifiers for fields of structs. After inserting one or more such identifiers followed by a '.', the Content Assist will again propose the list of root elements (tokens) independently of possible resources before the string (see second screenshot below).

It is not possible to define structures recursively. Thus, you have to explicitly define the whole structure to the desired (finite) depth if it is self-referential.

image335 image335

image336 image336

Validation and Errors

The syntax of the input code in the code snippet editor is continuously validated. Syntax errors are shown by underlining the errors in the code and adding an error description to the Model Inconsistencies view:

image337 image337

Code Generation

In this section, we will show how to generate code in an arbitrary target language from code snippets. As explained in the introduction of this chapter, the input code of a code snippet is parsed by a parser that depends on the chosen input language (e.g. C- or Text). From the resulting parse tree, Actifsource generates a model that is composed of temporary resources. The meta-model for parse trees of the language C- is available at http://www.actifsource.com/manuals/index.html. The parse tree for unvalidated input (Text) can be found in Section 10.3.3.

To generate output files from these temporary models, we can apply code templates or template functions to these temporary resources, i.e., the temporary resources behave in exactly the same way as persistent resources except that they are not shown in the resource browser (Project Explorer) and are deleted when the session ends (e.g. the project or the workspace is closed). To use the content of code snippets in templates, you can either use the built-in TemplateFunctions (see Section 10.5.1) or write your own templates or template functions by modifying the built-in templates or writing them from scratch. The behavior of the built-in template functions can be customized by overwriting the way names of variables and functions are created (see Section Overwrite Variable and Function Names (Name Provider) below).

Built-in Template Functions

Actifsource provides the following built-in template functions which are defined on resources of type ch.actifsource.codesnippet.metamodel.element.CodeSnippet:

  • codeSnippetToST: generates Structured Text from a CodeSnippet with input language CMinus or CMinusCondition.
  • codeSnippetToC: generates C code from a CodeSnippet with input language CMinus or CMinusCondition.
  • codeSnippetToText: generates code from a CodeSnippet with input language Text (unvalidated code).
  • codeSnippetToFormattedC: generates formatted C code (HTML) from a CodeSnippet with input language CMinus or CMinusCondition (the actual code is the p)
  • codeSnippetToVHDL: generates VHDL code from a generates C code from a CodeSnippet with input language CMinus or CMinusCondition

For all the above template functions, the names of variables and functions in the output code are generated by calling the function simpleName@BuiltIn on the corresponding resource.

Info

Note that the above template functions which are written for input languages CMinus and CMinusCondition can also be applied to Text. The output is the same as when calling the function codeSnippetToText in this case.

Overwrite Variable and Function Names (Name Provider)

Generating the names of variables and functions by calling simpleName@BuiltIn, is in practice not always sufficient to generate code that meets all the requirements (the requirements on the naming could depend on naming conventions of the target language or names of variables could depend on the context in which the corresponding resource is used). For these cases, Actifsource provides more flexible template functions which takes a Literal of type ch.actifsource.codesnippet.metamodel.parsetree.template.NameProvider as an additional parameter:

  • codeSnippetToSTwithNameProvider

  • codeSnippetToCwithNameProvider

  • codeSnippetToText

  • codeSnippetToFormattedC

  • codeSnippetToVHDL

Apart from the generation of function and variable names, these templates have exactly the same behavior as the corresponding template functions from the section above.

The additional parameter to this functions can be used to store additional context information necessary to generate the names and to overwrite the functions used to generate the names, namely variableName@TokenToName and functionName@TokenToName. These two functions take a parameter of type Resource (the resource corresponding to the variable resp. function) and generate the name by calling NameProvider.variableName@TokenToName resp. NameProvider.functionName@TokenToName:

image338 image338

image339 image339

The Code Snippet tutorial available at http://www.actifsource.com/tutorials/index.html show how to implement a NameProvider by guiding you step-by-step through an example.

Implement a custom NameProvider

In general, one can implement and use a NameProvider as follows:

  1. Write a LiteralAspect (e.g. MyNameProviderLiteralAspect) in Java which implements ch.actifsource.core.model.aspects.impl.IGenericLiteralAspect<MyNameProviderLiteralAspect>. image340 image340

  2. Create your own resource of type Literal (e.g. MyNameProvider) which extends ch.actifsource.codesnippet.metamodel.parsetree.template.NameProvider: image341 image341

  3. Create a Java interface (e.g. IMyNameProvider) which provides the members needed to manage and store the context information needed by the NameProvider. image342 image342

  4. Create a FunctionSpace (e.g. MyNameFunctions) which extends TokenToName with a FunctionContext for the newly created Literal type (e.g. MyNameProvider). Create the two functions variableName and functionName with exactly the same signature as corresponding functions in the TokenToName.

    image343 image343

    image344 image344

  5. Write a JavaFunctions (e.g. createMyNameProvider) that generates an instance of the newly created Java interface (e.g. IMyNameProvider).

    image345 image345

  6. In the template where the function to<Language>withNameProvider is used, call the newly created JavaFunction (createMyNameProvider) and call to<Language>withNameProvider with the output of the JavaFunction.

image346 image346

Info

Note that the TemplateFunctions presented in Section 10.5.1 generate the names by internally calling the name functions variableName and functionName on ch.actifsource.codesnippet.metamodel.parsetree.template.NameProvider (the default NameProvider). Thus, overwriting these functions in a FunctionSpace that extends TokenToName for the type NameProvider (see example below) also changes the behavior of this TemplateFunctions without NameProvider (e.g. toC@CodeSnippetToCode). This can, in particular, change the behavior of already existing templates and template functions. Therefore, this approach should normally be avoided and a customized NameProvider implemented instead.

image346 image346

Display Code Snippets in Diagrams

Since the parse trees created from the input code of a code snippet are temporary resources, they are only visible for the code generator. To use the content of code snippets in diagrams, Actifsource provides template functions which allow you to display the code in diagrams:

  • displayCodeSnippet
  • displayCodeSnippetSingleLine

These TemplateFunctions show the unprocessed code as it is entered by the user in the code snippet editor. Both functions are defined on resources of type ch.actifsource.codesnippet.metamodel.element.CodeSnippet. An example application of these functions can be found in the Installing Actifsource](/tutorials/\20_enterprise/60_code-snippet) .

Java API

Select-Fassade

Select Functions for Property

Function Return type Description
rangeOrNull Class Returns a Property’s range.
→ownerOrNull Class Returns a Property’s domain.
isComposition boolean Check if a Property is an Composition.
isDecoratingRelation boolean Check if a Property is a DecoratingRelation.
isSubRelation boolean Checks if a Relation extends another Relation.
isComposition boolean Checks if a Relation is a Composition.
superRelations Set of Relation Returns the Relations a Relation extends.
subRelations Set of Relations Returns the that extend a Relation given Relation.
rootProperty Relation Returns the first Properties of the Set of Properties a Property extends, including itself.
rootRelation Relation Returns the first Relations of the Set of Relations a Relation extends, including itself.
possibleDecoratingTypes Map ? ?

Select Functions for Statement

Function Return type Description
existsStatement boolean ?
findNext Property Set Returns the successor Statement of a given Statement.
nameOf Attribute Set Returns the composed simpleName in the form (Subject, Predicate, Object).
statementPath List of Statement ?
decoratedNode Resource Returns the Resource that is decorated via this decorating Statement.

Select Functions for Class

Function Return type Description
instances Set of Resource Returns the direct or indirect instances of a Class.
directInstances Set of Resource Returns the direct instances of a Class.
instancesWithPackage Set of Resource Returns the direct or indirect instances of a Class in all Packages.
instancesWithMainPackage Set of Resource Returns the direct or indirect instances of a Class with their main Package.
isTypeOfFilter Filter on Resource Returns a Filter which includes Resources of a given Class.
resourceBySimpleNameOrNull Resource with Package Returns the Instance having a given simple Name.
resourcesBySimpleName Set of Resource with Package Returns the Instances having a given simple Name.
resourceByFullNameOrNull Resource with Package Returns the Instance having a given simple Name.
resourcesByFullName Set of Resource with Package Returns the Instances having a given simple Name.
allowedPropertiesOfType Set of Property Returns the (inherited or defined) Properties of a Class.
allowedPropertiesOfTypeForRead Set of Property Returns the (inherited or defined) Properties of a Class,including the overridden Properties.
allowedAttributesOfType Set of Attribute Returns the (inherited or defined) Attributes of a Class.
allowedAttributesOfTypeForRead Set of Attribute Returns the (inherited or defined) Attributes of a Class, including the overridden Attributes.
allowedRelationsOfType Set of Attribute Returns the (inherited or defined) Relations of a Class.
allowedRelationsOfTypeForRead Set of Attribute Returns the (inherited or defined) Relations of a Class, including overridden Relations.
isAbstractClass boolean Checks if a Class is abstract.
isFinalClass boolean Checks if a Class is final.
isSubclass Set of Type Checks if a Class extends another Class.
subclasses Set of Resource with Package Returns the Sub-Classes of a given Class.
superclasses Set of Resource with Package Returns the Super-Classes of a given Class.
matchingInstances Set of Type ?
isMatchingObjectFilter Filter on Resource ?
matchingSuperTypes Set of Type ?
matchingSubTypes Set of Type ?
isMatchingSuperType boolean ?
rangeToType Set of Type ?

Select Functions for Resource

Function Return type Description
exists boolean ?
packages Relation Set ?
mainPackage Relation Set ?
asPackagedResource Resource with Package Decorate a Resource by its main Package.
asPackagedResource Set of Resource with Package Decorate a Set of Resources by their main Packages. ?
namespace string Returns the name of the Packages and owning Resources, concatenated with dot.
simpleName string Returns the Name of a Resource defined by the NameAspect, or else the GUID.
hasName boolean Checks if a Resource has a Name, that is it has a NameAspect defined.
hasModifiableName boolean ERROR
fullName boolean Returns the Name, predeeded by Package Names and Name of the owner Resources.
isOwned boolean Checks if a Resource is directly or indirectly owned by another Resource, or it is the same Resource.
isRootResource boolean Checks if a Resource is not owned by any other Resource.
isAllowedPredicate boolean ?
rootResource Resource Returns the owner Resource that directly resides in a Package.
rootStatements Statement ?
directlyOwnedResources Set of Resource ?
ownStatementOrNull Statement Returns the Statement stating that a given Resource is owned by another Resource.
decoratedNode Resource Returns the Resource being decorated by this Decorator.
shallowType Type Returns the direct Type of a Resource.
isTypeOf boolean Check if a Resource is instance of a given Class.
toMeRelationsForType Relation ?
toMeTypes Set of Type ?
isMatching boolean ?
matchingTypes Set of Type ?
allowedProperties Property Set Returns the (inherited or defined) Properties of a Resource’s Class.
allowedPropertiesForRead Property Set Returns the (inherited or defined) Properties of a Resource’s Class,including overridden Properties.
allowedAttributes Attribute Set Returns the (inherited or defined) Attributes of a Resource’s Class.
allowedAttributesForRead Attribute Set Returns the (inherited or defined) Attributes of a Resource’s Class, including overridden Attributes.
allowedRelations Relation Set Returns the (inherited or defined) Relations of a Resource’s Class.
allowedRelationsForRead Relation Set Returns the (inherited or defined) Relations of a Resource’s Class, including overridden Relations.
allowedToMeRelations Relation Set Returns the Relations having a Resource’s Class as range.

Select Functions for Extendable

Function Return type Description
isAbstractExtendable boolean Checks if an Extendable is abstract.
isFinalExtendable boolean Checks if an Extendable is final.
extensions Set of Extendable Returns the extending Resources.
extendedResource Set of Extendable Returns the extended Resources.
isExtension boolean Check if a Resource extends another Resource.

Select Functions for (Resource, Property)

Function Return type Description
attributeStatementOrNull Statement ?
allowedPropertiesForRead Property Set Returns the (inherited or defined) Properties of a Resource’s Class, including overridden Properties.
allowedAttributes Attribute Set Returns the (inherited or defined) Attributes of a Resource’s Class.
allowedAttributesForRead Attribute Set Returns the (inherited or defined) Attributes of a Resource’s Class, including overridden Attributes.
allowedRelations Relation Set Returns the (inherited or defined) Relations of a Resource’s Class.
allowedRelationsForRead Relation Set Returns the (inherited or defined) Relations of a Resource’s Class, including overridden Relations.
allowedToMeRelations Relation Set Returns the Relations having a Resource’s Class as range.
objectsForAttribute List of Any Returns the Objects as result of the Evaluation of a given Attribute on a given Resource
objectForAttribute List of Any Returns the first Objects as result of the Evaluation of a given Attribute on a given Resource, or else a default.
objectForAttributeOrNull List of Any Returns the first Objects as result of the Evaluation of a given Attribute on a given Resource.
statementForAttributeOrNull List of Statements Returns the first Statement on a given Resource for a given Attribute.
objectForPropertyOrNull List of Objects Returns the first Objects as result of the Evaluation of a given Property on a given Resource.
objectMaxCard int Returns the maximum allowed count of Statement of a given Relation for a Resource in the Relation’s range.
objectMinCard int Returns the minimum allowed count of Statement of a given Relation for a Resource in the Relation’s range.
attributeMinCard int Returns the minimum allowed count of Statement of a given Attribute for a Resource in the Attribute’s domain.
attributeMaxCard int Returns the minimum allowed count of Statement of a given Attribute for a Resource in the Attribute’s domain.
subjectMinCard int Returns the minimum allowed count of Statement of a given Relation for a Resource in the Property’s domain.
subjectMaxCard int Returns the minimum allowed count of Statement of a given Relation for a Resource in the Property’s domain.
objectForAttributeOrNull List of Literal Returns the first Objects as result of the Evaluation of a given Attribute on a given Resource.
valueForAttributeOrNull string Returns the string value of the first Object as result of the Evaluation of a given Attribute on a given Resource.
valueForBooleanAttribute boolean Returns the string value of the first Object as result of the Evaluation of a given Attribute on a given Resource, or a default value.
objectForRelationOrNull List of Resource Returns the first Objects as result of the Evaluation of a given Relation on a given Resource.
objectsForRelation List of Resource Returns the Objects as result of the Evaluation of a given Relation on a given Resource.
objectsForRelationOfType List of Resource Returns the Objects as result of the Evaluation of a given Relation on a given Resource, having a given Type.
ownerOrNull Resource Returns a Resource’s owner Resource.
relationStatementOrNull Statement ?
statementOrNull Statement Returns the Statement with given Subject, Predicate and Object.
statement Set of Statement Returns the Statements with given Subject.
statementsForAttribute Set of Statement Returns the Statements with Subject and Predicate given by Resource and Attribute.
statementsForRelation Set of Statement Returns the Statements with Subject and Predicate given by Resource and Relation.
statementForRelationOrNull Set of Statement Returns the first Statement with Subject and Predicate given by Resource and Relation.
subjectForRelationOrNull Set of Object Returns the first Subject with Statement and Predicate given by Resource and Relation.
subjectsForRelation Set of Statement Returns the Subjects with Object and Predicate given by Resource and Relation.
toMeStatementForRelationOrNull Set of Statement Returns the first Statement with Object and Predicate given by Resource and Relation.
toMeStatementsForAttribute Set of Statement Returns the Statements with Object and Predicate given by Resource and Attribute.
toMeStatementsForRelation Set of Statement Returns the Statements with Object and Predicate given by Resource and Relation.
toMeStatements Set of Statement Returns the first Statement with given Object.
treeSelectObjects Set of Object Calculates the closure for given Resource and Relation. ??
topoSelectObjects Set of Object ?
treeSelectSubjects Set of Object ?
decoratableNodes Set of Resource ?

Select Functions for Package

Function Return type Description
allReferencedPackages Package ?
allStatements Set of Statement Returns all the Statements in a Package.
allRequiredScopes Set of Statement ?
allAvailableRequiredScopes Set of Resource Scope ?
resourceByNameOrNull Resource Returns the Resource in the Package having a given simple Name.

Select Functions for Resource Scope

Function Return type Description
getScope Resource Scope Returns the Scope.
isRequired Set of Resource Scope ?
allResourcesInScope Unordered Set of Resource Returns all Resources reachable from a given Resource Scope.
allReferencedResourcesInScope Unordered Set of Resource ?
classByName Java class Loads a Java class of given name.
classByNameOrNull Java class Loads a Java class of given name.
packagesInScope Set of Package ?
unreferencedResource Set of Resource with Package ?
types Set of Class Returns the direct and indirect Types of a Resource.

Additional Select Functions

Function Return type Description
getScope Resource Scope Returns the Scope.
getRequiredScopes Set of Resource Scope ?
allRequiredScopes Set of Resource Scope ?
allAvailableRequiredScopes Set of Resource Scope ?
isRequired Set of Resource Scope ?
allResources Unordered Set of Resource Returns all Resources in Scope.
allResourcesInPackage Unordered Set of Resource Unordered Set of Resource
allResourcesInPackage2 Unordered Set of Resource with Package Returns all Resources in a Package.
allResourcesInPackages2 Unordered Set of Resource with Package Returns all Resources in a List of Packages.
allRootResourcesInPackage Unordered Set of Resource Returns all Resources residing directly in a Package.
allStatements Set of Statement Returns all Statements.
resourceBySimpleNameOrNull Resource with Package Returns the Resource having a given simple Name.
resourcesBySimpleName Set of Resource with Package Returns the Resource having a given simple Name.
resourceByFullNameOrNull Resource with Package Returns the Resource having a given full Name.
resourcesByFullName Set of Resource with Package Returns the Resource having a given full Name.
packagesByName Set of Package Returns the Packages having a given Name.
subPackagesByName Set of Package Returns the Packages having a given Name, including the Sub-Packages.
packagesByExpressions Iterable of Package ?
allPackages Iterable of Package ?

Update-Fassade

Context Sensitive Help

Overview

In this section we will show how to set up the context sensitive help system. The Actifsource context sensitive help is integrated into the Eclipse Platform help system.

As a very simple example, let us define a help system for the following meta-model. This example allows to show help information about the Class A, B and BaseAB, and the respective instances A1 and B1.

First, we create the help file “ClassDocument.html” which contains all the help information and which defines the link targets for the context sensitive help.

image348 image348

image349 image349

Table of Contents

The table of contents (toc) contains a collection of topics for display inside the Eclipse help system. The topics here unlike in the context sensitive help are not bound to a context. For the detailed information on the supported features (Topics, Link and Anchor), see the Eclipse documentation

Now we create a HelpSystem resource in Actifsource: “ExampleHelpSystem”. Let us add a table of contents which has its contents statically defined as xml file: “StaticTableOfContents”. It has two properties:

  • primary: If true: The table of contents is displayed as a book within the Eclipse help.
  • file: The location of the toc xml file.

image350 image350

For editing the toc xml file, you can use the Eclipse specific editor, or edit it directly in an xml editor.

The toc xml file consist of a root xml element “toc” having an attribute “label” and containing nested “topic” elements. A “topic” element has the two xml attributes:

  • label: The label to display for the topic.
  • href: The location of the html File. The link providing anchors.

Now we create a toc file (TableOfContentsFile.xml) with the following topics and nested topics.

image351 image351

image352 image352

To open the Eclipse help system choose Help -> Help Contents. Select the ‘Actifsource Help Sample’ and expand the topics and you will see the following.

image353 image353

Help Context

Context sensitive help is a mechanism for linking a Resource to a specific help topic. For the detailed information on the supported features (Context, Topics and Commands), see the Eclipse documentation.

image354 image354

The information, which defines the different contexts and how they are linked to a topic, is stored in a help context xml file. When triggering the context sensitive help, the defined contexts are matched against the currently selected resource in the following order (most specific to least specific):

  • Matching of the instance by its GUID (instance match)
  • Matching of a resource by the GUID of its class (direct class match), and it super-classes (indirect class match).

You can edit the help context xml file directly or you using the Eclipse specific editor. A context xml entry has the two attributes:

  • id: The GUID of the Resource to associate the help.
  • merge: If true, also the topics of less specific contexts than this context are shown. If false, the topics of less specific context matches are omitted.

A topic entry in the xml file has the attributes:

  • label: The label displayed for the topic.
  • href: The location of the html file. The link providing anchors.

Now we create a help context file (HelpContextfile.xml) with the following contexts and topics.

image355 image355

image356 image356

The content sensitive help can be opened by selecting a Resource via any Actifsource editor and pressing ‘F1’.

All related topics started from the selected Resource (A1) via his types (from specific to generic type) are merged together. If only a single context matches the currently selected resource (setting the “merge” flag to false), then the html content is immediately shown inside the Eclipse help view.

image357 image357

Generic Export Wizard

Overview

In this section we will show how to export any build config to the file system. As a very simple example, let us define a generic template wizard to export the build config ‘TestBuildConfig’.

image372 image372

Generic Template Wizard

Property Description
name Defines the export wizard name.
version Defines the version from the export wizard.
publisher Defines the publisher from the export wizard.
description Defines the description inside the eclipse info page. Html tags are allowed.
info Defines the info inside the export wizard.
buildConfig Defines the build config to export.

You can start the export sequence via the context menu in the project explorer.

image373 image373

Select the generic export wizard to continue the export.

image374 image374

Select the Test-Generic-Template-Wizard to continue the export.

image375 image375

Preselecting a project scope and output folder inside the workspace or file system to complete the exporting sequence.

image376 image376

After importing any errors and infos are shown in the info-Page.

image377 image377

Code Generator

Overview

Click on GUID

Eclipse Builder

Working with GCC