2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
isAny
|
|
|
|
} from '../modeling/util/ModelingUtil';
|
|
|
|
|
2016-04-13 10:36:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extention of GlobalConnect tool that implements BPMN specific rules about
|
|
|
|
* connection start elements.
|
|
|
|
*/
|
2018-04-02 19:01:53 +00:00
|
|
|
export default function BpmnGlobalConnect(globalConnect) {
|
2016-04-13 10:36:19 +00:00
|
|
|
globalConnect.registerProvider(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
BpmnGlobalConnect.$inject = [ 'globalConnect' ];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if given element can be used for starting connection.
|
|
|
|
*
|
|
|
|
* @param {Element} source
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
BpmnGlobalConnect.prototype.canStartConnect = function(source) {
|
|
|
|
|
|
|
|
if (nonExistantOrLabel(source)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var businessObject = source.businessObject;
|
|
|
|
|
|
|
|
return isAny(businessObject, [
|
|
|
|
'bpmn:FlowNode',
|
|
|
|
'bpmn:InteractionNode',
|
|
|
|
'bpmn:DataObjectReference',
|
|
|
|
'bpmn:DataStoreReference'
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function nonExistantOrLabel(element) {
|
|
|
|
return !element || isLabel(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
function isLabel(element) {
|
|
|
|
return element.labelTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|