diff --git a/capellambse/aird/_edge_factories.py b/capellambse/aird/_edge_factories.py
index 616b98d0a..a3bf5f957 100644
--- a/capellambse/aird/_edge_factories.py
+++ b/capellambse/aird/_edge_factories.py
@@ -9,6 +9,8 @@
import math
import typing as t
+from lxml import etree
+
from capellambse import diagram, helpers
from . import _common as C
@@ -474,9 +476,7 @@ def state_transition_factory(seb: C.SemanticElementBuilder) -> diagram.Edge:
seb.melodyobjs[0], seb.melodyobjs[0].get("triggers", "")
)
label = ", ".join(
- i.get("name", "(unnamed trigger)")
- for i in triggers
- if i is not None
+ _get_trigger_expression(i, seb) for i in triggers if i is not None
)
if guard := _guard_condition(seb, "guard"):
@@ -495,6 +495,29 @@ def state_transition_factory(seb: C.SemanticElementBuilder) -> diagram.Edge:
return edge
+def _get_trigger_expression(
+ trigger: etree._Element, seb: C.SemanticElementBuilder
+) -> str:
+ exprid = trigger.get("expression")
+ if not exprid:
+ return ""
+
+ change_event_type = trigger.attrib[helpers.ATT_XT]
+ if change_event_type.endswith("TimeEvent"):
+ kind = trigger.get("kind", "AT")
+ elif change_event_type.endswith("ChangeEvent"):
+ kind = trigger.get("kind", "WHEN")
+
+ constraint = seb.melodyloader.follow_link(seb.melodyobjs[0], exprid)
+ try:
+ spec = next(constraint.iterchildren("ownedSpecification"))
+ body = next(spec.iterchildren("bodies"))
+ except StopIteration:
+ return ""
+
+ return f"({kind}) {body.text}"
+
+
def sequence_link_factory(seb: C.SemanticElementBuilder) -> diagram.Edge:
"""Create a SequenceLink.
diff --git a/tests/data/melodymodel/5_2/Melody Model Test.aird b/tests/data/melodymodel/5_2/Melody Model Test.aird
index b1549ab89..5a56fb70f 100644
--- a/tests/data/melodymodel/5_2/Melody Model Test.aird
+++ b/tests/data/melodymodel/5_2/Melody Model Test.aird
@@ -12,7 +12,7 @@
-
+
@@ -1905,7 +1905,7 @@
-
+
diff --git a/tests/data/melodymodel/5_2/Melody Model Test.capella b/tests/data/melodymodel/5_2/Melody Model Test.capella
index f8113e57e..7499686ca 100644
--- a/tests/data/melodymodel/5_2/Melody Model Test.capella
+++ b/tests/data/melodymodel/5_2/Melody Model Test.capella
@@ -764,7 +764,8 @@ The predator is far away
+ id="680f13b6-c446-4510-974f-0de9da6bd2be" name="TimeEvent 3" expression="#20925467-cfbf-47bc-bad6-ad842973f4d4"
+ kind="AFTER">