December 23, 2008

Integrating the TextUML Toolkit with other modeling tools

Filed under: Eclipse, TextUML Toolkit, UML — rafael.chaves @ 8:22 pm

No tool is an island. That is even more important when we are talking about highly focused single-purpose tools such as the TextUML Toolkit. As you probably know, the TextUML Toolkit is a tool for UML modeling using a textual notation, but that is about it. The TextUML Toolkit itself won’t help if you need features such as code generation, reverse engineering or graphical modeling/visualization. That might look as a negative thing to some, but that is by design. I am a strong believer of separation of concerns, component-based software and using the best tool for the job, and that is reflected in the design of the Toolkit.

This post will describe how to use models created by other UML2-compatible modeling tools from models you create using the TextUML Toolkit. I plan to cover other areas of integration in future posts.

Reading models created by other UML tools using the TextUML notation

If you have the TextUML Toolkit installed, one of the editors available for UML files is the TextUML Viewer. As the name implies, it is not really an editor, i.e., you cannot edit models with it, just visualize them using the TextUML notation. But it is an useful tool for reading UML models you don’t have the source for, i.e. models created by other UML2 modeling tools.

Using models created by other tools…

There are a few different ways of using models created by other UML modeling tools from your models created in TextUML.

…by co-location

In this method, you just drop the UML model you want to use to at the root of your TextUML (i.e. MDD) project. All models at the root of the same MDD project are considered to be in the same repository and thus you can make cross-model references by either using qualified names or importing the package and using simple names.

This method is dirty simple, but it forces you to keep the foreign model at a specific location, potentially forcing you to keep multiple copies of the model.

…with project references

In this method (available starting in version 1.2), the UML model you want to use is in a different project than the one you want to refer it from. You just open the properties dialog for your TextUML (MDD) project and add the project providing the UML model you want to use to the list of referenced projects. Now models at the root of that project will also be visible from your TextUML (MDD) project, in other words, they are also seen as part of the same repository.

This method is more powerful than the previous one, as now models can be shared by reference instead of by copying. There is a limitation still: the models you use ought to be part of some project in the workspace, so you cannot refer to models stored at arbitrary locations in the file system or models that are contributed by Eclipse bundles.

…by explicitly loading them

For this method, you use the load directive to load an external model located by a URI.

This method allows you to load any model, provided its location can be represented as a resolvable URI. That is the case of any file system path, or Eclipse platform URLs. The caveat is that some URIs such as file system URIs are not portable, so they are are bound to be invalid on other machines.

The entire truth…

…is that even if you are using only the TextUML Toolkit for building UML models, these are the same mechanisms for creating models that make cross-package references (see also the TextUML Guide). For the TextUML Toolkit, all UML2-compatible models are equal, no matter how they were created.

December 15, 2008

TextUML Toolkit 1.2 M2 is now available

Filed under: Eclipse, TextUML Toolkit — rafael.chaves @ 3:30 am

The second milestone build towards TextUML Toolkit release 1.2 is now available from the milestone update site. Get it while it is hot.

This milestone adds support for some UML language features:

But what is really exciting is that this milestone is also the first build that includes a contribution from a new member of the TextUML Toolkit team: Massimiliano Federici provided a  patch that squished bug 2127735 (revision 194). Kudos to Massimiliano, his contribution was greatly appreciated, and it seems it might just be the first of many!

December 2, 2008

Feature: primitive types

Filed under: Eclipse, TextUML Toolkit, UML, v1.2 — rafael.chaves @ 8:13 pm

Yesterday I checked in support for UML primitive types in the TextUML Toolkit. As an example of the syntax, here is the UMLPrimitiveTypes model, shipped in Eclipse UML2, rendered by the TextUML Source viewer:

[Standard::ModelLibrary]
model UMLPrimitiveTypes;

apply Standard;

primitive Boolean;

primitive Integer;

primitive String;

primitive UnlimitedNatural;

end.

As you can see, primitive types are declared using the keyword ‘primitive’, and cannot specialize other types or have structural features (thus there is no ‘end’ terminating the type declaration). To be honest, I am not sure this is the intended semantics, as the UML specification does not seem to explicitly disallow that.

Here is the breakdown of the change sets (r188-191):

  • automated tests (r190)
  • parser and model generation (r191)
  • textual renderer (r189)
  • editor (r188)

To be frank, the only test case added was quite trivial:

public void testPrimitiveType() throws CoreException {
  String source = "";
  source += "model someModel;\n";
  source += "primitive Primitive1;\n";
  source += "end.";
  parseAndCheck(source);
  PrimitiveType found = (PrimitiveType) getRepository().findNamedElement(
    "someModel::Primitive1", IRepository.PACKAGE.getPrimitiveType(), null
  );
  assertNotNull(found);
}

But it is a good start. It ensures parsing works, and the model generated has the intended element created under the right parent package.

Any suggestions of what UML feature to cover next? And what is your take? Can UML primitive types have structural features or specialize other types/implement interfaces?

(By the way, if you want to understand how the TextUML Toolkit is implemented, feature posts like this are a good starting point)

Copyright Abstratt Technologies - Powered by WordPress - Entries (RSS) - Comments (RSS)