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
|
|
|
*/
|
2015-04-30 15:54:51 +00:00
|
|
|
function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool) {
|
2014-10-06 10:23:22 +00:00
|
|
|
|
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;
|
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
|
|
|
|
2015-04-30 15:54:51 +00:00
|
|
|
PaletteProvider.$inject = [ 'palette', 'create', 'elementFactory', 'spaceTool', 'lassoTool' ];
|
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,
|
|
|
|
lassoTool = this._lassoTool;
|
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,
|
2015-05-11 15:36:01 +00:00
|
|
|
title: title || 'Create ' + 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, {
|
2015-05-13 10:09:08 +00:00
|
|
|
'lasso-tool': {
|
2015-04-30 15:54:51 +00:00
|
|
|
group: 'tools',
|
2015-05-13 10:09:08 +00:00
|
|
|
className: 'icon-lasso-tool',
|
|
|
|
title: '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',
|
|
|
|
className: 'icon-space-tool',
|
|
|
|
title: 'Activate the create/remove space tool',
|
2015-04-15 07:43:55 +00:00
|
|
|
action: {
|
|
|
|
click: function(event) {
|
|
|
|
spaceTool.activateSelection(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-04-30 15:54:51 +00:00
|
|
|
'tool-separator': {
|
|
|
|
group: 'tools',
|
|
|
|
separator: true
|
|
|
|
},
|
2014-12-07 12:08:50 +00:00
|
|
|
'create.start-event': createAction(
|
2015-03-10 15:07:58 +00:00
|
|
|
'bpmn:StartEvent', 'event', 'icon-start-event-none'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.intermediate-event': createAction(
|
2015-03-10 15:07:58 +00:00
|
|
|
'bpmn:IntermediateThrowEvent', 'event', 'icon-intermediate-event-none'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.end-event': createAction(
|
2015-03-10 15:07:58 +00:00
|
|
|
'bpmn:EndEvent', 'event', 'icon-end-event-none'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.exclusive-gateway': createAction(
|
2015-03-10 15:07:58 +00:00
|
|
|
'bpmn:ExclusiveGateway', 'gateway', 'icon-gateway-xor'
|
2014-12-07 12:08:50 +00:00
|
|
|
),
|
|
|
|
'create.task': createAction(
|
|
|
|
'bpmn:Task', 'activity', 'icon-task'
|
|
|
|
),
|
|
|
|
'create.subprocess-expanded': createAction(
|
2015-05-11 15:36:01 +00:00
|
|
|
'bpmn:SubProcess', 'activity', 'icon-subprocess-expanded', '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',
|
|
|
|
className: 'icon-participant',
|
2015-05-11 15:36:01 +00:00
|
|
|
title: '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
|
|
|
};
|