/**
   * 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();
  }
Exemplo n.º 2
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();
 }