2015-02-02 13:46:21 +00:00
|
|
|
'use strict';
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
function getLabelAttr(semantic) {
|
|
|
|
if (semantic.$instanceOf('bpmn:FlowElement') ||
|
|
|
|
semantic.$instanceOf('bpmn:Participant') ||
|
|
|
|
semantic.$instanceOf('bpmn:Lane') ||
|
|
|
|
semantic.$instanceOf('bpmn:SequenceFlow') ||
|
|
|
|
semantic.$instanceOf('bpmn:MessageFlow')) {
|
|
|
|
return 'name';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (semantic.$instanceOf('bpmn:TextAnnotation')) {
|
|
|
|
return 'text';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-08 17:03:39 +00:00
|
|
|
module.exports.getLabel = function(element) {
|
|
|
|
var semantic = element.businessObject,
|
|
|
|
attr = getLabelAttr(semantic);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
if (attr) {
|
|
|
|
return semantic[attr] || '';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-09-08 17:03:39 +00:00
|
|
|
module.exports.setLabel = function(element, text) {
|
|
|
|
var semantic = element.businessObject,
|
|
|
|
attr = getLabelAttr(semantic);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
if (attr) {
|
2014-09-08 17:03:39 +00:00
|
|
|
semantic[attr] = text;
|
2014-06-17 09:53:07 +00:00
|
|
|
}
|
2014-09-08 17:03:39 +00:00
|
|
|
|
|
|
|
var label = element.label || element;
|
|
|
|
|
2014-09-09 13:20:30 +00:00
|
|
|
// show label
|
|
|
|
label.hidden = false;
|
2014-09-08 17:03:39 +00:00
|
|
|
|
|
|
|
return label;
|
2014-06-17 09:53:07 +00:00
|
|
|
};
|