+ bool aCanCommit = myWorkshop->module()->canCommitOperation();
+ setApplyEnabled(!myIsValidationLock && aCanCommit && anOperation->isValid());
+ }
+}
+
+void XGUI_OperationMgr::setLockValidating(bool toLock)
+{
+ myIsValidationLock = toLock;
+ onValidateOperation();
+}
+
+void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled)
+{
+ myIsApplyEnabled = theEnabled;
+ emit validationStateChanged(theEnabled);
+}
+
+bool XGUI_OperationMgr::isApplyEnabled() const
+{
+ return myIsApplyEnabled;
+}
+
+bool XGUI_OperationMgr::isParentOperationValid() const
+{
+ bool isValid = false;
+ // the enable state of the parent operation of the nested one is defined by the rules that
+ // firstly there are nested operations and secondly the parent operation is valid
+ ModuleBase_Operation* aPrevOp = 0;
+ Operations::const_iterator anIt = myOperations.end();
+ if (anIt != myOperations.begin()) { // there are items in the operations list
+ --anIt;
+ aPrevOp = *anIt; // the last top operation, the operation which is started
+ if (anIt != myOperations.begin()) { // find the operation where the started operation is nested
+ --anIt;
+ aPrevOp = *anIt;
+ }
+ }
+ return aPrevOp && aPrevOp->isValid();
+}
+
+bool XGUI_OperationMgr::canStopOperation()
+{
+ ModuleBase_Operation* anOperation = currentOperation();
+ if(operationsCount() > 1) //in case of nested (sketch) operation no confirmation needed
+ return true;
+ if (anOperation && anOperation->isModified()) {
+ QString aMessage = tr("%1 operation will be aborted.").arg(anOperation->id());
+ int anAnswer = QMessageBox::question(qApp->activeWindow(),
+ tr("Abort operation"),
+ aMessage,
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel);
+ return anAnswer == QMessageBox::Ok;