Referencing parent node from side transformation rule

Hello MPS forum,

I’m trying to improve the editing experience with this use case:

I’ve a Column concept with a description property and an Item concept as a child:

I’d like the user to be able to edit Column by typing the Item’s name property, optionally followed by a semicolon and a description.

So, for example, the user could simple type: 

FooItem

or

FooItem : BarDescription

This is how I’ve arranged things so far:

In the Column editor, the semicolon constant and the description property are grouped in a collection cell with a Show If method to hide null description:

The editor for the Item concept is as simple as this:

A constraint on the Item's name property defines space is an invalid character and lets the editor exits the Item's name editing when pressed:

And finally, a right side transformation on the Item concept intercepts the semicolon, makes description visible and moves focus there. 

While I'm not sure if this is the best way to implement the use case, it seems to work reasonably well.

Nevertheless, I'm not happy with Item side transformation having to references Column description in this line:

((node<Column>) node.parent).description = "";

I'd rather prefer a solution where Item concept would have a more generic reference to it's parent so as to be reused as a child with different concepts.

Any suggestion ?








 

3 comments
Comment actions Permalink

Hi Mauro,

my first through after seeing the structure is that "description" should be part of Item. Then your transformation would not need to check for the parent at all.

If, on the other hand, you have reasons to separate the two, you may use the "can execute" function to restrict the action to only the situations when Item is inside Column.

The most accurate solution that I can offer is as follows:

!. Define a named transformation on Item:

2. Add it to the Column editor's "child" cell:

Vaclav

0
Comment actions Permalink

Hi Vaclac,

thanks for your suggestions.

For some strange reason I can't see this topic by browsing the forum and I was missing your reply if it wasn't for the email sent by the forum system.

0
Comment actions Permalink

Thanks for pointing out the issue with listing the post. I'll investigate that. Most likely the system has marked your post for moderation (approval) and nobody has "approved" the post yet.

0

Please sign in to leave a comment.