2018-04-02 19:01:53 +00:00
|
|
|
import { is } from '../../util/ModelUtil';
|
2015-09-08 12:38:50 +00:00
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
function getLabelAttr(semantic) {
|
2019-03-25 15:43:41 +00:00
|
|
|
if (
|
|
|
|
is(semantic, 'bpmn:FlowElement') ||
|
|
|
|
is(semantic, 'bpmn:Participant') ||
|
|
|
|
is(semantic, 'bpmn:Lane') ||
|
|
|
|
is(semantic, 'bpmn:SequenceFlow') ||
|
|
|
|
is(semantic, 'bpmn:MessageFlow') ||
|
|
|
|
is(semantic, 'bpmn:DataInput') ||
|
|
|
|
is(semantic, 'bpmn:DataOutput')
|
|
|
|
) {
|
2014-06-17 09:53:07 +00:00
|
|
|
return 'name';
|
|
|
|
}
|
|
|
|
|
2015-09-08 12:38:50 +00:00
|
|
|
if (is(semantic, 'bpmn:TextAnnotation')) {
|
2014-06-17 09:53:07 +00:00
|
|
|
return 'text';
|
|
|
|
}
|
2019-05-22 06:45:12 +00:00
|
|
|
|
|
|
|
if (is(semantic, 'bpmn:Group')) {
|
|
|
|
return 'categoryValueRef';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCategoryValue(semantic) {
|
|
|
|
var categoryValueRef = semantic['categoryValueRef'];
|
|
|
|
|
|
|
|
if (!categoryValueRef) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return categoryValueRef.value || '';
|
2014-06-17 09:53:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function getLabel(element) {
|
2014-09-08 17:03:39 +00:00
|
|
|
var semantic = element.businessObject,
|
|
|
|
attr = getLabelAttr(semantic);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
if (attr) {
|
2019-05-22 06:45:12 +00:00
|
|
|
|
|
|
|
if (attr === 'categoryValueRef') {
|
|
|
|
|
|
|
|
return getCategoryValue(semantic);
|
|
|
|
}
|
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
return semantic[attr] || '';
|
|
|
|
}
|
2018-04-02 19:01:53 +00:00
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function setLabel(element, text, isExternal) {
|
2014-09-08 17:03:39 +00:00
|
|
|
var semantic = element.businessObject,
|
|
|
|
attr = getLabelAttr(semantic);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
if (attr) {
|
2019-05-22 06:45:12 +00:00
|
|
|
|
|
|
|
if (attr === 'categoryValueRef') {
|
|
|
|
semantic['categoryValueRef'].value = text;
|
|
|
|
} else {
|
|
|
|
semantic[attr] = text;
|
|
|
|
}
|
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
}
|
2014-09-08 17:03:39 +00:00
|
|
|
|
2016-03-03 16:09:43 +00:00
|
|
|
return element;
|
2018-04-02 19:01:53 +00:00
|
|
|
}
|