Implementation of a Graphical Modelica Editor with Preserved Source Code Formatting

Tobias Matsson
Department of Computer Science, Lund University, Sweden

Jon Sten
Department of Computer Science, Lund University, Sweden

Tove Bergdahl
Department of Automatic Control, Lund University, Sweden

Jesper Matsson
Department of Automatic Control, Lund University, Sweden

Johan Åkesson
Department of Automatic Control, Lund University/Modelon AB, Sweden

Ladda ner artikelhttp://dx.doi.org/10.3384/ecp12076375

Ingår i: Proceedings of the 9th International MODELICA Conference; September 3-5; 2012; Munich; Germany

Linköping Electronic Conference Proceedings 76:39, s. 375-384

Visa mer +

Publicerad: 2012-11-19

ISBN: 978-91-7519-826-2

ISSN: 1650-3686 (tryckt), 1650-3740 (online)


When an Integrated Development Environment (IDE) is developed; the support for multiple views of the same document is often essential. An example of this is Modelica models; as it should be possible to view and edit the same model in both its textual and graphical representation.

One implementation of Modelica is the open-source platform JModelica.org. It contains the JModelica.org IDE; that provides a text editor for Modelica code; based on the Eclipse platform.

In this paper; we present an implementation of a graphical editor for the JModelica.org IDE. Several challenges with implementing a graphical editor for Modelica are discussed. Among others; the difficulties in rendering Modelica diagrams and how to interact with existing frameworks in Eclipse are brought up. A method for preserving the formatting of a modified source code file is also presented; which is essential when the model is altered in the graphical editor.

The presented implementation is compared to other open source software (OSS) implementations of Modelica editors.


AST; JModelica.org; Eclipse; GEF; Graphical Editing; Icon Rendering; Preserved File Formatting; Pretty Printing


[1] J. Åkesson; K-E. Årzén; M. Gäfvert; T. Bergdahl; H. Tummescheit. Modeling and optimization with Optimica and JModelica.org—languages and tools for solving large-scale dynamic optimization problem. Computers and Chemical Engineering; 34(11):1737–1749; November 2010. doi: 10.1016/j.compchemeng.2009.11.011.

[2] J. Mattsson; The JModelica IDE: Developing an IDE by Reusing a JastAdd Compiler; Master’s thesis; Department of Computer Science; Lund University; Sweden; 2009.

[3] J. Sten; Graphical Editing in JModelica.org; Master’s thesis; Department of Computer Science; Lund University; Sweden; 2012.

[4] T. Mattsson; AST-driven Editor; Master’s thesis; Department of Computer Science; Lund University; Sweden; 2012.

[5] G. Hedin; E. Magnusson; JastAdd: an aspectoriented compiler construction system; Science of Computer Programming 47 (1) (2003) 37–58. doi: 10.1016/S0167-6423(02)00109-0.

[6] J. Åkesson. Optimica—an extension of modelica supporting dynamic optimization. In In 6th International Modelica Conference 2008. Modelica Association; March 2008.

[7] C. Andersson. A new Python-based class for simulation of complex hybrid DAEs and its integration in JModelica.org. Master’s thesis; Department of Mathematics; Lund University; Sweden; 2010.

[8] G. Hedin; "An Introductory Tutorial on JastADD Attribute Grammars;" in Generative and Transformational Techniques in Software Engineering III; ser. Lecture Notes in Computer Science; vol. 6491. Springer-Verlag Berlin Heidelberg; 2011; pp. 166–200.

[9] P. Fritzson; A. Pop; K. Norling; M. Blom; Comment- and Indentation Preserving Refactoring and Unparsing for Modelica. In 6th International Modelica Conference 2008; pp. 657–665. Modelica Association; March 2008.

[10] M. de Jonge; E. Visser; An Algorithm for Layout Preservation in Refactoring Transformations. Software Language Engineering; pp. 40–59; Springer; 2012.

[11] Eclipse Documentation: ASTRewrite; http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/rewrite/ASTRewrite.html; 2012.

[12] S. Asghar; S. Tariq; Design and Implementation of a User Friendly OpenModelica Graphical Connection Editor; Master’s thesis; Department of Computer and Information Science; Linköping University; Sweden; 2010.

[13] S. Asghar; S. Tariq; M. Torabzadeh-Tari; P. Fritzson; A. Pop; M. Sjölund; P. Vasaiely; W. Schamai; An Open Source Modelica Graphic Editor Integrated with Electronic Notebooks and Interactive Simulation. In 8th International Modelica Conference 2011; pp. 739–747. Modelica Association; March 2011.

[14] T. Ekman; G. Hedin: Rewritable Reference Attributed Grammars. ECOOP 2004. LNCS; vol. 3086; pp. 147–171. Springer; Heidelberg (2004).

[15] Modelica Association; Modelica - Language Specification 3.2 rev 1; 2012. http://modelica.org/documents/ModelicaSpec32Revision1.pdf.

Citeringar i Crossref