Beispiel #1
0
  movePreview && eventBus.on('shape.move.start', LOW_PRIORITY, function(e) {

    var context = e.context,
        shapes = context.shapes;

    var labels = [];

    forEach(shapes, function(element) {

      forEach(element.labels, function(label) {

        if (!label.hidden && context.shapes.indexOf(label) === -1) {
          labels.push(label);
        }

        if (element.labelTarget) {
          labels.push(element);
        }
      });
    });

    forEach(labels, function(label) {
      movePreview.makeDraggable(context, label, true);
    });

  });
Beispiel #2
0
  function handleIoSpecification(ioSpecification, context) {

    if (!ioSpecification) {
      return;
    }

    forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
    forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
  }
Beispiel #3
0
  forEach(this._providers, function(provider) {
    var e = provider.getContextPadEntries(element);

    forEach(e, function(entry, id) {
      entries[id] = entry;
    });
  });
    it('should bootstrap diagram with component', inject(function(eventBus, canvas) {

      // given
      var touchEvents = [
        'shape.tap',
        'shape.dbltap',
        'shape.click',
        'shape.dblclick',
        'connection.tap',
        'connection.dbltap',
        'connection.click',
        'connection.dblclick',
        'canvas.click',
        'canvas.tap'
      ];

      forEach(touchEvents, function(eventName) {
        eventBus.on(eventName, function(e) {
          console.log(eventName, e);
        });
      });

      canvas.addShape({ id: 's1', x: 100, y: 200, width: 50, height: 50 });
      canvas.addShape({ id: 's2', x: 300, y: 200, width: 50, height: 50 });

      canvas.addConnection({ id: 'c1', waypoints: [ { x: 150, y: 225 }, { x: 300, y: 225 } ] });

    }));
Beispiel #5
0
    forEach(elements, function(element) {
      var delta, labelTarget;

      // set label's relative position to their label target
      if (element.labelTarget) {
        labelTarget = find(elements, matchPattern({ id: element.labelTarget }));

        // just grab the delta from the first waypoint
        if (labelTarget.waypoints) {
          delta = posDelta(element, labelTarget.waypoints[0]);
        } else {
          delta = posDelta(element, labelTarget);
        }

      } else
      if (element.priority === 3) {
        // connections have priority 3
        delta = [];

        forEach(element.waypoints, function(waypoint) {
          var waypointDelta = posDelta(waypoint, bbox);

          delta.push(waypointDelta);
        });
      } else {
        delta = posDelta(element, bbox);
      }

      element.delta = delta;
    });
Beispiel #6
0
 function handleFlowElements(flowElements, context) {
   forEach(flowElements, function(e) {
     if (is(e, 'bpmn:SequenceFlow')) {
       deferred.push(function() {
         handleSequenceFlow(e, context);
       });
     } else if (is(e, 'bpmn:BoundaryEvent')) {
       deferred.unshift(function() {
         handleBoundaryEvent(e, context);
       });
     } else if (is(e, 'bpmn:FlowNode')) {
       handleFlowNode(e, context);
     } else if (is(e, 'bpmn:DataObject')) {
       // SKIP (assume correct referencing via DataObjectReference)
     } else if (is(e, 'bpmn:DataStoreReference')) {
       handleDataElement(e, context);
     } else if (is(e, 'bpmn:DataObjectReference')) {
       handleDataElement(e, context);
     } else {
       logError(
         translate('unrecognized flowElement {element} in context {context}', {
           element: elementToString(e),
           context: (context ? elementToString(context.businessObject) : 'null')
         }),
         { element: e, context: context }
       );
     }
   });
 }
Beispiel #7
0
Cli.prototype.parseArguments = function(args, command) {

  var results = [];

  var last = command.args.length -1;

  forEach(command.args, function(c, i) {

    var val;

    // last arg receives array of all remaining parameters
    if (i === last && args.length > command.args.length) {
      val = args.slice(i);
    } else {
      val = args[i];
    }

    try {
      results.push(c.parse(val));
    } catch (e) {
      throw new Error('could not parse <' + c.name + '>: ' + e.message);
    }
  });

  return results;
};
Beispiel #8
0
GraphicsFactory.prototype.updateContainments = function(elements) {

  var self = this,
      elementRegistry = this._elementRegistry,
      parents;

  parents = reduce(elements, function(map, e) {

    if (e.parent) {
      map[e.parent.id] = e.parent;
    }

    return map;
  }, {});

  // update all parents of changed and reorganized their children
  // in the correct order (as indicated in our model)
  forEach(parents, function(parent) {

    var children = parent.children;

    if (!children) {
      return;
    }

    var childGfx = self._getChildren(parent);

    forEach(children.slice().reverse(), function(c) {
      var gfx = elementRegistry.getGraphics(c);

      prependTo(gfx.parentNode, childGfx);
    });
  });
};
Beispiel #9
0
Overlays.prototype.remove = function(filter) {

  var overlays = this.get(filter) || [];

  if (!isArray(overlays)) {
    overlays = [ overlays ];
  }

  var self = this;

  forEach(overlays, function(overlay) {

    var container = self._getOverlayContainer(overlay.element, true);

    if (overlay) {
      domRemove(overlay.html);
      domRemove(overlay.htmlContainer);

      delete overlay.htmlContainer;
      delete overlay.element;

      delete self._overlays[overlay.id];
    }

    if (container) {
      var idx = container.overlays.indexOf(overlay);
      if (idx !== -1) {
        container.overlays.splice(idx, 1);
      }
    }
  });

};
  this.postExecuted([ 'shape.replace' ], 1500, function(e) {
    var context = e.context,
        oldShape = context.oldShape,
        newShape = context.newShape,
        newId = newShape.id;


    modeling.unclaimId(oldShape.businessObject.id, oldShape.businessObject);
    modeling.updateProperties(newShape, { id: oldShape.id });

    // update id of target connection references
    forEach(newShape.outgoing, function(connection) {
      var bo = connection.businessObject,
          extensionElements,
          extension;

      if (bo.$instanceOf('dmn:Association')) {
        bo.sourceRef.href = '#' + oldShape.id;
        extensionElements = bo.extensionElements;
      } else {
        bo.requiredDecision.href = '#' + oldShape.id;
        extensionElements = bo.$parent.extensionElements;
      }

      extension = filter(extensionElements.values, function(extension) {
        return extension.$type === 'biodi:Edge' && extension.source === newId;
      })[0];

      if (extension) {
        extension.source = oldShape.id;
      }
    });
  });
  forEach(groups, function(group, groupIdx) {
    var delta = {},
        prevGroup;

    if (group === firstGroup || group === lastGroup) {
      return;
    }

    prevGroup = groups[groupIdx - 1];

    group.range.max = 0;

    forEach(group.elements, function(element, idx) {
      delta[OFF_AXIS[axis]] = 0;
      delta[axis] = (prevGroup.range.max - element[axis]) + margin;

      if (group.range.min !== element[axis]) {
        delta[axis] += element[axis] - group.range.min;
      }

      if (delta[axis]) {
        modeling.moveElements([ element ], delta, element.parent);
      }

      group.range.max = Math.max(element[axis] + element[dimension], idx ? group.range.max : 0);
    });
  });
Beispiel #12
0
  forEach(properties, function(propName) {
    var refElementProp = refElement.get(propName),
        newElementProp = newElement.get(propName),
        propDescriptor = newElement.$model.getPropertyDescriptor(newElement, propName),
        newProperty, name;

    // we're not interested in cloning:
    // - same values from simple types
    // - cloning id's
    // - cloning reference elements
    if (newElementProp === refElementProp) {
      return;
    }

    if (propDescriptor && (propDescriptor.isId || propDescriptor.isReference)) {
      return;
    }

    // if the property is of type 'boolean', 'string', 'number' or 'null', just set it
    if (isType(refElementProp, [ 'boolean', 'string', 'number' ]) || refElementProp === null) {
      newElement.set(propName, refElementProp);

      return;
    }

    if (isArray(refElementProp)) {

      forEach(refElementProp, function(extElement) {
        var newProp;

        context.refTopLevelProperty = extElement;

        newProp = self._deepClone(extElement, context);

        if (context.hasNestedProperty) {
          newProp.$parent = newElement;

          newElementProp.push(newProp);
        }

        context.hasNestedProperty = false;
      });

    } else {
      name = propName.replace(/bpmn:/, '');

      context.refTopLevelProperty = refElementProp;

      newProperty = self._deepClone(refElementProp, context);

      if (context.hasNestedProperty) {
        newProperty.$parent = newElement;

        newElement.set(name, newProperty);
      }

      context.hasNestedProperty = false;
    }
  });
Beispiel #13
0
ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, replaceOptions) {

  var businessObject = getBusinessObject(element);

  var menuEntries = [];

  var modeling = this._modeling,
      moddle = this._moddle;

  var self = this;

  forEach(replaceOptions, function(entry) {

    switch (entry.actionName) {
    case 'replace-with-default-flow':
      if (businessObject.sourceRef.default !== businessObject &&
            (is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
             is(businessObject.sourceRef, 'bpmn:InclusiveGateway') ||
             is(businessObject.sourceRef, 'bpmn:ComplexGateway') ||
             is(businessObject.sourceRef, 'bpmn:Activity'))) {

        menuEntries.push(self._createMenuEntry(entry, element, function() {
          modeling.updateProperties(element.source, { default: businessObject });
        }));
      }
      break;
    case 'replace-with-conditional-flow':
      if (!businessObject.conditionExpression && is(businessObject.sourceRef, 'bpmn:Activity')) {

        menuEntries.push(self._createMenuEntry(entry, element, function() {
          var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });

          modeling.updateProperties(element, { conditionExpression: conditionExpression });
        }));
      }
      break;
    default:
      // default flows
      if (is(businessObject.sourceRef, 'bpmn:Activity') && businessObject.conditionExpression) {
        return menuEntries.push(self._createMenuEntry(entry, element, function() {
          modeling.updateProperties(element, { conditionExpression: undefined });
        }));
      }
      // conditional flows
      if ((is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
           is(businessObject.sourceRef, 'bpmn:InclusiveGateway') ||
           is(businessObject.sourceRef, 'bpmn:ComplexGateway') ||
           is(businessObject.sourceRef, 'bpmn:Activity')) &&
           businessObject.sourceRef.default === businessObject) {

        return menuEntries.push(self._createMenuEntry(entry, element, function() {
          modeling.updateProperties(element.source, { default: undefined });
        }));
      }
    }
  });

  return menuEntries;
};
Beispiel #14
0
// helpers //////////////////////

/**
 * Apply attributes from a map to the given element,
 * remove attribute from the map on application.
 *
 * @param {Base} element
 * @param {Object} attrs (in/out map of attributes)
 * @param {Array<String>} attributeNames name of attributes to apply
 */
function applyAttributes(element, attrs, attributeNames) {

  forEach(attributeNames, function(property) {
    if (attrs[property] !== undefined) {
      applyAttribute(element, attrs, property);
    }
  });
}
Beispiel #15
0
    forEach(enclosedElements, function(element) {
      forEach(element.labels, function(label) {

        if (!enclosedElements[label.id]) {
          enclosedLabels.push(label);
        }
      });
    });
ReplaceShapeHandler.prototype.postExecute = function(context) {
  var modeling = this._modeling;

  var oldShape = context.oldShape,
      newShape = context.newShape;

  // if an element gets resized on replace, layout the connection again
  forEach(newShape.incoming, function(c) {
    modeling.layoutConnection(c, { endChanged: true });
  });

  forEach(newShape.outgoing, function(c) {
    modeling.layoutConnection(c, { startChanged: true });
  });

  modeling.removeShape(oldShape);
};
Beispiel #17
0
Overlays.prototype._updateOverlaysVisibilty = function(viewbox) {

  var self = this;

  forEach(this._overlays, function(overlay) {
    self._updateOverlayVisibilty(overlay, viewbox);
  });
};
Beispiel #18
0
  /**
   * The new type constructor
   */
  function ModdleElement(attrs) {
    props.define(this, '$type', { value: name, enumerable: true });
    props.define(this, '$attrs', { value: {} });
    props.define(this, '$parent', { writable: true });

    forEach(attrs, bind(function(val, key) {
      this.set(key, val);
    }, this));
  }
Beispiel #19
0
  eventBus.on('elements.delete', function(event) {
    var elements = event.elements;

    forEach(elements, function(e) {
      if (self.isOpen(e)) {
        self.close();
      }
    });
  });
Beispiel #20
0
    exec: function() {
      var help = 'available commands:\n';

      forEach(self._commands, function(c, name) {
        help += '\n\t' + name;
      });

      return help;
    }
Beispiel #21
0
  function wireFlowNodeRefs(lane) {
    // wire the virtual flowNodeRefs <-> relationship
    forEach(lane.flowNodeRef, function(flowNode) {
      var lanes = flowNode.get('lanes');

      if (lanes) {
        lanes.push(lane);
      }
    });
  }
Beispiel #22
0
  /*
   * ## Updating Parent
   *
   * When morphing a Process into a Collaboration or vice-versa,
   * make sure that both the *semantic* and *di* parent of each element
   * is updated.
   *
   */
  function updateRoot(event) {
    var context = event.context,
        oldRoot = context.oldRoot,
        children = oldRoot.children;

    forEach(children, function(child) {
      if (is(child, 'bpmn:BaseElement')) {
        self.updateParent(child);
      }
    });
  }
Beispiel #23
0
  function handleCollaboration(collaboration) {

    forEach(collaboration.participants, contextual(handleParticipant));

    handleArtifacts(collaboration.artifacts);

    // handle message flows latest in the process
    deferred.push(function() {
      handleMessageFlows(collaboration.messageFlows);
    });
  }
Beispiel #24
0
DescriptorTree.prototype.getDepth = function(depth) {
  var newTree = {};

  forEach(this._tree, function(element) {
    if (element.depth === depth) {
      newTree[element.id] = element;
    }
  });

  return newTree;
};
Beispiel #25
0
CopyPaste.prototype._executeDescriptors = function(data) {
  if (!data.descriptor) {
    data.descriptor = {};
  }

  forEach(this._descriptors, function(descriptor) {
    data.descriptor = descriptor(data.element, data.descriptor);
  });

  return data;
};
Beispiel #26
0
DescriptorTree.prototype.getDepthLength = function(depth) {
  var length = 0;

  forEach(this._tree, function(element) {
    if (element.depth === depth) {
      length += 1;
    }
  });

  return length;
};
Beispiel #27
0
  function handleArtifacts(artifacts, context) {

    forEach(artifacts, function(e) {
      if (is(e, 'bpmn:Association')) {
        deferred.push(function() {
          handleArtifact(e, context);
        });
      } else {
        handleArtifact(e, context);
      }
    });
  }
Beispiel #28
0
  eventBus.on('element.changed', LOW_PRIORITY, function(e) {
    var element = e.element;

    var container = self._getOverlayContainer(element, true);

    if (container) {
      forEach(container.overlays, function(overlay) {
        self._updateOverlay(overlay);
      });

      self._updateOverlayContainer(container);
    }
  });
Beispiel #29
0
    forEach(shapes, function(element) {

      forEach(element.labels, function(label) {

        if (!label.hidden && context.shapes.indexOf(label) === -1) {
          labels.push(label);
        }

        if (element.labelTarget) {
          labels.push(element);
        }
      });
    });
Beispiel #30
0
  forEach(tree, function(branch, depth) {
    if (branch.length) {
      self._length += 1;
    }

    forEach(branch, function(element) {

      element.depth = parseInt(depth, 10);

      self._tree[element.id] = element;
    });

  });