【问题标题】:Custom editor in MPSMPS 中的自定义编辑器
【发布时间】:2019-11-17 15:34:36
【问题描述】:

我在 Jetbrains MPS 中有一个概念,我想为其创建一个自定义编辑器。

这个概念有很多孩子。

对于每个孩子,我想显示孩子自己的编辑器,但前面有一个“-”。

我不完全确定我是否正在尝试以正确的方式解决这个问题。

但我的第一次尝试是在子节点上循环自定义单元格。

我的问题是我不知道如何找到子节点的编辑器单元格:

我的手机提供者:

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;
}

【问题讨论】:

    标签: dsl mps


    【解决方案1】:

    您真正想要达到的目标是什么?一个例子在这里可能会有所帮助...... 如果没有进一步的上下文(所以我可能会误解您的问题),我认为您可以将 EditorComponent (https://www.jetbrains.com/help/mps/editor.html#editorcomponentsandeditorcomponentcells) 用于原始编辑器,然后制作一个带有“-”常量的编辑器,后跟 EditorComponent 以达到预期的效果。

    【讨论】:

    • 谢谢,我会试试的。我正在做的事情很简单。我有许多概念,当用作列表概念的孩子时,我想表现得不同。我希望它们在用作列表成员时在编辑器中呈现一些不同的效果。
    • 在这种情况下,基于 smodel 查询的带有条件的备用单元格 (if) 可能会对您有所帮助。
    • 非常感谢您的回答。我没有设法让自定义编辑器单元格正常工作,例如按插入不起作用。我现在已经实施了另一个丑陋的解决方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-04
    • 2017-08-24
    • 2015-01-27
    • 2012-11-04
    相关资源
    最近更新 更多