Book a Demo

Author Topic: How to display tagged value on an activity?  (Read 3625 times)

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
How to display tagged value on an activity?
« on: April 17, 2015, 02:25:13 am »
Hi,

I'm running into the same problem time to time, with no luck with the solution yet. The situation is rather simple in terms of EA customization: In a profile, I introduced a stereotype for activities, and defined a couple of tagged values for the sterotype. Let's say the stereotype is called stereo and the tagged value is called tvA1, tvA2 and tvB1 with a string type. tvA1 and tvA2 belongs to the tag group A, while tvB1 belongs to tag group B.

When using the profile in a test project, I've tried to turn on displaying tags both the diagram containing an activity of that stereotype, as well as turning on visibility in Feature and Compartment Visibility. None of the options reveled my tags. I remembered this may be caused by the fact that activities redraws the rectangle of the Class metaclass to a rounded rectangle.

Then I've tried a couple of shape scripts:
    [*] A script which calls DrawNativeShape() in shape main, and then calls SetCompartmentName and AppendCompartmentText. Nothing is displayed.
    [*] A script which creates a subshape and adds the subshape in shape main. The subshape uses print/println/printwrapped to display the tagged values. The text was overflowing the activity.
    [*] A script like above, without calling DrawNativeShape(). I've recreated the rounded rectangle. When I set it to the size of 100x100, the text was overflowing. When I set it to the size of 160x160, and used moveto and lineto to draw a horizontal line in the middle with a width of 160, it was overflowing on the left and right side of the activity (with the overflown segments suming cc 100 pixels or whatever the measurement unit is).
    [*] A script which calls DrawNativeShape() and then adds the tagged values using simple print/println/printwrapped. This works, the results, however, looks bad: I can not make group headings (A and B) bold, so the results is not really intelligible. In addition, I found resizing does not work properly: while the activitiy is displayed so that text fits it, when I try to select it, the selection handlers reveal a much smaller rectangle.
    [/list]

    Two of my attempts:


     shape main
     {      
          h_align = "center";
          editablefield = "name";
          roundrect(0,0,160,160,30,30);
          printwrapped("#name#");
          
           SetCompartmentName("My Tag Section");
          AppendCompartmentText("Hello World");
    }


    This script did not work. The result was the same if I called DrawNativeShape instead of drawing it myself.

    The other type of script was:



     shape main
     {      
          h_align = "center";
          editablefield = "name";
          roundrect(0,0,160,160,30,30);
          printwrapped("#name#");
          
          AddSubShape("tagA", 160, 60);
          AddSubShape("tagB", 160, 60);
          
          shape tagA {
                h_align = "left";            
                v_align= "bottom";
                moveto(0,50);
                lineto(100,50);
                printwrapped("Tags A");
                printwrapped("Tag 1: #TAG:tvA1#");
                printwrapped("Tag 2: #TAG:tvA2#");
          }
          
          shape tagB {
                h_align = "left";            
                v_align= "bottom";
                moveto(0,110);
                lineto(160,110);
                printwrapped("Tags B");
                printwrapped("Tag 1: #TAG:tvB1#");
          }
          
     }


    This neither worked.

    Please note that I have edited these scripts for this forum, and any syntax error I might have introduced are not present in my actual code in EA. :)


    Could anyone help in creating a shape script which displays tagged values on activities? It was great if I could add them to multiple compartments.

    Thanks for reading.
    « Last Edit: April 17, 2015, 02:25:31 am by imprestige »
    ------------------------
    Imprestige. Your issues in safe hands.

    qwerty

    • EA Guru
    • *****
    • Posts: 13584
    • Karma: +397/-301
    • I'm no guru at all
      • View Profile
    Re: How to display tagged value on an activity?
    « Reply #1 on: April 17, 2015, 05:08:25 am »
    In your second script you draw outside the shape. The shape is only within the rect (0|0,100|100).

    q.

    Edit: Try this:
    Code: [Select]
    shape main
    {      
         h_align = "center";
         editablefield = "name";
          DrawNativeShape();
          
         AddSubShape("tagA", 100, 60);
         AddSubShape("tagB", 100, 30);
        
         shape tagA {
               h_align = "left";            
               v_align= "bottom";
               moveto(0,50);
               lineto(100,50);
               println("Tags A");
               println("Tag 1: #TAG:tvA1#");
               println("Tag 2: #TAG:tvA2#");
         }
        
         shape tagB {
               h_align = "left";            
               v_align= "bottom";
               moveto(0,0);
               lineto(100,0);
               println("Tags B");
               printwrapped("Tag 1: #TAG:tvB1#");
         }
        
    }
    « Last Edit: April 17, 2015, 05:16:23 am by qwerty »

    KP

    • EA Administrator
    • EA Expert
    • *****
    • Posts: 2919
    • Karma: +55/-3
      • View Profile
    Re: How to display tagged value on an activity?
    « Reply #2 on: April 17, 2015, 09:13:45 am »
    Have you tried Right-click > Advanced > Use Rectangle Notation?
    The Sparx Team
    [email protected]