Show a list of nodes in a read-only style in an editor
Hi,
I have an entity language to define entities and their associations.
Associations are either owned by the source or the target entity.
I would like to show the "unowned" associations additionally at the other node in a readonly matter.
My first idea was to add a second list of children and automatically update its content.
e.g.
But that has some major disadvantages:
The content is saved in the model (instead of just showing it).
What I need:
Any ideas on that? Perhaps some kind of workaround?
Greets
I have an entity language to define entities and their associations.
Associations are either owned by the source or the target entity.
I would like to show the "unowned" associations additionally at the other node in a readonly matter.
My first idea was to add a second list of children and automatically update its content.
e.g.
reverseAssociations = node.model.nodes(Association).where({~it => it.target == node; }).select({~it => it.copy; });
But that has some major disadvantages:
The content is saved in the model (instead of just showing it).
What I need:
- A getter for a child?
- A cell where I can provide a list of strings or better: nodes to display.
Any ideas on that? Perhaps some kind of workaround?
Greets
Please sign in to leave a comment.
I had to wrap the cell (p0.createNodeCell) with a cell collection to work around some problems with cell IDs.
Can you please tell me where and how you enter this cell provider? Do I need some language therefore??
Thanks
Fabian
Currently it's not possible to handle somehow derived references in MPS in a "native" way, but if you'd like to display some kind of read-only information by adding cell into the editor. Such cell is able to display string based on model query, so you can iterate through all "unowned" associations there and collect a label representing this information in an editor.
Going back to the original question (not sure I understood it correctly) - in MPS it's possible to store node either inside another node or directly inside a model. In case you have to create associations and then bind them to source/target entities I think you can store all associations as model root nodes or create single root node "associationContainer" and save all associations there.
Please let me know if I did not answered original question.
I currently use the read only model access. But it's really inconvenient if you want to display a list of information, because you can just return a string. If you want to show a variable number of elements (for example all subclasses of a class) then you must construct the string with seperators and line wraps. But you can't use something like indentation. So it would be nice to return a collection of string, which could be embedded in a collection cell. Is this possible?
And what about modifying concept structure in order to save "unowned" associations as model roots or create one special root "Unowned Associations Container" ?
But I can alternatively make the special root node contain a mapping from Entity to its unowned associations. However, that is not much different from letting each entity have a child collection of unowned associations due to the similar memory cost and maintenance code needed.
yes this was also was I was looking for.
I had some difficulties and errors when using the actual nodes from another concept.
So i decided to use node.copy to create a transient copy for the AbstractCellProvider.
Now it is more stable. The only downside is, that changes to the original node are only displayed, when the editor containing the CellProvider is reopend.
How can I switch the editor for nodes displayed by CellProvider to readonly (editable=false). Can I use a switch in the editor definition? What is the condition for the switch? Or do i need to change this programmatically in the CellProvider?
Thanks for your help slisson!
You can use EditorCell_Label.setEditable() method implementation as an example:
Hi Jetbrains,
I was wondering if this "derived" attributes for Concepts have made it into MPS or if there is a better way of implementing them.
Thank you!