import { assign, forEach, isArray } from 'min-dash'
import { is } from 'bpmn-js/lib/util/ModelUtil'
import { isExpanded, isEventSubProcess } from 'bpmn-js/lib/util/DiUtil'
import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil'
import { getChildLanes } from 'bpmn-js/lib/features/modeling/util/LaneUtil'
import { hasPrimaryModifier } from 'diagram-js/lib/util/Mouse'
/**
* A provider for BPMN 2.0 elements context pad
*/
export default function ContextPadProvider(
config,
injector,
eventBus,
contextPad,
modeling,
elementFactory,
connect,
create,
popupMenu,
canvas,
rules,
translate
) {
config = config || {}
contextPad.registerProvider(this)
this._contextPad = contextPad
this._modeling = modeling
this._elementFactory = elementFactory
this._connect = connect
this._create = create
this._popupMenu = popupMenu
this._canvas = canvas
this._rules = rules
this._translate = translate
if (config.autoPlace !== false) {
this._autoPlace = injector.get('autoPlace', false)
}
eventBus.on('create.end', 250, function (event) {
const context = event.context,
shape = context.shape
if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
return
}
const entries = contextPad.getEntries(shape)
if (entries.replace) {
entries.replace.action.click(event, shape)
}
})
}
ContextPadProvider.$inject = [
'config.contextPad',
'injector',
'eventBus',
'contextPad',
'modeling',
'elementFactory',
'connect',
'create',
'popupMenu',
'canvas',
'rules',
'translate',
'elementRegistry'
]
ContextPadProvider.prototype.getContextPadEntries = function (element) {
const contextPad = this._contextPad,
modeling = this._modeling,
elementFactory = this._elementFactory,
connect = this._connect,
create = this._create,
popupMenu = this._popupMenu,
canvas = this._canvas,
rules = this._rules,
autoPlace = this._autoPlace,
translate = this._translate
const actions = {}
if (element.type === 'label') {
return actions
}
const businessObject = element.businessObject
function startConnect(event, element) {
connect.start(event, element)
}
function removeElement() {
modeling.removeElements([element])
}
function getReplaceMenuPosition(element) {
const Y_OFFSET = 5
const diagramContainer = canvas.getContainer(),
pad = contextPad.getPad(element).html
const diagramRect = diagramContainer.getBoundingClientRect(),
padRect = pad.getBoundingClientRect()
const top = padRect.top - diagramRect.top
const left = padRect.left - diagramRect.left
const pos = {
x: left,
y: top + padRect.height + Y_OFFSET
}
return pos
}
/**
* Create an append action
*
* @param {string} type
* @param {string} className
* @param {string} [title]
* @param {Object} [options]
*
* @return {Object} descriptor
*/
function appendAction(type, className, title, options) {
if (typeof title !== 'string') {
options = title
title = translate('Append {type}', { type: type.replace(/^bpmn:/, '') })
}
function appendStart(event, element) {
const shape = elementFactory.createShape(assign({ type: type }, options))
create.start(event, shape, {
source: element
})
}
const append = autoPlace
? function (event, element) {
const shape = elementFactory.createShape(assign({ type: type }, options))
autoPlace.append(element, shape)
}
: appendStart
return {
group: 'model',
className: className,
title: title,
action: {
dragstart: appendStart,
click: append
}
}
}
function splitLaneHandler(count) {
return function (event, element) {
// actual split
modeling.splitLane(element, count)
// refresh context pad after split to
// get rid of split icons
contextPad.open(element, true)
}
}
if (isAny(businessObject, ['bpmn:Lane', 'bpmn:Participant']) && isExpanded(businessObject)) {
const childLanes = getChildLanes(element)
assign(actions, {
'lane-insert-above': {
group: 'lane-insert-above',
className: 'bpmn-icon-lane-insert-above',
title: translate('Add Lane above'),
action: {
click: function (event, element) {
modeling.addLane(element, 'top')
}
}
}
})
if (childLanes.length < 2) {
if (element.height >= 120) {
assign(actions, {
'lane-divide-two': {
group: 'lane-divide',
className: 'bpmn-icon-lane-divide-two',
title: translate('Divide into two Lanes'),
action: {
click: splitLaneHandler(2)
}
}
})
}
if (element.height >= 180) {
assign(actions, {
'lane-divide-three': {
group: 'lane-divide',
className: 'bpmn-icon-lane-divide-three',
title: translate('Divide into three Lanes'),
action: {
click: splitLaneHandler(3)
}
}
})
}
}
assign(actions, {
'lane-insert-below': {
group: 'lane-insert-below',
className: 'bpmn-icon-lane-insert-below',
title: translate('Add Lane below'),
action: {
click: function (event, element) {
modeling.addLane(element, 'bottom')
}
}
}
})
}
if (is(businessObject, 'bpmn:FlowNode')) {
if (is(businessObject, 'bpmn:EventBasedGateway')) {
assign(actions, {
'append.receive-task': appendAction(
'bpmn:ReceiveTask',
'bpmn-icon-receive-task',
translate('Append ReceiveTask')
),
'append.message-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-message',
translate('Append MessageIntermediateCatchEvent'),
{ eventDefinitionType: 'bpmn:MessageEventDefinition' }
),
'append.timer-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-timer',
translate('Append TimerIntermediateCatchEvent'),
{ eventDefinitionType: 'bpmn:TimerEventDefinition' }
),
'append.condition-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-condition',
translate('Append ConditionIntermediateCatchEvent'),
{ eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
),
'append.signal-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-signal',
translate('Append SignalIntermediateCatchEvent'),
{ eventDefinitionType: 'bpmn:SignalEventDefinition' }
)
})
} else if (
isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')
) {
assign(actions, {
'append.compensation-activity': appendAction(
'bpmn:Task',
'bpmn-icon-task',
translate('Append compensation activity'),
{
isForCompensation: true
}
)
})
} else if (
!is(businessObject, 'bpmn:EndEvent') &&
!businessObject.isForCompensation &&
!isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
!isEventSubProcess(businessObject)
) {
assign(actions, {
'append.end-event': appendAction(
'bpmn:EndEvent',
'bpmn-icon-end-event-none',
translate('Append EndEvent')
),
'append.gateway': appendAction(
'bpmn:ExclusiveGateway',
'bpmn-icon-gateway-none',
translate('Append Gateway')
wjs2024
- 粉丝: 2424
- 资源: 5546
最新资源
- 单相LCL并网逆变器电容电流前馈与电网电压全前馈的谐波抑制 1MATLAB仿真 2效果非常好,可以在电网电压畸变情况下输出正弦电流 3matlab2019a及以上版本可用 共五种工况:
- 反激式开关电源全套设计资料 反激变压器参数自动计算,连续模式CCM,断续模式DCM, 变压器参数计算 原边匝数计算 副
- 汇川三轴示教 可编程 触摸屏程序 自己买来学习的 功能强大 触摸屏 PLC 程序 汇川H5U与 mcgs触摸屏简易示教系统,支持离线仿真 有较好的学习性,可以在源码基础上任意修改
- 指令表运动控制软件框架Demo 1.支持多程序增删改; 2.主程序可调用子程序运行; 3.工程文件可加载,保存,另存为; 4.含仿真界面窗口; 5.目前适配雷赛总线DMC-E3032控制卡为例子,其
- 90°塑料无缝链板转弯机sw16可编辑全套技术资料100%好用.zip
- MATLAB、PSasp、PowerWorld电力系统仿真建模分析 潮流(局部地区电网的建模,再潮流) 暂稳(对应上述潮流过程) 短路、稳定性计算等 新能源光伏建模,可大规模 新能源风电场建模,可大规
- 9060B手动喷砂机sw14可编辑全套技术资料100%好用.zip
- 分布式驱动电动汽车模糊直接横摆力矩控制 1.软件: MATLAB 2018以上;CarSim 2020.0 2.介绍: 选择(直接横摆力矩控制)DYC分层控制策略实现车辆控制,上层附加横摆力矩计算采用
- 全差分运放电路电路源文件,包含模块有:折叠共源共栅结构运放,开关电容共模反馈,连续时间共模反馈电路,gainboost增益自举电路,密勒补偿调零,偏执电路,二级结构 指标大致如下,增益140dB左右
- Matlab仿真矢量光场之角向偏振光束
- 1860型不锈钢板双面自动喷砂机sw14可编辑全套技术资料100%好用.zip
- 基于DP动态规划的混合动力汽车,P2构型 1.车辆数据来源advisor 2.电池SOC为电量维持型策略 ,52 3.全程序包含逆向迭代和正向寻优过程 4.DP可为后续mpc提供参考,也可将数据
- AGV移动小车-收集洗车污水sw18可编辑全套技术资料100%好用.zip
- IEEEtop期刊lunwen仿真复现 基于双曲-切线LOS制导和有限时间控制的欠驱动船舶路径跟踪 仿真全部资料 包含:全套matlab仿真,配套公式,仿真动图 关键词:无人船,控制,路径跟踪,轨迹跟
- 全桥LLC开环,闭环仿真,以及全套资料(全学会完全够用) 包含硬件设计资料、软件设计资料、环路设计资料、AD原理图、DSP超详细注释代码、物料选型、实验波形等 simulink
- AI组装机检测stp全套技术资料100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈