User Tools

Site Tools


v040:userguide

User Guide for version 0.4.0

Release notes, reporting bugs

Installation

Sample models

For a quick start we recommend experimenting with the sample models.

  • Download and unzip the sample models.
  • Import them into your Eclipse workspace (File / Import / General / Existing projects into workspace).
  • Due to a known issue about type resolution, you might get errors after importing the example projects. Use the Project / Clean menu to clean and rebuild the projects in this case.

Each sample model is implemented using both XtxtUML syntax (see the source packages <name of example>.x.model) and JtxtUML syntax (see the source packages <name of example>.j.model). In addition, the sample models are accompanied with class diagram descriptions (see the Java classes inheriting from the Diagram type).

We suggest reading the Generating diagrams and the Running and debugging models sections as the next steps of experimenting with the sample models.

Creating own models

New txtUML project

txtUML models should be placed in txtUML projects. A new txtUML project can be created by selecting File / New project… / txtUML / txtUML Project and setting the project name.

By default, the project will be created in the current workspace. In order to override this, uncheck the Use default location checkbox and select a location for the new project.

New txtUML model

Select File / New / Other… / txtUML / txtUML Model.

Select a Source folder from an existing project for the new model. Select an existing Package from that folder or type a new Package name. Type a Name for the new model.

Select the syntax of the new model:

  • JtxtUML for Java syntax.
  • XtxtUML for custom modelling syntax.

Both JtxtUML and XtxtUML models can be connected with Java code, can be run and debugged, and used as a source for Papyrus UML model generation.

A txtUML model is a package with

  • either a package-info.java file (in case of JtxtUML), where the package has an annotation of the form @Model(“ModelName”)1) annotation,
  • or a package-info.xtxtuml file (in case of XtxtUML), which has a model declaration of the form model “ModelName”;.

All files in this package (and its subpackages) are part of the model. The wizard described above creates one of these files depending on the JtxtUML/XtxtUML selection.

New model elements

For XtxtUML syntax, select File / New / File. Fill in the package to place the new source file in, then enter a file name with .xtxtuml extension.

For JtxtUML syntax, select File / New / Class to create a new Java class.

See the Language Guide for the syntax of the different model elements in JtxtUML and XtxtUML.

Modeling Language

See the Language Guide to study the txtUML language both in Java syntax (JtxtUML) and in custom syntax (XtxtUML). In case of JtxtUML, the JavaDoc of the API can also be used.

Generating diagrams

It is possible to generate EMF-UML2 models together with Papyrus diagrams from txtUML models. Currently class diagrams and state machine diagrams can be generated. Content and layout of the class diagrams can be defined by textual diagram descriptions. State machine diagrams are generated as is, and usually need to be laid out manually afterwards. (Support for state machine layout definitions is coming in a later release.)

The following simple example assumes classes A, B, C and D in the model. We create a class diagram with where classes A, B and C are in a row, and class D is below B. Diagram definitions can be written using a Java API. See the Diagram Language Guide for detailed description.

Our example diagram can be defined as follows:

public class ExampleDiagram extends Diagram {
	@Row({A.class, B.class, C.class})
	@Below(val = D.class, from = B.class)
	class ExampleLayout extends Layout {}
}

In order to generate diagrams, from the menu select txtUML / Generate diagrams from txtUML.

Fill in the name of the project containing the txtUML model, then the fully qualified name of the model. Using the Add txtUML diagram description button, you can add as many diagram descriptions as needed. In our example, there is only one. The fully qualified name of the Java class representing the diagram definition needs to be filled in. Tick the check box to generate state machine diagrams for each class of the model. (This is not needed in our example, as there are no state machines in the model.)

When clicking Finish, a Papyrus model is generated with the following class diagram:

Diagram language

See the Diagram Language Guide for detailed description of the diagram language of txtUML.

Running and debugging models

The following hold both for XtxtUML and JtxtUML.

Switch to Java or Debug perspective and create a new run/debug configuration. Use Java Application type if you only want to run or debug the model only in text. Use txtUML Application type if state machine animation is required as well.

Breakpoints can be created and managed the same way as for Java programs. The standard debug controls (stop, pause, resume, step, step-into) work as usual.

The variable view can show the current signal, current state, associations and the attribute values of the actual object.

State machine animation

txtUML can animate state machine diagrams generated by the txtUML visualization process. See the Generating diagrams section and do not forget to tick the generate state machine diagrams automatically check box. Make sure that the run/debug configuration is of txtUML Application type.

Open the generated Papyrus diagram and start the model either in run or in debug mode. The current state and currently executed transition gets highlighted.

For each state machine diagram, the state changes of the first activated object of the corresponding type will be highlighted. An expected later improvement will make it possible to select the object to be animated during the debug session.

Compilation to C++

Note: The generated C++ code is incomplete. It contains structure (classes, attributes, methods, state machine elements) only, the behaviors (method bodies, instructions of state machine entries etc.) are not generated. Complete code generation is expected in a later release.

The C++ model compiler can be reached by selecting the txtUML / Generate C++ code from txtUML menu.

The Eclipse project and the package that contains the model must be specified. The txtUML deployment configuration is a description of how the object instances will be distributed into different threads. We suggest reviewing the deployment configurations in the demo projects. Detailed documentation of the deployment configuration language will be available when the complete C++ code generation will be released.

The generated C++ code is saved in the cpp-gen folder of the selected project. Note that you might have to refresh the folder so that the newly generated files become visible in Eclipse.

1) Fully qualified name: hu.elte.txtuml.api.model.Model
v040/userguide.txt · Last modified: 2016/03/24 10:38 by deva