Retrieve Model by Name

Hi everyone,

I created a plugin (attached to Tools menu) that creates and updates new root concept in current model. I want to change this plugin to create the node in specific model, specified by name (e.g. "specialNodes") in the same solution. How can I do that? (Model operations like .siblings don't seem to work on "this.model" context parameter)

Thanks.

3 comments
Comment actions Permalink

Use the model-ptr/.../ construct:

model m = model-ptr/specialNodes/.resolve(this.model/.getRepository());

More info on the SModel language is available here: https://confluence.jetbrains.com/display/MPSD20181/SModel+language

Vaclav

 

1
Comment actions Permalink

Thanks, works like a charm. And the document was very useful as well.

Tomas

1
Comment actions Permalink

Just to make it clear, model-ptr/specialNodes/ makes your action bound to one specific model in a single specific solution. If, instead, your intention is to find model named "specialNodes" in a context solution of your action, use CONTEXT_MODULE, and then look up desired model with a help of SModule API (SModule#getModels(), SModel#getName())

0

Please sign in to leave a comment.