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);
|
|
|
|
}
|
|
|
|
|
2014-12-07 12:08:50 +00:00
|
|
|
return {
|
|
|
|
group: group,
|
|
|
|
className: className,
|
|
|
|
title: title || 'Create ' + type,
|
|
|
|
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-04-30 15:54:51 +00:00
|
|
|
'multi-select-tool': {
|
|
|
|
group: 'tools',
|
|
|
|
className: 'icon-multi-select-tool',
|
|
|
|
title: 'Active the multi select tool',
|
|
|
|
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-collapsed': createAction(
|
|
|
|
'bpmn:SubProcess', 'activity', 'icon-subprocess-collapsed', 'Sub Process (collapsed)',
|
|
|
|
{ isExpanded: false }
|
|
|
|
),
|
|
|
|
'create.subprocess-expanded': createAction(
|
|
|
|
'bpmn:SubProcess', 'activity', 'icon-subprocess-expanded', 'Sub Process (expanded)',
|
|
|
|
{ isExpanded: true }
|
2015-03-31 13:02:04 +00:00
|
|
|
),
|
|
|
|
'create.participant-expanded': {
|
|
|
|
group: 'collaboration',
|
|
|
|
className: 'icon-participant',
|
|
|
|
title: 'Create a participant',
|
|
|
|
action: {
|
|
|
|
dragstart: createParticipant,
|
|
|
|
click: createParticipant
|
|
|
|
}
|
|
|
|
}
|
2014-10-06 10:23:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return actions;
|
2015-02-26 15:19:34 +00:00
|
|
|
};
|