This is an automated email from the ASF dual-hosted git repository.

thiagoelg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 6ede1839dd7 [incubator-kie-issues#1933] The new React-based BPMN 
Editor - more bug fixes (#3555)
6ede1839dd7 is described below

commit 6ede1839dd72777a13da72ce12f1f0841d355fc7
Author: Kbowers <[email protected]>
AuthorDate: Sat May 30 04:30:06 2026 +0200

    [incubator-kie-issues#1933] The new React-based BPMN Editor - more bug 
fixes (#3555)
---
 packages/bpmn-editor/src/i18n/BpmnEditorI18n.ts    |   1 +
 packages/bpmn-editor/src/i18n/locales/en.ts        |   2 +
 packages/bpmn-editor/src/mutations/_dataMapping.ts |  10 +-
 .../src/mutations/addOrGetItemDefinitions.ts       |   9 +-
 .../bpmn-editor/src/mutations/addOrGetMessages.ts  |  44 ++++++++-
 .../src/mutations/addOrGetOperations.ts            |  10 +-
 .../src/mutations/deleteItemDefinition.ts          | 107 +++++++++++++++++++++
 .../bpmn-editor/src/mutations/deleteMessage.ts     |  24 +++++
 .../deleteOrphanedCorrelationSubscriptions.ts      |  79 +++++++++++++++
 .../bpmn-editor/src/mutations/renameMessage.ts     |   1 -
 .../src/propertiesPanel/GlobalProperties.tsx       |  12 +++
 .../propertiesPanel/correlations/Correlations.tsx  |  98 +++++++++++++++----
 .../dataMapping/DataMappingFormSection.tsx         | 102 +++++++++++++++++---
 .../eventDefinition/EventDefinitionProperties.tsx  |  31 +++++-
 .../ItemDefinitionRefSelector.tsx                  |  32 ++++--
 .../propertiesManager/PropertiesManager.tsx        |  83 +++++++++++++++-
 16 files changed, 576 insertions(+), 69 deletions(-)

diff --git a/packages/bpmn-editor/src/i18n/BpmnEditorI18n.ts 
b/packages/bpmn-editor/src/i18n/BpmnEditorI18n.ts
index 04d0807e07c..f9587990d41 100644
--- a/packages/bpmn-editor/src/i18n/BpmnEditorI18n.ts
+++ b/packages/bpmn-editor/src/i18n/BpmnEditorI18n.ts
@@ -112,6 +112,7 @@ interface BpmnEditorDictionary
       noDataMappings: (entryTitle: string) => string;
       noDataMappingsYet: (entryTitle: string) => string;
       addDataMapping: (entryTitle: string) => string;
+      messageInfoIconHelperText: string;
     };
     eventDefinitionProperties: {
       message: string;
diff --git a/packages/bpmn-editor/src/i18n/locales/en.ts 
b/packages/bpmn-editor/src/i18n/locales/en.ts
index 97d329e1025..58fc34cc4f7 100644
--- a/packages/bpmn-editor/src/i18n/locales/en.ts
+++ b/packages/bpmn-editor/src/i18n/locales/en.ts
@@ -116,6 +116,8 @@ export const en: BpmnEditorI18n = {
     noDataMappings: (entryTitle: string): string => `No ${entryTitle} data 
mappings`,
     noDataMappingsYet: (entryTitle: string): string => `No ${entryTitle} data 
mappings yet`,
     addDataMapping: (entryTitle: string): string => `Add ${entryTitle} data 
mapping`,
+    messageInfoIconHelperText:
+      "For message events, the data type is determined by the messages type. 
To change it, update the message type in the Properties Manager(Messages tab).",
   },
   eventDefinitionProperties: {
     message: "Message",
diff --git a/packages/bpmn-editor/src/mutations/_dataMapping.ts 
b/packages/bpmn-editor/src/mutations/_dataMapping.ts
index ababb15f90d..abd04109dd1 100644
--- a/packages/bpmn-editor/src/mutations/_dataMapping.ts
+++ b/packages/bpmn-editor/src/mutations/_dataMapping.ts
@@ -229,7 +229,8 @@ export function setInputDataMapping(
   itemDefinitionIdByDataTypes: Map<string, string>,
   inputDataMapping: DataMapping[],
   elementWithData: WithInputDataMapping | 
NonNullable<WithDataMapping["ioSpecification"]>,
-  elementWithAssociation: WithInputDataMapping | WithDataMapping
+  elementWithAssociation: WithInputDataMapping | WithDataMapping,
+  definitions?: Normalized<BPMN20__tDefinitions>
 ) {
   elementWithData.dataInput = [];
   elementWithAssociation.dataInputAssociation = [];
@@ -275,7 +276,8 @@ export function setOutputDataMapping(
   itemDefinitionIdByDataTypes: Map<string, string>,
   outputDataMapping: DataMapping[],
   elementWithData: WithOutputDataMapping | 
NonNullable<WithDataMapping["ioSpecification"]>,
-  elementWithAssociation: WithOutputDataMapping | WithDataMapping
+  elementWithAssociation: WithOutputDataMapping | WithDataMapping,
+  definitions?: Normalized<BPMN20__tDefinitions>
 ) {
   elementWithData.dataOutput = [];
   elementWithAssociation.dataOutputAssociation = [];
@@ -391,13 +393,13 @@ export function setDataMappingForElement({
       ) {
         setInputAndOutputDataMapping(itemDefinitionIdByDataTypes, 
inputDataMapping, outputDataMapping, e);
       } else if (e.__$$element === "endEvent" || e.__$$element === 
"intermediateThrowEvent") {
-        setInputDataMapping(itemDefinitionIdByDataTypes, inputDataMapping, e, 
e);
+        setInputDataMapping(itemDefinitionIdByDataTypes, inputDataMapping, e, 
e, definitions);
       } else if (
         e.__$$element === "startEvent" ||
         e.__$$element === "intermediateCatchEvent" ||
         e.__$$element === "boundaryEvent"
       ) {
-        setOutputDataMapping(itemDefinitionIdByDataTypes, outputDataMapping, 
e, e);
+        setOutputDataMapping(itemDefinitionIdByDataTypes, outputDataMapping, 
e, e, definitions);
       }
 
       return false; // Will stop visiting.
diff --git a/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts 
b/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
index 4fb17dbc852..bf9d96a8f45 100644
--- a/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
+++ b/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
@@ -22,6 +22,7 @@ import { ElementFilter } from 
"@kie-tools/xml-parser-ts/dist/elementFilter";
 import { Unpacked } from 
"@kie-tools/xyflow-react-kie-diagram/dist/tsExt/tsExt";
 import { Normalized } from "../normalization/normalize";
 import { generateUuid } from 
"@kie-tools/xyflow-react-kie-diagram/dist/uuid/uuid";
+import { RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES } from "./addOrGetMessages";
 
 export const DEFAULT_DATA_TYPES = {
   STRING: "String",
@@ -34,16 +35,20 @@ export const DEFAULT_DATA_TYPES = {
 export function addOrGetItemDefinitions({
   definitions,
   dataType,
+  id,
 }: {
   definitions: Normalized<BPMN20__tDefinitions>;
   dataType: string;
+  id?: string;
 }): {
   itemDefinition: 
ElementFilter<Unpacked<Normalized<BPMN20__tDefinitions["rootElement"]>>, 
"itemDefinition">;
 } {
   definitions.rootElement ??= [];
   const itemDefinitions = definitions.rootElement.filter((s) => s.__$$element 
=== "itemDefinition");
 
-  const existingItemDefinition = itemDefinitions.find((s) => 
s["@_structureRef"] === dataType);
+  const existingItemDefinition = itemDefinitions.find(
+    (s) => s["@_structureRef"] === dataType && s["@_id"] !== 
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+  );
   if (existingItemDefinition) {
     return { itemDefinition: existingItemDefinition };
   }
@@ -53,7 +58,7 @@ export function addOrGetItemDefinitions({
     "itemDefinition"
   > = {
     __$$element: "itemDefinition",
-    "@_id": generateUuid(),
+    "@_id": id ?? generateUuid(),
     "@_structureRef": dataType,
   };
 
diff --git a/packages/bpmn-editor/src/mutations/addOrGetMessages.ts 
b/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
index 0d9fd990abf..490cc4da7e7 100644
--- a/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
+++ b/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
@@ -22,28 +22,64 @@ import { ElementFilter } from 
"@kie-tools/xml-parser-ts/dist/elementFilter";
 import { Unpacked } from 
"@kie-tools/xyflow-react-kie-diagram/dist/tsExt/tsExt";
 import { Normalized } from "../normalization/normalize";
 import { generateUuid } from 
"@kie-tools/xyflow-react-kie-diagram/dist/uuid/uuid";
+import { addOrGetItemDefinitions, DEFAULT_DATA_TYPES } from 
"./addOrGetItemDefinitions";
+
+// Reserved ID for the shared ItemDefinition used by all messages and linked 
by the message @_itemRef.
+export const RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES = 
"__messageItemDefinition";
 
 export function addOrGetMessages({
   definitions,
   messageName,
+  dataType,
 }: {
   definitions: Normalized<BPMN20__tDefinitions>;
   messageName: string;
+  dataType?: string;
 }): {
   messageRef: string;
 } {
   definitions.rootElement ??= [];
   const messages = definitions.rootElement.filter((s) => s.__$$element === 
"message");
-  const existingMessage = messages.find((s) => s["@_id"] === messageName);
 
-  if (existingMessage) {
-    return { messageRef: existingMessage["@_id"] };
+  let itemDefinitionId: string;
+
+  if (dataType) {
+    const { itemDefinition } = addOrGetItemDefinitions({
+      definitions: definitions,
+      dataType: dataType,
+    });
+    itemDefinitionId = itemDefinition["@_id"];
+  } else {
+    const itemDefinitions = definitions.rootElement.filter((s) => 
s.__$$element === "itemDefinition");
+    const itemDefinitionForMessages = itemDefinitions.find(
+      (s) => s["@_id"] === RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+    );
+
+    if (!itemDefinitionForMessages) {
+      const newItemDefinition: ElementFilter<
+        Unpacked<Normalized<BPMN20__tDefinitions["rootElement"]>>,
+        "itemDefinition"
+      > = {
+        __$$element: "itemDefinition",
+        "@_id": RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES,
+        "@_structureRef": "",
+      };
+      definitions.rootElement.push(newItemDefinition);
+    }
+    itemDefinitionId = RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES;
+  }
+
+  if (messageName) {
+    const existingMessage = messages.find((s) => s["@_name"] === messageName);
+    if (existingMessage) {
+      return { messageRef: existingMessage["@_id"] };
+    }
   }
 
   const newMessage: 
ElementFilter<Unpacked<Normalized<BPMN20__tDefinitions["rootElement"]>>, 
"message"> = {
     __$$element: "message",
     "@_id": generateUuid(),
-    "@_itemRef": `${messageName}Type`, // broken reference to a placeholder 
type that has no meaning to the jBPM Workflow Engine
+    "@_itemRef": itemDefinitionId,
     "@_name": messageName,
   };
 
diff --git a/packages/bpmn-editor/src/mutations/addOrGetOperations.ts 
b/packages/bpmn-editor/src/mutations/addOrGetOperations.ts
index 53e860baef0..9bec7303bee 100644
--- a/packages/bpmn-editor/src/mutations/addOrGetOperations.ts
+++ b/packages/bpmn-editor/src/mutations/addOrGetOperations.ts
@@ -81,11 +81,7 @@ export function addOrGetOperations({
   }
 
   if (!operation) {
-    const { messageRef: inMessageId } = addOrGetMessages({
-      definitions,
-      messageName: "",
-    });
-    const { messageRef: outMessageId } = addOrGetMessages({
+    const { messageRef: messageId } = addOrGetMessages({
       definitions,
       messageName: "",
     });
@@ -93,8 +89,8 @@ export function addOrGetOperations({
     operation = {
       "@_id": generateUuid(),
       "@_name": operationName,
-      inMessageRef: { __$$text: inMessageId },
-      outMessageRef: { __$$text: outMessageId },
+      inMessageRef: { __$$text: messageId },
+      outMessageRef: { __$$text: messageId },
     };
     serviceTaskInterface.operation.push(operation);
   } else if (operation["@_name"] !== operationName) {
diff --git a/packages/bpmn-editor/src/mutations/deleteItemDefinition.ts 
b/packages/bpmn-editor/src/mutations/deleteItemDefinition.ts
index 317318b19c3..bd4b66afef1 100644
--- a/packages/bpmn-editor/src/mutations/deleteItemDefinition.ts
+++ b/packages/bpmn-editor/src/mutations/deleteItemDefinition.ts
@@ -21,6 +21,8 @@ import { BPMN20__tDefinitions } from 
"@kie-tools/bpmn-marshaller/dist/schemas/bp
 import { Normalized } from "../normalization/normalize";
 import { visitFlowElementsAndArtifacts } from "./_elementVisitor";
 import { addOrGetProcessAndDiagramElements } from 
"./addOrGetProcessAndDiagramElements";
+import { RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES } from "./addOrGetMessages";
+import { DEFAULT_DATA_TYPES } from "./addOrGetItemDefinitions";
 
 export function deleteItemDefinition({
   definitions,
@@ -95,4 +97,109 @@ export function deleteItemDefinition({
       }
     }
   });
+
+  definitions.rootElement
+    ?.filter((e) => e.__$$element === "message" && e["@_itemRef"] === 
itemDefinitionId)
+    .forEach((message) => {
+      if (message.__$$element === "message") {
+        message["@_itemRef"] = RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES;
+      }
+    });
+
+  definitions.rootElement
+    ?.filter((e) => e.__$$element === "correlationProperty" && e["@_type"] === 
itemDefinitionId)
+    .forEach((property) => {
+      if (property.__$$element === "correlationProperty") {
+        property["@_type"] = undefined;
+      }
+    });
+}
+
+export function deleteUnusedItemDefinitions({ definitions }: { definitions: 
Normalized<BPMN20__tDefinitions> }) {
+  definitions.rootElement ??= [];
+
+  const defaultDataTypes = new Set(Object.values(DEFAULT_DATA_TYPES));
+
+  const defaultItemDefinitions = definitions.rootElement.filter(
+    (e) =>
+      e.__$$element === "itemDefinition" &&
+      e["@_id"] &&
+      e["@_id"] !== RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES &&
+      e["@_structureRef"] &&
+      defaultDataTypes.has(e["@_structureRef"])
+  );
+
+  if (defaultItemDefinitions.length === 0) {
+    return;
+  }
+
+  const defaultItemDefinitionIds = new Set(
+    defaultItemDefinitions.map((def) => def["@_id"]).filter((id): id is string 
=> !!id)
+  );
+  const usedItemDefinitionIds = new Set<string>();
+
+  const addItemDefinitionIfUsed = (id: string | undefined) => {
+    if (id && defaultItemDefinitionIds.has(id)) {
+      usedItemDefinitionIds.add(id);
+    }
+  };
+
+  definitions.rootElement.forEach((element) => {
+    if (element.__$$element === "message") {
+      addItemDefinitionIfUsed(element["@_itemRef"]);
+    } else if (element.__$$element === "correlationProperty") {
+      addItemDefinitionIfUsed(element["@_type"]);
+    } else if (element.__$$element === "dataStore") {
+      addItemDefinitionIfUsed(element["@_itemSubjectRef"]);
+    }
+  });
+
+  const { process } = addOrGetProcessAndDiagramElements({ definitions });
+
+  process.property?.forEach((property) => {
+    addItemDefinitionIfUsed(property["@_itemSubjectRef"]);
+  });
+
+  visitFlowElementsAndArtifacts(process, ({ array, index }) => {
+    const element = array[index];
+
+    if (element.__$$element === "dataObject") {
+      addItemDefinitionIfUsed(element["@_itemSubjectRef"]);
+    } else if (element.__$$element === "dataObjectReference") {
+      addItemDefinitionIfUsed(element["@_itemSubjectRef"]);
+    } else if (element.__$$element === "dataStoreReference") {
+      addItemDefinitionIfUsed(element["@_itemSubjectRef"]);
+    } else if (
+      element.__$$element === "businessRuleTask" ||
+      element.__$$element === "callActivity" ||
+      element.__$$element === "serviceTask" ||
+      element.__$$element === "userTask"
+    ) {
+      element.ioSpecification?.dataInput?.forEach((dataInput) => {
+        addItemDefinitionIfUsed(dataInput["@_itemSubjectRef"]);
+      });
+      element.ioSpecification?.dataOutput?.forEach((dataOutput) => {
+        addItemDefinitionIfUsed(dataOutput["@_itemSubjectRef"]);
+      });
+    } else if (element.__$$element === "endEvent" || element.__$$element === 
"intermediateThrowEvent") {
+      element.dataInput?.forEach((dataInput) => {
+        addItemDefinitionIfUsed(dataInput["@_itemSubjectRef"]);
+      });
+    } else if (
+      element.__$$element === "startEvent" ||
+      element.__$$element === "intermediateCatchEvent" ||
+      element.__$$element === "boundaryEvent"
+    ) {
+      element.dataOutput?.forEach((dataOutput) => {
+        addItemDefinitionIfUsed(dataOutput["@_itemSubjectRef"]);
+      });
+    }
+  });
+
+  definitions.rootElement = definitions.rootElement.filter((e) => {
+    if (e.__$$element === "itemDefinition" && e["@_id"] && 
defaultItemDefinitionIds.has(e["@_id"])) {
+      return usedItemDefinitionIds.has(e["@_id"]);
+    }
+    return true;
+  });
 }
diff --git a/packages/bpmn-editor/src/mutations/deleteMessage.ts 
b/packages/bpmn-editor/src/mutations/deleteMessage.ts
index 02cd35adcfb..ec685cbb6f2 100644
--- a/packages/bpmn-editor/src/mutations/deleteMessage.ts
+++ b/packages/bpmn-editor/src/mutations/deleteMessage.ts
@@ -21,6 +21,7 @@ import { BPMN20__tDefinitions } from 
"@kie-tools/bpmn-marshaller/dist/schemas/bp
 import { Normalized } from "../normalization/normalize";
 import { visitFlowElementsAndArtifacts } from "./_elementVisitor";
 import { addOrGetProcessAndDiagramElements } from 
"./addOrGetProcessAndDiagramElements";
+import { RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES } from "./addOrGetMessages";
 
 export function deleteMessage({
   definitions,
@@ -41,6 +42,29 @@ export function deleteMessage({
   // Delete from root element
   definitions.rootElement?.splice(existingMessageIndex, 1);
 
+  const remainingMessages = definitions.rootElement?.filter((s) => 
s.__$$element === "message") ?? [];
+
+  const hasMessagesUsingReservedItemDef = remainingMessages.some(
+    (msg) => msg.__$$element === "message" && msg["@_itemRef"] === 
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+  );
+  if (!hasMessagesUsingReservedItemDef) {
+    const itemDefinitionIndex = definitions.rootElement?.findIndex(
+      (s) => s.__$$element === "itemDefinition" && s["@_id"] === 
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+    );
+    if (itemDefinitionIndex !== undefined && itemDefinitionIndex >= 0) {
+      definitions.rootElement?.splice(itemDefinitionIndex, 1);
+    }
+  }
+
+  definitions.rootElement
+    ?.filter((e) => e.__$$element === "correlationProperty")
+    .forEach((property) => {
+      if (property.__$$element === "correlationProperty") {
+        property.correlationPropertyRetrievalExpression =
+          property.correlationPropertyRetrievalExpression?.filter((cpre) => 
cpre["@_messageRef"] !== messageId) ?? [];
+      }
+    });
+
   const { process } = addOrGetProcessAndDiagramElements({ definitions });
 
   // Delete from all flow elements
diff --git 
a/packages/bpmn-editor/src/mutations/deleteOrphanedCorrelationSubscriptions.ts 
b/packages/bpmn-editor/src/mutations/deleteOrphanedCorrelationSubscriptions.ts
new file mode 100644
index 00000000000..1c655b1b09d
--- /dev/null
+++ 
b/packages/bpmn-editor/src/mutations/deleteOrphanedCorrelationSubscriptions.ts
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { BPMN20__tDefinitions } from 
"@kie-tools/bpmn-marshaller/dist/schemas/bpmn-2_0/ts-gen/types";
+import { Normalized } from "../normalization/normalize";
+import { addOrGetProcessAndDiagramElements } from 
"./addOrGetProcessAndDiagramElements";
+
+export function deleteOrphanedCorrelationSubscriptions({
+  definitions,
+}: {
+  definitions: Normalized<BPMN20__tDefinitions>;
+}) {
+  const { process } = addOrGetProcessAndDiagramElements({ definitions });
+
+  if (!process.correlationSubscription || 
process.correlationSubscription.length === 0) {
+    return;
+  }
+
+  const validCorrelationKeyIds = new Set<string>();
+  definitions.rootElement
+    ?.filter((e) => e.__$$element === "collaboration")
+    .forEach((collaboration) => {
+      if (collaboration.__$$element === "collaboration") {
+        collaboration.correlationKey?.forEach((key) => {
+          if (key["@_id"]) {
+            validCorrelationKeyIds.add(key["@_id"]);
+          }
+        });
+      }
+    });
+
+  const validCorrelationPropertyIds = new Set<string>();
+  definitions.rootElement
+    ?.filter((e) => e.__$$element === "correlationProperty")
+    .forEach((property) => {
+      if (property.__$$element === "correlationProperty" && property["@_id"]) {
+        validCorrelationPropertyIds.add(property["@_id"]);
+      }
+    });
+
+  const cleanedSubscriptions = [];
+
+  for (const subscription of process.correlationSubscription) {
+    const correlationKeyRef = subscription["@_correlationKeyRef"];
+
+    if (!correlationKeyRef || !validCorrelationKeyIds.has(correlationKeyRef)) {
+      continue;
+    }
+
+    if (subscription.correlationPropertyBinding) {
+      subscription.correlationPropertyBinding = 
subscription.correlationPropertyBinding.filter((binding) => {
+        const propertyRef = binding["@_correlationPropertyRef"];
+        return propertyRef && validCorrelationPropertyIds.has(propertyRef);
+      });
+    }
+
+    if (subscription.correlationPropertyBinding && 
subscription.correlationPropertyBinding.length > 0) {
+      cleanedSubscriptions.push(subscription);
+    }
+  }
+
+  process.correlationSubscription = cleanedSubscriptions;
+}
diff --git a/packages/bpmn-editor/src/mutations/renameMessage.ts 
b/packages/bpmn-editor/src/mutations/renameMessage.ts
index fb84d56b58c..138cf1ddc8e 100644
--- a/packages/bpmn-editor/src/mutations/renameMessage.ts
+++ b/packages/bpmn-editor/src/mutations/renameMessage.ts
@@ -51,7 +51,6 @@ export function renameMessage({
     "message"
   >;
   message["@_name"] = newMessageName;
-  message["@_itemRef"] = `${newMessageName}Type`;
 
   const { process } = addOrGetProcessAndDiagramElements({ definitions });
 
diff --git a/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx 
b/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
index f602cf541ad..38cbc78478e 100644
--- a/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
+++ b/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
@@ -259,7 +259,19 @@ export function GlobalProperties() {
                         const { process } = addOrGetProcessAndDiagramElements({
                           definitions: state.bpmn.model.definitions,
                         });
+                        const oldProcessId = process["@_id"];
                         process["@_id"] = newId;
+                        const collaboration = 
state.bpmn.model.definitions.rootElement?.find(
+                          (e) => e.__$$element === "collaboration"
+                        );
+                        if (collaboration && collaboration.__$$element === 
"collaboration") {
+                          const participant = collaboration.participant?.find(
+                            (p) => p["@_processRef"] === oldProcessId
+                          );
+                          if (participant) {
+                            participant["@_processRef"] = newId;
+                          }
+                        }
                       });
                     }}
                     aria-describedby="process-id-helper"
diff --git 
a/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx 
b/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
index 737a1be730b..fc5aabc0160 100644
--- a/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
+++ b/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
@@ -60,6 +60,8 @@ import {
 } from "../itemDefinitionRefSelector/ItemDefinitionRefSelector";
 import { MessageSelector } from "../messageSelector/MessageSelector";
 import TimesIcon from "@patternfly/react-icons/dist/js/icons/times-icon";
+import { deleteUnusedItemDefinitions } from 
"../../mutations/deleteItemDefinition";
+import { deleteOrphanedCorrelationSubscriptions } from 
"../../mutations/deleteOrphanedCorrelationSubscriptions";
 import "./Correlations.css";
 import { useBpmnEditorI18n } from "../../i18n";
 
@@ -183,6 +185,24 @@ export function Correlations() {
 
         if (property) {
           property["@_type"] = newItemDefinitionRef;
+          property.correlationPropertyRetrievalExpression.forEach((cpre) => {
+            if (cpre.messagePath) {
+              cpre.messagePath["@_evaluatesToTypeRef"] = newItemDefinitionRef;
+            }
+          });
+
+          const { process } = addOrGetProcessAndDiagramElements({ definitions: 
s.bpmn.model.definitions });
+          process.correlationSubscription?.forEach((subscription) => {
+            subscription.correlationPropertyBinding
+              ?.filter((binding) => binding["@_correlationPropertyRef"] === 
selectedPropertyId)
+              .forEach((binding) => {
+                if (binding.dataPath) {
+                  binding.dataPath["@_evaluatesToTypeRef"] = 
newItemDefinitionRef;
+                }
+              });
+          });
+
+          deleteUnusedItemDefinitions({ definitions: s.bpmn.model.definitions 
});
         }
       });
     },
@@ -210,6 +230,25 @@ export function Correlations() {
         s.bpmn.model.definitions.rootElement = 
s.bpmn.model.definitions.rootElement?.filter(
           (e) => e["@_id"] !== propertyId
         );
+
+        s.bpmn.model.definitions.rootElement
+          ?.filter((e) => e.__$$element === "collaboration")
+          .forEach((collaboration) => {
+            if (collaboration.__$$element === "collaboration") {
+              collaboration.correlationKey?.forEach((key) => {
+                if (key.correlationPropertyRef) {
+                  key.correlationPropertyRef = 
key.correlationPropertyRef.filter(
+                    (propRef) => propRef.__$$text !== propertyId
+                  );
+                }
+              });
+              collaboration.correlationKey = 
collaboration.correlationKey?.filter(
+                (key) => key.correlationPropertyRef && 
key.correlationPropertyRef.length > 0
+              );
+            }
+          });
+        deleteOrphanedCorrelationSubscriptions({ definitions: 
s.bpmn.model.definitions });
+        deleteUnusedItemDefinitions({ definitions: s.bpmn.model.definitions });
       });
     },
     [bpmnEditorStoreApi]
@@ -253,15 +292,13 @@ export function Correlations() {
   );
 
   const onChangeMessageBindingMessage = useCallback(
-    (i: number) => (newMessaage: string) => {
+    (i: number) => (newMessageRef: string) => {
       bpmnEditorStoreApi.setState((s) => {
         const property = s.bpmn.model.definitions.rootElement
           ?.filter((p) => p.__$$element === "correlationProperty")
           .find((p) => p["@_id"] === selectedPropertyId);
-
         if (property) {
-          property.correlationPropertyRetrievalExpression ??= [];
-          property.correlationPropertyRetrievalExpression[i]["@_messageRef"] = 
newMessaage;
+          property.correlationPropertyRetrievalExpression[i]["@_messageRef"] = 
newMessageRef || "";
         }
       });
     },
@@ -276,8 +313,8 @@ export function Correlations() {
           .find((p) => p["@_id"] === selectedPropertyId);
 
         if (property) {
-          property.correlationPropertyRetrievalExpression ??= [];
           property.correlationPropertyRetrievalExpression.splice(i, 1);
+          deleteUnusedItemDefinitions({ definitions: s.bpmn.model.definitions 
});
         }
       });
     },
@@ -306,6 +343,7 @@ export function Correlations() {
         if (collaboration) {
           collaboration.correlationKey = 
collaboration.correlationKey?.filter((k) => k["@_id"] !== keyId);
         }
+        deleteOrphanedCorrelationSubscriptions({ definitions: 
s.bpmn.model.definitions });
       });
     },
     [bpmnEditorStoreApi]
@@ -353,17 +391,29 @@ export function Correlations() {
     bpmnEditorStoreApi.setState((s) => {
       const { process } = addOrGetProcessAndDiagramElements({ definitions: 
s.bpmn.model.definitions });
       process.correlationSubscription ??= [];
+      const propertiesById = new Map(
+        (s.bpmn.model.definitions.rootElement ?? [])
+          .filter((e) => e.__$$element === "correlationProperty")
+          .map((p) => [p["@_id"], p])
+      );
       process.correlationSubscription?.push({
         "@_id": generateUuid(),
         "@_correlationKeyRef": selectedKeyId,
-        correlationPropertyBinding: (selectedKey!.correlationPropertyRef ?? 
[]).map((propRef) => ({
-          "@_id": generateUuid(),
-          "@_correlationPropertyRef": propRef.__$$text,
-          dataPath: {
+        correlationPropertyBinding: (selectedKey!.correlationPropertyRef ?? 
[]).map((propRef) => {
+          const property = propertiesById.get(propRef.__$$text);
+          const propertyType =
+            property && property.__$$element === "correlationProperty" ? 
property["@_type"] : undefined;
+          return {
             "@_id": generateUuid(),
-            __$$text: "",
-          },
-        })),
+            "@_correlationPropertyRef": propRef.__$$text,
+            dataPath: {
+              "@_id": generateUuid(),
+              "@_language": "java",
+              "@_evaluatesToTypeRef": propertyType,
+              __$$text: "",
+            },
+          };
+        }),
       });
     });
   }, [bpmnEditorStoreApi, selectedKey, selectedKeyId]);
@@ -385,9 +435,11 @@ export function Correlations() {
     (propertyIndex: number) => {
       return (e: React.FormEvent) => {
         bpmnEditorStoreApi.setState((s) => {
-          const key = s.bpmn.model.definitions.rootElement
-            ?.find((e) => e.__$$element === "collaboration")
-            ?.correlationKey?.find((k) => k["@_id"] === selectedKeyId);
+          const collaboration = s.bpmn.model.definitions.rootElement?.find((e) 
=> e.__$$element === "collaboration");
+          const key =
+            collaboration && collaboration.__$$element === "collaboration"
+              ? collaboration.correlationKey?.find((k) => k["@_id"] === 
selectedKeyId)
+              : undefined;
 
           if (key) {
             key.correlationPropertyRef ??= [];
@@ -395,13 +447,19 @@ export function Correlations() {
             key.correlationPropertyRef.splice(propertyIndex, 1);
 
             const { process } = addOrGetProcessAndDiagramElements({ 
definitions: s.bpmn.model.definitions });
-            for (const subs of process.correlationSubscription ?? []) {
-              if (subs["@_correlationKeyRef"] === selectedKeyId) {
-                subs.correlationPropertyBinding ??= [];
-                subs.correlationPropertyBinding = 
subs.correlationPropertyBinding.filter(
+            process.correlationSubscription
+              ?.filter((subs) => subs["@_correlationKeyRef"] === selectedKeyId)
+              .forEach((subs) => {
+                subs.correlationPropertyBinding = 
subs.correlationPropertyBinding?.filter(
                   (b) => b["@_correlationPropertyRef"] !== 
removedCorrelationPropertyRef.__$$text
                 );
-              }
+              });
+            if (
+              key.correlationPropertyRef.length === 0 &&
+              collaboration &&
+              collaboration.__$$element === "collaboration"
+            ) {
+              collaboration.correlationKey = 
collaboration.correlationKey?.filter((k) => k["@_id"] !== selectedKeyId);
             }
           }
         });
diff --git 
a/packages/bpmn-editor/src/propertiesPanel/dataMapping/DataMappingFormSection.tsx
 
b/packages/bpmn-editor/src/propertiesPanel/dataMapping/DataMappingFormSection.tsx
index 0e4c13af5b2..0b5e3a6f476 100644
--- 
a/packages/bpmn-editor/src/propertiesPanel/dataMapping/DataMappingFormSection.tsx
+++ 
b/packages/bpmn-editor/src/propertiesPanel/dataMapping/DataMappingFormSection.tsx
@@ -41,6 +41,8 @@ import { ItemDefinitionRefSelector } from 
"../itemDefinitionRefSelector/ItemDefi
 import { VariableSelector } from "../variableSelector/VariableSelector";
 import { ImportIcon } from "@patternfly/react-icons/dist/js/icons/import-icon";
 import { ExportIcon } from "@patternfly/react-icons/dist/js/icons/export-icon";
+import { InfoCircleIcon } from 
"@patternfly/react-icons/dist/js/icons/info-circle-icon";
+import { Tooltip } from "@patternfly/react-core/dist/js/components/Tooltip";
 import {
   DATA_INPUT_RESERVED_NAMES,
   DataMapping,
@@ -380,6 +382,14 @@ export function DataMappingsList({
 
   const [hoveredIndex, setHoveredIndex] = useState<number | 
undefined>(undefined);
 
+  const hasMessageEventDefinition =
+    "eventDefinition" in flowElement
+      ? flowElement.eventDefinition?.some((ed) => ed.__$$element === 
"messageEventDefinition")
+      : false;
+
+  const currentMappings = section === "input" ? inputDataMapping : 
outputDataMapping;
+  const canAddMoreMappings = !hasMessageEventDefinition || 
currentMappings.length === 0;
+
   const { lastColumnLabel, entryTitle } = useMemo(() => {
     if (section === "input") {
       return {
@@ -435,8 +445,15 @@ export function DataMappingsList({
                     variant={ButtonVariant.plain}
                     style={{ paddingLeft: 0 }}
                     onClick={() => addDataMapping(section, { isExpression: 
false })}
+                    isDisabled={!canAddMoreMappings || isReadOnly}
                   >
-                    <PlusCircleIcon 
color="var(--pf-c-button--m-primary--BackgroundColor)" />
+                    <PlusCircleIcon
+                      color={
+                        canAddMoreMappings && !isReadOnly
+                          ? "var(--pf-c-button--m-primary--BackgroundColor)"
+                          : "var(--pf-global--disabled-color--100)"
+                      }
+                    />
                   </Button>
                 </GridItem>
               </Grid>
@@ -470,12 +487,22 @@ export function DataMappingsList({
                         />
                       </GridItem>
                       <GridItem span={3}>
-                        <ItemDefinitionRefSelector
-                          value={itemDefinitionIdByDataTypes.get(entry.dtype)}
-                          onChange={(_, newDataType) => {
-                            handleInputChange(i, "dtype", newDataType!, 
"input", { isExpression: false });
-                          }}
-                        />
+                        <div style={{ display: "flex", alignItems: "center", 
gap: "4px" }}>
+                          <div style={{ flex: 1 }}>
+                            <ItemDefinitionRefSelector
+                              
value={itemDefinitionIdByDataTypes.get(entry.dtype)}
+                              onChange={(_, newDataType) => {
+                                handleInputChange(i, "dtype", newDataType!, 
"input", { isExpression: false });
+                              }}
+                              isDisabled={hasMessageEventDefinition}
+                            />
+                          </div>
+                          {hasMessageEventDefinition && (
+                            <Tooltip 
content={<div>{i18n.dataMapping.messageInfoIconHelperText}</div>}>
+                              <InfoCircleIcon style={{ color: 
"var(--pf-global--info-color--100)" }} />
+                            </Tooltip>
+                          )}
+                        </div>
                       </GridItem>
                       <GridItem span={4}>
                         <VariableSelector
@@ -534,12 +561,22 @@ export function DataMappingsList({
                         />
                       </GridItem>
                       <GridItem span={3}>
-                        <ItemDefinitionRefSelector
-                          value={itemDefinitionIdByDataTypes.get(entry.dtype) 
?? entry.dtype}
-                          onChange={(_, newDataType) => {
-                            handleInputChange(i, "dtype", newDataType!, 
"output", { isExpression: false });
-                          }}
-                        />
+                        <div style={{ display: "flex", alignItems: "center", 
gap: "4px" }}>
+                          <div style={{ flex: 1 }}>
+                            <ItemDefinitionRefSelector
+                              
value={itemDefinitionIdByDataTypes.get(entry.dtype) ?? entry.dtype}
+                              onChange={(_, newDataType) => {
+                                handleInputChange(i, "dtype", newDataType!, 
"output", { isExpression: false });
+                              }}
+                              isDisabled={hasMessageEventDefinition}
+                            />
+                          </div>
+                          {hasMessageEventDefinition && (
+                            <Tooltip 
content={<div>{i18n.dataMapping.messageInfoIconHelperText}</div>}>
+                              <InfoCircleIcon style={{ color: 
"var(--pf-global--info-color--100)" }} />
+                            </Tooltip>
+                          )}
+                        </div>
                       </GridItem>
                       <GridItem span={4}>
                         <VariableSelector
@@ -667,9 +704,42 @@ export function useDataMapping(
 
   const addDataMapping = useCallback(
     (section: "input" | "output", { isExpression }: { isExpression: boolean }) 
=> {
+      let initialDataType = "";
+
+      const isMessageEvent =
+        "eventDefinition" in element &&
+        element.eventDefinition?.some((ed) => ed.__$$element === 
"messageEventDefinition");
+
+      if (isMessageEvent && "eventDefinition" in element) {
+        const messageEventDef = element.eventDefinition?.find((ed) => 
ed.__$$element === "messageEventDefinition");
+        if (messageEventDef && messageEventDef.__$$element === 
"messageEventDefinition") {
+          const messageRef = messageEventDef["@_messageRef"];
+          if (messageRef) {
+            const message = bpmnEditorStoreApi
+              .getState()
+              .bpmn.model.definitions.rootElement?.find(
+                (el) => el.__$$element === "message" && el["@_id"] === 
messageRef
+              );
+            if (message && message.__$$element === "message") {
+              const itemDefId = message["@_itemRef"];
+              if (itemDefId) {
+                const itemDef = bpmnEditorStoreApi
+                  .getState()
+                  .bpmn.model.definitions.rootElement?.find(
+                    (el) => el.__$$element === "itemDefinition" && el["@_id"] 
=== itemDefId
+                  );
+                if (itemDef && itemDef.__$$element === "itemDefinition") {
+                  initialDataType = itemDef["@_structureRef"] || "";
+                }
+              }
+            }
+          }
+        }
+      }
+
       const newDataMapping: DataMapping = isExpression
-        ? { name: "", dtype: "", isExpression: true, value: "" }
-        : { name: "", dtype: "", isExpression: false, variableRef: undefined };
+        ? { name: "", dtype: initialDataType, isExpression: true, value: "" }
+        : { name: "", dtype: initialDataType, isExpression: false, 
variableRef: undefined };
 
       if (section === "input") {
         setInputDataMapping([...inputDataMapping, newDataMapping]);
@@ -677,7 +747,7 @@ export function useDataMapping(
         setOutputDataMapping([...outputDataMapping, newDataMapping]);
       }
     },
-    [inputDataMapping, outputDataMapping]
+    [inputDataMapping, outputDataMapping, element, bpmnEditorStoreApi]
   );
 
   const removeDataMapping = useCallback(
diff --git 
a/packages/bpmn-editor/src/propertiesPanel/eventDefinition/EventDefinitionProperties.tsx
 
b/packages/bpmn-editor/src/propertiesPanel/eventDefinition/EventDefinitionProperties.tsx
index cded8083586..a1c9035a426 100644
--- 
a/packages/bpmn-editor/src/propertiesPanel/eventDefinition/EventDefinitionProperties.tsx
+++ 
b/packages/bpmn-editor/src/propertiesPanel/eventDefinition/EventDefinitionProperties.tsx
@@ -58,12 +58,41 @@ export function EventDefinitionProperties({ event }: { 
event: Event }) {
         const { process } = addOrGetProcessAndDiagramElements({ definitions: 
s.bpmn.model.definitions });
         visitFlowElementsAndArtifacts(process, ({ element: e }) => {
           if (e["@_id"] === event?.["@_id"] && e.__$$element === 
event.__$$element) {
+            const { messageRef: actualMessageRef } = addOrGetMessages({
+              definitions: s.bpmn.model.definitions,
+              messageName: newMessage,
+            });
+
             const messageEventDefinition = e.eventDefinition?.find(
               (event) => event.__$$element === "messageEventDefinition"
             );
             if (messageEventDefinition) {
               messageEventDefinition["@_drools:msgref"] = newMessage;
-              messageEventDefinition["@_messageRef"] = newMessageRef;
+              messageEventDefinition["@_messageRef"] = actualMessageRef;
+            }
+
+            const message = s.bpmn.model.definitions.rootElement?.find(
+              (el) => el.__$$element === "message" && el["@_id"] === 
actualMessageRef
+            );
+
+            if (message && message.__$$element === "message" && 
message["@_itemRef"]) {
+              const itemDef = s.bpmn.model.definitions.rootElement?.find(
+                (el) => el.__$$element === "itemDefinition" && el["@_id"] === 
message["@_itemRef"]
+              );
+              const messageDataType =
+                itemDef && itemDef.__$$element === "itemDefinition" ? 
itemDef["@_structureRef"] || "" : "";
+
+              if ("dataInput" in e && e.dataInput) {
+                e.dataInput.forEach((dataInput) => {
+                  dataInput["@_drools:dtype"] = messageDataType;
+                });
+              }
+
+              if ("dataOutput" in e && e.dataOutput) {
+                e.dataOutput.forEach((dataOutput) => {
+                  dataOutput["@_drools:dtype"] = messageDataType;
+                });
+              }
             }
           }
         });
diff --git 
a/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
 
b/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
index 40994c12f88..10f2fafb1d7 100644
--- 
a/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
+++ 
b/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
@@ -42,9 +42,11 @@ export type OnChangeItemDefinitionRefSelector = (
 export function ItemDefinitionRefSelector({
   value,
   onChange,
+  isDisabled,
 }: {
   value: string | undefined;
   onChange: OnChangeItemDefinitionRefSelector;
+  isDisabled?: boolean;
 }) {
   const { i18n } = useBpmnEditorI18n();
   const isReadOnly = useBpmnEditorStore((s) => s.settings.isReadOnly);
@@ -132,15 +134,25 @@ export function ItemDefinitionRefSelector({
   const v = selectedDataType ? 
itemDefinitionsByDataType.get(selectedDataType)?.itemDefinitionRef : undefined;
 
   return (
-    <TypeaheadSelect
-      isMultiple={false}
-      isDisabled={isReadOnly}
-      id={`kie-bpmn-editor--item-definition-ref-selector--${id}`}
-      selected={v}
-      setSelected={_onChange}
-      options={options}
-      onCreateNewOption={(newOptionLabel) => addOrGetItemDefinitionId({ 
newDataType: newOptionLabel })}
-      createNewOptionLabel={i18n.propertiesPanel.createDataType as string}
-    />
+    <div
+      style={{
+        ...(isDisabled && {
+          backgroundColor: "var(--pf-global--disabled-color--300)",
+          borderRadius: "3px",
+          opacity: 0.6,
+        }),
+      }}
+    >
+      <TypeaheadSelect
+        isMultiple={false}
+        isDisabled={isDisabled ?? isReadOnly}
+        id={`kie-bpmn-editor--item-definition-ref-selector--${id}`}
+        selected={v}
+        setSelected={_onChange}
+        options={options}
+        onCreateNewOption={(newOptionLabel) => addOrGetItemDefinitionId({ 
newDataType: newOptionLabel })}
+        createNewOptionLabel={i18n.propertiesPanel.createDataType as string}
+      />
+    </div>
   );
 }
diff --git 
a/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
 
b/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
index 7e38a36bf14..d77bb0e84af 100644
--- 
a/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
+++ 
b/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
@@ -50,9 +50,10 @@ import { addOrGetItemDefinitions, DEFAULT_DATA_TYPES } from 
"../../mutations/add
 import { deleteItemDefinition } from "../../mutations/deleteItemDefinition";
 import { renameItemDefinition } from "../../mutations/renameItemDefinition";
 import { deduplicateItemDefinitions } from "../../normalization/normalize";
-import { addOrGetMessages } from "../../mutations/addOrGetMessages";
+import { addOrGetMessages, RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES } from 
"../../mutations/addOrGetMessages";
 import { renameMessage } from "../../mutations/renameMessage";
 import { deleteMessage } from "../../mutations/deleteMessage";
+import { ItemDefinitionRefSelector } from 
"../itemDefinitionRefSelector/ItemDefinitionRefSelector";
 import { addOrGetSignals } from "../../mutations/addOrGetSignals";
 import { renameSignal } from "../../mutations/renameSignal";
 import { deleteSignal } from "../../mutations/deleteSignal";
@@ -87,7 +88,9 @@ export function PropertiesManager({ p }: { p: undefined | 
WithVariables }) {
   const itemDefinitions = useBpmnEditorStore((s) =>
     s.bpmn.model.definitions.rootElement?.filter((s) => s.__$$element === 
"itemDefinition")
   )?.filter(
-    (s) => Object.values(DEFAULT_DATA_TYPES).findIndex((defaultDataType) => 
defaultDataType === s["@_structureRef"]) < 0
+    (s) =>
+      Object.values(DEFAULT_DATA_TYPES).findIndex((defaultDataType) => 
defaultDataType === s["@_structureRef"]) < 0 &&
+      s["@_id"] !== RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
   );
   const messages = useBpmnEditorStore((s) => {
     const allMessages = s.bpmn.model.definitions.rootElement?.filter((s) => 
s.__$$element === "message") ?? [];
@@ -252,11 +255,16 @@ export function PropertiesManager({ p }: { p: undefined | 
WithVariables }) {
             <>
               <div style={{ padding: "0 8px" }}>
                 <Grid md={12} style={{ alignItems: "center", columnGap: "12px" 
}}>
-                  <GridItem span={11}>
+                  <GridItem span={6}>
                     <div style={entryColumnStyle}>
                       <b>{i18n.propertiesManager.messages}</b>
                     </div>
                   </GridItem>
+                  <GridItem span={5}>
+                    <div style={entryColumnStyle}>
+                      <b>{i18n.dataMapping.dataType}</b>
+                    </div>
+                  </GridItem>
                   <GridItem span={1}>
                     <div style={{ textAlign: "right" }}>
                       {!isReadOnly && (
@@ -285,7 +293,7 @@ export function PropertiesManager({ p }: { p: undefined | 
WithVariables }) {
                     onMouseLeave={() => setHoveredIndex(undefined)}
                     style={{ columnGap: "12px" }}
                   >
-                    <GridItem span={11}>
+                    <GridItem span={6}>
                       <input
                         autoFocus={true}
                         style={entryColumnStyle}
@@ -303,6 +311,73 @@ export function PropertiesManager({ p }: { p: undefined | 
WithVariables }) {
                         }}
                       />
                     </GridItem>
+                    <GridItem span={5}>
+                      <ItemDefinitionRefSelector
+                        value={entry["@_itemRef"]}
+                        onChange={(newItemDefinitionRef) => {
+                          bpmnEditorStoreApi.setState((s) => {
+                            const message = 
s.bpmn.model.definitions.rootElement?.find(
+                              (e) => e.__$$element === "message" && e["@_id"] 
=== entry["@_id"]
+                            );
+
+                            if (message && message.__$$element === "message" 
&& newItemDefinitionRef) {
+                              message["@_itemRef"] = newItemDefinitionRef;
+
+                              const newItemDef = 
s.bpmn.model.definitions.rootElement?.find(
+                                (e) => e.__$$element === "itemDefinition" && 
e["@_id"] === newItemDefinitionRef
+                              );
+                              const newDataType =
+                                newItemDef && newItemDef.__$$element === 
"itemDefinition"
+                                  ? newItemDef["@_structureRef"] || ""
+                                  : "";
+
+                              const process = 
s.bpmn.model.definitions.rootElement?.find(
+                                (e) => e.__$$element === "process"
+                              );
+                              if (process && process.__$$element === 
"process") {
+                                process.flowElement?.forEach((flowElement) => {
+                                  if ("eventDefinition" in flowElement) {
+                                    const messageEventDef = 
flowElement.eventDefinition?.find(
+                                      (ed) =>
+                                        ed.__$$element === 
"messageEventDefinition" &&
+                                        ed["@_messageRef"] === entry["@_id"]
+                                    );
+
+                                    if (messageEventDef) {
+                                      if ("dataInput" in flowElement && 
flowElement.dataInput) {
+                                        
flowElement.dataInput.forEach((dataInput: any) => {
+                                          dataInput["@_drools:dtype"] = 
newDataType;
+                                        });
+                                      }
+
+                                      if ("dataOutput" in flowElement && 
flowElement.dataOutput) {
+                                        
flowElement.dataOutput.forEach((dataOutput: any) => {
+                                          dataOutput["@_drools:dtype"] = 
newDataType;
+                                        });
+                                      }
+                                    }
+                                  }
+                                });
+                              }
+                              const hasMessagesUsingReservedItemDef = 
s.bpmn.model.definitions.rootElement?.some(
+                                (e) =>
+                                  e.__$$element === "message" &&
+                                  e["@_itemRef"] === 
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+                              );
+                              if (!hasMessagesUsingReservedItemDef) {
+                                s.bpmn.model.definitions.rootElement = 
s.bpmn.model.definitions.rootElement?.filter(
+                                  (e) =>
+                                    !(
+                                      e.__$$element === "itemDefinition" &&
+                                      e["@_id"] === 
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+                                    )
+                                );
+                              }
+                            }
+                          });
+                        }}
+                      />
+                    </GridItem>
                     <GridItem span={1} style={{ textAlign: "right" }}>
                       {hoveredIndex === i && (
                         <Button


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to