Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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 :-)
-
You're talking about shape script, aren't you?
q.
-
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 :)
-
In that case I have to confirm your above observation :-/
Maybe you can create something using the add-in escape?
q.
-
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!
-
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.
-
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#>>");
}
-
Yes, but it does not touch the attr/oper compartments in any way. They are rendered independently.
q.
-
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.
-
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?
-
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 :)
-
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)
-
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
-
Good point, Nabil. Seems this was already implemented in 9.3. Has passed my attention.
q.
-
Thanks Q.
Regards,
Nabil
-
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 :)
-
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 :)
-
Remove the part from the diagram. EA will either show the element OR the compartment text, not both.
-
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 :-)
-
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
-
Its there anyway I can change the appearance of the default attributes compartment?
-
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.
-
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.
-
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.
-
How do you want to modify them?
q.