Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Fri, 19 Sep 2014 12:20:32 +0000 (16:20 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 19 Sep 2014 12:20:32 +0000 (16:20 +0400)
22 files changed:
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEdit.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_Command.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index 12eb36e53b40d9b8503c51319d6c7316aa6a0164..9b24d742d722f407fd27ae9c99fc0a1b7e056f70 100644 (file)
@@ -174,9 +174,3 @@ bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const
   return false;
 }
 
-bool ModuleBase_Operation::keyReleased(const int theKey)
-{
-  // Do nothing...
-  return false;
-}
-
index e29bdc6bc925bef59fa04669f28b8c23f71b0233..0a5e1a54db084bdc52072512f008d0368a5427d8 100644 (file)
@@ -72,7 +72,9 @@ Q_OBJECT
   /// Returns True if the current operation works with the given object (feature or result)
   virtual bool hasObject(ObjectPtr theObj) const;
 
-  virtual bool keyReleased(const int theKey);
+  virtual void keyReleased(const int theKey) {};
+
+  virtual void activateNextToCurrentWidget() {};
 
  public slots:
   /// Slots which listen the mode widget activation
index 16837acce7f66f27bb19032263bb96be839ebccf..6d470dbbd14567860f40444e50068f7f1ce2b6e6 100644 (file)
@@ -128,20 +128,3 @@ QList<QWidget*> ModuleBase_WidgetDoubleValue::getControls() const
   aList.append(mySpinBox);
   return aList;
 }
-
-bool ModuleBase_WidgetDoubleValue::eventFilter(QObject *theObject, QEvent *theEvent)
-{
-  if (theObject == mySpinBox) {
-    if (theEvent->type() == QEvent::KeyRelease) {
-      QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
-      if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
-                        aKeyEvent->key() == Qt::Key_Enter)) {
-        emit focusOutWidget(this);
-      }
-      emit keyReleased((QKeyEvent*) theEvent);
-      return true;
-    }
-  }
-  return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
-}
-
index 70c8a272b15d309684668836b7a6447d07295a95..20afafbe18f9862e7a43b15c0287660334f79ed7 100644 (file)
@@ -43,11 +43,6 @@ Q_OBJECT
     return myContainer;
   }
 
-  /// Process key release envent on the widget spin box controls
-  /// \param theObject the object where the event happens
-  /// \param theEvent the processed event
-  virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
-
  public slots:
  /// Delayed value chnged: when user starts typing something,
  // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
index b20f2e8d7065077c142cdde128f593c3f631d74f..8feec7a6c5e96aa9f7d7983c0d4e7af82a8b9cf7 100644 (file)
@@ -144,22 +144,6 @@ QList<QWidget*> ModuleBase_WidgetPoint2D::getControls() const
   return aControls;
 }
 
-bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
-{
-  if (theObject == myXSpin || theObject == myYSpin) {
-    if (theEvent->type() == QEvent::KeyRelease) {
-      QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
-      if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
-                        aKeyEvent->key() == Qt::Key_Enter)) {
-        emit focusOutWidget(this);
-      }
-      emit keyReleased((QKeyEvent*) theEvent);
-      return true;
-    }
-  }
-  return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
-}
-
 bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
 {
   if (myOptionParam.length() == 0)
index 0151d14552be491a033517f70f01eb71fe7ee779..29d65a7b23288511f351566c41cdd561c0f26b5f 100644 (file)
@@ -53,11 +53,6 @@ Q_OBJECT
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
 
-  /// Process key release envent on the widget spin box controls
-  /// \param theObject the object where the event happens
-  /// \param theEvent the processed event
-  virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
-
   bool initFromPrevious(ObjectPtr theObject);
 
 signals:
index 8f0c1324f5d2daf943468e4dc29c39be308e0511..f5b5af3b1023fb98326f9317d5fe6ac92b61bce4 100644 (file)
@@ -207,18 +207,6 @@ void ModuleBase_WidgetSelector::updateSelectionName()
     myTextLine->setText("");
 }
 
-//********************************************************************
-bool ModuleBase_WidgetSelector::eventFilter(QObject* theObj, QEvent* theEvent)
-{
-  if (theObj == myTextLine) {
-    //if (theEvent->type() == QEvent::Polish) {
-    //  myActivateBtn->setChecked(myActivateOnStart);
-    //  onSelectionChanged();
-    //}
-  }
-  return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
-}
-
 //********************************************************************
 void ModuleBase_WidgetSelector::enableOthersControls(bool toEnable) const
 {
index 5973c520a143852d2e1df90b2e20317e61a32fef..e39f97f32b0943ea790c917ae43d0e7bf9ee5c27 100644 (file)
@@ -60,9 +60,6 @@ Q_OBJECT
   /// Activate or deactivate selection
   void activateSelection(bool toActivate);
 
- protected:
-  bool eventFilter(QObject* theObj, QEvent* theEvent);
-
  private slots:
   void onSelectionChanged();
 
index 211bc89cc2eb2f3c32eb8095375238d6d1b78a35..082c8cfa777ae913e113f45068a181ee2a545e61 100644 (file)
@@ -127,11 +127,6 @@ void PartSet_Module::featureCreated(QAction* theFeature)
   connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
 }
 
-QStringList PartSet_Module::nestedFeatures(QString)
-{
-  return QStringList();
-}
-
 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
 {
   return myFeaturesInFiles[theFeatureId];
index 39ee6a763a40fc68d16900c91a1ed8b3e1c5da82..803015f38786d38701b1e26281598b8d4c960464 100644 (file)
@@ -41,8 +41,6 @@ Q_OBJECT
   /// Called on creation of menu item in desktop
   virtual void featureCreated(QAction* theFeature);
 
-  /// Returnc list of nested commands for the given feature
-  virtual QStringList nestedFeatures(QString theFeature);
   std::string featureFile(const std::string&);
 
   /// Creates an operation and send it to loop
index 0bfd4a4bcbc0c8ba3f0982ec601c9979dd67ba16..759356cd24b40c0530f00ff45977d5af9600c7f7 100644 (file)
@@ -184,7 +184,7 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
   }
 }
 
-bool PartSet_OperationFeatureCreate::keyReleased(const int theKey)
+void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
 {
   switch (theKey) {
     case Qt::Key_Return:
@@ -195,16 +195,14 @@ bool PartSet_OperationFeatureCreate::keyReleased(const int theKey)
       }
     }
       break;
-    case Qt::Key_Escape: {
-      if (!commit()) {
-        abort();
-      }
-    }
-      break;
     default:
       break;
   }
-  return true;
+}
+
+void PartSet_OperationFeatureCreate::activateNextToCurrentWidget()
+{
+  emit activateNextWidget(myActiveWidget);
 }
 
 void PartSet_OperationFeatureCreate::startOperation()
index 6fcadf5c0aee948b1118252169a4ba6078eb7143..07dd0eab52e127d07cb1d180ebd9485c1c85a75e 100644 (file)
@@ -71,7 +71,9 @@ Q_OBJECT
   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Processes the key pressed in the view
   /// \param theKey a key value
-  virtual bool keyReleased(const int theKey);
+  virtual void keyReleased(const int theKey);
+
+  virtual void activateNextToCurrentWidget();
 
  public slots:
   /// Slots which listen the mode widget activation
index 6524fc215cf0f094ef284af832bcd88eee65356f..7a16b92405ee559a0fda5f0009e1e0970e8f6193 100644 (file)
@@ -161,15 +161,6 @@ void PartSet_OperationFeatureEdit::mouseDoubleClick(
   }
 }
 
-bool PartSet_OperationFeatureEdit::keyReleased(const int theKey)
-{
-  if (theKey == Qt::Key_Return || theKey == Qt::Key_Enter) {
-    commit();
-    return true;
-  }
-  return PartSet_OperationSketchBase::keyReleased(theKey);
-}
-
 void PartSet_OperationFeatureEdit::startOperation()
 {
   PartSet_OperationSketchBase::startOperation();
index 0f7ed18c83b36eb63d827a7ecaa9291930529871..7bdb6aee29cb67eba2e24a1cc91c729a724d84bc 100644 (file)
@@ -111,10 +111,6 @@ Q_OBJECT
                                 const std::list<ModuleBase_ViewerPrs>& theSelected,
                                 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
-  /// Processes the key pressed in the view
-  /// \param theKey a key value
-  virtual bool keyReleased(const int theKey);
-
  protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
index 294faab4b38f988fedeb4c52bd4618e9fadb2999..bf69b04c2c2b0c581e57aa496034a84772db6f43 100644 (file)
@@ -61,10 +61,10 @@ void XGUI_ActionsMgr::update()
   if (myOperationMgr->hasOperation()) {
     setAllEnabled(false);
     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
-    QString anOperationId = anOperation->id();
-    setActionEnabled(anOperationId, true);
-    bool isNestedEnabled = anOperation->isNestedOperationsEnabled();
-    setNestedCommandsEnabled(isNestedEnabled, anOperationId);
+    FeaturePtr aFeature = anOperation->feature();
+    QString aFeatureId = QString::fromStdString(aFeature->getKind());
+    setActionEnabled(aFeatureId, true);
+    setNestedStackEnabled(anOperation);
   } else {
     setAllEnabled(true);
     setNestedCommandsEnabled(false);
@@ -80,20 +80,30 @@ void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
   }
 }
 
+void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+{
+  if(theOperation == NULL)
+    return;
+  FeaturePtr aFeature = theOperation->feature();
+  QString aFeatureId = QString::fromStdString(aFeature->getKind());
+  bool isNestedEnabled = theOperation->isNestedOperationsEnabled();
+  setNestedCommandsEnabled(isNestedEnabled, aFeatureId);
+
+  setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
+}
+
 //!
 void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent)
 {
   QStringList ltNestedActions;
   if (theParent.isEmpty()) {  //Disable ALL nested
-    foreach(QString eachParent, myNestedActions.keys())
-    {
+    foreach(QString eachParent, myNestedActions.keys()) {
       ltNestedActions << myNestedActions[eachParent];
     }
   } else {
     ltNestedActions << myNestedActions[theParent];
   }
-  foreach(QString eachNested, ltNestedActions)
-  {
+  foreach(QString eachNested, ltNestedActions) {
     setActionEnabled(eachNested, theEnabled);
   }
 }
@@ -117,13 +127,11 @@ void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabl
 void XGUI_ActionsMgr::updateCheckState()
 {
   QString eachCommand = QString();
-  foreach(eachCommand, myActions.keys())
-  {
+  foreach(eachCommand, myActions.keys()) {
     setActionChecked(eachCommand, false);
   }
   QStringList ltActiveCommands = myOperationMgr->operationList();
-  foreach(eachCommand, ltActiveCommands)
-  {
+  foreach(eachCommand, ltActiveCommands) {
     setActionChecked(eachCommand, true);
   }
 }
index 753330a22cff11be5467958619c4a18ade087c1c..4a6ad4a6bc1d5e757bc882eab730bbf15f42eced 100644 (file)
@@ -16,6 +16,7 @@
 class XGUI_Command;
 class XGUI_Workshop;
 class XGUI_OperationMgr;
+class ModuleBase_Operation;
 class QAction;
 
 class XGUI_EXPORT XGUI_ActionsMgr : public QObject
@@ -51,6 +52,8 @@ Q_OBJECT
  protected:
   //! Sets all actions to isEnabled state.
   void setAllEnabled(bool isEnabled);
+  //! Sets to isEnabled state all siblings of the given operation and it's parents recursively
+  void setNestedStackEnabled(ModuleBase_Operation* theOperation);
   //! Sets all nested actions to isEnabled state for the command with given ID.
   //! If ID is empty - all nested actions will be affected.
   void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
index 59df312b1e3338caf61be7232afe89797af4c5da..07d0d310f8add811d55e7c3446d1f41b1423416e 100644 (file)
@@ -1,6 +1,8 @@
 #include "XGUI_Command.h"
 #include <QEvent>
 #include <QToolButton>
+#include <QVariant>
+#include <QDebug>
 
 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
     : QWidgetAction(parent),
@@ -65,4 +67,4 @@ const QStringList& XGUI_Command::nestedCommands() const
 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
 {
   this->myNestedCommands = myUnblockableCommands;
-}
+}
\ No newline at end of file
index 3a5060d8cda0538d3f8c7f90b36c4c85e42980aa..e0692fc0b9bf860cd3ce672ae82adc46e14cc92e 100644 (file)
@@ -38,16 +38,39 @@ int XGUI_OperationMgr::operationsCount() const
   return myOperations.count();
 }
 
-QStringList XGUI_OperationMgr::operationList()
+QStringList XGUI_OperationMgr::operationList() const
 {
   QStringList result;
-  foreach(ModuleBase_Operation* eachOperation, myOperations)
-  {
-    result << eachOperation->id();
+  foreach(ModuleBase_Operation* eachOperation, myOperations) {
+    FeaturePtr aFeature = eachOperation->feature();
+    if(aFeature) {
+      result << QString::fromStdString(aFeature->getKind());
+    }
   }
   return result;
 }
 
+ModuleBase_Operation* XGUI_OperationMgr::previousOperation(ModuleBase_Operation* theOperation) const
+{
+  int idx = myOperations.lastIndexOf(theOperation);
+  if(idx == -1 || idx == 0) {
+    return NULL;
+  }
+  return myOperations.at(idx - 1);
+}
+
+bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
+{
+  if (theEvent->type() == QEvent::KeyRelease) {
+    QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
+    if(aKeyEvent) {
+      onKeyReleased(aKeyEvent);
+      return true;
+    }
+  }
+  return QObject::eventFilter(theObject, theEvent);
+}
+
 bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
 {
   if (!canStartOperation(theOperation))
@@ -68,7 +91,9 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
 
 bool XGUI_OperationMgr::abortAllOperations()
 {
-  if (operationsCount() == 1) {
+  if(!hasOperation()) {
+    return true;
+  } else if (operationsCount() == 1) {
     onAbortOperation();
     return true;
   }
@@ -106,25 +131,13 @@ void XGUI_OperationMgr::onValidateOperation()
   validateOperation(currentOperation());
 }
 
-bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
-{
-  if (theEvent->type() == QEvent::KeyRelease) {
-    QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
-    // TODO: this is Escape button processing when the property panel has empty content,
-    // but the operation should be stopped by the Enter has been clicked
-    if(aKeyEvent) {
-      onKeyReleased(aKeyEvent);
-      return true;
-    }
-  }
-  return QObject::eventFilter(theObject, theEvent);
-}
-
-void XGUI_OperationMgr::commitOperation()
+bool XGUI_OperationMgr::commitOperation()
 {
   if (validateOperation(currentOperation())) {
     onCommitOperation();
+    return true;
   }
+  return false;
 }
 
 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
@@ -154,7 +167,6 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
 void XGUI_OperationMgr::onCommitOperation()
 {
   ModuleBase_Operation* anOperation = currentOperation();
-  anOperation->onWidgetActivated(NULL);
   if (anOperation)
     anOperation->commit();
 }
@@ -169,6 +181,8 @@ void XGUI_OperationMgr::onAbortOperation()
 bool XGUI_OperationMgr::canAbortOperation()
 {
   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(),
@@ -212,24 +226,27 @@ void XGUI_OperationMgr::onOperationStopped()
 
 void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
 {
-  ModuleBase_Operation* anOperation = currentOperation();
-  if (anOperation) {
-    bool isFinished = anOperation->keyReleased(theEvent->key());
-    if(isFinished)
-      return;
-  }
   // Let the manager decide what to do with the given key combination.
+  ModuleBase_Operation* anOperation = currentOperation();
+  bool isRestart = false;
   switch (theEvent->key()) {
-    case Qt::Key_Escape:
+    case Qt::Key_Escape: {
       onAbortOperation();
+    }
       break;
     case Qt::Key_Return:
-    case Qt::Key_Enter:
+    case Qt::Key_Enter: {
+      if(anOperation) {
+         anOperation->activateNextToCurrentWidget();
+      }
       commitOperation();
+    }
       break;
     default:
       break;
   }
+  if(anOperation)
+    anOperation->keyReleased(theEvent->key());
 }
 
 void XGUI_OperationMgr::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
index 954f61e88327c1a95b17b8bbbffe3ff67a8b5fde..e43485b5c392a0a850267cea3a1107a6b26ea2d5 100644 (file)
@@ -42,7 +42,11 @@ Q_OBJECT
   /// Returns number of operations in the stack
   int operationsCount() const;
   /// Returns list of all operations IDs
-  QStringList operationList();
+  QStringList operationList() const;
+
+  /// Returns previous (parent) operation if given operation started.
+  /// else, or if there is no parent - returns NULL
+  ModuleBase_Operation* previousOperation(ModuleBase_Operation* theOperation) const;
 
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
@@ -78,7 +82,7 @@ signals:
  protected:
 
   /// Commits the current operatin if it is valid
-  void commitOperation();
+  bool commitOperation();
   /// Sets the current operation or NULL
   /// \param theOperation the started operation
   /// \param isCheckBeforeStart the flag whether to check whether the operation can be started
@@ -99,11 +103,7 @@ signals:
   /// Returns true if the operation can be aborted
   bool canAbortOperation();
 
- protected slots:
-  /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
-  /// If there is a suspended operation, restart it.
-  void onOperationStopped();
-
+ public slots:
   /// SLOT, that is called by the key in the property panel is clicked.
   /// \param theName the attribute name
   /// \param theEvent the mouse event
@@ -113,6 +113,11 @@ signals:
   /// \param theWidget an activated widget
   void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
 
+  protected slots:
+  /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
+  /// If there is a suspended operation, restart it.
+  void onOperationStopped();
+
  private:
   typedef QList<ModuleBase_Operation*> Operations;  ///< definition for a list of operations
   Operations myOperations;  ///< a stack of started operations. The active operation is on top,
index d6b88d19c9171e29cb6d9f754b1c3532f6e52a84..dd3cc642da41886a793674850d7f4a41948837c4 100644 (file)
@@ -84,9 +84,7 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
       theWidgets.end();
   for (; anIt != aLast; anIt++) {
-    //TODO(sbh): Think how to connect prop panle hotkeys and operations mgr
-    connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this,
-            SIGNAL(keyReleased(QKeyEvent*)));
+    connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
 
     connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
             SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
@@ -112,7 +110,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
       setTabOrder(anOkBtn, aCancelBtn);
     }
   }
-  onActivateNextWidget(NULL);
 }
 
 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
index d6ff28170106dca9d63e71dca0c6207f49646826..c292321105817d2fc898a13ab630f8c1f0a2efa4 100644 (file)
@@ -31,7 +31,6 @@ Q_OBJECT
 
   void cleanContent();
 
- protected:
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
  public slots:
index 5ed671cc7018739cd9e70394bd561e7052251773..b5fb72d02de51e651e78dea7d21689137250715a 100644 (file)
@@ -476,6 +476,7 @@ void XGUI_Workshop::onOperationStarted()
     }
 
     myPropertyPanel->setModelWidgets(aWidgets);
+    myPropertyPanel->onActivateNextWidget(NULL);
     myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
   }
   updateCommandStatus();
@@ -575,11 +576,14 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
     aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
   } else {
     XGUI_MainMenu* aMenu = myMainWindow->menuObject();
-    aCommand = aMenu->feature(theOperation->getDescription()->operationId());
+    FeaturePtr aFeature = theOperation->feature();
+    if(aFeature)
+      aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
   }
   //Abort operation on uncheck the command
-  if (aCommand)
+  if (aCommand) {
     connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
+  }
 }
 
 /*
@@ -867,8 +871,7 @@ void XGUI_Workshop::updateCommandStatus()
   if (aMgr->hasModuleDocument()) {
     QAction* aUndoCmd;
     QAction* aRedoCmd;
-    foreach(QAction* aCmd, aCommands)
-    {
+    foreach(QAction* aCmd, aCommands) {
       QString aId = aCmd->data().toString();
       if (aId == "UNDO_CMD")
         aUndoCmd = aCmd;
@@ -881,8 +884,7 @@ void XGUI_Workshop::updateCommandStatus()
     aUndoCmd->setEnabled(aMgr->canUndo());
     aRedoCmd->setEnabled(aMgr->canRedo());
   } else {
-    foreach(QAction* aCmd, aCommands)
-    {
+    foreach(QAction* aCmd, aCommands) {
       QString aId = aCmd->data().toString();
       if (aId == "NEW_CMD")
         aCmd->setEnabled(true);
@@ -949,10 +951,8 @@ void XGUI_Workshop::createDockWidgets()
   connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
   QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
   connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
-//TODO(sbh): KeyReleasedProblem
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
           SLOT(onKeyReleased(QKeyEvent*)));
-
   connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
           SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
   connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
@@ -1158,16 +1158,27 @@ void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
 //**************************************************************
 void XGUI_Workshop::updateCommandsOnViewSelection()
 {
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   XGUI_Selection* aSelection = mySelector->selection();
   if (aSelection->getSelected().size() == 0)
     return;
 
+  // Restrict validators to manage only nested (child) features
+  // of the current feature i.e. if current feature is Sketch -
+  // Sketch Features & Constraints can be validated.
+  QStringList aNestedIds;
+  if(myOperationMgr->hasOperation()) {
+    FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
+    if(aFeature) {
+      aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
+    }
+  }
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   QList<QAction*> aActions = getModuleCommands();
-  foreach(QAction* aAction, aActions)
-  {
+  foreach(QAction* aAction, aActions) {
     QString aId = aAction->data().toString();
+    if(!aNestedIds.contains(aId))
+      continue;
     std::list<ModelAPI_Validator*> aValidators;
     std::list<std::list<std::string> > anArguments;
     aFactory->validators(aId.toStdString(), aValidators, anArguments);