The EMF EPackage Registry View

The EPackage registry (EPackage.Registry.INSTANCE) contains references to all registered ECore EPackages in EMF. To visualise the contents of the registry, we have implemented the following EPackage Registry view.

image

Using this view, one can browse through the EClasses contained in each registered EPackage, discover the super/sub types of each EClass, and navigate through its features and operations. The view provides options to show/hide derived features, operations, inherited features and opposite references, supports quick navigation from a feature to it’s type (double-click), and integrates with the Properties view.

If you’d like to give it a spin, it comes as a part of Epsilon 0.8.3 (or later) and can be installed via the update site.

Posted in Uncategorized | 2 Comments

Error Markers and Quick Fixes in GMF editors using EVL

The Epsilon Validation Language (EVL) is a model validation language that provides additional features to OCL, such as guards, constraint dependency management, user interaction, access to Java objects, and the ability to specify a number of fixes for each constraint, that the user can invoke if the constraint fails in order to repair the model. We’ve been recently working on integrating EVL with GMF so that failed constraints can appear as error/warning markers in GMF editors, and fixes can be invoked using the standard Quick Fix mechanism. An example follows:

The following screenshot shows a file system model in a GMF-based editor (constructed here).

FileSystem

We now specify the following EVL constraints and bind them to the editor (using the instructions provided here):

context File {
 
    constraint HasName {
 
        check : self.name.isDefined()
 
        message : 'Unnamed ' + self.eClass().name + ' not allowed'
 
    }
 
}
 
context Folder {
 
    critique NameStartsWithCapital {
 
        guard : self.satisfies('HasName')
 
        check : self.name.firstToUpperCase() = self.name
 
        message : 'Folder ' + self.name +
            ' should start with an upper-case letter'
 
        fix {
 
            title : 'Rename to ' + self.name.firstToUpperCase()
 
            do {
                self.name := self.name.firstToUpperCase();
            }
        }
 
    }
 
}
 
context Sync {
 
    constraint MustLinkSame {
 
        check : self.source.eClass() = self.target.eClass()
 
        message : 'Cannot synchronize a ' + self.source.eClass().name
            + ' with a ' + self.target.eClass().name
 
        fix {
 
            title : 'Synchronize with another ' +
                self.source.eClass().name
 
            do {
 
                var target := UserInput.choose('Select target',
                    _Model.getAllOfType(self.source.eClass().name));
 
                if (target.isDefined()) self.target := target;
 
            }
 
        }
 
    }
 
}

Then, we evaluate the constraints by clicking Diagram->Validate, and our editor and Problems view now look like this:

FileSystemWithErrorsHighlighted

ProblemsView

We can now right click on the warning and invoke quick fix we have defined for the NameStartsWithCapital critique.

QuickFix 

By clicking Finish, the fix is executed and the warning disappears.

AfterQuickFix

A complete reference of the syntax and semantics of EVL can be found in Chapter 6 of the Epsilon Book (PDF). Also, instructions for binding EVL constraints with an existing GMF editor can be found here. Finally, a Flash screencast of this example is available here.

Posted in Uncategorized | 2 Comments

New in HUTN 0.7.1

Last week we released v0.7.1 of our Human-Usable Textual Notation implementation. It’s available as part of Epsilon 0.8.1. In this release, we’ve aligned our implementation more closely to the OMG specification, and added some new features. Here’s a summary of the changes:

Validation

An error is now produced when enumerations, data types and abstract classes are specified as the type of an object.

An error is now produced for objects that do not specify the value of attributes with a lower bound greater than zero.

Adjectives

Positive adjectives are no longer prefixed with the # symbol. For instance:

DogPackage {
    male Dog "Fido" {}     // old syntax was #male Dog
}

Adjectives prefixed with the # symbol will cause a deprecation warning.

Enumeration Values

Support for enumeration values in association instances has been added. The syntax is:

DogPackage {
    Dog "Lassie" {
        breed: Collie    // Enumeration value
        name: "Lassie"   // String value
    }
}

Classifier-Level Attributes

Support for classifier-level attributes has been added. The syntax is:

DogPackage {
    Dog.breed: Collie;  // All dogs in this package are Collies by default

    Dog "Lassie" {}
    Dog "Jessie" {}

    Dog "Scooby" {
        breed: GreatDane
    }
}

Classifier-level attribute values take precedence over any default value rules specified in a HUTN configuration model.

Associations: Block and Infix Notations

Support for association blocks has been added. Assuming that the Family class has a reference called “pets” accepting objects of type Dog, the syntax is:

DogPackage {
    Family "The Smiths" {}
    Dog "Rover" {}
    pets {
        Family "The Smiths"
        Dog "Rover"        // Refers to the existing Pet object, defined above
        Family "The Smiths"
        Dog "Fido"        // Created automatically by the association block
    }
}

Similarly, associations may be specified using an infix notation. The example above could be written:

DogPackage {
    Family "The Smiths" {}
    Dog "Rover" {}
    Family "The Smiths" pets Dog "Rover";
    Family "The Smiths" pets Dog "Fido";
}

We hope you find the improved validation and more flexible syntax useful. You can update your installation using the Eclipse update manager, or follow the instructions on the Epsilon download page.

Posted in Uncategorized | Leave a comment

Negative Text Search Engine

A little off-topic but hopefully useful. Recently, I needed to find all the .java files in my workspace that did not contain a particular phrase (“Eclipse Public License”) to find out which files I had forgot to add copyright notices to. I tried to do this with regular expressions but couldn’t seem to make it work. So I looked into the Eclipse search plugin and finally managed to scribble a negative text search engine i.e. an engine that returns all the files that do not contain a particular phrase. Instructions on how to install and use the plugin are available here.

Posted in Uncategorized | 4 Comments

EuGENia: Kick-start your GMF editor development

GMF is a great piece of software in terms of features – and not only because it’s built atop GEF and EMF. Nevertheless, (here it comes) it also requires significant effort to learn, the error messages it produces during validation are often cryptic, the gmfmap wizard typically gets it all wrong, and all put together just make it too hard for the inexperienced user.

To reduce the effort required to build a basic editor we’ve implemented a tool, called EuGENia, which can derive the gmfgraph, gmftool and gmfmap models that are required to generate a fully functional GMF editor using only the ECore metamodel itself, augmented with a few GMF-specific annotations (I know that annotations pollute metamodels but they’re irresistibly convenient).

The Filesystem editor example

In this example we’ll construct a GMF editor for a filesystem metamodel. To generate a basic GMF editor from the metamodel, all we need to know is that:

  • The root of the diagram is FileSystem
  • File and all of its subclasses (Drive, Folder, Shortcut etc) are nodes with a label that reflects the value of their name attribute
  • Shortcut.target is a link
  • Sync is also a link class with Sync.source as the one end, Sync.target as the other and lastSync as the label

To capture the above, plus a bit of formatting information, we add the following @gmf.* annotations to the metamodel (in Emfatic):

@namespace(uri="filesystem", prefix="filesystem")
@gmf
package filesystem;

@gmf.diagram
class Filesystem {
    val Drive[*] drives;
    val Sync[*] syncs;
}

class Drive extends Folder {

}

class Folder extends File {
    @gmf.compartment
    val File[*] contents;
}

class Shortcut extends File {
    @gmf.link(target.decoration="arrow", style="dash")
    ref File target;
}

@gmf.link(label="lastSync", source="source",
                 target="target", style="dot", width="2")
class Sync {
    ref File source;
    ref File target;
    attr String lastSync;
}

@gmf.node(label = "name")
class File {
    attr String name;
}

Through the process demonstrated in this screencast EuGENia can generate the following editor without the user needing to touch any of the .gmfgraph, .gmfmap or .gmftool models manually.

image

Obviously EuGENia doesn’t support all the options the .gmfgraph and .gmfmap models do but only a small subset of commonly needed features. A complete list of the annotations EuGENia supports as well as instructions for obtaining it is available here.

Follow up: EuGENia: Polishing your GMF editor

Posted in Uncategorized | 18 Comments

Inspecting EMF models with Exeed

Exeed is an extended version of the built-in EMF reflective editor that enables customisation of labels and icons by adding annotations to ECore metamodels. Another feature it provides is the ability to display structural information about the elements of an EMF model. To see the types of all elements in the editor tree as well as the feature in which each element is contained, open your EMF model with Exeed and click Exeed->Show Structural Info.

image

By doing this, the structural information of each element appears next to its label. For example, selecting this option for a GMF .gmfgraph model will make it look like this:

image

The red-underlined text shows the type of the element (FigureGallery), the blue-underlined text shows the feature in which it is contained (figures), and the green-underlined text shows the EClass that owns the containing feature (Canvas). So next time you need to open an EMF model with a text editor to inspect its structure by reading the underlying XMI, you may want to consider giving Exeed a try instead.

Posted in Uncategorized | Leave a comment

EpsilonLabs

We’ve launched a satellite project of Epsilon, called EpsilonLabs (http://epsilonlabs.sourceforge.net), where we are hosting experimental contributions built atop Epsilon and contributions that use libraries which conflict with EPL (and as such they cannot be hosted in the Eclipse CVS). The initial contributions to EpsilonLabs include two non-EPL drivers for accessing MDR (MOF 1.4, XMI 1.x) and Z (LaTeX) models from Epsilon programs, and an experimental integration of (a slightly modified version of) EMF Compare with the Epsilon Comparison Language (ECL).

Posted in Uncategorized | Leave a comment