parent
66801df111
commit
7207d010db
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 211 KiB |
Binary file not shown.
Binary file not shown.
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var assign = require('lodash/object/assign'),
|
||||
forEach = require('lodash/collection/forEach');
|
||||
var assign = require('lodash/object/assign');
|
||||
|
||||
var getReplacementMenuEntries = require('./ReplaceMenuFactory').getReplacementMenuEntries;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -70,8 +70,8 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
}
|
||||
}
|
||||
|
||||
function replaceElement(element, newType, newBusinessAtt) {
|
||||
replace.replaceElement(element, {type: newType}, newBusinessAtt);
|
||||
function replaceElement(element, newType, options) {
|
||||
replace.replaceElement(element, {type: newType}, options);
|
||||
}
|
||||
|
||||
function getPosition(element) {
|
||||
|
@ -91,146 +91,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
return pos;
|
||||
}
|
||||
|
||||
function getReplacementMenuEntries(element) {
|
||||
|
||||
function addMenuEntry(label, newType, newBusinessAtt, actionName, className) {
|
||||
|
||||
function appendListener() {
|
||||
replaceElement(element, newType, newBusinessAtt);
|
||||
}
|
||||
|
||||
return {
|
||||
label: label,
|
||||
className: className,
|
||||
action: {
|
||||
name: actionName,
|
||||
handler: appendListener
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// var startEventReplace = [];
|
||||
// var interEventReplace = [];
|
||||
// var endEventReplace = [];
|
||||
|
||||
var gatewayReplace = [
|
||||
{
|
||||
label: 'Exclusive Gateway',
|
||||
actionName: 'replace-with-exclusive-gateway',
|
||||
className: 'icon-exclusive-gateway-variant-1',
|
||||
targetType: 'bpmn:ExclusiveGateway'
|
||||
},
|
||||
{
|
||||
label: 'Parallel Gateway',
|
||||
actionName: 'replace-with-parallel-gateway',
|
||||
className: 'icon-parallel-gateway',
|
||||
targetType: 'bpmn:ParallelGateway'
|
||||
},
|
||||
{
|
||||
label: 'Inclusive Gateway',
|
||||
actionName: 'replace-with-inclusive-gateway',
|
||||
className: 'icon-inclusive-gateway',
|
||||
targetType: 'bpmn:InclusiveGateway'
|
||||
},
|
||||
{
|
||||
label: 'Complex Gateway',
|
||||
actionName: 'replace-with-complex-gateway',
|
||||
className: 'icon-complex-gateway',
|
||||
targetType: 'bpmn:ComplexGateway'
|
||||
},
|
||||
{
|
||||
label: 'Event based Gateway',
|
||||
actionName: 'replace-with-event-based-gateway',
|
||||
className: 'icon-event-based-gateway',
|
||||
targetType: 'bpmn:EventBasedGateway',
|
||||
newBusinessAtt: {instantiate: false, eventGatewayType: 'Exclusive'}
|
||||
},
|
||||
{
|
||||
label: 'Event based instantiating Gateway',
|
||||
actionName: 'replace-with-exclusive-event-based-gateway',
|
||||
className: 'icon-exclusive-event-based',
|
||||
targetType: 'bpmn:EventBasedGateway',
|
||||
newBusinessAtt: {instantiate: true, eventGatewayType: 'Exclusive'}
|
||||
},
|
||||
{
|
||||
label: 'Parallel Event based instantiating Gateway',
|
||||
actionName: 'replace-with-parallel-event-based-instantiate-gateway',
|
||||
className: 'icon-parallel-event-based-instantiate-gateway',
|
||||
targetType: 'bpmn:EventBasedGateway',
|
||||
newBusinessAtt: {instantiate: true, eventGatewayType: 'Parallel'}
|
||||
}
|
||||
];
|
||||
|
||||
var taskReplace = [
|
||||
{
|
||||
label: 'Send Task',
|
||||
actionName: 'replace-with-send-task',
|
||||
className: 'icon-send',
|
||||
targetType: 'bpmn:SendTask'
|
||||
},
|
||||
{
|
||||
label: 'Receive Task',
|
||||
actionName: 'replace-with-receive-task',
|
||||
className: 'icon-receive',
|
||||
targetType: 'bpmn:ReceiveTask'
|
||||
},
|
||||
{
|
||||
label: 'User Task',
|
||||
actionName: 'replace-with-user-task',
|
||||
className: 'icon-user',
|
||||
targetType: 'bpmn:UserTask'
|
||||
},
|
||||
{
|
||||
label: 'Manual Task',
|
||||
actionName: 'replace-with-manual-task',
|
||||
className: 'icon-manual',
|
||||
targetType: 'bpmn:ManualTask'
|
||||
},
|
||||
{
|
||||
label: 'Business Rule Task',
|
||||
actionName: 'replace-with-rule-task',
|
||||
className: 'icon-business-rule',
|
||||
targetType: 'bpmn:BusinessRuleTask'
|
||||
},
|
||||
{
|
||||
label: 'Service Task',
|
||||
actionName: 'replace-with-service-task',
|
||||
className: 'icon-service',
|
||||
targetType: 'bpmn:ServiceTask'
|
||||
},
|
||||
{
|
||||
label: 'Script Task',
|
||||
actionName: 'replace-with-script-task',
|
||||
className: 'icon-script',
|
||||
targetType: 'bpmn:ScriptTask'
|
||||
}
|
||||
];
|
||||
|
||||
var menuEntries = [];
|
||||
|
||||
if (element.businessObject.$instanceOf('bpmn:Event')) {
|
||||
|
||||
console.warn('Replace for event is not implemented yet.');
|
||||
} else if (element.businessObject.$instanceOf('bpmn:Gateway')) {
|
||||
|
||||
forEach(gatewayReplace, function(definition) {
|
||||
|
||||
var entry = addMenuEntry(definition.label, definition.targetType, definition.newBusinessAtt,
|
||||
definition.actionName, definition.className);
|
||||
menuEntries.push(entry);
|
||||
});
|
||||
} else if (element.businessObject.$instanceOf('bpmn:FlowNode')) {
|
||||
|
||||
forEach(taskReplace, function(definition) {
|
||||
|
||||
var entry = addMenuEntry(definition.label, definition.targetType, {},
|
||||
definition.actionName, definition.className);
|
||||
menuEntries.push(entry);
|
||||
});
|
||||
}
|
||||
|
||||
return menuEntries;
|
||||
}
|
||||
|
||||
function appendAction(type, className) {
|
||||
|
||||
|
@ -255,10 +116,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
!bpmnElement.$instanceOf('bpmn:EventBasedGateway')) {
|
||||
|
||||
assign(actions, {
|
||||
'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event'),
|
||||
'append.gateway': appendAction('bpmn:ExclusiveGateway', 'icon-gateway'),
|
||||
'append.end-event': appendAction('bpmn:EndEvent', 'icon-01-none-end'),
|
||||
'append.gateway': appendAction('bpmn:ExclusiveGateway', 'icon-exclusive-gateway-variant-1'),
|
||||
'append.append-task': appendAction('bpmn:Task', 'icon-task'),
|
||||
'append.intermediate-event': appendAction('bpmn:IntermediateThrowEvent', 'icon-intermediate-event'),
|
||||
'append.intermediate-event': appendAction('bpmn:IntermediateThrowEvent', 'icon-01-none-intermediate-throwing'),
|
||||
'connect': {
|
||||
group: 'connect',
|
||||
className: 'icon-connection',
|
||||
|
@ -271,7 +132,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
}
|
||||
|
||||
if (bpmnElement.$instanceOf('bpmn:EventBasedGateway')) {
|
||||
// TODO Add Receiving Events
|
||||
|
||||
assign(actions, {
|
||||
'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive'),
|
||||
'connect': {
|
||||
|
@ -291,26 +152,28 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
|
||||
|
||||
// Replace menu entry
|
||||
assign(actions, {
|
||||
'replace': {
|
||||
group: 'edit',
|
||||
className: 'icon-screw-wrench',
|
||||
action: {
|
||||
if (!bpmnElement.$instanceOf('bpmn:SubProcess')) {
|
||||
assign(actions, {
|
||||
'replace': {
|
||||
group: 'edit',
|
||||
className: 'icon-screw-wrench',
|
||||
action: {
|
||||
|
||||
click: function(event, element) {
|
||||
var pos = getPosition(element);
|
||||
click: function(event, element) {
|
||||
var pos = getPosition(element);
|
||||
|
||||
var entries = getReplacementMenuEntries(element);
|
||||
var entries = getReplacementMenuEntries(element, replaceElement);
|
||||
|
||||
popupMenu.open(
|
||||
pos,
|
||||
entries,
|
||||
{ className: 'replace-menu' }
|
||||
);
|
||||
popupMenu.open(
|
||||
pos,
|
||||
entries,
|
||||
{ className: 'replace-menu' }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Delete Element Entry
|
||||
|
|
|
@ -0,0 +1,399 @@
|
|||
'use strict';
|
||||
|
||||
var startEventReplace = [
|
||||
{
|
||||
options: {},
|
||||
label: 'Start Event',
|
||||
actionName: 'replace-with-none-start',
|
||||
className: 'icon-01-none-start',
|
||||
targetType: 'bpmn:StartEvent'
|
||||
},
|
||||
{
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
},
|
||||
label: 'Intermediate Throw Event',
|
||||
actionName: 'replace-with-intermediate-throwing',
|
||||
className: 'icon-01-none-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateThrowEvent'
|
||||
},
|
||||
{
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
},
|
||||
label: 'End Event',
|
||||
actionName: 'replace-with-message-end',
|
||||
className: 'icon-01-none-end',
|
||||
targetType: 'bpmn:EndEvent'
|
||||
},
|
||||
{
|
||||
label: 'Message Start Event',
|
||||
actionName: 'replace-with-message-start',
|
||||
className: 'icon-02-message-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:MessageEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Timer Start Event',
|
||||
actionName: 'replace-with-timer-start',
|
||||
className: 'icon-03-timer-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:TimerEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Escalation Start Event',
|
||||
actionName: 'replace-with-escalation-start',
|
||||
className: 'icon-04-escalation-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:EscalationEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Conditional Start Event',
|
||||
actionName: 'replace-with-conditional-start',
|
||||
className: 'icon-05-conditional-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options:{
|
||||
eventDefinition: 'bpmn:ConditionalEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Error Start Event',
|
||||
actionName: 'replace-with-error-start',
|
||||
className: 'icon-07-error-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:ErrorEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Compensation Start Event',
|
||||
actionName: 'replace-with-compensation-start',
|
||||
className: 'icon-09-compensation-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:CompensateEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Signal Start Event',
|
||||
actionName: 'replace-with-signal-start',
|
||||
className: 'icon-10-signal-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:SignalEventDefinition'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var intermediateEventReplace = [
|
||||
{
|
||||
label: 'Start Event',
|
||||
actionName: 'replace-with-none-start',
|
||||
className: 'icon-01-none-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Intermediate Throw Event',
|
||||
actionName: 'replace-with-message-intermediate-throw',
|
||||
className: 'icon-01-none-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateThrowEvent',
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'End Event',
|
||||
actionName: 'replace-with-message-end',
|
||||
className: 'icon-01-none-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Message Intermediate Catch Event',
|
||||
actionName: 'replace-with-intermediate-catch',
|
||||
className: 'icon-02-message-intermediate',
|
||||
targetType: 'bpmn:IntermediateCatchEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:MessageEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Message Intermediate Throw Event',
|
||||
actionName: 'replace-with-intermediate-throw',
|
||||
className: 'icon-02-message-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateThrowEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:MessageEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Timer Intermediate Catch Event',
|
||||
actionName: 'replace-with-timer-intermediate-catch',
|
||||
className: 'icon-03-timer-intermediate',
|
||||
targetType: 'bpmn:IntermediateCatchEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:TimerEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Timer Intermediate Catch Event',
|
||||
actionName: 'replace-with-escalation-throwing',
|
||||
className: 'icon-04-escalation-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateCatchEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:EscalationEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Conditional Intermediate Catch Event',
|
||||
actionName: 'replace-with-conditional-intermediate-catch',
|
||||
className: 'icon-05-conditional-intermediate',
|
||||
targetType: 'bpmn:IntermediateCatchEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:ConditionalEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Link Intermediate Catch Event',
|
||||
actionName: 'replace-with-link-intermediate-catch',
|
||||
className: 'icon-06-link-intermediate',
|
||||
targetType: 'bpmn:IntermediateCatchEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:LinkEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Link Intermediate Throw Event',
|
||||
actionName: 'replace-with-link-intermediate-throw',
|
||||
className: 'icon-06-link-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateThrowEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:LinkEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Signal Intermediate Catch Event',
|
||||
actionName: 'replace-with-signal-intermediate-catch',
|
||||
className: 'icon-10-signal-intermediate',
|
||||
targetType: 'bpmn:IntermediateCatchEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:SignalEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Signal Intermediate Throw Event',
|
||||
actionName: 'replace-with-signal-intermediate-throw',
|
||||
className: 'icon-10-signal-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateThrowEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:SignalEventDefinition'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
||||
var endEventReplace = [
|
||||
{
|
||||
label: 'Start Event',
|
||||
actionName: 'replace-with-none-start',
|
||||
className: 'icon-01-none-start',
|
||||
targetType: 'bpmn:StartEvent',
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Intermediate Throw Event',
|
||||
actionName: 'replace-with-message-intermediate-throw',
|
||||
className: 'icon-01-none-intermediate-throwing',
|
||||
targetType: 'bpmn:IntermediateThrowEvent',
|
||||
options: {
|
||||
eventDefinition: ''
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'End Event',
|
||||
actionName: 'replace-with-message-end',
|
||||
className: 'icon-01-none-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {},
|
||||
},
|
||||
{
|
||||
label: 'Message End Event',
|
||||
actionName: 'replace-with-message-end',
|
||||
className: 'icon-02-message-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:MessageEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Escalation End Event',
|
||||
actionName: 'replace-with-escalation-end',
|
||||
className: 'icon-04-escalation-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:EscalationEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Error End Event',
|
||||
actionName: 'replace-with-error-end',
|
||||
className: 'icon-07-error-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:ErrorEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Cancel End Event',
|
||||
actionName: 'replace-with-cancel-end',
|
||||
className: 'icon-08-cancel-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:CancelEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Compensation End Event',
|
||||
actionName: 'replace-with-compensation-end',
|
||||
className: 'icon-09-compensation-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:CompensateEventDefinition'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Terminate End Event',
|
||||
actionName: 'replace-with-terminate-end',
|
||||
className: 'icon-13-terminate-end',
|
||||
targetType: 'bpmn:EndEvent',
|
||||
options: {
|
||||
eventDefinition: 'bpmn:TerminateEventDefinition'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var gatewayReplace = [
|
||||
{
|
||||
label: 'Exclusive Gateway',
|
||||
actionName: 'replace-with-exclusive-gateway',
|
||||
className: 'icon-exclusive-gateway-variant-1',
|
||||
targetType: 'bpmn:ExclusiveGateway'
|
||||
},
|
||||
{
|
||||
label: 'Parallel Gateway',
|
||||
actionName: 'replace-with-parallel-gateway',
|
||||
className: 'icon-parallel-gateway',
|
||||
targetType: 'bpmn:ParallelGateway'
|
||||
},
|
||||
{
|
||||
label: 'Inclusive Gateway',
|
||||
actionName: 'replace-with-inclusive-gateway',
|
||||
className: 'icon-inclusive-gateway',
|
||||
targetType: 'bpmn:InclusiveGateway'
|
||||
},
|
||||
{
|
||||
label: 'Complex Gateway',
|
||||
actionName: 'replace-with-complex-gateway',
|
||||
className: 'icon-complex-gateway',
|
||||
targetType: 'bpmn:ComplexGateway'
|
||||
},
|
||||
{
|
||||
label: 'Event based Gateway',
|
||||
actionName: 'replace-with-event-based-gateway',
|
||||
className: 'icon-event-based-gateway',
|
||||
targetType: 'bpmn:EventBasedGateway',
|
||||
options: {
|
||||
newBusinessAtt: { instantiate: false, eventGatewayType: 'Exclusive' }
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Event based instantiating Gateway',
|
||||
actionName: 'replace-with-exclusive-event-based-gateway',
|
||||
className: 'icon-exclusive-event-based',
|
||||
targetType: 'bpmn:EventBasedGateway',
|
||||
options: {
|
||||
newBusinessAtt: { instantiate: true, eventGatewayType: 'Exclusive' }
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Parallel Event based instantiating Gateway',
|
||||
actionName: 'replace-with-parallel-event-based-instantiate-gateway',
|
||||
className: 'icon-parallel-event-based-instantiate-gateway',
|
||||
targetType: 'bpmn:EventBasedGateway',
|
||||
options: {
|
||||
newBusinessAtt: { instantiate: true, eventGatewayType: 'Parallel' }
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var taskReplace = [
|
||||
{
|
||||
label: 'Task',
|
||||
actionName: 'replace-with-task',
|
||||
className: 'icon-task',
|
||||
targetType: 'bpmn:Task'
|
||||
},
|
||||
{
|
||||
label: 'Send Task',
|
||||
actionName: 'replace-with-send-task',
|
||||
className: 'icon-send',
|
||||
targetType: 'bpmn:SendTask'
|
||||
},
|
||||
{
|
||||
label: 'Receive Task',
|
||||
actionName: 'replace-with-receive-task',
|
||||
className: 'icon-receive',
|
||||
targetType: 'bpmn:ReceiveTask'
|
||||
},
|
||||
{
|
||||
label: 'User Task',
|
||||
actionName: 'replace-with-user-task',
|
||||
className: 'icon-user',
|
||||
targetType: 'bpmn:UserTask'
|
||||
},
|
||||
{
|
||||
label: 'Manual Task',
|
||||
actionName: 'replace-with-manual-task',
|
||||
className: 'icon-manual',
|
||||
targetType: 'bpmn:ManualTask'
|
||||
},
|
||||
{
|
||||
label: 'Business Rule Task',
|
||||
actionName: 'replace-with-rule-task',
|
||||
className: 'icon-business-rule',
|
||||
targetType: 'bpmn:BusinessRuleTask'
|
||||
},
|
||||
{
|
||||
label: 'Service Task',
|
||||
actionName: 'replace-with-service-task',
|
||||
className: 'icon-service',
|
||||
targetType: 'bpmn:ServiceTask'
|
||||
},
|
||||
{
|
||||
label: 'Script Task',
|
||||
actionName: 'replace-with-script-task',
|
||||
className: 'icon-script',
|
||||
targetType: 'bpmn:ScriptTask'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
module.exports.startEventReplace = startEventReplace;
|
||||
module.exports.intermediateEventReplace = intermediateEventReplace;
|
||||
module.exports.endEventReplace = endEventReplace;
|
||||
module.exports.gatewayReplace = gatewayReplace;
|
||||
module.exports.taskReplace = taskReplace;
|
|
@ -0,0 +1,101 @@
|
|||
'use strict';
|
||||
|
||||
var forEach = require('lodash/collection/forEach'),
|
||||
filter = require('lodash/collection/filter');
|
||||
|
||||
var ReplaceMenuEntries = require ('./ReplaceMenuEntries');
|
||||
|
||||
var startEventReplace = ReplaceMenuEntries.startEventReplace,
|
||||
intermediateEventReplace = ReplaceMenuEntries.intermediateEventReplace,
|
||||
endEventReplace = ReplaceMenuEntries.endEventReplace,
|
||||
gatewayReplace = ReplaceMenuEntries.gatewayReplace,
|
||||
taskReplace = ReplaceMenuEntries.taskReplace;
|
||||
|
||||
|
||||
|
||||
function getReplacementMenuEntries(element, replaceElement) {
|
||||
|
||||
var menuEntries = [];
|
||||
var bo = element.businessObject;
|
||||
|
||||
|
||||
if (bo.$instanceOf('bpmn:StartEvent')) {
|
||||
|
||||
addEntries(startEventReplace, function(entry) {
|
||||
var eventDefinition = bo.eventDefinition ? bo.eventDefinition[0].$type : '';
|
||||
|
||||
return entry.options.eventDefinition !== eventDefinition.$type;
|
||||
});
|
||||
} else if (bo.$instanceOf('bpmn:IntermediateCatchEvent') ||
|
||||
bo.$instanceOf('bpmn:IntermediateThrowEvent')) {
|
||||
|
||||
addEntries(intermediateEventReplace, function(entry) {
|
||||
|
||||
var eventDefinition = bo.eventDefinitions ? bo.eventDefinitions[0].$type : '';
|
||||
var isEventDefinitionEqual = entry.options.eventDefinition === eventDefinition;
|
||||
var isEventTypeEqual = bo.$type === entry.targetType;
|
||||
|
||||
return ((!isEventDefinitionEqual && isEventTypeEqual) ||
|
||||
!isEventTypeEqual) ||
|
||||
!(isEventDefinitionEqual && isEventTypeEqual);
|
||||
});
|
||||
} else if (bo.$instanceOf('bpmn:EndEvent')) {
|
||||
|
||||
addEntries(endEventReplace, function(entry) {
|
||||
var eventDefinition = bo.eventDefinition ? bo.eventDefinition[0].$type : '';
|
||||
|
||||
return entry.options.eventDefinition !== eventDefinition.$type;
|
||||
});
|
||||
} else if (bo.$instanceOf('bpmn:Gateway')) {
|
||||
|
||||
addEntries(gatewayReplace, function(entry) {
|
||||
|
||||
return entry.targetType !== bo.$type;
|
||||
});
|
||||
} else if (bo.$instanceOf('bpmn:FlowNode')) {
|
||||
|
||||
addEntries(taskReplace, function(entry) {
|
||||
|
||||
return entry.targetType !== bo.$type;
|
||||
});
|
||||
}
|
||||
|
||||
function addEntries(entries, filterFun) {
|
||||
// Filter selected type from the array
|
||||
var filteredEntries = filter(entries, filterFun);
|
||||
|
||||
// Add entries to replace menu
|
||||
forEach(filteredEntries, function(definition) {
|
||||
|
||||
var entry = addMenuEntry(definition);
|
||||
menuEntries.push(entry);
|
||||
});
|
||||
}
|
||||
|
||||
function addMenuEntry(definition) {
|
||||
|
||||
var label = definition.label,
|
||||
newType = definition.targetType,
|
||||
options = definition.options,
|
||||
actionName = definition.actionName,
|
||||
className = definition.className;
|
||||
|
||||
function appendListener() {
|
||||
replaceElement(element, newType, options);
|
||||
}
|
||||
|
||||
return {
|
||||
label: label,
|
||||
className: className,
|
||||
action: {
|
||||
name: actionName,
|
||||
handler: appendListener
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return menuEntries;
|
||||
}
|
||||
|
||||
|
||||
module.exports.getReplacementMenuEntries = getReplacementMenuEntries;
|
|
@ -45,14 +45,14 @@ ModelingRules.prototype.init = function() {
|
|||
|
||||
if (targetBo.$instanceOf('bpmn:ReceiveTask')) {
|
||||
eventBasedGatewayCheck = false;
|
||||
} else if (targetBo.$instanceOf('bpmn:ReceiveMessageEvent')) { // ReceiveMessageEvent check name
|
||||
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||
} else if (targetBo.$instanceOf('bpmn:ReceiveTimerEvent')) { // TimerEvent check name
|
||||
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||
} else if (targetBo.$instanceOf('bpmn:ReceiveSignalEvent')) { // TimerEvent check name
|
||||
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||
} else if (targetBo.$instanceOf('bpmn:ReceiveConditionEvent')) { // TimerEvent check name
|
||||
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||
} else if (targetBo.$instanceOf('bpmn:IntermediateCatchEvent') &&
|
||||
targetBo.eventDefinitions && (
|
||||
targetBo.eventDefinitions[0].$type === 'bpmn:MessageEventDefinition' ||
|
||||
targetBo.eventDefinitions[0].$type === 'bpmn:TimerEventDefinition' ||
|
||||
targetBo.eventDefinitions[0].$type === 'bpmn:ConditionEventDefinition' ||
|
||||
targetBo.eventDefinitions[0].$type === 'bpmn:SignalConditionEventDefinition')) {
|
||||
|
||||
eventBasedGatewayCheck = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,16 +50,16 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|||
|
||||
assign(actions, {
|
||||
'create.start-event': createAction(
|
||||
'bpmn:StartEvent', 'event', 'icon-start-event'
|
||||
'bpmn:StartEvent', 'event', 'icon-01-none-start'
|
||||
),
|
||||
'create.intermediate-event': createAction(
|
||||
'bpmn:IntermediateThrowEvent', 'event', 'icon-intermediate-event'
|
||||
'bpmn:IntermediateThrowEvent', 'event', 'icon-01-none-intermediate-throwing'
|
||||
),
|
||||
'create.end-event': createAction(
|
||||
'bpmn:EndEvent', 'event', 'icon-end-event'
|
||||
'bpmn:EndEvent', 'event', 'icon-01-none-end'
|
||||
),
|
||||
'create.exclusive-gateway': createAction(
|
||||
'bpmn:ExclusiveGateway', 'gateway', 'icon-gateway'
|
||||
'bpmn:ExclusiveGateway', 'gateway', 'icon-exclusive-gateway-variant-1'
|
||||
),
|
||||
'create.task': createAction(
|
||||
'bpmn:Task', 'activity', 'icon-task'
|
||||
|
@ -75,4 +75,4 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|||
});
|
||||
|
||||
return actions;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ var _ = require('lodash');
|
|||
var LabelUtil = require('../label-editing/LabelUtil'),
|
||||
BaseReplace = require('diagram-js/lib/features/replace/Replace');
|
||||
|
||||
function BpmnReplace(modeling, eventBus) {
|
||||
function BpmnReplace(modeling, eventBus, moddle) {
|
||||
|
||||
BaseReplace.call(this, modeling);
|
||||
|
||||
|
@ -20,9 +20,21 @@ function BpmnReplace(modeling, eventBus) {
|
|||
var context = event.context,
|
||||
oldShape = context.oldShape,
|
||||
newShape = context.newShape,
|
||||
newBusinessAtt = context.options ? context.options.newBusinessAtt || {} : {};
|
||||
newBusinessAtt = context.options ? context.options.newBusinessAtt || {} : {},
|
||||
eventDefinitionType = context.options ? context.options.eventDefinition : null;
|
||||
|
||||
// Attach eventDefinitions
|
||||
if (eventDefinitionType) {
|
||||
var eventDefinitions = newShape.businessObject.get('eventDefinitions'),
|
||||
newEventDefinition = moddle.create(eventDefinitionType);
|
||||
|
||||
eventDefinitions.push(newEventDefinition);
|
||||
}
|
||||
|
||||
// extend newBusinessAtt
|
||||
_.assign(newShape.businessObject, newBusinessAtt);
|
||||
|
||||
// set label
|
||||
modeling.updateLabel(newShape, LabelUtil.getLabel(oldShape));
|
||||
});
|
||||
|
||||
|
@ -33,11 +45,13 @@ function BpmnReplace(modeling, eventBus) {
|
|||
|
||||
module.exports = BpmnReplace;
|
||||
|
||||
BpmnReplace.$inject = [ 'modeling', 'eventBus' ];
|
||||
BpmnReplace.$inject = [ 'modeling', 'eventBus', 'moddle' ];
|
||||
|
||||
|
||||
|
||||
BpmnReplace.prototype = Object.create(BaseReplace.prototype);
|
||||
|
||||
BpmnReplace.prototype.replaceElement = function(oldElement, newElementData, newBusinessAtt) {
|
||||
BpmnReplace.prototype.replaceElement = function(oldElement, newElementData, options) {
|
||||
|
||||
if (oldElement.waypoints) {
|
||||
throw new Error('connections cannot be replaced (yet)');
|
||||
|
@ -53,5 +67,5 @@ BpmnReplace.prototype.replaceElement = function(oldElement, newElementData, newB
|
|||
newElementData.height = oldElement.height;
|
||||
}
|
||||
|
||||
return this._originalReplaceElement(oldElement, newElementData, {newBusinessAtt: newBusinessAtt});
|
||||
return this._originalReplaceElement(oldElement, newElementData, options || {});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue