'use strict'; var _ = require('lodash'), $ = require('jquery'); /** * A BPMN instance of the palette. */ function BpmnPaletteProvider(eventBus, palette, modeling, elementRegistry, canvas) { this._eventBus = eventBus; this._palette = palette; this._modeling = modeling; this._elementRegistry = elementRegistry; this._canvas = canvas; palette.registerProvider(this); } module.exports = BpmnPaletteProvider; BpmnPaletteProvider.$inject = [ 'eventBus', 'palette', 'modeling', 'elementRegistry', 'canvas' ]; BpmnPaletteProvider.prototype.getPaletteEntries = function(element) { var actions = {}, modeling = this._modeling, elementRegistry = this._elementRegistry, canvas = this._canvas; var root = elementRegistry.getRoot(); var vbox = canvas.viewbox(); var center = { x: Math.round(vbox.outer.width * 1 / vbox.scale / 2), y: Math.round(vbox.outer.height * 1 / vbox.scale / 2) }; _.extend(actions, { 'add.start-event': { group: 'model-event', img: '', alt: 'Start Event', action: function(event, element) { modeling.createShape({ type: 'bpmn:StartEvent' }, center, root); } }, 'add.inter-throw-event': { group: 'model-event', img: '' + '', alt: 'Intermediate Throw Event', action: function(event, element) { modeling.createShape({ type: 'bpmn:IntermediateThrowEvent' }, center, root); } }, 'add.end-event': { group: 'model-event', img: '', alt: 'End Event', action: function(event, element) { modeling.createShape({ type: 'bpmn:EndEvent' }, center, root); } }, 'add.exclusive-gateway': { group: 'model-gateway', img: '', alt: 'Exclusive Gateway', action: function(event, element) { modeling.createShape({ type: 'bpmn:ExclusiveGateway' }, center, root); } }, 'add.task': { group: 'model-activity', img: '', alt: 'Task', action: function(event, element) { modeling.createShape({ type: 'bpmn:Task' }, center, root); } }, 'add.subProcess-collapsed': { group: 'model-activity', img: '' + '', alt: 'Subprocess collapsed', action: function(event, element) { modeling.createShape({ type: 'bpmn:SubProcess', isExpanded: false }, center, root); } }, 'add.subProcess-expanded': { group: 'model-activity', img: '' + '', alt: 'Subprocess Expanded', action: function(event, element) { modeling.createShape({ type: 'bpmn:SubProcess', isExpanded: true }, center, root); } } }); return actions; }; BpmnPaletteProvider.prototype.open = function() { this._palette.open(); }; BpmnPaletteProvider.prototype.close = function() { this._palette.close(); };