Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue imixs#219
  • Loading branch information
rsoika committed Apr 2, 2023
1 parent 868d977 commit 4204e64
Showing 1 changed file with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
********************************************************************************/
package org.openbpmn.extension;

import java.util.Optional;
import java.util.Set;

import javax.json.JsonArray;
Expand All @@ -30,6 +29,7 @@
import org.openbpmn.bpmn.elements.Event;
import org.openbpmn.bpmn.elements.core.BPMNElement;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.openbpmn.glsp.bpmn.BPMNGNode;
import org.openbpmn.glsp.bpmn.LabelGNode;
import org.openbpmn.glsp.model.BPMNGModelState;
import org.openbpmn.glsp.utils.BPMNGraphUtil;
Expand Down Expand Up @@ -95,9 +95,10 @@ public int getPriority() {
/**
* This method updates the name attribute of a BPMNElement and also the
* corresponding GNode Element in the diagram plane.
*
* <p>
* The method distinguish between LabelGNode elements (multiline) and simple
* The method distinguish between embedded labels (Task) and BPMNLabes.
*
* In case of a LabelGNode elements can support multilineor simple line
* GLabel elements
*
* @param json
Expand All @@ -111,24 +112,32 @@ public void updateNameProperty(final JsonObject json, BPMNElement bpmnElement,
String name = json.getString("name", "");
if (!name.equals(bpmnElement.getName())) {
bpmnElement.setName(name);
// Update Label...
Optional<GModelElement> label = modelState.getIndex().get(gNodeElement.getId() + "_bpmnlabel");
if (!label.isEmpty()) {
GModelElement gModelElement = label.get();
// do we have a BPMN LabelGNode
if (gModelElement instanceof LabelGNode) {
LabelGNode lgn = (LabelGNode) gModelElement;
// update the bpmn-text-node of the GNodeElement
GNode gnode = BPMNGraphUtil.findMultiLineTextNode(lgn);
if (gnode != null) {
gnode.getArgs().put("text", name);
}
if (gNodeElement instanceof BPMNGNode) {
// find MultiLineTextNode used in Tasks and BPMNLabels
GNode gMultiLineTextNode = BPMNGraphUtil.findMultiLineTextNode((BPMNGNode) gNodeElement);
if (gMultiLineTextNode != null) {
gMultiLineTextNode.getArgs().put("text", name);
} else {
// we expect a GLabel
GLabel gLabel = (GLabel) gModelElement;
gLabel.setText(name);
// test if we find a corresponding bpmnLabel (Events, Gateways,...)
GModelElement gModelElement = modelState.getIndex().get(gNodeElement.getId() + "_bpmnlabel")
.orElse(null);
// is it a multiline label?
if (gModelElement != null) {
// do we have a BPMN LabelGNode
if (gModelElement instanceof LabelGNode) {
LabelGNode lgn = (LabelGNode) gModelElement;
// update the bpmn-text-node of the GNodeElement
gMultiLineTextNode = BPMNGraphUtil.findMultiLineTextNode(lgn);
if (gMultiLineTextNode != null) {
gMultiLineTextNode.getArgs().put("text", name);
}
} else {
// default to GLabel
GLabel gLabel = (GLabel) gModelElement;
gLabel.setText(name);
}
}
}

}
}
}
Expand Down

0 comments on commit 4204e64

Please sign in to comment.