Book a Demo

Author Topic: DrawComposedDiagram in shape script  (Read 10730 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
DrawComposedDiagram in shape script
« on: January 16, 2014, 05:27:43 am »
Does this script (copied from the help) actually work?
Code: [Select]
shape main {
 layouttype="Border";
// if(HasProperty("ShowComposedDiagram", "true")) {
         addsubshape("ComposedDiagram", "CENTER");
// }

 shape ComposedDiagram {
      DrawComposedDiagram();
 }
}
I don't see any composite diagram.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #1 on: January 16, 2014, 10:05:10 am »
I know that something similar is used for BPMN types.

You need to uncomment the lines you have commented out. Once you have done that, EA will know that your shape script is supporting showing the composite diagram and will enable the option in the context menu.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #2 on: January 16, 2014, 09:59:45 pm »
Unfortunately not. Comment or not: There is no composite diagram shown in any case. Does it work for you? I did not use MDG but tried with board tools (Settings/UML).

q.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #3 on: January 16, 2014, 11:19:37 pm »
I suspect for this one you will need to define a profile/mdg - so sparx knows that composite diagrams are supported for the stereotype and their type ???

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #4 on: January 17, 2014, 12:39:54 am »
You may be right with your assumption, but the help does not tell anything about it. And why should a plain stereotype not allow a script which produces the composed diagram inside the shape?

Anyhow I'll see how a MDG changes things. But that will be the next step. For the moment I try to put together the basics. Tough enough...

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #5 on: January 17, 2014, 08:51:43 am »
I added your shape script to a simple stereotype and uncommented the lines I said. The option was in the context menu and worked perfectly.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #6 on: January 17, 2014, 09:32:34 am »
I am by no means an expert in Shape Scripts. I sit in my sandpit, plastic spade in one hand and keyboard in the other, and play with the scripts to produce the actual screenshots you see in the Help.  If I can make those work, believe me, there are no hidden pre-requisites or complications! Other than, perhaps, a whack with a plastic spade?
« Last Edit: January 17, 2014, 09:53:44 am by RoyC »
Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #7 on: January 17, 2014, 10:58:20 am »
Well, here it does not work. I may be doing something completely stupid, but it's actually this:
- define the shape script
- create a class and assign the stereotype
- make the class composite by Add Diagram/Composite
- place something in that diagram
--> see nothing appear in the class. It's completely blank.
Was that stupid?

q.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #8 on: January 17, 2014, 12:18:57 pm »
On the Class, you also need to select the context menu option New Child Diagram > Show Composite Diagram in Compartment.

The point is, some Shape Scripts change element display, and if you have a Composite Diagram shown in the compartment the Shape Script would change things so that the diagram would not display. THIS bit of Shape Script honours the Show Composite Diagram In Compartment setting so that the diagram does display. I hate to point it out, but that is explained in the Show Composite Diagram topic in the Help.

http://www.sparxsystems.com/enterprise_architect_user_guide/10/extending_uml_models/add_composite_diagram_compartm.html
Best Regards, Roy

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #9 on: January 17, 2014, 02:56:55 pm »
The important thing is: It is behaving this way so that a well authored shape script can behave much the same way as the UML elements. We've actually put a lot of effort into that (although I'm aware there more we need to do.)

For that reason, if I find out that you don't make a point of saying that for the benefit of your end users you should use pen colours, fill colours, line widths etc very very sparingly (ie. only to a small part of the script) then I will be forced to write my own shape scripting book.  ;) Users get very upset when they can't set those things for themselves.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #10 on: January 17, 2014, 10:45:42 pm »
When working with the shape script I  was not aware of this additional option, so I just stopped after adding the composite diagram. Actually I do not often use displaying a composite as diagram inside an element (there are different ways to achieve the same result) so may simply have forgotten how to correctly deal with it.

Thanks to both of you for helping me out :-)

q.

P.S. On the other hand: if I write a shape script and place the DrawCompositeDiagram wouldn't I expect to appear that diagram rather to have the user to set the option manually??? That's probably some EAUI as my way of thinking differs from that of the EA developers. Well, I take it as it is but finally have some explanation for my "stupidity" ;-)

P.P.S: The method itself is not described the the drawing methods. It only appears in one example. Roy, could you add that to the table?
« Last Edit: January 17, 2014, 11:01:42 pm by qwerty »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #11 on: January 17, 2014, 11:24:09 pm »
Quote
For that reason, if I find out that you don't make a point of saying that for the benefit of your end users you should use pen colours, fill colours, line widths etc very very sparingly (ie. only to a small part of the script) then I will be forced to write my own shape scripting book.  ;) Users get very upset when they can't set those things for themselves.
I think I have said this more than once in the past. But many people seem to let the business force them to use non-standard UML. So what the heck. They want to feel the pain. Could also be fun ;D

My current intro yet does not emphasis this fact, but I'll revise it.

q.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #12 on: January 20, 2014, 09:19:05 am »
Quote
On the other hand: if I write a shape script and place the DrawCompositeDiagram wouldn't I expect to appear that diagram rather to have the user to set the option manually??? That's probably some EAUI as my way of thinking differs from that of the EA developers.

No, because this piece of script is for responding to the user's requirement to show a composite diagram WITHIN A COMPARTMENT OF THE PARENT ELEMENT. The user still has to indicate whether to display the composite diagram separately or within the parent element.
Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #13 on: January 20, 2014, 09:32:13 am »
It's just a different pair of glasses we're looking through ;-) Interestingly UML deals exactly with that fact: how can imaginations of different people be brought to a common sense. Basically, I think, this is impossible.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DrawComposedDiagram in shape script
« Reply #14 on: January 21, 2014, 09:46:39 am »
Quote
I am by no means an expert in Shape Scripts. I sit in my sandpit, plastic spade in one hand and keyboard in the other, and play with the scripts to produce the actual screenshots you see in the Help.  If I can make those work, believe me, there are no hidden pre-requisites or complications! Other than, perhaps, a whack with a plastic spade?
Since I'm addicted to Minecraft for some time I now found the analogy: You have a plastic spade and I use a pick axe :-)

q.