Skip to content

Commit

Permalink
Handle the curly braces used in text annotation (#7509)
Browse files Browse the repository at this point in the history
Fixes #7493
Display the parameter values reference via instance name
  • Loading branch information
adeas31 committed Jun 1, 2021
1 parent d8f7882 commit 11a0d1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions OMEdit/OMEditLIB/Annotations/TextAnnotation.cpp
Expand Up @@ -538,6 +538,7 @@ void TextAnnotation::updateTextStringHelper(QRegExp regExp)
QString variable = regExp.cap(0).trimmed();
if ((!variable.isEmpty()) && (variable.compare("%%") != 0) && (variable.compare("%name") != 0) && (variable.compare("%class") != 0)) {
variable.remove("%");
variable = StringHandler::removeFirstLastCurlBrackets(variable);
if (!variable.isEmpty()) {
QString textValue;
/* Ticket:4204
Expand Down Expand Up @@ -617,9 +618,9 @@ void TextAnnotation::updateTextString()
return;
}
/* handle variables now */
updateTextStringHelper(QRegExp("(%%|%\\w*)"));
updateTextStringHelper(QRegExp("(%%|%\\{?\\w+(\\.\\w+)*\\}?)"));
/* call again with non-word characters so invalid % can be removed. */
updateTextStringHelper(QRegExp("(%%|%\\W*)"));
updateTextStringHelper(QRegExp("(%%|%\\{?\\W+(\\.\\W+)*\\}?)"));
/* handle %% */
if (mOriginalTextString.toLower().contains("%%")) {
mTextString.replace(QRegExp("%%"), "%");
Expand Down
12 changes: 10 additions & 2 deletions OMEdit/OMEditLIB/Element/Element.cpp
Expand Up @@ -1442,7 +1442,8 @@ QString Element::getParameterDisplayString(QString parameterName)
/* How to get the display value,
* 0. If the component is inherited component then check if the value is available in the class extends modifiers.
* 1. Check if the value is available in component modifier.
* 2. Check if the value is available in the component's class as a parameter or variable.
* 2. Check if the value is available in the component's containing class as a parameter or variable.
* 2.1 Check if the value is available in the component's class as a parameter or variable.
* 3. Find the value in extends classes and check if the value is present in extends modifier.
* 4. If there is no extends modifier then finally check if value is present in extends classes.
*/
Expand All @@ -1467,10 +1468,17 @@ QString Element::getParameterDisplayString(QString parameterName)
if (mpLibraryTreeItem) {
mpLibraryTreeItem->getModelWidget()->loadDiagramView();
foreach (Element *pElement, mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->getElementsList()) {
if (pElement->getElementInfo()->getName().compare(parameterName) == 0) {
if (pElement->getElementInfo()->getName().compare(StringHandler::getFirstWordBeforeDot(parameterName)) == 0) {
if (displayString.isEmpty()) {
displayString = pElement->getElementInfo()->getParameterValue(pOMCProxy, mpLibraryTreeItem->getNameStructure());
}
/* case 2.1
* Fixes issue #7493. Handles the case where value is from instance name e.g., %instanceName.parameterName
*/
if (displayString.isEmpty()) {
displayString = pOMCProxy->getParameterValue(pElement->getElementInfo()->getClassName(), StringHandler::getLastWordAfterDot(parameterName));
}

typeName = pElement->getElementInfo()->getClassName();
checkEnumerationDisplayString(displayString, typeName);
break;
Expand Down

0 comments on commit 11a0d1c

Please sign in to comment.