JetBrains MPS multible Editors for one Concept

benjamin wieser profile picture
Benjamin Wieser
30/01/2025

In MPS you have the possibility to define multiple editors for a single concept. This can be useful, when you want to enable different views on the same code. For example you can represent your model as text for developers and as a table for domain experts. Or as text for developing and as a graph to get a better overview.

It is good practice to put your second set of editors in a different language. Thereby it is easier to get an overview what belongs to what.

First we need to create a new editor component: mps_new_language.png

We call it diagram_hints and create a hint, that is called diagram. mps_editor_component.png

concept editor context hints diagram_hints 
  hints: 
    ID: diagram Presentation: Show as diagram  hints: 
    ID: diagram Presentation: Show as diagram

Now to define a second editor: Instead of the "" in front of the editor key-word, we now have "diagram". This automatically renames the editor in the logical view of your project from "Database_Editor" to "Database_diagram_Editor".

diagram editor for concept Database
  node cell layout:   
     [/ /] 
                       
  inspected cell layout        
    <choose cell model>

To be able to use your new editor, go to your model file. Right click anywhere on the page and click "Push Editor Hints"

mps_push_editor_hints.png

Now you can use your new editor by checking the checkbox you defined in the editor hint. mps_editor_checkbox.png

Überzeugt? Kontaktieren Sie uns!

Schicken Sie uns einfach eine Email an office@vorstieg.eu oder füllen Sie das folgende Kontakt-Formular aus: