2015-02-02 13:46:21 +00:00
|
|
|
'use strict';
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2015-09-08 12:38:50 +00:00
|
|
|
var is = require('../../util/ModelUtil').is;
|
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
function getLabelAttr(semantic) {
|
2015-09-08 12:38:50 +00:00
|
|
|
if (is(semantic, 'bpmn:FlowElement') ||
|
|
|
|
is(semantic, 'bpmn:Participant') ||
|
|
|
|
is(semantic, 'bpmn:Lane') ||
|
|
|
|
is(semantic, 'bpmn:SequenceFlow') ||
|
|
|
|
is(semantic, 'bpmn:MessageFlow')) {
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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] || '';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-03-03 16:09:43 +00:00
|
|
|
module.exports.setLabel = function(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) {
|
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
|
|
|
|
2016-03-03 16:09:43 +00:00
|
|
|
// show external label if not empty
|
|
|
|
if (isExternal) {
|
|
|
|
element.hidden = !text;
|
|
|
|
}
|
2014-09-08 17:03:39 +00:00
|
|
|
|
2016-03-03 16:09:43 +00:00
|
|
|
return element;
|
2014-06-17 09:53:07 +00:00
|
|
|
};
|