Alter context node in editor via baselanguage expression
Base setup: I want to render a reference cell, however the reference type is an abstract concept.
concept AttributeDescriptor
klass : ParameterClass[1]
concept IntegerParameterClass extends ParameterClass
...
children:
min : IntegerLiteral[0..1]
max : IntegerLiteral[0..1]
default : IntegerLiteral[0..1]
I want to display certain parts of klass. For instance, if klass instanceof IntegerParameterClass, then I want to display editor for "min" children.
Basically (%klass% -> %min%) is not allowed since klass is not of IntegerParameterClass.
I want something like (%klass% =node:IntegerParameterClass=> %min%) or switch-case like editor.
As I tried (%klass% -> $custom cell$), it seems to be rather hard to get it right. I just want to "get default editor cell for %min%".
1) context.getCellFactory().createEditorCell(node.klass : IntegerParameterClass.min, false) does not work as it produces an EditorCell with pre-populated cellId. Later $cutomcell$ tries to call setCellId, and it fails due to assert in EditorCell_Basic.setCellId
getCellFactory().createEditorCell seems to be overcomplicated for simple cases like "just a simple cast/node traversal" is required.
It does not support usage of regular style language.
2) I found mbeddr's createCell operation. It is much better than createEditorCell, as it allows usage of regular editor to describe the desired result.
Unfortunately, it is not compatible with $custom cell$ as well due to setCellId assertion.
In order to workaround setCellId, I use reflection to reset myCellId field. It produces the desired effect, however, the editor configuration looks awkward:
2.1) AbstractCellProvider -> ... -> setAccessible is just ugly
2.2) Styling "-> %min%" is complicated, as it requires "inspecting" the node that is already located in inspector. It is doable, yet it is not convenient.
I wonder if switch-like CellModel can be added to enable (%klass% -> case when node.isInstanceOf(IntegerParameterKlass) then -> %min% when ... end) kind of editors.
Here's what I get at the moment (it does work and produce the desired results):

AbstractCellProvider + getCellFactory().createEditorCell() == assertion in EditorCell_Basic.setCellId
Please sign in to leave a comment.
com.mbeddr.mpsutil.editor.querylist should be helpful. You get some new editor cells like querylist or queryproperty in which you can cast you node to for example IntegerParameterClass.
Have you tried using Editor Components? They can be overridden for subconcepts. Looks like this is exactly what you need.
querylist/querylink is a bit complex to configure.
I'm not sure why I did not try editor components. It might be the right thing in the long run.
I prefer to code as simple as it is possible to get first results fast, so I just copy-pasted Min/Max/Default columns.
EditorComponent-based approach requires creation of lots of small components. That requires to involve some brain and lots of clicks.
Here's current state of my editor:
Here's editorcomponent-based, well, editor. It works, however it looks like a lot of boilerplate code: lots of single-cell components. Will try to follow this way.
Sad thing with components is they do not accept arguments. That will explode the number of components: IntegerParamterValue_Value and IntegerParamterValue_ValueReadOnly components.
EditorComponent + partial table + reference combination does not seem to work.
MPS 3.3.3 (143.1160), mbeddr from 3.3.2.
Autocomplete seems to replace the whole ParameterValue node (a row in table) rather than EnumParameterValue.value reference. If I make editor component a bit more complex (e.g. add "abc" constant), then autocomplete works as expected.
With "abc" autocomplete works:
Without "abc", autocomplete replaces the whole row:
Is it a known/new editor component bug? With "custom cell" approach it worked as expected.