提交 | 用户 | 时间
|
820397
|
1 |
import { assign } from 'min-dash' |
H |
2 |
|
|
3 |
/** |
|
4 |
* A palette provider for BPMN 2.0 elements. |
|
5 |
*/ |
|
6 |
export default function PaletteProvider( |
|
7 |
palette, |
|
8 |
create, |
|
9 |
elementFactory, |
|
10 |
spaceTool, |
|
11 |
lassoTool, |
|
12 |
handTool, |
|
13 |
globalConnect, |
|
14 |
translate |
|
15 |
) { |
|
16 |
this._palette = palette |
|
17 |
this._create = create |
|
18 |
this._elementFactory = elementFactory |
|
19 |
this._spaceTool = spaceTool |
|
20 |
this._lassoTool = lassoTool |
|
21 |
this._handTool = handTool |
|
22 |
this._globalConnect = globalConnect |
|
23 |
this._translate = translate |
|
24 |
|
|
25 |
palette.registerProvider(this) |
|
26 |
} |
|
27 |
|
|
28 |
PaletteProvider.$inject = [ |
|
29 |
'palette', |
|
30 |
'create', |
|
31 |
'elementFactory', |
|
32 |
'spaceTool', |
|
33 |
'lassoTool', |
|
34 |
'handTool', |
|
35 |
'globalConnect', |
|
36 |
'translate' |
|
37 |
] |
|
38 |
|
|
39 |
PaletteProvider.prototype.getPaletteEntries = function () { |
|
40 |
const actions = {}, |
|
41 |
create = this._create, |
|
42 |
elementFactory = this._elementFactory, |
|
43 |
spaceTool = this._spaceTool, |
|
44 |
lassoTool = this._lassoTool, |
|
45 |
handTool = this._handTool, |
|
46 |
globalConnect = this._globalConnect, |
|
47 |
translate = this._translate |
|
48 |
|
|
49 |
function createAction(type, group, className, title, options) { |
|
50 |
function createListener(event) { |
|
51 |
const shape = elementFactory.createShape(assign({ type: type }, options)) |
|
52 |
|
|
53 |
if (options) { |
|
54 |
shape.businessObject.di.isExpanded = options.isExpanded |
|
55 |
} |
|
56 |
|
|
57 |
create.start(event, shape) |
|
58 |
} |
|
59 |
|
|
60 |
const shortType = type.replace(/^bpmn:/, '') |
|
61 |
|
|
62 |
return { |
|
63 |
group: group, |
|
64 |
className: className, |
|
65 |
title: title || translate('Create {type}', { type: shortType }), |
|
66 |
action: { |
|
67 |
dragstart: createListener, |
|
68 |
click: createListener |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
function createSubprocess(event) { |
|
74 |
const subProcess = elementFactory.createShape({ |
|
75 |
type: 'bpmn:SubProcess', |
|
76 |
x: 0, |
|
77 |
y: 0, |
|
78 |
isExpanded: true |
|
79 |
}) |
|
80 |
|
|
81 |
const startEvent = elementFactory.createShape({ |
|
82 |
type: 'bpmn:StartEvent', |
|
83 |
x: 40, |
|
84 |
y: 82, |
|
85 |
parent: subProcess |
|
86 |
}) |
|
87 |
|
|
88 |
create.start(event, [subProcess, startEvent], { |
|
89 |
hints: { |
|
90 |
autoSelect: [startEvent] |
|
91 |
} |
|
92 |
}) |
|
93 |
} |
|
94 |
|
|
95 |
function createParticipant(event) { |
|
96 |
create.start(event, elementFactory.createParticipantShape()) |
|
97 |
} |
|
98 |
|
|
99 |
assign(actions, { |
|
100 |
'hand-tool': { |
|
101 |
group: 'tools', |
|
102 |
className: 'bpmn-icon-hand-tool', |
|
103 |
title: translate('Activate the hand tool'), |
|
104 |
action: { |
|
105 |
click: function (event) { |
|
106 |
handTool.activateHand(event) |
|
107 |
} |
|
108 |
} |
|
109 |
}, |
|
110 |
'lasso-tool': { |
|
111 |
group: 'tools', |
|
112 |
className: 'bpmn-icon-lasso-tool', |
|
113 |
title: translate('Activate the lasso tool'), |
|
114 |
action: { |
|
115 |
click: function (event) { |
|
116 |
lassoTool.activateSelection(event) |
|
117 |
} |
|
118 |
} |
|
119 |
}, |
|
120 |
'space-tool': { |
|
121 |
group: 'tools', |
|
122 |
className: 'bpmn-icon-space-tool', |
|
123 |
title: translate('Activate the create/remove space tool'), |
|
124 |
action: { |
|
125 |
click: function (event) { |
|
126 |
spaceTool.activateSelection(event) |
|
127 |
} |
|
128 |
} |
|
129 |
}, |
|
130 |
'global-connect-tool': { |
|
131 |
group: 'tools', |
|
132 |
className: 'bpmn-icon-connection-multi', |
|
133 |
title: translate('Activate the global connect tool'), |
|
134 |
action: { |
|
135 |
click: function (event) { |
|
136 |
globalConnect.toggle(event) |
|
137 |
} |
|
138 |
} |
|
139 |
}, |
|
140 |
'tool-separator': { |
|
141 |
group: 'tools', |
|
142 |
separator: true |
|
143 |
}, |
|
144 |
'create.start-event': createAction( |
|
145 |
'bpmn:StartEvent', |
|
146 |
'event', |
|
147 |
'bpmn-icon-start-event-none', |
|
148 |
translate('Create StartEvent') |
|
149 |
), |
|
150 |
'create.intermediate-event': createAction( |
|
151 |
'bpmn:IntermediateThrowEvent', |
|
152 |
'event', |
|
153 |
'bpmn-icon-intermediate-event-none', |
|
154 |
translate('Create Intermediate/Boundary Event') |
|
155 |
), |
|
156 |
'create.end-event': createAction( |
|
157 |
'bpmn:EndEvent', |
|
158 |
'event', |
|
159 |
'bpmn-icon-end-event-none', |
|
160 |
translate('Create EndEvent') |
|
161 |
), |
|
162 |
'create.exclusive-gateway': createAction( |
|
163 |
'bpmn:ExclusiveGateway', |
|
164 |
'gateway', |
|
165 |
'bpmn-icon-gateway-none', |
|
166 |
translate('Create Gateway') |
|
167 |
), |
|
168 |
'create.user-task': createAction( |
|
169 |
'bpmn:UserTask', |
|
170 |
'activity', |
|
171 |
'bpmn-icon-user-task', |
|
172 |
translate('Create User Task') |
|
173 |
), |
9259c2
|
174 |
'create.service-task': createAction( |
H |
175 |
'bpmn:ServiceTask', |
|
176 |
'activity', |
|
177 |
'bpmn-icon-service', |
|
178 |
translate('Create Service Task') |
|
179 |
), |
820397
|
180 |
'create.data-object': createAction( |
H |
181 |
'bpmn:DataObjectReference', |
|
182 |
'data-object', |
|
183 |
'bpmn-icon-data-object', |
|
184 |
translate('Create DataObjectReference') |
|
185 |
), |
|
186 |
'create.data-store': createAction( |
|
187 |
'bpmn:DataStoreReference', |
|
188 |
'data-store', |
|
189 |
'bpmn-icon-data-store', |
|
190 |
translate('Create DataStoreReference') |
|
191 |
), |
|
192 |
'create.subprocess-expanded': { |
|
193 |
group: 'activity', |
|
194 |
className: 'bpmn-icon-subprocess-expanded', |
|
195 |
title: translate('Create expanded SubProcess'), |
|
196 |
action: { |
|
197 |
dragstart: createSubprocess, |
|
198 |
click: createSubprocess |
|
199 |
} |
|
200 |
}, |
|
201 |
'create.participant-expanded': { |
|
202 |
group: 'collaboration', |
|
203 |
className: 'bpmn-icon-participant', |
|
204 |
title: translate('Create Pool/Participant'), |
|
205 |
action: { |
|
206 |
dragstart: createParticipant, |
|
207 |
click: createParticipant |
|
208 |
} |
|
209 |
}, |
|
210 |
'create.group': createAction( |
|
211 |
'bpmn:Group', |
|
212 |
'artifact', |
|
213 |
'bpmn-icon-group', |
|
214 |
translate('Create Group') |
|
215 |
) |
|
216 |
}) |
|
217 |
|
|
218 |
return actions |
|
219 |
} |