Book a Demo

Author Topic: Activities in diagrams as hyperlinks  (Read 3300 times)

yonatan.lehman

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Activities in diagrams as hyperlinks
« on: February 20, 2022, 11:13:33 pm »
As part of our workflow we create Activities that model component operations and insert the activities into Activity diagrams and Component diagrams.
We want the activities to act as hyperlinks so that when they are clicked , the diagram associated with that activity will open.

This works if we create an activity by right clicking on a component and doing Add>Activity>With Activity diagram.

But it only works with the diagram created when the activity was created. Our problem is that all out activities have already been created (automatically from the code) - only later in the workflow do we draw the details of each particular activity.

If we add an diagram underneath an activity, by dragging it there, of even by doing Add>Diagram on the activity,  when the activity in a diagram is clicked is does NOT open the diagram, but rather opens the Elements Property window instead.

So the question is
What do we need to do to get an activity in a diagram to act as a hyperlink so that double clicking it will open a diagram that was at some point associated with that activity ?

We are using EA 14.0
Thanks




Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Activities in diagrams as hyperlinks
« Reply #1 on: February 20, 2022, 11:36:41 pm »
Right click on the Activity New Child Diagram | Select Composite Diagram

Geert

PS. Activity Diagrams should only contain Actions, not Activities.

yonatan.lehman

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Activities in diagrams as hyperlinks
« Reply #2 on: February 21, 2022, 12:09:35 am »
Thanks, Geert - super-fast reaction!

Is there a way I can do this programmatically (JavaScript)

Regarding "Activity Diagrams should only contain Actions, not Activities."

Can you explain this? Is this a UML or EA limitation? (It does work....)

Using activities is very convenient since
1) The project browser is a model of our code file system and its C components. The functions in each component are represented as activities.

2) To model the behavior of a function we create an activity diagram (i.e. flow chart like diagram) and drag an instance of the activities of the functions it calls, connecting then with connectors, decision points and so on.

3) We can then do searches for the diagrams where an activity (i.e. function) appears, and find the activity in the browser for an activity in a diagram.

How would we create Actions from the activities in the tree simply and quickly and what advantage would it give us over what we do currently?





Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Activities in diagrams as hyperlinks
« Reply #3 on: February 21, 2022, 02:18:02 am »
Yes, you can. There's a property Element.CompositeDiagram you can use to read it.

To set the composite diagram is a bit more complicated.

This is the function I use (from github: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/Util.vbs)

Code: [Select]
'set the given diagram as composite diagram for this element
function setCompositeDiagram (element, diagram)
if not diagram is nothing then
'Tell EA this element is composite
dim objectQuery
objectQuery = "update t_object set NType = 8 where Object_ID = " & element.ElementID
Repository.Execute objectQuery
if element.Type = "Object" then
'Tell EA which diagram is the composite diagram
dim xrefQuery
xrefquery = "insert into t_xref (XrefID, Name, Type, Visibility, Partition, Client, Supplier) values ('"&CreateGuid&"', 'DefaultDiagram', 'element property', 'Public', '0', '"& element.ElementGUID & "', '"& diagram.DiagramGUID &"')"
Repository.Execute xrefquery
elseif element.Type = "Activity" then
'for activities we need to update PDATA1 with the diagramID
dim updatequery
updatequery = "update t_object set PDATA1 = "& diagram.DiagramID & " where Object_ID = " & element.ElementID
Repository.Execute updatequery
end if
end if
end function

About the Activities on an Activity Diagram, if you try it manually with the latest EA version you'll notice that EA will start to complain when you try to connecto a control flow to an Activity.
That is because it's simply not valid UML.

You don't use Statemachines in a State Machine Diagram either do you?

Instead you should use a CallBehaviorAction that invokes your Activity.
Ctrl-Dragging an Activity onto a diagram will give you the option to drop it as an Invocation.

More info details in this article I wrote a long time ago: https://bellekens.com/2012/12/09/uml-best-practice-there-are-no-activities-on-an-activity-diagram/

Geert