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