Author Topic: Automatically show customer compartments...  (Read 268 times)

OpenIT Solutions

  • EA User
  • **
  • Posts: 456
  • Karma: +4/-0
    • View Profile
Automatically show customer compartments...
« on: August 11, 2017, 11:26:58 pm »
Hi,

Is there a way to automatically show custom compartments for a given stereotype? I've added a shapescript to a stereotype. It works and displays my compartments - but only if I select the Features & Properties -> Feature and Compartment Visibility and check the option to show my custom compartment. I'd like them to be shown by default somehow. My shapescript is below, it adds and compartment and shows the details of related Activities and Components...

shape RelatedElement
{

if(HasProperty("Element.Stereotype", "Activity"))
   {      
   SetCompartmentName("Process");
   AppendCompartmentText("#Connector.Name#   #TAG:taskType#: #Element.Name#");
   }   
   
      if(HasProperty("Element.Type", "Component"))
   {      
   SetCompartmentName("IT Systems");
   AppendCompartmentText("#Connector.Name#   #Element.Stereotype#: #Element.Name# - #Element.Alias#");   
   }         

   
   
   if(HasProperty("Element.Stereotype", "MeasurementPoint"))
   {      
   SetCompartmentName("Measurement Points");
   AppendCompartmentText("#Connector.Name#   #Element.Name#:  #Element.Alias#");
    }         
   
   if(HasProperty("Element.Stereotype", "ControlCategory"))
   {      
   SetCompartmentName("Control Category");
   AppendCompartmentText("#Connector.Name#   #Element.Name#");
    }
   
   
   if(HasProperty("Element.Stereotype", "DataObject"))
   {      
   SetCompartmentName("Deliverables");
   AppendCompartmentText("#Connector.Name#:  #Element.Name#");   
   }   
}

qwerty

  • EA Guru
  • *****
  • Posts: 8849
  • Karma: +134/-120
  • I'm no guru at all
    • View Profile
Re: Automatically show customer compartments...
« Reply #1 on: August 12, 2017, 12:33:17 am »
That would be tricky. t_diagram.styleex contained something like
Code: [Select]
OPTIONS_83E1ECEE=CCOMP_Measurement Points=0:after removing the check mark (or =1 if it shall be shown) where the 83E1ECEE is the DUID= value from the diagram object in question. I guess that the "Measurement Points" somehow is created from the related MeasurementPoint stereotyped element to which I related the element.

q.

OpenIT Solutions

  • EA User
  • **
  • Posts: 456
  • Karma: +4/-0
    • View Profile
Re: Automatically show customer compartments...
« Reply #2 on: August 19, 2017, 02:10:38 am »
Hi,

Thanks; yes had to code something up in the end, see snippet of vscript for those that are interested below. You would need to replace the contents of the str variable with your own custom compartment names:

dim obj as EA.DiagramObject
dim elm as EA.Element
dim diagramObjects as EA.Collection
dim objRegEx
set objRegEx = CreateObject("VBScript.RegExp")
set diagramObjects = currentDiagram.DiagramObjects
style = currentDiagram.StyleEx
      
for each obj in diagramObjects
   set elm = Repository.GetElementByID (obj.ElementID)
         
   if elm.Stereotype = "Container" then
      uid = obj.InstanceGUID
      str = "OPTIONS_" & uid & "=CCOMP_Deliverables=1:CCOMP_Process=1:CCOMP_Measurement Points=1:CCOMP_Applications=1:CCOMP_Control Category=1;"
            
      if InStr (1, style, "OPTIONS_" & uid, 1) = 0 then
         style = str & style
      else
         objRegEx.Global = True
         objRegEx.Pattern = "OPTIONS_" & uid & ".+?;"
         style = objRegEx.Replace (style, str)
      end if
   end if
next
      
currentDiagram.StyleEx = style
currentDiagram.Update
Repository.ReloadDiagram (currentDiagram.DiagramID)