You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.2 KiB
67 lines
1.2 KiB
import { is } from '../../util/ModelUtil'; |
|
|
|
function getLabelAttr(semantic) { |
|
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') |
|
) { |
|
return 'name'; |
|
} |
|
|
|
if (is(semantic, 'bpmn:TextAnnotation')) { |
|
return 'text'; |
|
} |
|
|
|
if (is(semantic, 'bpmn:Group')) { |
|
return 'categoryValueRef'; |
|
} |
|
} |
|
|
|
function getCategoryValue(semantic) { |
|
var categoryValueRef = semantic['categoryValueRef']; |
|
|
|
if (!categoryValueRef) { |
|
return ''; |
|
} |
|
|
|
|
|
return categoryValueRef.value || ''; |
|
} |
|
|
|
export function getLabel(element) { |
|
var semantic = element.businessObject, |
|
attr = getLabelAttr(semantic); |
|
|
|
if (attr) { |
|
|
|
if (attr === 'categoryValueRef') { |
|
|
|
return getCategoryValue(semantic); |
|
} |
|
|
|
return semantic[attr] || ''; |
|
} |
|
} |
|
|
|
|
|
export function setLabel(element, text, isExternal) { |
|
var semantic = element.businessObject, |
|
attr = getLabelAttr(semantic); |
|
|
|
if (attr) { |
|
|
|
if (attr === 'categoryValueRef') { |
|
semantic['categoryValueRef'].value = text; |
|
} else { |
|
semantic[attr] = text; |
|
} |
|
|
|
} |
|
|
|
return element; |
|
} |