Author Topic: Element sub-compartments  (Read 12820 times)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Element sub-compartments
« Reply #15 on: November 18, 2014, 08:59:09 am »
Cheers Nabil

I have avoided the add-in route thus far because I need to "rage against the machine" in order to get access to Visual Studio.
However, I have just begun to rage and if I am successful, then I will use this as a starting point.

Thanks a bunch  :)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Element sub-compartments
« Reply #16 on: December 05, 2014, 09:14:08 am »
Alrighty, so these sub compartments are driving me ever so "slightly" crazy!

I have pretty much copied an example out of the book and it just doesn't do what it is supposed to!

The Shape Script is as follows:

=====================
//Shape main affects the parent
  shape main
  {
        //Set the color of the parent element to red
        setfillcolor(255,0,0);
 
        //draw the parents native shape
        drawnativeshape();
  }
 
  //Shape ChildElement adds Child Compartments to the parent.
   shape ChildElement
  {
         if(HasProperty("stereotype", "part"))
         {
                SetCompartmentName("Parts");
          }
         else if(HasProperty("stereotype", "Attr"))
         {
               SetCompartmentName("Attr");
          }
          AppendCompartmentText("#NAME#");
  }
===============================

I have created a stereotype "Attr" based on class and whenever I drag this onto the stereotype that has THIS shape script, nothing happens!

The "Attr" element sits smack in the middle of the parent element, but doesn't trigger the rendering of the custom compartment.

I'm assuming that the sample script is not wrong, so can only assume I need to do something different when specifying my stereotype or dragging onto the parent.

But, what????????????

Thanks in advance

Jays  :)

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Element sub-compartments
« Reply #17 on: December 05, 2014, 09:36:08 am »
Remove the part from the diagram. EA will either show the element OR the compartment text, not both.
The Sparx Team
[email protected]

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Element sub-compartments
« Reply #18 on: December 05, 2014, 10:30:13 am »
Ah, yup that works but presents me with a new problem.
I want the user to be able to add these "things" to the parent and have it display them in a sub-compartment IMMEDIATELY without further action.

Is there any way to change the default action such that the child element appears in the compartment immediately?

Cheers :-)

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Element sub-compartments
« Reply #19 on: December 05, 2014, 04:13:59 pm »
Hi Jason,

If you are adding the child element from code after
ChildElem.Update();
Repository.RefreshOpenDiagrams(true);

or if your adding it manually

EA_OnPostNewElement

Both will refelect the change in compartment immediately.

Thanks,
Nabil
« Last Edit: December 05, 2014, 04:45:01 pm by nabilsparx »
Nabil

gloriatorios

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Element sub-compartments
« Reply #20 on: December 11, 2014, 08:07:07 pm »
Its there anyway I can change the appearance of the default attributes compartment?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Element sub-compartments
« Reply #21 on: December 11, 2014, 08:44:31 pm »
The diagram properties offers a couple of options and the context menu Feature Visibility. Else you would need to go the Shape Script path.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Element sub-compartments
« Reply #22 on: December 12, 2014, 08:55:01 am »
Quote
Its there anyway I can change the appearance of the default attributes compartment?
Other than the options provided, no. It can't be modified via shape scripts.

mariolita

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Element sub-compartments
« Reply #23 on: December 14, 2014, 12:58:32 am »
I can copy the examples out of the user manual that adds a custom compartment for properties and it works.

I try to modify it for attributes or tagged values and I get zip.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Element sub-compartments
« Reply #24 on: December 14, 2014, 01:47:27 am »
How do you want to modify them?

q.