Norwegian University of Science and Technology

Global navigation


The properties view

The properties view consists of a set of tabs, each of which supports editing a set of related features of the selected model element. For most elements there is an Appearance tab, with visual features only (like position and size), a Core tab, with all the semantic features (like name and type information) and a Behavior tab, with selected semantic features. The Core tab is based on the textual editing support that is generated from the underlying semantic model, while the Behavior tab complements the pure textual syntax with more usable form-based editing. We will only cover the Behavior tab here, since it includes the most important features.

The behavior tab

The behavior tab contains simple forms for editing selected features of the selected element(s). Each feature, like the type of a variable and the function of a connection, has its own form. In each form there is a dropdown that indicates the type of the current feature value and that may be used to select a different type. The form below the dropdown depends on the current type. Most dropdowns include a “None” type for no value, and an “Other” type, that utilises the same textual syntax as the Core tab. If you are interested in understanding the textual syntax, select a type and fill in its form, then select the “Other” type and inspect the corresponding text.

Types

Types play an important role, by limiting the values stored in variables, passed along connections and used and returned by functions. There are many kinds of types, the most important being classes, either Java or Ecore classes, and list of some element type. In addition, null values may be allowed or not.

A class (type) is indicated by its name (including package prefix), and appending a + or - sign allows or disallows null values. A list type allowing from <n> to <m> values of some element type is written as the element type followed by [<n>..<m>]. If one or both of <n> and <m>, are omitted, they default to 0 and unlimited, respectively. E.g. an unlimited list of strings is written as String[..].

Functions

Functions are used for many purposes, and is the most important property of connections, computations and gates. There are many kinds of functions, e.g. type checking and conversion, getting and setting properties, transforming and filtering lists and more generic script functions.

The simplest function is the property getter. A property getter is defined by means of a property name. The property getter accepts one argument and returns the corresponding property value. Property getters work with both standard Java objects and Ecore instances.

A related function is the property setter. A property setter is defined by means of a property name. The property setter accepts two arguments, an object and a value and sets the corresponding property of the object to the provided value.

Types (see above) may be used to define type checking and conversion functions. A type checking function is defined by means of a single type. Such a function takes one argument and return this argument if it is of the appropriate type. Otherwise it returns null. A type conversion function is defined by means of source and target types. Such a function takes one argument and converts and returns this argument to the target type, if it is of the source type. Otherwise it returns null. The type checking function may be thought of as a type converting function with equal source and target types.

A mapping function transforms (maps across) a value of a List type, by calling an element function for each element of the given list and assembling them into a new list. In addition, an element type may be used to filter out values that should not be included. A mapping function is written as '['<element function>':'<element type>']'. The colon and the element type may be omitted. E.g. [propertyName] maps the property getter for 'propertyName' across the list argument. The return value will be a new list with the property value in the same place as the corresponding object in the argument. The Behavior tab provides a special form for the case where the mapping function is a script function.

A (Java)script function is the most complex and generic function type, as it supports using Javascript to implement 'any' computation. Such a function is defined by a set of argument types, the return type and the body code. The body code can either be a simple expression, the value of which is implicitly return, or a full body with braces and containing an explicit return statement. Since the argument list is defined implicitly by the argument types, but no names, the notation $n must be used to refer to argument (value) nr. n (counting from 1). The generic syntax is 'js:'<argtype 1>,<argtype 2,…,<argtype N>'→'<result type>|<body>. E.g. js:String→Integer|$.length() defines a function from String to Integer, that returns the length (number of characters) in the argument string. ('js' stands for Javascript, and is included in the syntax to enable support of several scripting languages. E.g. at some time Diamodl included support for a language named 'pnuts').




2007/11/07 18:03, Hallvard Trætteberg
NTNU, NO-7491 Trondheim. Telephone: +47 73 59 50 00. Contact us
Editorial responsibility: hal@idi.ntnu.no