Ejemplo n.º 1
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * Update the targetCount Label
   *
   * @generated NOT
   */
  private void updateTargetCountLabel() {
    Label targetCount = (Label) ((AssociationFigure) getFigure()).gettargetCountEdgeObjectFigure();

    Association association = (Association) Utils.getElement(getGraphEdge());
    if (association != null) {

      String lowerBound = association.getSecondEnd().getCardMin();
      String upperBound = association.getSecondEnd().getCardMax();

      if (upperBound == null) {
        upperBound = new String("0");
      }

      if (lowerBound == null) {
        lowerBound = new String("0");
      }

      if (upperBound.equals("-1")) {
        upperBound = "*";
      }

      if (lowerBound.equals(upperBound)) {
        if (!(lowerBound.equals("1"))) targetCount.setText(lowerBound);
        else targetCount.setText("");
      } else {
        targetCount.setText(lowerBound + ".." + upperBound);
      }
    }
  }
Ejemplo n.º 2
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * Update the targetName Label
   *
   * @generated NOT
   */
  private void updateTargetNameLabel() {
    Label targetName = (Label) ((AssociationFigure) getFigure()).gettargetNameEdgeObjectFigure();

    Association association = (Association) Utils.getElement(getGraphEdge());

    targetName.setText(association.getSecondEnd().getName());
  }
Ejemplo n.º 3
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * Update the middleName Label
   *
   * @generated NOT
   */
  private void updateMiddleNameLabel() {
    Association association = (Association) Utils.getElement(getGraphEdge());

    AssociationFigure fig = ((AssociationFigure) getFigure());
    EdgeObjectOffsetEditableLabel label =
        (EdgeObjectOffsetEditableLabel) fig.getmiddleNameEdgeObjectFigure();
    label.setText(association.getName());
  }
Ejemplo n.º 4
0
 /**
  * Gets the association name.
  *
  * @param association the association
  * @return the association name
  */
 public String getAssociationName(Association association) {
   EList<Comment> comments = association.getComments();
   for (Comment comment : comments) {
     EList<Stereotype> stereotypes = comment.getStereotypes();
     for (Stereotype stereotype : stereotypes) {
       if (stereotype.getName().equals(FormGeneratorsManager.ALFRESCO_NAME_ASSOCIATION)) {
         return comment.getValue();
       }
     }
   }
   return association.getName();
 }
Ejemplo n.º 5
0
  /** Update the target decoration */
  private void updateTargetDecoration() {
    Association association = (Association) Utils.getElement(getGraphEdge());

    boolean isNavigable = false;
    if (association.getSecondEnd() != null) {
      isNavigable = association.getSecondEnd().isNavigable();
    }

    if (!isNavigable) {
      if (association.getAssociationType() == AssociationType.COMPOSITION) {
        targetDecor = createCompositionDecoration();
      } else if (association.getAssociationType() == AssociationType.AGGREGATION) {
        targetDecor = createAggregationDecoration();
      } else {
        targetDecor = null;
      }
    } else {
      targetDecor = createNavigableDecoration();
    }
    ((PolylineConnection) figure).setTargetDecoration(targetDecor);
  }
Ejemplo n.º 6
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated NOT
   */
  protected void refreshEdgeObjects() {
    super.refreshEdgeObjects();

    // Check whether the association has its two Properties set
    if (((GraphEdge) getModel()).getAnchor().size() != 0) {
      Association association = (Association) Utils.getElement(getGraphEdge());
      if (association.getName() == null) {
        association.setName("Association");
      }
      // create associationEnd objects
      AssociationHelper.createAssociationsEnds(this, association);
      updateSourceDecoration();
      updateTargetDecoration();
      updateSrcCountLabel();
      updateSrcNameLabel();
      updateTargetCountLabel();
      updateTargetNameLabel();
    }

    updateMiddleNameLabel();
  }
Ejemplo n.º 7
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * Update the srcName Label
   *
   * @generated NOT
   */
  private void updateSrcNameLabel() {
    Label srcName = (Label) ((AssociationFigure) getFigure()).getsrcNameEdgeObjectFigure();

    Association association = (Association) Utils.getElement(getGraphEdge());
    srcName.setText(association.getFirstEnd().getName());
  }
Ejemplo n.º 8
0
  protected void synchronizeMissingAssociations(
      FormContainer o,
      List<FormElement> children,
      AbstractClass real_class,
      Set<FormGroup> groups,
      String filterNS) {

    List<Association> allAssociations = real_class.getAllSourceAssociations();

    // get FormElement that miss
    ArrayList<Association> missAtt = new ArrayList<Association>();

    if (allAssociations != null) {
      missAtt.addAll(allAssociations);
    }

    for (FormElement formElement : children) {
      ModelElement ref = formElement.getRef();
      if (ref != null && ref instanceof Association) {
        // linked element is attribute so remove this attribute from the missing list
        missAtt.remove(ref);
      }
    }

    EList<FormGroup> allSubGroups = o.getAllSubGroups();
    groups.addAll(allSubGroups);

    // now we have the attribute missing list
    // initialize missing Field
    for (Association ass : missAtt) {

      FormElement fieldForAssociation = null;
      if (o instanceof FormClass || o instanceof FormWorkflow) {
        fieldForAssociation = ClassDiagramUtils.getModelChoiceFieldForAssociation(ass, real_class);
      } else if (o instanceof FormSearch) {
        fieldForAssociation =
            ClassDiagramUtils.transformAssociationIntoModelChoiceSearchField(ass, real_class);
      }

      if (WorkflowInitialization.filterFormElement(filterNS, fieldForAssociation)) {

        // get where to add the field
        FormGroup parent = null;
        // mybe a group exist with ref to the attribute container

        // search for matching group

        for (FormGroup formGroup : groups) {
          ModelElement ref = formGroup.getRef();
          if (ref instanceof AbstractClass
              && ((AbstractClass) ref).getSourceAssociations().contains(ass)) {
            // matching group founded
            parent = formGroup;
            break;
          }
        }

        if (createMissingGroup && parent == null) {
          AbstractClass source = null;
          EList<AbstractClass> sources = ass.getSource();
          if (sources.size() == 1) {
            source = sources.get(0);
          } else {
            EList<AbstractClass> allLinkedAbstractClass = real_class.getAllLinkedAbstractClass();
            boolean contains = allLinkedAbstractClass.contains(sources.get(0));
            if (contains) {
              source = sources.get(0);
            } else {
              source = sources.get(1);
            }
          }
          parent = ClassInitialization.createGroup(source);
          addChild(o, parent);
        }

        // add new Field to the parent
        if (parent == null) {
          parent = o;
        }
        addChild(parent, fieldForAssociation);
      }
    }
  }