/* * (non-Javadoc) * * @see com.cea.accordcpp.core.ui.panels.AccordAbstractPanel#checkModifications() */ @Override public boolean checkModifications() { String ptrValue = StereotypeUtil.isApplied(selectedParameter, Ptr.class) ? "*" : ""; if (!docPtr.get().equals(ptrValue)) { return true; } String refValue = StereotypeUtil.isApplied(selectedParameter, Ref.class) ? "&" : ""; if (!docRef.get().equals(refValue)) { return true; } String defaultValue = selectedParameter.getDefault(); if (defaultValue == null) { if (!docDefault.get().equals("")) { return true; } } else if (!docDefault.get().equals(defaultValue)) { return true; } String arrayValue = StereotypeUtil.isApplied(selectedParameter, Array.class) ? "[]" : ""; if (!docArray.get().equals(arrayValue)) { return true; } return false; }
/** * 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(); }
/* * (non-Javadoc) * * @see com.cea.accordcpp.core.ui.panels.AccordAbstractPanel#refreshPanel() */ @Override protected void refreshPanel() { if (selectedParameter != null) { // Const isConst.setSelection(StereotypeUtil.isApplied(selectedParameter, Const.class)); // TODO: examine effect; // isConst.setSelection(selectedParameter.getEffect?); docPtr.set(StereotypeUtil.isApplied(selectedParameter, Ptr.class) ? "*" : ""); docRef.set(StereotypeUtil.isApplied(selectedParameter, Ref.class) ? "&" : ""); docDefault.set(selectedParameter.getDefault()); docArray.set(StereotypeUtil.isApplied(selectedParameter, Array.class) ? "[]" : ""); // need definition? } }
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(); }