/** * get the list of stereotype to display from the eannotation * * @return the list of stereotypes to display */ public String stereotypesToDisplay(GraphicalEditPart editPart) { View view = (View) editPart.getModel(); // retrieve all stereotypes to be displayed // try to display stereotype properties String stereotypesPropertiesToDisplay = AppliedStereotypeHelper.getAppliedStereotypesPropertiesToDisplay(view); String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay(view); String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(view); // now check presentation. // if horizontal => equivalent to the inBrace visualization in nodes // (i.e. only name = // value, separator = comma, delimited with brace // if vertical => equivalent to compartment visualization name of // stereotype, NL, property = // value, NL, etC. // check the presentation kind. if only icon => do not display // stereotype, only values if (UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION.equals( stereotypespresentationKind)) { return StereotypeUtil.getPropertiesValuesInBrace( stereotypesPropertiesToDisplay, getUMLElement(editPart)); } String stereotypesToDisplayWithQN = AppliedStereotypeHelper.getStereotypesQNToDisplay(view); String display = ""; if (UMLVisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION.equals( stereotypespresentationKind)) { display += stereotypesAndPropertiesToDisplay( editPart, "\n", stereotypesToDisplay, stereotypesToDisplayWithQN, stereotypesPropertiesToDisplay); } else { final String st = stereotypesToDisplay(editPart, ", ", stereotypesToDisplay, stereotypesToDisplayWithQN); if (st != null && !st.equals("")) { display += Activator.ST_LEFT + st + Activator.ST_RIGHT + " "; } final String propSt = StereotypeUtil.getPropertiesValuesInBrace( stereotypesPropertiesToDisplay, getUMLElement(editPart)); if (propSt != null && !propSt.equals("")) { if (st != null && !st.equals("")) { // display += "\n"; } display += "{" + propSt + "} "; } } return display; }
@Override public String stereotypesOnlyToDisplay() { Object hostModel = getHost().getModel(); String result = ""; // $NON-NLS-1$ View view = (View) hostModel; EObject viewElement = view.getElement(); Element element = (Element) viewElement; Iterator<Stereotype> listStereotype = element.getAppliedStereotypes().iterator(); StringBuffer buffer = new StringBuffer(); while (listStereotype.hasNext()) { Stereotype stereotypec = listStereotype.next(); String stereotype_string = stereotypec.getQualifiedName(); buffer.append(stereotype_string); if (listStereotype.hasNext()) { buffer.append(","); // $NON-NLS-1$ } } result = buffer.toString(); if (result.length() != 0) { String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(view); // vertical representation if (UMLVisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION.equals( stereotypespresentationKind)) { return Activator.ST_LEFT + stereotypesToDisplay(Activator.ST_RIGHT + "\n" + Activator.ST_LEFT, result, "") + Activator.ST_RIGHT; } else { // horizontal representation return Activator.ST_LEFT + stereotypesToDisplay(", ", result, "") + Activator.ST_RIGHT; } } return result; }