2015-02-02 13:46:21 +00:00
|
|
|
'use strict';
|
2014-10-06 10:23:22 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
var assign = require('lodash/object/assign');
|
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
|
|
|
*/
|
2016-04-13 10:36:19 +00:00
|
|
|
function PaletteProvider(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);
|
|
|
|
}
|
|
|
|
|
2014-11-17 10:01:07 +00:00
|
|
|
module.exports = PaletteProvider;
|
2014-10-06 10:23:22 +00:00
|
|
|
|
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
|
|
|
|
2015-03-31 13:02:04 +00:00
|
|
|
var actions = {},
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-05-11 15:36:01 +00:00
|
|
|
var shortType = type.replace(/^bpmn\:/, '');
|
|
|
|
|
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
|
|
|
|
2015-03-31 13:02:04 +00:00
|
|
|
function createParticipant(event, collapsed) {
|
|
|
|
create.start(event, elementFactory.createParticipantShape(collapsed));
|
|
|
|
}
|
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(
|
2015-11-16 14:28:18 +00:00
|
|
|
'bpmn:StartEvent', 'event', 'bpmn-icon-start-event-none'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
2016-04-25 12:47:51 +00:00
|
|
|
'create.intermediate-event': createAction('bpmn:IntermediateThrowEvent', 'event',
|
|
|
|
'bpmn-icon-intermediate-event-none', translate('Create IntermediateThrowEvent/BoundaryEvent')
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.end-event': createAction(
|
2015-11-16 14:28:18 +00:00
|
|
|
'bpmn:EndEvent', 'event', 'bpmn-icon-end-event-none'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.exclusive-gateway': createAction(
|
2015-11-16 14:28:18 +00:00
|
|
|
'bpmn:ExclusiveGateway', 'gateway', 'bpmn-icon-gateway-xor'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.task': createAction(
|
2015-11-16 14:28:18 +00:00
|
|
|
'bpmn:Task', 'activity', 'bpmn-icon-task'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
2015-10-06 10:33:21 +00:00
|
|
|
'create.data-object': createAction(
|
2015-11-16 14:28:18 +00:00
|
|
|
'bpmn:DataObjectReference', 'data-object', 'bpmn-icon-data-object'
|
2015-10-06 10:33:21 +00:00
|
|
|
),
|
2016-01-25 20:29:16 +00:00
|
|
|
'create.data-store': createAction(
|
|
|
|
'bpmn:DataStoreReference', 'data-store', 'bpmn-icon-data-store'
|
|
|
|
),
|
2014-12-07 12:08:50 +00:00
|
|
|
'create.subprocess-expanded': createAction(
|
2016-02-25 16:40:56 +00:00
|
|
|
'bpmn:SubProcess', 'activity', 'bpmn-icon-subprocess-expanded', translate('Create expanded SubProcess'),
|
2014-12-07 12:08:50 +00:00
|
|
|
{ isExpanded: true }
|
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
|
|
|
|
}
|
|
|
|
}
|
2014-10-06 10:23:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return actions;
|
2015-02-26 15:19:34 +00:00
|
|
|
};
|