Author Topic: Prevent metaclass's shape when dropping an instance of a stereotype  (Read 7939 times)

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Hello all,

I created an MDG profile with several stereotyped elements.

One is 'Committee' : a stereotype of Actor metaclass with a dedicated shape (set with ShapeScript)
Once one is created in Browser, I can drag it drop as an Instance (Ctrl-DnD) in my diagram but then, visual aspect becomes again the Actor's stickman and not the shape I set up
 :(
Ideally, I'd like to do as UML Profile: same shape with a different color and a underlined name.

Thank's for your recipe !


Eric

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13283
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #1 on: October 12, 2024, 05:11:20 pm »
You have to make a stereotype for the instance as well.
In the classifier stereotype you can set which stereotype should be used for it's instances.

Geert

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #2 on: October 12, 2024, 11:53:53 pm »
Hi Geert and (once again...) thx !

"Yes, I have added to  my toolbox an element named 'committee instance', which is a stereotype of Object metaclass. This metaclass is connected (I logically used an 'instantiates' relationship) to the Committee stereotype of the Actor metaclass."

This approach seems to work. But then, I don't know how to retrieve the list of already defined committee names in order to specify which committee this newly created instance is of. 

Hope to be clear...  :-\ ( I don't know how to show my metamodel fragment...


Eric

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13283
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #3 on: October 13, 2024, 12:13:48 am »
I ususally don't put instances in a toolbox. It's much easier to drop the classifier on the diagram and create an instance that way.

Geert

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #4 on: October 13, 2024, 12:46:14 am »
Quote
to drop the classifier on the diagram...

Do you mean : Dropping a class onto diagram then selecting the element it's an instance of through Advanced/Instance Classifier ?

Eric


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #5 on: October 13, 2024, 07:49:27 am »
Guess no. You can make an instance stereotype than you can place in the toolbox. Creating that will make you link it to its classifier after creation (or it will stay an anonymous object). Depends on what you prefer or do the most.

q.

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #6 on: October 13, 2024, 10:00:27 am »
Yes,qwerty I configured it that way (as an object stereotype in my TB as Eve recently recommended me), but then...how can I access attributes of the metaclass and, even better, values of theses attributes that have been defined so far?

For example:
  for:   Committee.name='Steering committee'
 
  being able to get:  Committee instance.name =:Steering committee
by selecting in a listbox among all existing names

  instead of simply getting :  :Committee Instance

In metamodel, what should be the relation type between  Committee stereotype that extend Actor metaclass and Committee Instance stereotype that extend Object metaclass  to make Committee element attributes, TV accessible to Committee Instance element ?

 :-\

Eric

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #7 on: October 13, 2024, 09:43:48 pm »
The attributes are only available via the classifier (which you have ro set manually). However, you probably need to set runtime states via the context menu if I guess you intention correctly (which I'm nor sure about). So probably you should elborate a bit about your modeling goals.

q.

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #8 on: October 14, 2024, 04:45:16 am »
Quote
The attributes are only available via the classifier (which you have ro set manually)

Too bad...

And what about a code sequence being fired when TB element is dropped to diagram ? Is that possible ?


Eric

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #9 on: October 14, 2024, 09:10:19 am »
Yes sure. You have to subscribe to on_new_element in the add-in API to get a notice when the object (or anything else)  is created.

IIRC Geert has some framework that would save you from writing all the sdd-in clutter, though that's not too difficult itself (see his write an add-in in 10 minutes post).

q.

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #10 on: October 15, 2024, 07:05:49 am »
OK, It requires an add-in setup. It's another step for me.
but I'll throw a look into Geert's work.

Thx for all, qwerty !

Eric

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13283
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #11 on: October 15, 2024, 03:50:15 pm »
OK, It requires an add-in setup. It's another step for me.
but I'll throw a look into Geert's work.

Thx for all, qwerty !

Eric
I'm not convinced you need an add-in. I think you can use some of the properties of the classifier in a shapescript.

These are the properties that you can use from a shapescript:

Quote
classifier
classifier.actualname - same as 'classifier.name' except that it does not react to the 'Use Alias if Available' setting
classifier.alias
classifier.metatype
classifier.name
classifier.stereotype
classifier.type

Geert

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #12 on: January 01, 2025, 03:06:03 am »
Geert,

I just discovered your precision. Thank you !!

Any info or example how to use classifier with shapescript would enlight me.

BTW, Happy new year !

Eric

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13283
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #13 on: January 01, 2025, 07:03:19 pm »
Something like this:
Code: [Select]
if(hasproperty("classifier",""))
{
   {
println("#NAME# :#CLASSIFIER#");
   }
        }

Geert

elr

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Prevent metaclass's shape when dropping an instance of a stereotype
« Reply #14 on: January 02, 2025, 05:36:23 am »
Thx Geert !