One of the features of the DSL Tools is extensibility. With the language definition files, you can define a wide range of thing-and-link style graphical notations. The current version of the Tools comes with a set of templates for creating class, use case and activities diagrams; but the idea is that you adapt the language definitions to suit your own purposes – for example to add new sorts of classes, or cut out some sorts of association.
That kind of change can be made in the language definition files. But by plugging in your own custom code, you can extend the features of your language to obtain even more interesting effects.
For example, in the Activity Diagrams template in the latest version of the Tools, there’s a shape called Synchronisation Bar. It comes onto the diagram as a long thin black rectangle; but of course, the user can pull the corners so that it doesn’t look like a Sync Bar any more. But with a bit of custom code, you can constrain the height to be constant – so that the user can only make it longer or shorter. (Actually, a neat trick is to snap it either to a thin horizontal bar or a thin vertical one, depending on how the user tries to reshape it – so they can reorient it and change the length, but it’s always a bar, one way or the other.)
Another useful extension is connectivity restrictions. With the Class Diagrams template, you can make a language with classes, associations and inheritance etc. Again, your first step would probably be to adapt the language definition to do what your team needs; but pretty soon, you’ll notice that it’s perfectly possible to draw diagrams in which Class A inherits from Class B inherits from Class A – round in a loop. If your application needs to exclude this, you can write code that stops the user making a loop — popping up a warning as soon as the mouse hovers over the target of the last link.
There are also a few features you can obtain with custom code in the current version of the Tools, that will probably be controlled through the language definition files in the Release version — for example, whether connectors are straight or rectangular, background color is graduated, and other basic stuff. Other features require fairly complex code at present, but will be simplified in the future – for example, if you want to add your own menu commands to the designer.
We’ve recently released a Customization Samples & How-To Guide package that explains these techniques, and include code for all these features. Follow the link, download, and enjoy!