dslmps

Custom editor in MPS


I have an concept in Jetbrains MPS which I would like to create a custom editor for.

The concept have a number of children.

For each child I would like to display the child's own editor but with a "-" in front of it.

I'm not completely sure I'm trying to solve this in the right way.

But my first attempt is a custom cell looping over the child nodes.

My problem is that I can't figure out how to find the editor cell of the child nodes:

My cell provider:

return new AbstractCellProvider(node) {
@Override
public EditorCell createEditorCell(EditorContext ctx) {
  EditorCell_Collection cells = EditorCell_Collection.createVertical(ctx, node);
  foreach n in node.elements {  
    EditorCell_Collection a = EditorCell_Collection.createHorizontal(ctx, node);
    EditorCell_Label label = new EditorCell_Constant(ctx, node, "-");
    a.addEditorCell(label);
    cells.addEditorCell(a);

       how to add the child node's editor here? 

   }
return cells;
}

Solution

  • What are you really trying to achieve? An example might help here... Without further context (so I may misunderstand your problem), I think you could use an EditorComponent (https://www.jetbrains.com/help/mps/editor.html#editorcomponentsandeditorcomponentcells) for the original editor and then make an editor with a "-" constant followed by the EditorComponent to achieve the desired effect.