/*
   * (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;
  }
 /**
  * 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;
 }
  /** Called when the static checkbox is modified */
  protected void checkConst() {

    boolean boxState = isConst.getSelection();

    if (boxState) {
      if (!StereotypeUtil.isApplied(selectedParameter, Const.class)) {
        StereotypeUtil.apply(selectedParameter, Const.class);
      }
    } else {
      if (StereotypeUtil.isApplied(selectedParameter, Const.class)) {
        StereotypeUtil.unapply(selectedParameter, Const.class);
      }
    }
  }
  /*
   * (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?
    }
  }
 /**
  * Returns a String that displays stereotypes (using their simple name or their qualified name)
  * and their properties
  *
  * @param editPart the edit part for which the label is edited
  * @param separator the separator used to split the string representing the stereotypes.
  * @param stereotypesToDisplay the list of stereotypes displayed
  * @param stereotypeWithQualifiedName the list of stereotypes displayed using their qualified
  *     names
  * @param stereotypesPropertiesToDisplay the list of properties to display
  * @return a string that displays stereotypes (using their simple name or their qualified name)
  *     and their properties
  */
 public String stereotypesAndPropertiesToDisplay(
     GraphicalEditPart editPart,
     String separator,
     String stereotypesToDisplay,
     String stereotypeWithQualifiedName,
     String stereotypesPropertiesToDisplay) {
   // Get the preference from PreferenceStore. there should be an assert
   final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
   if (store == null) {
     Activator.log.warn("The preference store was not found");
     return "";
   }
   // retrieve if the name of the stereotype has to put to lower case or
   // not
   String sNameAppearance =
       store.getString(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_APPEARANCE);
   // changes the string of properties into a map, where the entries of the
   // map are the
   // stereotype qualified name, and the properties to display are the data
   Map<String, List<String>> propertiesToDisplay =
       parseStereotypeProperties(editPart, stereotypesToDisplay, stereotypesPropertiesToDisplay);
   StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ",");
   String out = "";
   while (strQualifiedName.hasMoreElements()) {
     String currentStereotype = strQualifiedName.nextToken();
     // check if current stereotype is applied
     final Element umlElement = getUMLElement(editPart);
     Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
     if (stereotype != null) {
       String name = currentStereotype;
       if ((stereotypeWithQualifiedName.indexOf(currentStereotype)) == -1) {
         // property value contains qualifiedName ==> extract name
         // from it
         StringTokenizer strToken = new StringTokenizer(currentStereotype, "::");
         while (strToken.hasMoreTokens()) {
           name = strToken.nextToken();
         }
       }
       // AL Changes Feb. 07 - Beg
       // Handling STEREOTYPE_NAME_APPEARANCE preference (from
       // ProfileApplicationPreferencePage)
       // Previously lowercase forced onto first letter (standard UML)
       // stereotypesToDisplay = stereotypesToDisplay+name.substring(0,
       // 1).toLowerCase()+name.substring(1,
       // name.length())+","+separator;
       // check that the name has not already been added to the
       // displayed string
       if (sNameAppearance.equals(
           UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_DISPLAY_USER_CONTROLLED)) {
         if (out.indexOf(name) == -1) {
           out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
         }
       } else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM))
         // {
         name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
         if (out.indexOf(name) == -1) {
           out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
         }
       }
       // now should add all properties associated to this stereotype
       List<String> properties = propertiesToDisplay.get(stereotype.getQualifiedName());
       if (properties != null) {
         // retrieve property
         for (String propertyName : properties) {
           out =
               out
                   + StereotypeUtil.displayPropertyValue(
                       stereotype,
                       StereotypeUtil.getPropertyByName(stereotype, propertyName),
                       getUMLElement(editPart),
                       " ");
         }
       }
     }
   }
   if (out.endsWith(",")) {
     return out.substring(0, out.length() - 1);
   }
   if (out.endsWith(separator)) {
     return out.substring(0, out.length() - separator.length());
   }
   return out;
 }