Skip to content

Commit

Permalink
- return empty string when checkModel fails and set add error message.
Browse files Browse the repository at this point in the history
- Only show InformationDialog if instantiateModel & checkModel succeed otherwise put the error message in Messages Browser.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25251 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 25, 2015
1 parent c9556dc commit 81cdc58
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
31 changes: 15 additions & 16 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -769,11 +769,12 @@ void MainWindow::instantiatesModel(LibraryTreeNode *pLibraryTreeNode)
// show the progress bar
mpProgressBar->setRange(0, 0);
showProgressBar();
bool instantiateModelSuccess = false;
QString instantiateModelResult = mpOMCProxy->instantiateModel(pLibraryTreeNode->getNameStructure(), &instantiateModelSuccess);
QString windowTitle = QString(Helper::instantiateModel).append(" - ").append(pLibraryTreeNode->getName());
InformationDialog *pInformationDialog = new InformationDialog(windowTitle, instantiateModelResult, instantiateModelSuccess, this);
pInformationDialog->show();
QString instantiateModelResult = mpOMCProxy->instantiateModel(pLibraryTreeNode->getNameStructure());
if (!instantiateModelResult.isEmpty()) {
QString windowTitle = QString(Helper::instantiateModel).append(" - ").append(pLibraryTreeNode->getName());
InformationDialog *pInformationDialog = new InformationDialog(windowTitle, instantiateModelResult, true, this);
pInformationDialog->show();
}
// hide progress bar
hideProgressBar();
// clear the status bar message
Expand All @@ -795,9 +796,11 @@ void MainWindow::checkModel(LibraryTreeNode *pLibraryTreeNode)
mpProgressBar->setRange(0, 0);
showProgressBar();
QString checkModelResult = mpOMCProxy->checkModel(pLibraryTreeNode->getNameStructure());
QString windowTitle = QString(Helper::checkModel).append(" - ").append(pLibraryTreeNode->getName());
InformationDialog *pInformationDialog = new InformationDialog(windowTitle, checkModelResult, false, this);
pInformationDialog->show();
if (!checkModelResult.isEmpty()) {
QString windowTitle = QString(Helper::checkModel).append(" - ").append(pLibraryTreeNode->getName());
InformationDialog *pInformationDialog = new InformationDialog(windowTitle, checkModelResult, false, this);
pInformationDialog->show();
}
// hide progress bar
hideProgressBar();
// clear the status bar message
Expand All @@ -818,14 +821,10 @@ void MainWindow::checkAllModels(LibraryTreeNode *pLibraryTreeNode)
// show the progress bar
mpProgressBar->setRange(0, 0);
showProgressBar();
QString checkModelResult = mpOMCProxy->checkAllModelsRecursive(pLibraryTreeNode->getNameStructure());
if (checkModelResult.length()) {
QString windowTitle = QString(Helper::checkModel).append(" - ").append(pLibraryTreeNode->getName());
InformationDialog *pInformationDialog = new InformationDialog(windowTitle, checkModelResult, false, this);
pInformationDialog->show();
} else {
mpMessagesWidget->addGUIMessage(MessageItem("", false, 0, 0, 0, 0, "Check of " + pLibraryTreeNode->getName() + " failed.",
Helper::scriptingKind, Helper::notificationLevel));
QString checkAllModelsResult = mpOMCProxy->checkAllModelsRecursive(pLibraryTreeNode->getNameStructure());
if (!checkAllModelsResult.isEmpty()) {
mpMessagesWidget->addGUIMessage(MessageItem("", false, 0, 0, 0, 0, checkAllModelsResult, Helper::scriptingKind,
Helper::notificationLevel));
}
// hide progress bar
hideProgressBar();
Expand Down
19 changes: 11 additions & 8 deletions OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -1980,7 +1980,11 @@ bool OMCProxy::closeSimulationResultFile()
QString OMCProxy::checkModel(QString className)
{
sendCommand("checkModel(" + className + ")");
return getResult();
QString result = StringHandler::unparse(getResult());
if (result.isEmpty()) {
printMessagesStringInternal();
}
return result;
}

/*!
Expand All @@ -2004,25 +2008,24 @@ bool OMCProxy::ngspicetoModelica(QString fileName)
QString OMCProxy::checkAllModelsRecursive(QString className)
{
sendCommand("checkAllModelsRecursive(" + className + ")");
return getResult();
QString result = StringHandler::unparse(getResult());
printMessagesStringInternal();
return result;
}

/*!
Instantiates the model.
\param className - the name of the class.
\return the instantiated model
*/
QString OMCProxy::instantiateModel(QString className, bool *instantiateModelSuccess)
QString OMCProxy::instantiateModel(QString className)
{
sendCommand("instantiateModel(" + className + ")");
QString result = StringHandler::unparse(getResult());
if (result.isEmpty()) {
*instantiateModelSuccess = false;
return getErrorString();
} else {
*instantiateModelSuccess = true;
return result;
printMessagesStringInternal();
}
return result;
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -159,7 +159,7 @@ class OMCProxy : public QObject
bool saveModifiedModel(QString modelText);
bool saveTotalSCode(QString fileName, QString className);
QString list(QString className);
QString instantiateModel(QString className, bool *instantiateModelSuccess);
QString instantiateModel(QString className);
bool addClassAnnotation(QString className, QString annotation);
QString getDefaultComponentName(QString className);
QString getDefaultComponentPrefixes(QString className);
Expand Down

0 comments on commit 81cdc58

Please sign in to comment.