Exemple #1
0
  private void registerConnection(GraphNode source, GraphNode destination) {
    if (source.getSourceConnections().contains(this)) {
      source.removeSourceConnection(this);
    }
    if (destination.getTargetConnections().contains(this)) {
      destination.removeTargetConnection(this);
    }
    (source).addSourceConnection(this);
    (destination).addTargetConnection(this);

    if (source.getParent().getItemType() == GraphItem.CONTAINER
        && destination.getParent().getItemType() == GraphItem.CONTAINER
        && (source.getParent() == destination.getParent())) {
      // 196189: Edges should not draw on the edge layer if both the src
      // and dest are in the same container
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=196189
      graph.addConnection(this, false);
    } else {
      graph.addConnection(this, true);
    }

    if ((source.getParent()).getItemType() == GraphItem.CONTAINER) {
      // If the container of the source is a container, we need to draw
      // another
      // arc on that arc layer
      sourceContainerConnectionFigure = doCreateFigure();
      ((GraphContainer) source.getParent()).addConnectionFigure(sourceContainerConnectionFigure);
      this.setVisible(false);
    }

    if ((destination.getParent()).getItemType() == GraphItem.CONTAINER) { // &&
      // src_destSameContainer
      // ==
      // false)
      // {
      // If the container of the source is a container, we need to draw
      // another
      // arc on that arc layer
      targetContainerConnectionFigure = doCreateFigure();
      ((GraphContainer) destination.getParent())
          .addConnectionFigure(targetContainerConnectionFigure);
      this.setVisible(false);
    }
    graph.registerItem(this);
  }