function UpdateLabelHandler(modeling) {

  var textUtil = new TextUtil();

  /**
   * Set the label and return the changed elements.
   *
   * Element parameter can be label itself or connection (i.e. sequence flow).
   *
   * @param {djs.model.Base} element
   * @param {String} text
   */
  function setText(element, text) {

    // external label if present
    var label = element.label || element;

    var labelTarget = element.labelTarget || element;

    LabelUtil.setLabel(label, text, labelTarget !== label);

    return [ label, labelTarget ];
  }

  function execute(ctx) {
    ctx.oldLabel = LabelUtil.getLabel(ctx.element);
    return setText(ctx.element, ctx.newLabel);
  }

  function revert(ctx) {
    return setText(ctx.element, ctx.oldLabel);
  }

  function postExecute(ctx) {
    var element = ctx.element,
        label = element.label || element,
        bounds = ctx.bounds;

    // ignore internal labels for elements except text annotations
    if (!hasExternalLabel(element) && !is(element, 'bpmn:TextAnnotation')) {
      return;
    }

    var bo = getBusinessObject(label);

    var text = bo.name || bo.text;

    if (!text) {
      return;
    }

    // get layouted text bounds and resize external
    // external label accordingly
    var newBounds = is(element, 'bpmn:TextAnnotation') ? bounds : getLayoutedBounds(label, text, textUtil);

    modeling.resizeShape(label, newBounds, NULL_DIMENSIONS);
  }

  // API

  this.execute = execute;
  this.revert = revert;
  this.postExecute = postExecute;
}
/**
 * A handler that updates the text of a BPMN element.
 */
A handler that updates the text of a BPMN element.
A handler that updates the text of a BPMN element .
function UpdateLabelHandler(modeling) {
  var textUtil = new TextUtil();
  function setText(element, text) {
    var label = element.label || element;
    var labelTarget = element.labelTarget || element;
    LabelUtil.setLabel(label, text, labelTarget !== label);
    return [ label, labelTarget ];
  }
  function execute(ctx) {
    ctx.oldLabel = LabelUtil.getLabel(ctx.element);
    return setText(ctx.element, ctx.newLabel);
  }
  function revert(ctx) {
    return setText(ctx.element, ctx.oldLabel);
  }
  function postExecute(ctx) {
    var element = ctx.element,
        label = element.label || element,
        bounds = ctx.bounds;
    if (!hasExternalLabel(element) && !is(element, 'bpmn:TextAnnotation')) {
      return;
    }
    var bo = getBusinessObject(label);
    var text = bo.name || bo.text;
    if (!text) {
      return;
    }
    var newBounds = is(element, 'bpmn:TextAnnotation') ? bounds : getLayoutedBounds(label, text, textUtil);
    modeling.resizeShape(label, newBounds, NULL_DIMENSIONS);
  }
  this.execute = execute;
  this.revert = revert;
  this.postExecute = postExecute;
}
function UpdateLabelHandler ( modeling ) { var textUtil = new TextUtil ( ) ; function setText ( element , text ) { var label = element . label || element ; var labelTarget = element . labelTarget || element ; LabelUtil . setLabel ( label , text , labelTarget !== label ) ; return [ label , labelTarget ] ; } function execute ( ctx ) { ctx . oldLabel = LabelUtil . getLabel ( ctx . element ) ; return setText ( ctx . element , ctx . newLabel ) ; } function revert ( ctx ) { return setText ( ctx . element , ctx . oldLabel ) ; } function postExecute ( ctx ) { var element = ctx . element , label = element . label || element , bounds = ctx . bounds ; if ( ! hasExternalLabel ( element ) && ! is ( element , 'bpmn:TextAnnotation' ) ) { return ; } var bo = getBusinessObject ( label ) ; var text = bo . name || bo . text ; if ( ! text ) { return ; } var newBounds = is ( element , 'bpmn:TextAnnotation' ) ? bounds : getLayoutedBounds ( label , text , textUtil ) ; modeling . resizeShape ( label , newBounds , NULL_DIMENSIONS ) ; } this . execute = execute ; this . revert = revert ; this . postExecute = postExecute ; }
A handler that updates the text of a BPMN element.
A handler that updates the text of a BPMN element .
/**
   * Set the label and return the changed elements.
   *
   * Element parameter can be label itself or connection (i.e. sequence flow).
   *
   * @param {djs.model.Base} element
   * @param {String} text
   */ // external label if present // ignore internal labels for elements except text annotations // get layouted text bounds and resize external // external label accordingly // API