public static void updateConnections(
      IFeatureProvider fp, AnchorContainer ac, List<Connection> alreadyUpdated) {
    for (int ai = 0; ai < ac.getAnchors().size(); ++ai) {
      Anchor a = ac.getAnchors().get(ai);
      for (int ci = 0; ci < a.getIncomingConnections().size(); ++ci) {
        Connection c = a.getIncomingConnections().get(ci);
        if (c instanceof FreeFormConnection) {
          if (!alreadyUpdated.contains(c)) {
            updateConnection(fp, c, true);
            alreadyUpdated.add(c);
          }
        }
      }
    }

    for (int ai = 0; ai < ac.getAnchors().size(); ++ai) {
      Anchor a = ac.getAnchors().get(ai);
      for (int ci = 0; ci < a.getOutgoingConnections().size(); ++ci) {
        Connection c = a.getOutgoingConnections().get(ci);
        if (c instanceof FreeFormConnection) {
          if (!alreadyUpdated.contains(c)) {
            updateConnection(fp, c, true);
            alreadyUpdated.add(c);
          }
        }
      }
    }
  }
  public static void setContainerChildrenVisible(
      IFeatureProvider fp, ContainerShape container, boolean visible) {
    List<PictogramElement> list = new ArrayList<PictogramElement>();
    list.addAll(container.getChildren());
    for (PictogramElement pe : list) {
      if (ShapeDecoratorUtil.isActivityBorder(pe)) continue;

      if (ShapeDecoratorUtil.isEventSubProcessDecorator(pe)) {
        pe.setVisible(!visible);
      } else pe.setVisible(visible);

      if (visible) FeatureSupport.updateLabel(fp, pe, null);
      if (pe instanceof AnchorContainer) {
        AnchorContainer ac = (AnchorContainer) pe;
        for (Anchor a : ac.getAnchors()) {
          for (Connection c : a.getOutgoingConnections()) {
            c.setVisible(visible);
            if (visible) FeatureSupport.updateLabel(fp, c, null);
            for (ConnectionDecorator decorator : c.getConnectionDecorators()) {
              decorator.setVisible(visible);
            }
          }
        }
      }
    }
  }
 private Set<Contract> getExistingConnections(AnchorContainer container) {
   Set<Contract> existingConnections = new LinkedHashSet<Contract>();
   for (Anchor anchor : container.getAnchors()) {
     for (Connection connection : anchor.getIncomingConnections()) {
       Object bo = getBusinessObjectForPictogramElement(connection.getStart());
       if (bo instanceof Contract || bo == null) {
         existingConnections.add((Contract) bo);
       }
     }
   }
   return existingConnections;
 }