Need help understanding IMainClass interface concept in calculator tutorial

Would like to understand how IMainClass interface concept works , esp its plugin interaction part to add a new item to right-click-menu.

Tried to add this to generator-tutorial , i got a little confused as the interface concept implementation on Document and other Main method generating items only led to run context menu addition on 2 solution models (test1 and test7) but rest of the solution models weren't influenced.

Attaching the demo project with custom changes for reference.

generator_demo.zip (507KB)
0
3 comments
I'm not sure I understand you problem - whichever model imports demoLang7 (the only language using IMainClass), allows me to run nodes of the XMLDocument concept from the context menu. I have to rebuild/compile the model first, though, to get the Java class generated.

I also noticed that you declared Button and Label in demoLang6 as IMainClass, although they generate into XML and are not root concepts. Why is that?

Vaclav
0
Thanks for your response Vaclav Pech.

I should've been more clear explaining the problem, am kind of new to MPS and learning it by the days. :)


I actually expected all concepts implementing IMainClass and generating a java Main-Class to add a context menu item on right-click of its Node.But it seems ,if we have an abandon root rule , it wouldn't work.Is it by design?

The attached project had cases to test.

Let me show my intentions:

First i made the root Concept in sampleXML implement IMainClass.
Hence i saw  in solution module's model test1's two Document nodes ; on right click Run Node context menu item.test1 used sampleXML language and it's generator engaged demoLang1.

Second i expected test2 model in solution model to act the same way test1 was acting.After all it too used sampleXML language and engaged demoLang2 for generation.In demoLang2 ,we do generate a main class but the main gen. config only has a condition root and abandon roots rules.But if you see right-click on node's under test2 do not add the run Node menu item.

Hence was wondering if its b/c of abandon-root usage or something else that stops IMainClass from working?

model test3's generator engaged langugage demoLang3 , also has an abandon root rule, and right-click does not seem to work on that also.

Same is with test4, test5 and test6.

However test7 does not abandon the document node , and IMainClass seems to work on that.


Also adding IMainClass to those two non-root concepts was another test,i wanted to see if there any errors of some sort which would lead me to trace inner workings.Sorry about attaching that too.
0
Yes, the mapping between the original nodes and the generated class is not preserved in this case.
Since the original root nodes are inserted through a reduction rule inside a LOOP macro, the generator does not see the intent to have the generated class invocable by right-clicking on the original nodes.
0

Please sign in to leave a comment.