2018-04-02 21:01:53 +02:00
|
|
|
import {
|
|
|
|
assign
|
|
|
|
} from 'min-dash';
|
|
|
|
|
2014-10-06 12:23:22 +02:00
|
|
|
|
|
|
|
/**
|
2014-11-17 11:01:07 +01:00
|
|
|
* A palette provider for BPMN 2.0 elements.
|
2014-10-06 12:23:22 +02:00
|
|
|
*/
|
2018-04-02 21:01:53 +02:00
|
|
|
export default function PaletteProvider(
|
2018-01-05 14:32:52 +01:00
|
|
|
palette, create, elementFactory,
|
|
|
|
spaceTool, lassoTool, handTool,
|
|
|
|
globalConnect, translate) {
|
2014-10-06 12:23:22 +02:00
|
|
|
|
2016-01-25 14:26:26 +01:00
|
|
|
this._palette = palette;
|
2014-12-07 13:08:50 +01:00
|
|
|
this._create = create;
|
|
|
|
this._elementFactory = elementFactory;
|
2015-04-15 09:43:55 +02:00
|
|
|
this._spaceTool = spaceTool;
|
2015-04-30 17:54:51 +02:00
|
|
|
this._lassoTool = lassoTool;
|
2016-01-25 14:26:26 +01:00
|
|
|
this._handTool = handTool;
|
2016-04-13 12:36:19 +02:00
|
|
|
this._globalConnect = globalConnect;
|
2016-02-25 10:40:56 -06:00
|
|
|
this._translate = translate;
|
2014-10-06 12:23:22 +02:00
|
|
|
|
|
|
|
palette.registerProvider(this);
|
|
|
|
}
|
|
|
|
|
2016-01-25 14:26:26 +01:00
|
|
|
PaletteProvider.$inject = [
|
|
|
|
'palette',
|
|
|
|
'create',
|
|
|
|
'elementFactory',
|
|
|
|
'spaceTool',
|
|
|
|
'lassoTool',
|
2016-02-25 10:40:56 -06:00
|
|
|
'handTool',
|
2016-04-13 12:36:19 +02:00
|
|
|
'globalConnect',
|
|
|
|
'translate'
|
2016-01-25 14:26:26 +01:00
|
|
|
];
|
2014-10-06 12:23:22 +02:00
|
|
|
|
|
|
|
|
2014-11-17 11:01:07 +01:00
|
|
|
PaletteProvider.prototype.getPaletteEntries = function(element) {
|
2014-10-06 12:23:22 +02:00
|
|
|
|
2018-02-27 10:08:31 +01:00
|
|
|
var actions = {},
|
2015-03-31 15:02:04 +02:00
|
|
|
create = this._create,
|
2015-04-15 09:43:55 +02:00
|
|
|
elementFactory = this._elementFactory,
|
2015-04-30 17:54:51 +02:00
|
|
|
spaceTool = this._spaceTool,
|
2016-01-25 14:26:26 +01:00
|
|
|
lassoTool = this._lassoTool,
|
2016-02-25 10:40:56 -06:00
|
|
|
handTool = this._handTool,
|
2016-04-13 12:36:19 +02:00
|
|
|
globalConnect = this._globalConnect,
|
2016-02-25 10:40:56 -06:00
|
|
|
translate = this._translate;
|
2015-03-31 15:02:04 +02:00
|
|
|
|
2014-12-07 13:08:50 +01:00
|
|
|
function createAction(type, group, className, title, options) {
|
2014-12-23 16:48:12 +01:00
|
|
|
|
|
|
|
function createListener(event) {
|
2015-02-02 14:46:21 +01:00
|
|
|
var shape = elementFactory.createShape(assign({ type: type }, options));
|
2014-12-23 16:48:12 +01:00
|
|
|
|
|
|
|
if (options) {
|
|
|
|
shape.businessObject.di.isExpanded = options.isExpanded;
|
|
|
|
}
|
|
|
|
|
|
|
|
create.start(event, shape);
|
|
|
|
}
|
|
|
|
|
2018-01-05 14:32:52 +01:00
|
|
|
var shortType = type.replace(/^bpmn:/, '');
|
2015-05-11 17:36:01 +02:00
|
|
|
|
2014-12-07 13:08:50 +01:00
|
|
|
return {
|
|
|
|
group: group,
|
|
|
|
className: className,
|
2016-02-25 10:40:56 -06:00
|
|
|
title: title || translate('Create {type}', { type: shortType }),
|
2014-12-07 13:08:50 +01:00
|
|
|
action: {
|
2014-12-23 16:48:12 +01:00
|
|
|
dragstart: createListener,
|
|
|
|
click: createListener
|
2014-12-07 13:08:50 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2014-10-06 12:23:22 +02:00
|
|
|
|
2019-08-06 18:57:30 +02:00
|
|
|
function createSubprocess(event) {
|
|
|
|
var subProcess = elementFactory.createShape({
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
isExpanded: true
|
|
|
|
});
|
|
|
|
|
|
|
|
var startEvent = elementFactory.createShape({
|
|
|
|
type: 'bpmn:StartEvent',
|
|
|
|
x: 40,
|
|
|
|
y: 82,
|
|
|
|
parent: subProcess
|
|
|
|
});
|
|
|
|
|
2019-08-08 14:13:56 +02:00
|
|
|
create.start(event, [ subProcess, startEvent ], {
|
|
|
|
hints: {
|
|
|
|
autoSelect: [ startEvent ]
|
|
|
|
}
|
|
|
|
});
|
2019-08-06 18:57:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function createParticipant(event) {
|
|
|
|
create.start(event, elementFactory.createParticipantShape());
|
2015-03-31 15:02:04 +02:00
|
|
|
}
|
2014-10-06 12:23:22 +02:00
|
|
|
|
2015-02-02 14:46:21 +01:00
|
|
|
assign(actions, {
|
2016-01-27 13:10:21 +01:00
|
|
|
'hand-tool': {
|
|
|
|
group: 'tools',
|
|
|
|
className: 'bpmn-icon-hand-tool',
|
2016-02-25 10:40:56 -06:00
|
|
|
title: translate('Activate the hand tool'),
|
2016-01-27 13:10:21 +01:00
|
|
|
action: {
|
|
|
|
click: function(event) {
|
|
|
|
handTool.activateHand(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-05-13 12:09:08 +02:00
|
|
|
'lasso-tool': {
|
2015-04-30 17:54:51 +02:00
|
|
|
group: 'tools',
|
2015-11-16 15:28:18 +01:00
|
|
|
className: 'bpmn-icon-lasso-tool',
|
2016-02-25 10:40:56 -06:00
|
|
|
title: translate('Activate the lasso tool'),
|
2015-04-30 17:54:51 +02:00
|
|
|
action: {
|
|
|
|
click: function(event) {
|
|
|
|
lassoTool.activateSelection(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-04-15 09:43:55 +02:00
|
|
|
'space-tool': {
|
2015-04-30 17:54:51 +02:00
|
|
|
group: 'tools',
|
2015-11-16 15:28:18 +01:00
|
|
|
className: 'bpmn-icon-space-tool',
|
2016-02-25 10:40:56 -06:00
|
|
|
title: translate('Activate the create/remove space tool'),
|
2015-04-15 09:43:55 +02:00
|
|
|
action: {
|
|
|
|
click: function(event) {
|
|
|
|
spaceTool.activateSelection(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-04-13 12:36:19 +02:00
|
|
|
'global-connect-tool': {
|
|
|
|
group: 'tools',
|
|
|
|
className: 'bpmn-icon-connection-multi',
|
|
|
|
title: translate('Activate the global connect tool'),
|
|
|
|
action: {
|
|
|
|
click: function(event) {
|
|
|
|
globalConnect.toggle(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-04-28 11:40:47 +02:00
|
|
|
'tool-separator': {
|
|
|
|
group: 'tools',
|
|
|
|
separator: true
|
|
|
|
},
|
2014-12-07 13:08:50 +01:00
|
|
|
'create.start-event': createAction(
|
2019-05-13 09:47:40 -04:00
|
|
|
'bpmn:StartEvent', 'event', 'bpmn-icon-start-event-none',
|
|
|
|
translate('Create StartEvent')
|
2014-12-07 13:08:50 +01:00
|
|
|
),
|
2018-03-20 11:11:04 +01:00
|
|
|
'create.intermediate-event': createAction(
|
|
|
|
'bpmn:IntermediateThrowEvent', 'event', 'bpmn-icon-intermediate-event-none',
|
|
|
|
translate('Create Intermediate/Boundary Event')
|
2014-12-07 13:08:50 +01:00
|
|
|
),
|
|
|
|
'create.end-event': createAction(
|
2019-05-13 09:47:40 -04:00
|
|
|
'bpmn:EndEvent', 'event', 'bpmn-icon-end-event-none',
|
|
|
|
translate('Create EndEvent')
|
2014-12-07 13:08:50 +01:00
|
|
|
),
|
|
|
|
'create.exclusive-gateway': createAction(
|
2018-03-23 15:05:43 +01:00
|
|
|
'bpmn:ExclusiveGateway', 'gateway', 'bpmn-icon-gateway-none',
|
2018-03-20 11:11:04 +01:00
|
|
|
translate('Create Gateway')
|
2014-12-07 13:08:50 +01:00
|
|
|
),
|
|
|
|
'create.task': createAction(
|
2019-05-13 09:47:40 -04:00
|
|
|
'bpmn:Task', 'activity', 'bpmn-icon-task',
|
|
|
|
translate('Create Task')
|
2014-12-07 13:08:50 +01:00
|
|
|
),
|
2015-10-06 12:33:21 +02:00
|
|
|
'create.data-object': createAction(
|
2019-05-13 09:47:40 -04:00
|
|
|
'bpmn:DataObjectReference', 'data-object', 'bpmn-icon-data-object',
|
|
|
|
translate('Create DataObjectReference')
|
2015-10-06 12:33:21 +02:00
|
|
|
),
|
2016-01-25 21:29:16 +01:00
|
|
|
'create.data-store': createAction(
|
2019-05-13 09:47:40 -04:00
|
|
|
'bpmn:DataStoreReference', 'data-store', 'bpmn-icon-data-store',
|
|
|
|
translate('Create DataStoreReference')
|
2016-01-25 21:29:16 +01:00
|
|
|
),
|
2019-08-06 18:57:30 +02:00
|
|
|
'create.subprocess-expanded': {
|
|
|
|
group: 'activity',
|
|
|
|
className: 'bpmn-icon-subprocess-expanded',
|
|
|
|
title: translate('Create expanded SubProcess'),
|
|
|
|
action: {
|
|
|
|
dragstart: createSubprocess,
|
|
|
|
click: createSubprocess
|
|
|
|
}
|
|
|
|
},
|
2015-03-31 15:02:04 +02:00
|
|
|
'create.participant-expanded': {
|
|
|
|
group: 'collaboration',
|
2015-11-16 15:28:18 +01:00
|
|
|
className: 'bpmn-icon-participant',
|
2016-02-25 10:40:56 -06:00
|
|
|
title: translate('Create Pool/Participant'),
|
2015-03-31 15:02:04 +02:00
|
|
|
action: {
|
|
|
|
dragstart: createParticipant,
|
|
|
|
click: createParticipant
|
|
|
|
}
|
2019-05-08 11:09:06 +02:00
|
|
|
},
|
|
|
|
'create.group': createAction(
|
2019-08-07 16:29:48 +02:00
|
|
|
'bpmn:Group', 'artifact', 'bpmn-icon-group',
|
|
|
|
translate('Create Group')
|
2019-05-08 11:09:06 +02:00
|
|
|
),
|
2014-10-06 12:23:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return actions;
|
2015-02-26 16:19:34 +01:00
|
|
|
};
|