diff --git a/OMEdit/OMEditLIB/Annotations/LineAnnotation.cpp b/OMEdit/OMEditLIB/Annotations/LineAnnotation.cpp index be3607fda0a..b43dcfc44db 100644 --- a/OMEdit/OMEditLIB/Annotations/LineAnnotation.cpp +++ b/OMEdit/OMEditLIB/Annotations/LineAnnotation.cpp @@ -2458,21 +2458,21 @@ void CreateConnectionDialog::createConnection() mpConnectionLineAnnotation->setStartElementName(startElementName); mpConnectionLineAnnotation->setEndElementName(endElementName); if (mpGraphicsView->getModelWidget()->isNewApi()) { - mpConnectionLineAnnotation->setLine(new ModelInstance::Line(mpGraphicsView->getModelWidget()->getModelInstance())); - mpConnectionLineAnnotation->updateLine(); - mpConnectionLineAnnotation->drawCornerItems(); - mpConnectionLineAnnotation->setCornerItemsActiveOrPassive(); - ModelInfo oldModelInfo = mpGraphicsView->getModelWidget()->createModelInfo(); - mpGraphicsView->addConnectionToView(mpConnectionLineAnnotation, false); - mpGraphicsView->addConnectionToClass(mpConnectionLineAnnotation); - ModelInfo newModelInfo = mpGraphicsView->getModelWidget()->createModelInfo(); - mpGraphicsView->getModelWidget()->getUndoStack()->push(new OMCUndoCommand(mpGraphicsView->getModelWidget()->getLibraryTreeItem(), oldModelInfo, newModelInfo, "Add Connection")); - mpGraphicsView->getModelWidget()->updateModelText(); - - if (!mpGraphicsView->getModelWidget()->getModelInstance()->isValidConnection(startElementName, endElementName)) { - MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, - GUIMessages::getMessage(GUIMessages::MISMATCHED_CONNECTORS_IN_CONNECT).arg(startElementName, endElementName), - Helper::scriptingKind, Helper::errorLevel)); + if (mpGraphicsView->getModelWidget()->getModelInstance()->isValidConnection(startElementName, endElementName)) { + mpConnectionLineAnnotation->setLine(new ModelInstance::Line(mpGraphicsView->getModelWidget()->getModelInstance())); + mpConnectionLineAnnotation->updateLine(); + mpConnectionLineAnnotation->drawCornerItems(); + mpConnectionLineAnnotation->setCornerItemsActiveOrPassive(); + ModelInfo oldModelInfo = mpGraphicsView->getModelWidget()->createModelInfo(); + mpGraphicsView->addConnectionToView(mpConnectionLineAnnotation, false); + mpGraphicsView->addConnectionToClass(mpConnectionLineAnnotation); + ModelInfo newModelInfo = mpGraphicsView->getModelWidget()->createModelInfo(); + mpGraphicsView->getModelWidget()->getUndoStack()->push(new OMCUndoCommand(mpGraphicsView->getModelWidget()->getLibraryTreeItem(), oldModelInfo, newModelInfo, "Add Connection")); + mpGraphicsView->getModelWidget()->updateModelText(); + } else { + QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), + GUIMessages::getMessage(GUIMessages::MISMATCHED_CONNECTORS_IN_CONNECT).arg(startElementName, endElementName), Helper::ok); + reject(); } } else { mpGraphicsView->getModelWidget()->getUndoStack()->push(new AddConnectionCommand(mpConnectionLineAnnotation, true)); diff --git a/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp b/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp index b530259a4b0..89229eefd22 100644 --- a/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp +++ b/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp @@ -3244,21 +3244,21 @@ void GraphicsView::addConnection(Element *pElement) } else { if (mpModelWidget->isNewApi()) { if (!connectionExists(startElementName, endElementName, false)) { - mpConnectionLineAnnotation->setLine(new ModelInstance::Line(mpModelWidget->getModelInstance())); - mpConnectionLineAnnotation->updateLine(); - mpConnectionLineAnnotation->drawCornerItems(); - mpConnectionLineAnnotation->setCornerItemsActiveOrPassive(); - ModelInfo oldModelInfo = mpModelWidget->createModelInfo(); - addConnectionToView(mpConnectionLineAnnotation, false); - addConnectionToClass(mpConnectionLineAnnotation); - ModelInfo newModelInfo = mpModelWidget->createModelInfo(); - mpModelWidget->getUndoStack()->push(new OMCUndoCommand(mpModelWidget->getLibraryTreeItem(), oldModelInfo, newModelInfo, "Add Connection")); - mpModelWidget->updateModelText(); - - if (!mpModelWidget->getModelInstance()->isValidConnection(startElementName, endElementName)) { - MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, - GUIMessages::getMessage(GUIMessages::MISMATCHED_CONNECTORS_IN_CONNECT).arg(startElementName, endElementName), - Helper::scriptingKind, Helper::errorLevel)); + if (mpModelWidget->getModelInstance()->isValidConnection(startElementName, endElementName)) { + mpConnectionLineAnnotation->setLine(new ModelInstance::Line(mpModelWidget->getModelInstance())); + mpConnectionLineAnnotation->updateLine(); + mpConnectionLineAnnotation->drawCornerItems(); + mpConnectionLineAnnotation->setCornerItemsActiveOrPassive(); + ModelInfo oldModelInfo = mpModelWidget->createModelInfo(); + addConnectionToView(mpConnectionLineAnnotation, false); + addConnectionToClass(mpConnectionLineAnnotation); + ModelInfo newModelInfo = mpModelWidget->createModelInfo(); + mpModelWidget->getUndoStack()->push(new OMCUndoCommand(mpModelWidget->getLibraryTreeItem(), oldModelInfo, newModelInfo, "Add Connection")); + mpModelWidget->updateModelText(); + } else { + QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), + GUIMessages::getMessage(GUIMessages::MISMATCHED_CONNECTORS_IN_CONNECT).arg(startElementName, endElementName), Helper::ok); + removeCurrentConnection(); } } else { removeCurrentConnection();