protected String getTargetOS(InstanceSpecification node) {
   Target target = UMLUtil.getStereotypeApplication(node, Target.class);
   if (target == null) {
     // get information from node referenced by the instance
     target = UMLUtil.getStereotypeApplication(DepUtils.getClassifier(node), Target.class);
   }
   if (target != null) {
     OperatingSystem os = target.getUsedOS();
     if (os != null) {
       return os.getBase_Class().getName();
     }
   }
   return null;
 }
  /**
   * Checks if is correct graphical view.
   *
   * @param connectorEnd a connector end
   * @param view a view
   * @return <code>true</code> if the view represents the role of the connector AND if the view is
   *     encapsulated as required by the nested path of the connector end
   */
  protected boolean isCorrectGraphicalView(final ConnectorEnd connectorEnd, final View view) {
    final NestedConnectorEnd nestedConnectorEnd =
        org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(
            connectorEnd, NestedConnectorEnd.class);
    final Property partWithPort = connectorEnd.getPartWithPort();
    // final ConnectableElement role = end.getRole();
    // 1. we get the top view of this view with the same semantic element
    View localView = getTopViewWithSameSemanticElement(view);

    // 2. we verify the part with port
    if (partWithPort != null) {
      View parent = getTopViewWithSameSemanticElement(ViewUtil.getViewContainer(localView));
      if (parent.getElement() != partWithPort) {
        return false;
      }
    }

    // 3. we verify the nested path
    if (nestedConnectorEnd != null && nestedConnectorEnd.getPropertyPath().size() > 0) {
      View parent = view;
      final List<Property> paths = nestedConnectorEnd.getPropertyPath();
      for (int i = paths.size() - 1; i >= 0; i--) {
        final Property currentProperty = paths.get(i);
        parent = getTopViewWithSameSemanticElement(ViewUtil.getViewContainer(parent));
        if (parent.getElement() != currentProperty) {
          return false;
        }
      }
    }
    return true;
  }
 /**
  * Is this property a DataFlow Port
  *
  * @param port
  * @return is this a DataFlow port ?
  */
 public static Boolean isDataFlowPort(Port port) {
   DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
   if (dfp == null) {
     return false;
   }
   return true;
 }
 /** Refreshes the stereotype display */
 protected void refreshAppliedStereotypesPropertiesInCompartment(
     String stereotypesPropertiesToDisplay, IPapyrusNodeUMLElementFigure figure) {
   final boolean displayInCompartment =
       AppliedStereotypeHelper.hasAppliedStereotypesPropertiesToDisplay(
           (View) (View) getHost().getModel(),
           UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);
   // if the string is not empty, then, the figure has to display it. Else,
   // it displays nothing
   final GraphicalEditPart editPart = (GraphicalEditPart) getHost();
   final View node = editPart.getNotationView();
   int i = 0;
   // we go through all sub nodes
   while (i < node.getChildren().size()) {
     if ((node.getChildren().get(i)) instanceof Node) {
       final Node currentNode = (Node) (node.getChildren().get(i));
       if (currentNode.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
         EObject stereotypeApplication = currentNode.getElement();
         Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
         if (stereotype != null
             && stereotypesPropertiesToDisplay.contains(stereotype.getQualifiedName())) {
           setVisivility(currentNode, displayInCompartment);
         } else {
           setVisivility(currentNode, false);
         }
       }
     }
     i++;
   }
 }
Esempio n. 5
0
 /**
  * Tell if the ActivityPartition is a AllocateActivityPartition implementation
  *
  * @param ActivityPartition
  * @return
  * @generated
  */
 protected Boolean isAllocateActivityPartitionFromActivityPartition(
     ActivityPartition activityPartition_) {
   if (UMLUtil.getStereotypeApplication(activityPartition_, AllocateActivityPartition.class)
       != null) {
     return true;
   }
   return false;
 }
 public static int getOutputPortBufferSize(Port p) {
   org.eclipse.papyrus.RobotML.DataFlowPort dfp =
       org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(
           p, org.eclipse.papyrus.RobotML.DataFlowPort.class);
   if (dfp == null) {
     return 0;
   }
   return dfp.getBufferSize();
 }
 public static String getNativeComponentNameForComponent(org.eclipse.uml2.uml.Class c) {
   org.eclipse.papyrus.RobotML.System sys =
       org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(
           c, org.eclipse.papyrus.RobotML.System.class);
   if (sys == null) {
     return null;
   }
   return sys.getLibraryComponentName();
 }
 public static Boolean hasNativeImplementation(org.eclipse.uml2.uml.Class c) {
   org.eclipse.papyrus.RobotML.System sys =
       org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(
           c, org.eclipse.papyrus.RobotML.System.class);
   if (sys == null) {
     return false;
   }
   return sys.isNative();
 }
 /**
  * Bind C++ const initializer
  *
  * @param operation
  * @param actual
  * @throws TransformationException
  */
 public static void bindOperation(Operation operation, Classifier actual)
     throws TransformationException {
   // perform binding in case of C++ initializer
   ConstInit cppConstInit = UMLUtil.getStereotypeApplication(operation, ConstInit.class);
   if (cppConstInit != null) {
     // TODO: specific to C++
     String init = cppConstInit.getInitialisation();
     String newInit = AcceleoDriverWrapper.bind(init, actual);
     cppConstInit.setInitialisation(newInit);
   }
 }
Esempio n. 10
0
  public boolean matches(EObject eObject) {

    boolean isMatch = false;
    if (eObject instanceof Comment) {

      Comment element = (Comment) eObject;
      if (UMLUtil.getStereotypeApplication(element, Rationale.class) != null) {
        isMatch = true;
      }
    }
    return isMatch;
  }
Esempio n. 11
0
  public boolean matches(EObject eObject) {

    boolean isMatch = false;
    if (eObject instanceof Dependency) {

      Dependency element = (Dependency) eObject;
      if (UMLUtil.getStereotypeApplication(element, Conform.class) != null) {
        isMatch = true;
      }
    }
    return isMatch;
  }
Esempio n. 12
0
 /**
  * For DataFlow ports: is it an Output Port ?
  *
  * @param port
  * @return false if the port is not a DataFlowPort or not an input/output port.
  */
 public static Boolean isAnInputOutputPort(Port port) {
   try {
     DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
     if (dfp == null) {
       return false;
     }
     if (dfp.getDirection() == DataFlowDirectionKind.INOUT) {
       return true;
     }
     return false;
   } catch (Exception e) {
     java.lang.System.out.println("EXCEPTION caught:" + e.toString());
   }
   return false;
 }
Esempio n. 13
0
 /**
  * For RobotML ServicePorts: is the port a "Required" port?
  *
  * @param port
  * @return false if the port is not a ServicePort or not a "Required" ServicePort.
  */
 public static Boolean isARequiredPort(Port port) {
   try {
     ServicePort sp = UMLUtil.getStereotypeApplication(port, ServicePort.class);
     if (sp == null) {
       return false;
     }
     if (sp.getKind() == ServiceFlowKind.REQUIRED) {
       return true;
     }
     return false;
   } catch (Exception e) {
     java.lang.System.out.println("EXCEPTION caught:" + e.toString());
   }
   return false;
 }
Esempio n. 14
0
  public boolean matches(EObject eObject) {

    boolean isFlowPort_NA = false;

    if (eObject instanceof Port) {

      Port port = (Port) eObject;
      FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class);

      if ((flowPort != null) && (!flowPort.isAtomic())) {
        isFlowPort_NA = true;
      }
    }

    return isFlowPort_NA;
  }
Esempio n. 15
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated NOT
   */
  @Override
  public EList<FeatureModel> getTechnicalFeatureModel() {
    EList<FeatureModel> results = new BasicEList<FeatureModel>();
    FeatureModel adlFeatureModel = null;
    if (getBase_NamedElement() != null) {
      Iterator<Element> it = getBase_NamedElement().getOwnedElements().iterator();

      while (it.hasNext()) {
        Element element = it.next();
        adlFeatureModel = UMLUtil.getStereotypeApplication(element, FeatureModel.class);
        if (adlFeatureModel != null) {
          results.add(adlFeatureModel);
        }
      }
    }

    return new BasicInternalEList<FeatureModel>(
        FeatureModel.class, results.size(), results.toArray());
  }
Esempio n. 16
0
  /** {@inheritDoc} */
  public boolean matches(EObject eObject) {

    boolean isMatch = false;
    if ((eObject instanceof Property) && !(eObject instanceof Port)) {

      Property element = (Property) eObject;

      // The property is necessary a composition and has a type
      if ((element.getType() != null)
          && (element.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {

        // Moreover its type has to be a Block
        if (UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
          isMatch = true;
        }
      }
    }
    return isMatch;
  }
  /** {@inheritDoc} */
  @Override
  protected Diagram doCreateDiagram(
      Resource diagramResource,
      EObject owner,
      EObject element,
      ViewPrototype prototype,
      String name) {
    // Start of user code Custom diagram creation
    Diagram diagram = null;

    org.eclipse.uml2.uml.Class cOwner = (org.eclipse.uml2.uml.Class) element;
    Block block = UMLUtil.getStereotypeApplication(cOwner, Block.class);

    if (block != null) {
      canvasDomainElement = (EObject) element;
      Package owningPackage = ((Element) element).getNearestPackage();
      diagram = super.doCreateDiagram(diagramResource, owner, owningPackage, prototype, name);
    }

    return diagram;
    // End of user code
  }
Esempio n. 18
0
  @Override
  protected void setUp() {
    super.setUp();

    pkg = umlf.createPackage();
    pkg.setName("pkg");

    valueType = pkg.createOwnedPrimitiveType("Value");
    valueType
        .createOwnedOperation(
            "<",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            "<=",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            ">",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            ">=",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);

    thingType = pkg.createOwnedClass("Thing", false);

    values = thingType.createOwnedAttribute("values", valueType);
    values.setUpper(LiteralUnlimitedNatural.UNLIMITED);
    values.setIsOrdered(true);
    values.setIsUnique(true);

    bdValue = thingType.createOwnedAttribute("bdValue", getEcoreBigDecimal());
    biValue = thingType.createOwnedAttribute("biValue", getEcoreBigInteger());

    numeroType = pkg.createOwnedClass("Numero", false);

    numeroType
        .createOwnedOperation(
            "+",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "-",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "*",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "/",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);

    numeroType
        .createOwnedOperation(
            "-", ECollections.<String>emptyEList(), ECollections.<Type>emptyEList(), numeroType)
        .setIsQuery(true);

    numeroType
        .createOwnedOperation(
            "<",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "<=",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            ">",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            ">=",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "asLong",
            ECollections.<String>emptyEList(),
            ECollections.<Type>emptyEList(),
            getEcoreLong())
        .setIsQuery(true);

    numeros = thingType.createOwnedAttribute("numeros", numeroType);
    numeros.setUpper(LiteralUnlimitedNatural.UNLIMITED);
    numeros.setIsOrdered(true);
    numeros.setIsUnique(true);

    comparable = pkg.createOwnedClass("Comparable", true);
    comparable
        .createOwnedOperation(
            "compareTo",
            new BasicEList<String>(Collections.singleton("c")),
            new BasicEList<Type>(Collections.singleton(comparable)),
            getUMLInteger())
        .setIsQuery(true);

    // the Ecore counterpart

    epkg = UMLUtil.convertToEcore(pkg, null).iterator().next();

    ethingType = (EClass) epkg.getEClassifier(thingType.getName());
    enumeros = (EReference) ethingType.getEStructuralFeature(numeros.getName());
    evalues = (EAttribute) ethingType.getEStructuralFeature(values.getName());
    ebdValue = (EAttribute) ethingType.getEStructuralFeature(bdValue.getName());
    ebiValue = (EAttribute) ethingType.getEStructuralFeature(biValue.getName());

    enumeroType = (EClass) epkg.getEClassifier(numeroType.getName());
    enumeroType.setInstanceClass(Numero.class);

    evalueType = (EDataType) epkg.getEClassifier(valueType.getName());
    evalueType.setInstanceClass(Value.class);

    efactory = epkg.getEFactoryInstance();
    thing = efactory.create(ethingType);

    EPackage.Registry.INSTANCE.put(epkg.getNsURI(), epkg);

    @SuppressWarnings("unchecked")
    EList<Numero> list = (EList<Numero>) thing.eGet(enumeros);
    list.add(new Numero(6));
    list.add(new Numero(2));
  }
Esempio n. 19
0
 /**
  * Is this property a Service Port
  *
  * @param port
  * @return is this a service port ?
  */
 public static Boolean isServicePort(Port port) {
   ServicePort serviceport = UMLUtil.getStereotypeApplication(port, ServicePort.class);
   return serviceport != null;
 }
  /**
   * Bind a named element. Besides of binding the passed element, this operation will bind all
   * elements that are referenced (required) by the passed element.
   *
   * <p>In consequence, typically only a small part of a package template is actually created within
   * the bound package. We call this mechanism lazy instantiation/binding
   *
   * @param copier Source and target model
   * @param namedElement A member within the package template which should be bound, i.e. for which
   *     template instantiation should be performed.
   * @param binding The binding between the bound package and the package template
   * @param args Acceleo arguments
   */
  @SuppressWarnings("unchecked")
  public <T extends NamedElement> T bindNamedElement(T namedElement)
      throws TransformationException {
    if (namedElement == null) {
      // user should never see this exception
      throw new TransformationException(Messages.TemplateInstantiation_TemplateIsNull);
    }

    Package boundPackage = (Package) binding.getBoundElement();
    EList<Namespace> path = TemplateUtils.relativePathWithMerge(namedElement, packageTemplate);
    Template template = UMLUtil.getStereotypeApplication(namedElement, Template.class);
    BindingHelper helper = (template != null) ? template.getHelper() : null;

    /*
    if((templateKind == TemplateKind.ACCUMULATE) || (templateKind == TemplateKind.LATE_EVALUATION)) {
    	// TODO: not very clean yet
    	path = TemplateUtils.relativePathWithMerge(namedElement, copy.source);
    	if(path == null) {
    		// element is imported
    		path = namedElement.allNamespaces();
    	}
    	boundPackage = copy.target; // CreationUtils.getAndCreate
    								// (sat.target, "accumulate");
    }
    */

    if (path != null) {
      // register owning package template (template can be defined in
      // multiple packages)
      Element owner = TemplateUtils.getTemplateOwner(namedElement, signature);
      if (owner != null) {
        // note that we might overwrite an existing value
        copier.put(owner, boundPackage);
      }
    } else {
      // element is not part of the package template referenced by the
      // binding
      if (namedElement instanceof TemplateableElement) {
        // check whether the referenced element is part of another
        // package template,
        // (for which we allow for implicit binding with the first
        // template parameter)
        TemplateSignature signatureOfNE =
            TemplateUtils.getSignature((TemplateableElement) namedElement);
        if ((signatureOfNE != null) && (signature != signatureOfNE)) {
          TemplateBinding subBinding =
              TemplateUtils.getSubBinding(
                  copier.target, (TemplateableElement) namedElement, binding);
          TemplateInstantiation ti = new TemplateInstantiation(copier, subBinding, args);
          NamedElement ret = ti.bindNamedElement(namedElement);
          return (T) ret;
        }
      }

      // => nothing to do with respect to template instantiation, but
      // since the template is potentially instantiated in another model,
      // the referenced element might need to be copied.

      return copier.getCopy(namedElement);
    }
    // element is contained in the template package, examine whether it
    // already exists in the
    // bound package.

    NamedElement existingMember = (NamedElement) copier.get(namedElement);
    /*
    if((existingMember != null) && (templateKind != TemplateKind.ACCUMULATE)) {
    	// element is already existing (and thus bound), nothing to do
    	// additional check, whether the ACCUMULATE information is unset)
    	// however: if the element is a package, existence is not sufficient
    	// since it might have been created via getAndCreate above

    	//if(namedElement instanceof Package) {
    	//	bindPackage((Package)namedElement);
    	//}
    	return (T)existingMember;
    }
    */
    if (existingMember == null) {
      FilterTemplate.getInstance().setActive(false);
      T copiedElement = copier.getCopy(namedElement);
      FilterTemplate.getInstance().setActive(true);
      copier.setPackageTemplate(null, null);
      return copiedElement;
    }

    return (T) existingMember;
  }
Esempio n. 21
0
 public EPackage getEPackage(Package pkg) {
   return UMLUtil.convertToEcore(pkg, null).iterator().next();
 }
Esempio n. 22
0
 /**
  * Tell if the Abstraction is a Allocate implementation
  *
  * @param Abstraction
  * @return
  * @generated
  */
 protected Boolean isAllocateFromAbstraction(Abstraction abstraction_) {
   if (UMLUtil.getStereotypeApplication(abstraction_, Allocate.class) != null) {
     return true;
   }
   return false;
 }
Esempio n. 23
0
 /**
  * Tell if the NamedElement is a Allocated implementation
  *
  * @param NamedElement
  * @return
  * @generated
  */
 protected Boolean isAllocatedFromNamedElement(NamedElement namedElement_) {
   if (UMLUtil.getStereotypeApplication(namedElement_, Allocated.class) != null) {
     return true;
   }
   return false;
 }