/**
   * Bind an operation by copying the signature from the actual.
   *
   * @param copy the copier
   * @param actual the actual. If an operation, its signature is copied to the template
   * @param operation The operation template
   * @return
   */
  public static Operation instantiateOperation(
      LazyCopier copy, Element actual, Operation operation) {
    try {
      Operation newOperation = copy.getCopy(operation);
      if (actual instanceof Operation) {
        for (Parameter parameter : ((Operation) actual).getOwnedParameters()) {
          Parameter newParam = EcoreUtil.copy(parameter); // copy parameter via EcoreUtil
          newParam.setType(copy.getCopy(parameter.getType()));
          newOperation.getOwnedParameters().add(newParam);
        }
      }
      TransformationContext.classifier = newOperation.getClass_();
      if (actual instanceof Classifier) {
        bindOperation(newOperation, (Classifier) actual);
      }
      String newName = AcceleoDriverWrapper.evaluate(operation.getName(), actual, null);
      newOperation.setName(newName);

      return newOperation;
    } catch (TransformationException e) {
      // throw runtime exception
      throw new RuntimeException(
          String.format(Messages.TemplateInstantiationListener_TrafoException, e.getMessage()));
    }
  }
 /**
  * Set correctly the invoked object, by creating it if needed. Then, notifies that the ok button
  * of this dialog has been pressed.
  *
  * @see org.eclipse.jface.dialogs.Dialog#okPressed()
  */
 @Override
 protected void okPressed() {
   // create element
   createdParameter = UMLFactory.eINSTANCE.createParameter();
   createdParameter.setName(selectedName);
   createdParameter.setType((Type) selectedType);
   createdParameter.setDirection(selectedDirection);
   addParameter(createdParameter);
   super.okPressed();
 }