Using the example project SimpleTextEditor
DeltaJ |
Installation |
Using the example project |
Creating new DeltaJ project
We created an example Software Product Line (SPL)
SimpleTextEditor (STE) using
DeltaJ 1.5. This website presents a short hands-on with DeltaJ 1.5 and the STE. After
you have read this page - and tried it on your machine - you should be able to use
DeltaJ, maybe you ahould have a look at the
Creating a new
DeltaJ project site to learn how to start from scratch.
This site is devided into the following sections:
Download an Import |
Project structure overview |
Editing SPL declaration |
Editing DeltaJ
Source Code |
Generating products
Download and Import
In this section you learn how to download and import the STE into you Eclipse workspace
with installed DeltaJ 1.5 plug-in.
- Download the STE from out website [1] and unpack it to your
local file system. Important: The STE uses the Eclipse SWT API which is
platform-dependent. Use one of the prepared versions for
Linux,
Mac OS X or
Windows. These packages include
the necessary APIs for your machine.
- Import the unpacked project folder into you Eclipse Workspace. Select [File / Import ...]
to open up the import dialog.
- Select Existing Project into Workspace which you find in the General
folder and hit [Next >].
- Now choose Select root directory and hit [Browse] to navigate to the STE
project folder. Now you can choose the SimpleTextEditor and hit [Finish]
- After you have successfully imported the project, Eclipse will
build it. This process may take a while. During this process
you will see some output in the console. When you see this, a dialog window
appears on your main screen and asks you to select the products to be generated.
Please select at least one of the products.
Now, You can start to examine the project and get in touch with DeltaJ 1.5.
Overview of the STE project (general structure of a DeltaJ project)
This picture shows the
Package Explorer of Eclipse with the STE example. IT contains
- like every DeltaJ project - three important source code folders:
src: This is the default source folder. It normally contains the delta modules,
which are saved as .deltaj files.
spl-info: This folder contains the Software Product Line Declaration (SPLD)
file. There you define Features, Delta modules, Constraints which structure the
features and declare dependencies, the n-m-mapping of Features and Delta Modules
and the Product definitions.
src-gen: This folder contains the generated source code for the products. In the
beginning it is empty. The generation process will generate Java source files which are
then saved in this folder. Each product has its own root package, that allows to
generate different products side-by-side. Depending on your Eclipse setting you might
see a pretended chaotic list of a lot of packages there. But don't worry!
Every DeltaJ project is based on default Java projects. That gives you the ability to
also add Java source files to the src folder or to link external APIs which are used
within the SPLs source code.
Learn how generate products
Editing the SPL declaration file
There is a domain-specific language (DSL) to define the SPL declaration. The syntax is
intuitive. It contains a set to define features and a set to define delta modules. Then
it contains a block to define constraints which are used to express the Feature Model
with a set of boolean expressions over feature names. Next is a block to map delta modules
to feature configurations. This is an n-to-m mapping! The partitions block provide a partial
application order of the delta modules. Delta modules referenced in an early
partition are applied earlier then delta modules referenced in later partitions. Delta
modules which are referenced within the same partition can be applied in any order.
A partition contain so called
when clauses, which are separeted by a comma. Partitions
themselve are separated by a semicolon. A when clause begins with a set of delta modules followed
by the keyword
when followed by an expression over features.
The last block of the SPLD file contains product definitions. These sets look like the
features set.
Editing DeltaJ Source Code
The DeltaJ editor is the main editor for DeltaJ projects. It shows the source code. For
a better user experiance it supports syntax highlighting. DeltaJ-specific keywords are
green and Java keywords are magenta, like in the Java editor. There is also some of the
Java syntax coloring, but it is not implemented completely. But the editor supports
pretty printing to automatically format the source code. If your Eclipse
shows the Outline view you can find Compilation Units, type definitions, fields and methods
easily by clicking on them in the outline view. In the current version there is only the
static validation which was generated from the grammar. For complete validation you have
to open the generted Java files. We are planning to implement a better validation in the
future. The well known proposal feature of Eclipse does not support semantic porposals
in the current version. It will be implemented in the future.
You can use the hole Java 1.5 syntax to implement classes.
Generating products of the product line
In the current version there is no button or menu item for generating the products. But
the product generation is implemented! You have to use the SPLD file to generate a product.
The workflow to generate any product is the following:
- Open the product line declaration (see here). The generation
process is triggered with saving this file. Make sure that Eclipse shows that it is
edited.
- Save the file. This action triggers the product generation process. The plug-in
tells you about the progress in the console view of Eclipse.
If you see Waiting for the user to select the products that should be
generated ... in the console, the process has opened a dialog window which
asks for the products to be generated. Please select the products you want to
generate and hit [Continue],
- The product generation will take a while. The process will tell you what it is
currently doing in the console. The process is determined if you see the message
Selected products of >SPLName< are successfully generated.
- Now, go to the src-gen folder, it contains the generated source of the
selected products. Each product is contained in the product's root package.
Navigate to the class which contains the main(String[]) method, open it
and then you can run the generated product.
If the generated source code contains any errors, you have to correct these in the corresponding
delta module. An easy way to figure out which delta module contains the error, are the generated
Javadoc comments above each element. Here you see three screenshots of the same method which
was modified by different deltas.
And here are the corresponding operations in the delta modules:
[1]
DeltaJ website at TU Braunschweig
(
back to text)