Tutorial - Using the Hummingbird Example

Introduction

Sphinx provides an example called Hummingbird to illustrate its main interesting features. This example consists in a small model-based application manipulating a meta-model.

Sphinx is able to manage simultaneously several versions of a same metamodel. Thus, two ecore models are provided, Hummingbird10 and Hummingbird20, that represent version 1.0 and version 2.0 of a same meta-model.

This tutorial introduces the Hummingbird example and proposes a step-by-step tour of its main functions.

Step 1: Creating a new project

The first step consists in creating a new project to experiment the Hummingbird example.

  1. Run Sphinx;
  2. Create a new simple project (menu File > New > Project... > General > Project);
  3. Call it MyProject.

Step 2: Creating a new model

The second step consists in creating a new model conform with the Hummingbird meta-model.

  1. Create an empty model (right-click on the project, then new > Other... > Example EMF Model Creation Wizards > Hummingbird10 Model);
  2. Call it MyModel.hummingbird;
  3. Select Application as root model object of this model.

At this step, the project has no yet the Hummingbird nature.

Step 3: Providing the Hummingbird nature

To give the Hummingbird nature to our project, we need to edit the .project file.

  1. Open the .project file;
  2. In section natures, add the following line:
<nature>org.eclipse.sphinx.examples.hummingbird.ide.HummingbirdNature</nature>

Now, the icon of the project has a new decoration, "20", that tells that the project has the Hummingbird nature. More precisely, it is supposed to be configured to the last version of the Hummingbird meta-model, 2.0.

A warning decoration also appears on the model icon to indicate that its version (Hummingbird 1.0) is not compatible with the version of the enclosing project. A message is available in the Problems view to explain this warning.

Step 4: Setting the version of the meta-model

By default, the last version of the meta-model is supposed to be associated to the project. This preference may be changed by editing the .settings directory.

  1. Create a directory called .settings on top of the project;
  2. Create a file called org.eclipse.sphinx.examples.hummingbird.ide.prefs in this directory;
  3. Add in this file the following line:
hummingbird.metamodel.version=org.eclipse.sphinx.examples.hummingbird10

Now the warning disappears and the nature decoration of the project changes.

Step 5: Model Explorer View

An explorer example is provided to illustrate the relation with the edited models.

  1. Open the Model Explorer view (menu Window > Show View > Other... > Sphinx Example Views > Model Explorer).

In this explorer we can see about the same content as in other navigator views, except that we also see the root object of our model.

Step 6: Editing the model

Now we will add objects in our model.

  1. Double-click on the model to open the associated editor;
  2. In the editor, right-click on the Application root object and add a new subcomponent (New Child > Components > Component).

Now the editor tab is marked dirty (with a star '*' in front of the name). The Model Explorer view is also marked dirty. Saving one of them will save the changes.

Several means exist to edit the model. Creating a new element may also be done from the Model Explorer view.

Step 7: Exploring other features

Sphinx provides many interesting features. Let's explore them through the Hummingbird example: