310 likes | 546 Views
Tools for Diagrammatic Specifications. Stian Skjerveggen Supervisors: Yngve Lamo, Adrian Rutle, Uwe Egbert Wolter. The background. Formal models can be expressed by specification techniques specified in Diagrammatic Predicate Logic (DPL)
E N D
Tools for Diagrammatic Specifications Stian Skjerveggen Supervisors: Yngve Lamo, Adrian Rutle, Uwe Egbert Wolter
The background • Formal models can be expressed by specification techniques specified in Diagrammatic Predicate Logic (DPL) • DPL is a proposed formalism for Model-Driven Software Architecture • Our focus is on investigating, adapting, evaluating… these proposals
Todays situation • Many different editors for modeling languages exists • The main problem is that they have no generic way to describe modeling languages • … and most of them have semi-formal semantics
The project • A graphical editor is to be designed and implemented that allows to specify abstract signatures corresponding to metamodels of modeling languages and also supports the definition of transformations between those signatures. • Slogan: Signature ~ Modeling Language
Related work • Sketcher95 • Incomplete • Not fully functional • No source code • Sketcher v1.0 (.NET) • Previous master thesis • Also incomplete and not fully functional • Tries to recreate Sketcher95
The platform • Previous version in C # • Eclipse was chosen as the developing platform • So why choose Eclipse? • Alot of model related projects in the Eclipse community (Eclipse Modeling Framework) • You get a lot for free by using Eclispe • Eclipse is much more than just a Java IDE • Eclipse can be used to create many different types of applications
What Eclipse provides • Open source, robust, commercial quality platform • Extensible frameworks • For this project, the main features are the Eclipse Modeling Framework, the Graphical Editing Framework and the Graphical Modeling Framework
Eclipse Modeling Framework - EMF • A modeling framework and code generation facility • Model specification described in XMI • XMI (XML Metadata Interchange) is OMGs standard for exchanging Metadata information • The core of EMF is called Ecore (metamodel of EMF models is Ecore)
The advantages of EMF • Serialization • Notification • Code generation • Low cost entry for/into modeling
Graphical Editing Framework • Allows developers to take an existing application model and quickly create a rich graphical editor • Many common operations are provided • MVC architecture
The advantages of GEF • Most of the graphical elements are predefined and can be extended • A standard look and feel for all graphical editors in Eclipse
Graphical Modeling Framework - GMF • GMF bridges the gap between the model (EMF), the view and the controller (both from GEF) • With GMF you can produce graphical editors for Eclipse
Domain Model (ECore) Generator Model (GMFGen) Java code Mapping (GMFMap) Platform Graphical Definition (GMFGraph) GMF Runtime Tool Definition (GMFTool) GMF Workflow
Example GMF application View Domain Model <eClassifier eType=”EClass” name=”Supplier”> <eStructuralFeature eType=”eReference” name=”orders” eReferenceType=”PurchaseOrder”/> … </eClassifier> Drawing palette
Summary of the frameworks used • EMF provides the model and serialization of it • GEF provides the visualization and the controllers • GMF maps the model, controllers, the visualization and tools (drawing palette) together and generates a diagram editor
Challenges • The biggest challenge is finding out how to do things in Eclipse • Eclipse is a prime example of Agile Development • Eclipse UI Guideline • Eclipse Best Practices • ”Ready for Rational Software” -- IBM
Challenges EMF • Need additional info for our model • EMF supports Extended Meta Data and this gets recorded as annotations in the Ecore model
Challenges GMF • The code that GMF generates must often be adapted • A lot of code has to be customized to support our additional information
GMF generated code • For a simple diagram containing only Nodes and Edges, 90 source files are generated, with most of the classes extending other classes
Modeling and DPL formalism • Signatures ~ Modeling languages • Signature := collection of predicates • Predicate ~ constraints set by modeling languages • Diagram Specifications ~ models
Predicates • You can compare a predicate to a Design Pattern • Want to label elements (nodes, arrows and diagrams) from the model by one or more predicates • This must be visualized somehow (next) • The predicate information needs to be saved with the model
How are Predicates Visualized? • Predicates on arrows Arrow decorations • Predicates on nodes Node decorations • Predicates on diagrams Diagram decorations • Diagram dec. := decoration on a set of nodes and arrows
Arrow decorations in GMF • By default, edges generated by GMF are just lines • Need to add arrowheads manually, either by setting up a point-path or creating your own
Dynamic visualization • We want to change visualization based on attributes on the model elements • Ex. A predicate has been added to a node • This is not default behaviour in GMF, so it needs to be custom made
Changing view based on model attributes • Normally, GMF doesn’t change the view of an element once it has been painted • But since the view is attached to the model as a listener, we can detect changes in the model via the method handleNotifications()
Example customization – Coloring nodes /** * @generated NOT */ protected IFigure createNodeShape() { NodeFigure figure = new NodeFigure(); // checking for red color changeFigureColor(figure); return primaryShape = figure; } privatevoid changeFigureColor(IFigure figure) { Node node = (Node) ((View)getModel()).getElement(); if (node.getNodeTypes().contains(NodeType.RED)) { figure.setBackgroundColor(ColorConstants.red); if (node.getNodeTypes().contains(NodeType.BLUE)) figure.setBackgroundColor(new Color(null, 153, 51, 255)); } elseif (node.getNodeTypes().contains(NodeType.BLUE)) figure.setBackgroundColor(ColorConstants.blue); else figure.setBackgroundColor(ColorConstants.white); node = null; }
Coloring nodes – cntd(1) /** * Need to override this to get the colorchanging bit to work */ @Override protectedvoid handleNotificationEvent(Notification notification) { super.handleNotificationEvent(notification); changeFigureColor(primaryShape); }
Testing • Everything in Eclipse is testable • The tests may not be straightforward and time-consuming to set up, but doable • To test a Plug-in you need a Plug-in test project
Summary • This project spans multiple areas • Modeling • Graphical development • Eclipse development / Plug-in development • Which means that there is a lot of documentation to go through