JetBrains MPS multible Editors for one Concept

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 easy developers and as a table for domain experts. Or as text for developing and as a graph to get a bather 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:


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

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


Now to define a second editor: Instead of the "<default>" 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"

Now you can use your new editor be checking the checkbox you defined in the editor hint.



JetBrains MPS with Git