Example #1
0
 /**
  * Convenient implementation of the {@link #getLinkElements(InternalProject, EObject, EReference)}
  * method to use the {@link ItemPropertyDescriptor} to get all object of an object.
  *
  * @param project the project the call is from
  * @param modelElement {@link EObject} to add the {@link EReference} to
  * @param eReference the {@link EReference} to add
  * @return {@link Iterator} of {@link EObject} that can be linked
  */
 @Override
 public Iterator<EObject> getLinkElements(
     InternalProject project, EObject modelElement, EReference eReference) {
   final EClass elementClass = modelElement.eClass();
   EClassifier type =
       EcoreUtil.getReifiedType(elementClass, eReference.getEGenericType()).getEClassifier();
   if (type == null) {
     type = eReference.getEType();
   }
   return ItemPropertyDescriptor.getReachableObjectsOfType(modelElement, type).iterator();
 }
    /**
     * @see org.eclipse.emf.edit.provider.ItemPropertyDescriptor#setPropertyValue(java.lang.Object,
     *     java.lang.Object)
     */
    @Override
    public void setPropertyValue(Object object, Object value) {

      TypedElement typedElement = (TypedElement) object;

      // the value can either be a type parameter ...
      if (value instanceof TypeParameter) {
        TypeParameter typeParameter = (TypeParameter) value;

        // create a new generic type for type parameters and set its
        // referenced type parameter
        ParameterGenericType genericType = PivotModelFactory.eINSTANCE.createParameterGenericType();
        genericType.setTypeParameter(typeParameter);

        setGenericType(typedElement, genericType);
      }

      // ... or a normal type
      else if (value instanceof Type) {
        Type type = (Type) value;

        // check if the type has any type parameters
        if (!type.getOwnedTypeParameter().isEmpty()) {

          // create a new complex generic type and set the given type
          // as a reference
          ComplexGenericType genericType = PivotModelFactory.eINSTANCE.createComplexGenericType();
          genericType.setUnboundType(type);

          // append type arguments for each type parameter
          for (int i = 0, size = type.getOwnedTypeParameter().size(); i < size; i++) {
            genericType.getTypeArgument().add(PivotModelFactory.eINSTANCE.createTypeArgument());
          }

          setGenericType(typedElement, genericType);
        }

        // just a normal type without type parameters
        else {
          // remove any previously created generic types
          setGenericType(typedElement, null);
          super.setPropertyValue(object, value);
        }
      }
    }
 public void setPropertyValue(Object object, Object value) {
   super.setPropertyValue(findCorrectOwner(feature, (EObject) object), value);
 }