Ejemplo n.º 1
0
  public RefOntoUML.Association DealAssociationStereotype(org.eclipse.uml2.uml.Association a1) {
    System.out.print("<Association> ");
    RefOntoUML.Association a2 = null;

    if (a1.getAppliedStereotypes().size() == 1) {
      org.eclipse.uml2.uml.Stereotype s = a1.getAppliedStereotypes().get(0);

      System.out.print("<<" + s.getName() + ">> ");
      String stereoname = s.getName();

      if (stereoname.compareTo("Formal") == 0) {
        a2 = myfactory.createFormalAssociation();
      } else if (stereoname.compareTo("Material") == 0) {
        a2 = myfactory.createMaterialAssociation();
      } else if (stereoname.compareTo("Mediation") == 0) {
        a2 = myfactory.createMediation();
      } else if (stereoname.compareTo("Derivation") == 0) {
        a2 = myfactory.createDerivation();
      } else if (stereoname.compareTo("Characterization") == 0) {
        a2 = myfactory.createCharacterization();
      } else if (stereoname.compareTo("componentOf") == 0) {
        a2 = myfactory.createcomponentOf();
      } else if (stereoname.compareTo("memberOf") == 0) {
        a2 = myfactory.creatememberOf();
      } else if (stereoname.compareTo("subCollectionOf") == 0) {
        a2 = myfactory.createsubCollectionOf();
      } else if (stereoname.compareTo("subQuantityOf") == 0) {
        a2 = myfactory.createsubQuantityOf();
      }

      if (a2 instanceof RefOntoUML.Meronymic) {
        boolean isShareable = (Boolean) a1.getValue(s, "isShareable");
        boolean isEssential = (Boolean) a1.getValue(s, "isEssential");
        boolean isInseparable = (Boolean) a1.getValue(s, "isInseparable");
        boolean isImmutablePart = (Boolean) a1.getValue(s, "isImmutablePart");
        boolean isImmutableWhole = (Boolean) a1.getValue(s, "isImmutableWhole");

        ((RefOntoUML.Meronymic) a2).setIsShareable(isShareable);
        ((RefOntoUML.Meronymic) a2).setIsEssential(isEssential);
        ((RefOntoUML.Meronymic) a2).setIsInseparable(isInseparable);
        ((RefOntoUML.Meronymic) a2).setIsImmutablePart(isImmutablePart);
        ((RefOntoUML.Meronymic) a2).setIsImmutableWhole(isImmutableWhole);
      }
    } else if (a1.getAppliedStereotypes().size() == 0) {
      org.eclipse.uml2.uml.Property memberEnd2 = a1.getMemberEnds().get(1);
      org.eclipse.uml2.uml.AggregationKind ak = memberEnd2.getAggregation();

      if (ak.getValue() == org.eclipse.uml2.uml.AggregationKind.NONE) {
        a2 = myfactory.createAssociation();
      } else {
        a2 = myfactory.createcomponentOf();
      }
    }

    DealAssociation(a1, a2);
    return a2;
  }
    /**
     * Gets the proposals.
     *
     * @param contents the contents
     * @param position the position
     * @return the proposals
     */
    @Override
    public DecoratedContentProposal[] getProposals(String contents, int position) {
      ArrayList<DecoratedContentProposal> proposals = new ArrayList<DecoratedContentProposal>();

      if (possibleElementList != null) {
        Iterator it = possibleElementList.getElements().iterator();
        while (it.hasNext()) {
          final Stereotype stereotype = (Stereotype) it.next();
          final String simpleName = stereotype.getName();
          final String qualifiedName = stereotype.getQualifiedName();

          if (position < simpleName.length()
              && contents
                  .substring(0, position)
                  .equalsIgnoreCase(simpleName.substring(0, position))) {
            proposals.add(new DecoratedContentProposal(stereotype, labelProvider));
          }

          if (position < qualifiedName.length()
              && contents
                  .substring(0, position)
                  .equalsIgnoreCase(qualifiedName.substring(0, position))) {
            proposals.add(new DecoratedContentProposal(stereotype, qualifiedLabelProvider));
          }
        }
      }

      Collections.sort(proposals);
      return proposals.toArray(new DecoratedContentProposal[proposals.size()]);
    }
Ejemplo n.º 3
0
  /**
   * Returns the new Id for the section
   *
   * @param selectionClass the selected class
   * @param selectionSize size of the selection
   * @return the new Id for the section
   */
  protected String getNewFragmentId(
      EClassifier selectionClass, Stereotype stereotype, int selectionSize) {
    for (int i = 0;
        i < 100;
        i++) { // no need to go to more than 100, because 100 is already a very big number of
               // fragments
      boolean found = false; // indicates if the id has been found in already fragments or not

      StringBuffer buffer = new StringBuffer();
      buffer.append("fragment_");
      if (selectionSize == 1) {
        buffer.append("single");
      } else if (selectionSize < 0) {
        buffer.append("multi");
      } else {
        buffer.append(selectionSize);
      }
      buffer.append("_");

      if (selectionClass != null && selectionClass.getInstanceClass() != null) {
        buffer.append(selectionClass.getInstanceClass().getSimpleName());
      } else if (stereotype != null && stereotype.getName() != null) {
        buffer.append(stereotype.getName());
      } else {
        buffer.append("NoName");
      }
      if (i > 0) {
        buffer.append(i);
      }
      String name = buffer.toString();

      Iterator<IFragmentDescriptorState> it =
          sectionDescriptorState.getFragmentDescriptorStates().iterator();
      while (it.hasNext()) {
        IFragmentDescriptorState fragmentDescriptorState = it.next();
        String id = fragmentDescriptorState.getDescriptor().getId();
        if (name.equalsIgnoreCase(id)) {
          found = true;
        }
      }

      if (!found) {
        return name;
      }
    }
    return "";
  }
Ejemplo n.º 4
0
  public RefOntoUML.Class DealClassStereotype(org.eclipse.uml2.uml.Class c1) {
    System.out.print("<Class> ");
    RefOntoUML.Class c2 = null;

    if (c1.getAppliedStereotypes().size() == 1) {
      org.eclipse.uml2.uml.Stereotype s = c1.getAppliedStereotypes().get(0);

      System.out.print("<<" + s.getName() + ">> ");
      String stereoname = s.getName();

      if (stereoname.compareTo("Kind") == 0) {
        c2 = myfactory.createKind();
      } else if (stereoname.compareTo("SubKind") == 0) {
        c2 = myfactory.createSubKind();
      } else if (stereoname.compareTo("Collective") == 0) {
        c2 = myfactory.createCollective();

        boolean isExtensional = (Boolean) c1.getValue(s, "isExtensional");
        ((RefOntoUML.Collective) c2).setIsExtensional(isExtensional);
      } else if (stereoname.compareTo("Quantity") == 0) {
        c2 = myfactory.createQuantity();
      } else if (stereoname.compareTo("Role") == 0) {
        c2 = myfactory.createRole();
      } else if (stereoname.compareTo("Phase") == 0) {
        c2 = myfactory.createPhase();
      } else if (stereoname.compareTo("Category") == 0) {
        c2 = myfactory.createCategory();
      } else if (stereoname.compareTo("Mixin") == 0) {
        c2 = myfactory.createMixin();
      } else if (stereoname.compareTo("RoleMixin") == 0) {
        c2 = myfactory.createRoleMixin();
      } else if (stereoname.compareTo("Relator") == 0) {
        c2 = myfactory.createRelator();
      } else if (stereoname.compareTo("Mode") == 0) {
        c2 = myfactory.createMode();
      } else if (stereoname.compareTo("Quality") == 0) {
        c2 = myfactory.createQuality();
      }
    } else if (c1.getAppliedStereotypes().size() == 0) {
      c2 = myfactory.createSubKind();
    }

    DealClass(c1, c2);
    return c2;
  }
  @Override
  public Image stereotypeIconToDisplay() {

    // retrieve the first stereotype in the list of displayed stereotype

    // String firstStereotypeName = tokenizer.nextToken();
    EList<Stereotype> stereotype_list = getUMLElement().getAppliedStereotypes();
    if (stereotype_list.size() != 0) {
      Stereotype stereotype = stereotype_list.get(0);
      if (stereotype.getName().equals("DataFlowPort")
          || stereotype.getName().equals("ServicePort")) {
        Image icon = Activator.getIconElement(getUMLElement(), stereotype, false);

        IFigure portView = getHostFigure();
        IFigure parentView = portView.getParent().getParent();

        Rectangle parentBounds = parentView.getBounds();
        Rectangle portBounds = portView.getBounds();

        if (portBounds.x() <= parentBounds.x()) {
          // left
          return icon;
        } else if (portBounds.x() >= (parentBounds.right() - portBounds.width())) {
          // right
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 180));
        } else if (portBounds.y() <= parentBounds.y()) {
          // top
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 90));
        } else if (portBounds.y() >= parentBounds.bottom() - portBounds.height()) {
          // bottom
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, -90));
        } else {
          return null;
        }
      }
      return Activator.getIconElement(getUMLElement(), stereotype, false);
    }
    return null;
  }
 /**
  * Checks if is selectable element.
  *
  * @param text the text
  * @return true, if is selectable element
  */
 @Override
 protected boolean isSelectableElement(String text) {
   // iterate through all possibilities and return true if text corresponds
   Iterator<Stereotype> it = possibleElementList.getElements().iterator();
   while (it.hasNext()) {
     Stereotype element = it.next();
     if (text.equalsIgnoreCase(element.getName())
         || text.equalsIgnoreCase(element.getQualifiedName())) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 7
0
  public static List<org.eclipse.uml2.uml.Property> getOnPort(
      org.eclipse.uml2.uml.Parameter param) {
    LinkedList<org.eclipse.uml2.uml.Property> result =
        new LinkedList<org.eclipse.uml2.uml.Property>();
    for (Stereotype st : param.getAppliedStereotypes()) {
      if (st.getName().contains("OnPort")) {
        for (Property p : st.getAttributes()) {
          result.add(p);
        }
      }
    }

    return result;
  }
 /**
  * Run add element.
  *
  * @param name the name
  */
 @Override
 protected void runAddElement(String name) {
   // find the stereotype in the list
   Stereotype stereotype = null;
   Iterator<Stereotype> it = possibleElementList.getElements().iterator();
   while (it.hasNext()) {
     Stereotype element = it.next();
     if (name.equalsIgnoreCase(element.getName())
         || name.equalsIgnoreCase(element.getQualifiedName())) {
       stereotype = element;
     }
   }
   if (stereotype != null) {
     runActionAdd(stereotype);
   }
 }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object,
   *     int, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.resource.ResourceSet)
   * @generated
   */
  public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
      editingPart.setContext(elt, allResource);

      final Stereotype stereotype = (Stereotype) elt;
      final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart) editingPart;
      // init values
      if (isAccessible(UmlViewsRepository.General.name))
        generalPart.setName(
            EEFConverterUtil.convertToString(TypesPackage.Literals.STRING, stereotype.getName()));

      if (isAccessible(UmlViewsRepository.General.visibility)) {
        generalPart.initVisibility(
            EEFUtils.choiceOfValues(stereotype, UMLPackage.eINSTANCE.getNamedElement_Visibility()),
            stereotype.getVisibility());
      }
      generalPart.setAbstract_(stereotype.isAbstract());

      generalPart.setLeaf(stereotype.isLeaf());

      // FIXME NO VALID CASE INTO template public updater(editionElement : PropertiesEditionElement,
      // view : View, pec : PropertiesEditionComponent) in widgetControl.mtl module, with the values
      // : icon, General, Stereotype.
      generalPart.setActive(stereotype.isActive());

      // init filters

      // FIXME NO VALID CASE INTO template public filterUpdater(editionElement :
      // PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) in
      // widgetControl.mtl module, with the values : icon, General, Stereotype.

      // init values for referenced views

      // init filters for referenced views

    }
    setInitializing(false);
  }
 protected void appendStereotype(
     final Element element, final StringBuffer sb, final boolean includeWrappers) {
   boolean first = true;
   final List stereotypes = element.getAppliedStereotypes();
   if (stereotypes.isEmpty()) {
     return;
   }
   if (includeWrappers) {
     sb.append("<<"); // $NON-NLS-1$
   }
   final Iterator iter = stereotypes.iterator();
   while (iter.hasNext()) {
     final Stereotype stereotype = (Stereotype) iter.next();
     if (!first) {
       sb.append(","); // $NON-NLS-1$
     }
     first = false;
     sb.append(stereotype.getName());
   }
   if (includeWrappers) {
     sb.append(">>"); // $NON-NLS-1$
   }
 }