Editor: list of many children types

Hello.

I have probably simple problem which I can not find easy way to solve. I have few children entires defined in concept (e.g 0..1 isRequired, 0..1 default,0..n validator). What I would like to do is to have simple way to edit them all like one 0..n list of childrens. I would like to have empty editor in case of not having any children and then add as many of them I want: eg isRequired and 3 validators each in new line). What I could do is to have one child entry "content" but I would lost easy way of validation and inheritance, beside I like refrence to seprate child. I also tried "empty text" setting but it leaved empty space or new line.

3 comments
Comment actions Permalink

Hi,

if I understand you correctly, you have children of different types and you want to allow them to be edited in the same editor cell, but still, depending on their types, be assigned to different "slots" of your outer concept.

I don't think this can be done in MPS (maybe if you create some custom cell editor, but I wouldn't recommend).

If you really want to have a single cell edit different types, I think you have to make a single child of a common super-type (like StatementList/Statement in baseLanguage). But then you will have to manually implement the semantics of multiplicity, i.e., you will have to manage yourself that there can be only a single isRequired in the collection. You can do that, for example, by making the common supertype an interface and providing clever menus for its editors (which only show the types still available when pressing Ctrl-space). And then you can also provide some methods in the behaviour aspect to easily access the different types of children.

Hope this helps.

[]s

Thiago

0
Comment actions Permalink

If i properly understand your use case, you are trying to spread child elements around two child roles (isRequired and validator) keeping an editor behavior similar to the situation then you have only one child reference. I can suggest you to model this situation with one child link 0..n cardinality and creating a couple of behavior methods modeling necessary operations by using this single child reference.

0
Comment actions Permalink

You understand me correctly. Thing I little afraid is to model concept for editor. If I will want to change editor I will need to change concept (for example I will want isREquired to be attribute up side). Beside I will need to model realtionships multplicity by "can be child" "can be aprent". But is eems to be only way. I also experimented with menu and "show if" but not very well. I found some simillar case for my in TypeVariableDeclaration (pressing < adds child) but do not understand this example.

0

Please sign in to leave a comment.