Page 1 of 1

Show Metaclass in Generic Table Custom Column Script

PostPosted: Mon Aug 06, 2018 12:46 pm
by james.ciarcia@navy.mil
Using CSM 18.5 sp3 I've created a Generic Table with a bunch of different model elements. It's easy to show what Stereotypes are applied, and it also shows the name of the (base) Metaclass in grey brackets after it. However, if there is no stereotype applied, or if the stereotype is applied to a more specific metaclass then there is no easy way to show the metaclass. So I figured a simple custom column would work. What is the right function(s) to call? cause I can't find it in the jdoc, and this code did not appear to work.

Groovy code:
Code: Select all
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element
import com.nomagic.magicdraw.core.Application
import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper

StereotypesHelper.getMetaClassByClass(Application.getInstance().getProject(), arg1)


http://jdocs.nomagic.com/185_sp3/com/no ... ang.Class-

I've also found that custom column only seems to work when returning onjects of Java class mdkernel.impl.*Impl, a previous post suggesting returning a String, from getID() for example would work, but it does not. What are the restrictions on the return types from scripted custom columns?

https://community.nomagic.com/post16198.html?hilit=custom%20column%20script#p16198

Re: Show Metaclass in Generic Table Custom Column Script

PostPosted: Mon Jan 13, 2020 5:02 pm
by james.ciarcia@navy.mil
Ran across this groovy script in another post. I tried it and it works.

I embedded it into an Opaque Behavior for reusability and referenced the Opaque Behavior using the Custom Column "Operation from Model"

Code: Select all
import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper
StereotypesHelper.getUML2BaseClass(THIS)


I also embedded it into the "Script" operation, but changed it slightly to reference arg1 instead of THIS. This worked as well but less reusable.
Code: Select all
import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper
StereotypesHelper.getUML2BaseClass(arg1)