/**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.CreateCallActionDialog#hasOutParameters(org.eclipse.emf.ecore.EObject)
  */
 @Override
 protected boolean hasOutParameters(EObject invokedObject) {
   if (invokedObject instanceof Behavior) {
     for (Parameter param : ((Behavior) invokedObject).getOwnedParameters()) {
       if (ParameterDirectionKind.INOUT_LITERAL.equals(param.getDirection())
           || ParameterDirectionKind.OUT_LITERAL.equals(param.getDirection())) {
         return true;
       }
     }
   }
   return false;
 }
Ejemplo n.º 2
0
 public static List<Parameter> filterParameters(
     List<Parameter> original, ParameterDirectionKind... direction) {
   List<ParameterDirectionKind> directionList = Arrays.asList(direction);
   List<Parameter> filtered = new ArrayList<Parameter>(original.size());
   for (Parameter parameter : original)
     if (directionList.contains(parameter.getDirection())) filtered.add(parameter);
   return filtered;
 }
Ejemplo n.º 3
0
 /**
  * Gives the return parameter for this operation, or <code>null</code> if none exists.
  *
  * @return the return parameter of the operation or <code>null</code>
  */
 private static Parameter getReturnParameter(Operation operation) {
   // Retrieve the return parameter (assume to be unique if defined)
   Parameter returnParameter = null;
   Iterator<Parameter> it = operation.getOwnedParameters().iterator();
   while ((returnParameter == null) && (it.hasNext())) {
     Parameter parameter = it.next();
     if (parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
       returnParameter = parameter;
     }
   }
   return returnParameter;
 }
Ejemplo n.º 4
0
  /**
   * Returns the string used to represent this parameter
   *
   * @param parameter a parameter
   * @return the string used to represent this parameter
   */
  public static String getLabel(Parameter parameter) {
    StringBuffer buffer = new StringBuffer();
    // visibility
    buffer.append(" "); // $NON-NLS-1$
    buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));

    // direction
    buffer.append(" "); // $NON-NLS-1$
    buffer.append(parameter.getDirection().getLiteral());

    // name
    buffer.append(" "); // $NON-NLS-1$
    if (parameter.getName() != null) {
      buffer.append(parameter.getName());
    }

    // type
    if (parameter.getType() != null) {
      EList<Namespace> namespaces = parameter.allNamespaces();
      buffer.append(
          " : "
              + getTypeLabel(
                  parameter.getType(), namespaces.get(namespaces.size() - 1))); // $NON-NLS-1$
    } else {
      buffer.append(" : " + TypeUtil.UNDEFINED_TYPE_NAME); // $NON-NLS-1$
    }

    // multiplicity -> do not display [1]
    String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
    if (!multiplicity.trim().equals("[1]")) { // $NON-NLS-1$
      buffer.append(multiplicity);
    }

    // default value
    if (parameter.getDefault() != null) {
      buffer.append(" = "); // $NON-NLS-1$
      buffer.append(parameter.getDefault());
    }

    // property modifiers
    buffer.append(ParameterUtil.getModifiersAsString(parameter, false));
    buffer.append(getEffectAsString(parameter));
    return buffer.toString();
  }
Ejemplo n.º 5
0
 /**
  * Returns operation parameters as a string, the label is customized using a bit mask
  *
  * @param e
  * @return a string containing all parameters separated by commas
  */
 private static String getParametersAsString(
     Message e, Operation operation, Collection<String> displayValue) {
   StringBuffer paramString = new StringBuffer();
   Iterator<Parameter> paramIterator = operation.getOwnedParameters().iterator();
   boolean firstParameter = true;
   int paramIndex = 0;
   while (paramIterator.hasNext()) {
     Parameter parameter = paramIterator.next();
     // Do not include return parameters
     if (!parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
       // get the label for this parameter
       String parameterString = getCustomLabel(e, paramIndex, parameter, displayValue).trim();
       paramIndex++;
       if (!parameterString.equals("")) {
         if (!firstParameter) {
           paramString.append(", ");
         }
         paramString.append(parameterString);
         firstParameter = false;
       }
     }
   }
   return paramString.toString();
 }
Ejemplo n.º 6
0
 public static String getCustomLabel(
     Message e, int paramIndex, Parameter parameter, Collection<String> displayValue) {
   StringBuffer buffer = new StringBuffer();
   // visibility
   buffer.append(" ");
   if (displayValue.contains(ICustomAppearance.DISP_VISIBILITY)) {
     buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
   }
   // direction property
   if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_DIRECTION)) {
     buffer.append(" ");
     buffer.append(parameter.getDirection().getLiteral());
   }
   boolean showEqualMark = false;
   // name
   if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_NAME)) {
     buffer.append(" ");
     String name = StringHelper.trimToEmpty(parameter.getName());
     if (name.trim().length() > 0) {
       showEqualMark = true;
     }
     buffer.append(name);
   }
   if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_TYPE)) {
     // type
     if (parameter.getType() != null) {
       buffer.append(": " + StringHelper.trimToEmpty(parameter.getType().getName()));
     } else {
       buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
     }
     showEqualMark = true;
   }
   if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY)) {
     // multiplicity -> do not display [1]
     String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
     buffer.append(multiplicity);
   }
   if (displayValue.contains(ICustomAppearance.DISP_DERIVE)) {
     String value = getValue(e, paramIndex, parameter);
     if (value != null) {
       if (showEqualMark) {
         buffer.append(" = ");
       }
       buffer.append(value);
     }
   } else if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_DEFAULT)) {
     // default value
     if (parameter.getDefault() != null) {
       if (showEqualMark) {
         buffer.append(" = ");
       }
       buffer.append(parameter.getDefault());
     }
   }
   if (displayValue.contains(ICustomAppearance.DISP_MODIFIERS)) {
     boolean multiLine = displayValue.contains(ICustomAppearance.DISP_MULTI_LINE);
     // property modifiers
     String modifiers = ParameterUtil.getModifiersAsString(parameter, multiLine);
     if (!modifiers.equals("")) {
       if (multiLine) {
         buffer.append("\n");
       }
       buffer.append(modifiers);
     }
   }
   return buffer.toString();
 }