chore(label-editing): integrate into modeling

This commit is contained in:
Nico Rehwaldt 2014-08-04 09:32:36 +02:00
parent b1663db035
commit 9e2ad175df
4 changed files with 17 additions and 8 deletions

View File

@ -2,7 +2,7 @@
var _ = require('lodash');
var UpdateTextHandler = require('./cmd/UpdateTextHandler');
var UpdateLabelHandler = require('./cmd/UpdateLabelHandler');
var LabelUtil = require('./LabelUtil'),
DiUtil = require('../../util/Di');
@ -17,7 +17,7 @@ var minBounds = {
function LabelEditingProvider(eventBus, canvas, directEditing, commandStack) {
directEditing.registerProvider(this);
commandStack.registerHandler('bpmnElement.updateText', UpdateTextHandler);
commandStack.registerHandler('element.updateLabel', UpdateLabelHandler);
// per default, listen to double click events
eventBus.on('shape.dblclick', function(event) {
@ -101,11 +101,10 @@ LabelEditingProvider.prototype.getEditingBBox = function(element, maxBounds) {
};
LabelEditingProvider.prototype.update = function(element, newText, oldText) {
this._commandStack.execute('bpmnElement.updateText', {
LabelEditingProvider.prototype.update = function(element, newLabel) {
this._commandStack.execute('element.updateLabel', {
element: element,
oldText: oldText,
newText: newText
newLabel: newLabel
});
};

View File

@ -20,11 +20,12 @@ function UpdateTextHandler(eventBus) {
}
function execute(ctx) {
setText(ctx.element, ctx.newText);
ctx.oldLabel = LabelUtil.getLabel(ctx.element.businessObject);
setText(ctx.element, ctx.newLabel);
}
function revert(ctx) {
setText(ctx.element, ctx.oldText);
setText(ctx.element, ctx.oldLabel);
}

View File

@ -44,6 +44,14 @@ Modeling.prototype.registerHandlers = function(commandStack) {
};
Modeling.prototype.updateLabel = function(element, newLabel) {
this._commandStack.execute('element.updateLabel', {
element: element,
newLabel: newLabel
});
};
/**
* Append a flow node to the element with the given source
* at the specified position.

View File

@ -2,6 +2,7 @@ module.exports = {
__init__: [ 'modeling', 'bpmnUpdater', 'labelSupport' ],
__depends__: [
require('../../core'),
require('../label-editing'),
require('diagram-js/lib/command'),
require('diagram-js/lib/features/change-support')
],