aParameter->data()->blockSendAttributeUpdated(false);
}
+#include <QMessageBox>
+#include <ModelAPI_ResultPart.h>
+bool allDocumentsActivated(QString& theNotActivatedNames)
+{
+ bool anAllPartActivated = true;
+ QStringList aRefNames;
+
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
+ for (int i = 0; i < aSize; i++) {
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+ if (!aPart->isActivated()) {
+ anAllPartActivated = false;
+ aRefNames.append(aObject->data()->name().c_str());
+ }
+ }
+ theNotActivatedNames = aRefNames.join(", ");
+ return anAllPartActivated;
+}
+
void ParametersPlugin_EvalListener::processObjectRenamedEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
if (!aParameter.get())
return;
+ QString aNotActivatedNames;
+ if (!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),
+ 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())