Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Jayson on November 13, 2014, 01:04:56 pm

Title: Element sub-compartments
Post by: Jayson on November 13, 2014, 01:04:56 pm
Okie

So, I am trying to do two things:

1. Add a sub-compartment with some tagged values contained in it, and
2. Modify the existing attribute compartment to display some tagged values (belonging to my own custom attribute stereotype) alongside the standard attribute information.

If I can't modify the existing attribute compartment, then I want to add a new compartment with the required attribute information.

However, the sub-compartment method doesn't seem to work with either attributes or tagged values.

It appears (I could be wrong) that:

a) Custom compartments only work with child elements and
b) Attributes & tagged values are not treated as child elements.

All help appreciated.

Cheers :-)
Title: Re: Element sub-compartments
Post by: qwerty on November 13, 2014, 08:54:27 pm
You're talking about shape script, aren't you?

q.
Title: Re: Element sub-compartments
Post by: Jayson on November 14, 2014, 02:55:20 am
Hey Q, yup I 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.

Jays  :)
Title: Re: Element sub-compartments
Post by: qwerty on November 14, 2014, 07:41:42 am
In that case I have to confirm your above observation  :-/

Maybe you can create something using the add-in escape?

q.
Title: Re: Element sub-compartments
Post by: Jayson on November 14, 2014, 08:04:26 am
Ah, so I thought this was a simple case of gross stupidity on my part which is generally the most common cause of my problems with Sparx.

But if this is a genuine limitation, its a bloody BIG one!
Title: Re: Element sub-compartments
Post by: Jayson on November 14, 2014, 08:05:29 am
Oh, actuall Q.
Its there anyway I can change the appearance of the default attributes compartment?
I tried defining a shape script for my attribute stereotype, but it seemed to make no difference.
Title: Re: Element sub-compartments
Post by: AndyJ on November 14, 2014, 08:55:51 am
The usual method is to define something new with a stereotype and an associated shape script.

This one draws a small, blue person, and includes a tagged value below it:

shape main
{      
      // Blue Person by Andy J;
      fixedAspectRatio = "true";
      setfillcolor(0,192,255); // (R,G,B)
      setpencolor(0,192,255);
      ellipse(70,-15,90,20);  // (x1,y1,x2,y2)
      rectangle(60,25,100,75);// (x1,y1,x2,y2)
      rectangle(70,75,90,110);
      setfillcolor(255,255,255);
      rectangle(80,75,82,110);
      rectangle(66,40,68,75);
      rectangle(92,40,94,75);
      setorigin("CENTER",0,0);
      println(" ");
      println(" ");
      println(" ");
      println(" ");
      println(" ");
      println("#NAME#");
      println("#TAG:Stakeholder Type#");
      println("<<#stereotype#>>");
}      
Title: Re: Element sub-compartments
Post by: qwerty on November 14, 2014, 11:00:56 am
Yes, but it does not touch the attr/oper compartments in any way. They are rendered independently.

q.
Title: Re: Element sub-compartments
Post by: qwerty on November 14, 2014, 11:04:13 am
Quote
Oh, actuall Q.
Its there anyway I can change the appearance of the default attributes compartment?
I tried defining a shape script for my attribute stereotype, but it seemed to make no difference.
To my knowledge there is no way to react to stereotyped attributes in a shape script. Except (as indicated) maybe with the add-in escape. But even that will likely not allow very much in the direction you'd like it to be, I guess. Shape Script IS limited. See one of the recent suggestions post. Maybe you should join there.

q.
Title: Re: Element sub-compartments
Post by: AndyJ on November 14, 2014, 11:13:42 am
OK I'm confused.

You know you can display the "tagged values" compartment?

"Feature and Compartment Visibility"

"Show Element Compartments"

Put a tick in the "Tagged Values" box.

So, you can show tagged values on something that isn't controlled by a shape script, and you can show tagged values on something that IS controlled by a shape script.

What's missing?
Title: Re: Element sub-compartments
Post by: Jayson on November 14, 2014, 11:19:31 am
Hey there

What I want to do is render a compartment that contains both:

* Attributes, and
* The tagged values belonging to those attributes.

So if the attribute has an enumerated tagged value called "Importance" with values {High, Medium, Low} I would want to display as follows:

Attribute1 (High)
Attribute2 (Medium)
Attribute3 (Low)

But as yet I can't figure out how to do this.

Cheers  :)
Title: Re: Element sub-compartments
Post by: AndyJ on November 14, 2014, 11:22:12 am
I see, (I think).

Normally I display those as separate things. ie:

Attribute Name:Attribute Name.

The second part of the name is the "type".

In this case the "type" is an enumerated list.

The enumeration can be displayed on the same diagram and associated to the class (or not) as you see fit.

Andy

Edited:

i.e. something like this:

(http://i932.photobucket.com/albums/ad164/AndyJ4Sparx/enumeration_zpsad5c16a0.jpg)
Title: Re: Element sub-compartments
Post by: Nabil on November 17, 2014, 05:23:45 pm
Hey Jason,

if you are interested to define Element Compartment via Addin, Refer this post in EA community

http://community.sparxsystems.com/community-resources/500-72showing-classifier-notes-in-a-custom-compartment

Regards,
Nabil
Title: Re: Element sub-compartments
Post by: qwerty on November 17, 2014, 05:37:19 pm
Good point, Nabil. Seems this was already implemented in 9.3. Has passed my attention.

q.
Title: Re: Element sub-compartments
Post by: Nabil on November 17, 2014, 06:11:49 pm
Thanks Q.

Regards,
Nabil
Title: Re: Element sub-compartments
Post by: Jayson 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  :)
Title: Re: Element sub-compartments
Post by: Jayson 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  :)
Title: Re: Element sub-compartments
Post by: KP 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.
Title: Re: Element sub-compartments
Post by: Jayson 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 :-)
Title: Re: Element sub-compartments
Post by: Nabil 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
Title: Re: Element sub-compartments
Post by: gloriatorios on December 11, 2014, 08:07:07 pm
Its there anyway I can change the appearance of the default attributes compartment?
Title: Re: Element sub-compartments
Post by: qwerty 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.
Title: Re: Element sub-compartments
Post by: Eve 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.
Title: Re: Element sub-compartments
Post by: mariolita 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.
Title: Re: Element sub-compartments
Post by: qwerty on December 14, 2014, 01:47:27 am
How do you want to modify them?

q.