diff --git a/lib/features/context-pad/ContextPadProvider.js b/lib/features/context-pad/ContextPadProvider.js index 82b7ceda..ca9681bc 100644 --- a/lib/features/context-pad/ContextPadProvider.js +++ b/lib/features/context-pad/ContextPadProvider.js @@ -47,29 +47,23 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) { var bpmnElement = element.businessObject; - function startConnect(event, element) { - connect.start(event, element, null); - } - - function append(element, type) { - var target = modeling.appendShape(element, { type: type }); - - selection.select(target); - directEditing.activate(target); + function startConnect(event, element, autoActivate) { + connect.start(event, element, autoActivate); } function appendAction(type, className) { + + function appendListener(event, element) { + var shape = elementFactory.createShape({ type: type }); + create.start(event, shape, element); + } + return { group: 'model', className: className, action: { - dragstart: function(event, element) { - var shape = elementFactory.createShape({ type: type }); - create.start(event, shape, element); - }, - click: function(event, element) { - append(element, type); - } + dragstart: appendListener, + click: appendListener } }; } @@ -99,17 +93,21 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) { }); } + function removeElement(e) { + if (element.waypoints) { + modeling.removeConnection(element); + } else { + modeling.removeShape(element); + } + } + _.extend(actions, { 'delete': { group: 'edit', className: 'icon-trash', - action: function(e) { - - if (element.waypoints) { - modeling.removeConnection(element); - } else { - modeling.removeShape(element); - } + action: { + click: removeElement, + dragstart: removeElement } } }); diff --git a/lib/features/palette/PaletteProvider.js b/lib/features/palette/PaletteProvider.js index 5447dffd..da15f9d6 100644 --- a/lib/features/palette/PaletteProvider.js +++ b/lib/features/palette/PaletteProvider.js @@ -20,20 +20,24 @@ PaletteProvider.$inject = [ 'palette', 'create', 'elementFactory' ]; PaletteProvider.prototype.getPaletteEntries = function(element) { function createAction(type, group, className, title, options) { + + function createListener(event) { + var shape = elementFactory.createShape(_.extend({ type: type }, options)); + + if (options) { + shape.businessObject.di.isExpanded = options.isExpanded; + } + + create.start(event, shape); + } + return { group: group, className: className, title: title || 'Create ' + type, action: { - dragstart: function(event) { - var shape = elementFactory.createShape(_.extend({ type: type }, options)); - - if (options) { - shape.businessObject.di.isExpanded = options.isExpanded; - } - - create.start(event, shape); - } + dragstart: createListener, + click: createListener } }; }