Salome HOME
Fix for the issue #1605 : optimization of undo/redo and abort processing
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_EvalListener.cpp
index fe2665b1081f8678cc5467613489a3a472f3f654..d63741c9fa606596f832c40bd95ddb6524d0b2ac 100644 (file)
@@ -26,6 +26,8 @@
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
 
+#include <QMessageBox>
+
 #include <string>
 #include <set>
 #include <sstream>
@@ -336,7 +338,8 @@ void ParametersPlugin_EvalListener::renameInDependents(std::shared_ptr<ModelAPI_
 
 bool isValidAttribute(const AttributePtr& theAttribute)
 {
-  std::string aValidator, anError;
+  std::string aValidator;
+  Events_InfoMessage anError;
   return ModelAPI_Session::get()->validators()->validate(theAttribute, aValidator, anError);
 }
 
@@ -344,7 +347,7 @@ void setParameterName(ResultParameterPtr theResultParameter, const std::string&
 {
   theResultParameter->data()->blockSendAttributeUpdated(true);
   theResultParameter->data()->setName(theName);
-  theResultParameter->data()->blockSendAttributeUpdated(false);
+  theResultParameter->data()->blockSendAttributeUpdated(false, false);
 
   std::shared_ptr<ParametersPlugin_Parameter> aParameter = 
       std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
@@ -380,6 +383,18 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
   if (!aParameter.get())
     return;
 
+  std::string aNotActivatedNames;
+  if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
+    QMessageBox::StandardButton aRes = QMessageBox::warning(0, QObject::tr("Warning"),
+               QObject::tr("Selected objects can be used in Part documents which are not loaded: \
+%1. Whould you like to continue?").arg(aNotActivatedNames.c_str()),
+               QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+    if (aRes != QMessageBox::Yes) {
+      setParameterName(aResultParameter, aMessage->oldName());
+      return;
+    }
+  }
+
   // try to update the parameter feature according the new name
   setParameterName(aResultParameter, aMessage->newName());
   // TODO(spo): replace with ModelAPI_Session::get()->validators()->validate(aParameter, ParametersPlugin_Parameter::VARIABLE_ID())