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;
 }
 /**
  * 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;
 }
  /**
   * 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;
  }
 /**
  * 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 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();
 }
 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();
 }
 /**
  * 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);
   }
 }
Example #9
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;
  }
Example #10
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;
  }
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #13
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;
  }
Example #14
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());
  }
Example #15
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
  }
  /**
   * 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;
  }
 /**
  * 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;
 }
Example #19
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;
 }
Example #20
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;
 }