コード例 #1
0
  private void addLink(
      EObject sourceEObject, EObject targetEObject, EReference eReference, int targetPosition) {
    Object_ sourceObject = map.getObject(sourceEObject);
    Object_ targetObject = map.getObject(targetEObject);
    Association association = getFUMLAssociation(eReference);

    if (hasOppositeReference(eReference)
        && haveProcessedAsOpposite(eReference, sourceObject, targetObject, association)) {
      return;
    }

    // Setup target property end
    LinkCreationData linkData = new LinkCreationData(sourceObject, targetObject, association);
    LinkEndCreationData targetEndData = linkData.createLinkEndCreationData();
    targetEndData.setEnd(getTargetPropertyEnd(eReference, association));
    linkData.setTargetEndData(targetEndData);
    linkData.setTargetPosition(targetPosition);

    // Setup source property end
    LinkEndCreationData sourceEndData = linkData.createLinkEndCreationData();
    if (hasOppositeReference(eReference)) {
      EReference oppositeReference = eReference.getEOpposite();
      sourceEndData.setEnd(getTargetPropertyEnd(oppositeReference, association));
      int sourcePosition = getPosition(targetEObject, oppositeReference, sourceEObject);
      linkData.setSourcePosition(sourcePosition);
      addProcessedOpposite(sourceEndData);
    } else {
      sourceEndData.setEnd(getSourcePropertyEnd(eReference, association));
    }
    linkData.setSourceEndData(sourceEndData);
    Link link = linkData.createNewLink();
    map.addExtensionalValue(link);
    // link.addTo(locus);
    locus.add(link);
  }
コード例 #2
0
 private boolean haveProcessedAsOpposite(
     EReference eReference, Object_ sourceObject, Object_ targetObject, Association association) {
   for (LinkEndCreationData processedEnd : processedOpposites) {
     if (processedEnd.representsOpposite(eReference, sourceObject, targetObject)) {
       return true;
     }
   }
   return false;
 }