Salome HOME
Issue 1303 Re-ordering of Sketcher menus: additional structure for feature info to...
[modules/shaper.git] / src / XGUI / XGUI_MenuMgr.cpp
index 1e55b62187c618175d1da70c834e36880d520af1..8dff16c1f295fbd9ce53bd3039a810b6608eaa7e 100755 (executable)
@@ -8,6 +8,8 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_ActionsMgr.h>
 #include <XGUI_OperationMgr.h>
+#include <XGUI_MenuWorkbench.h>
+#include <XGUI_MenuGroup.h>
 
 #include <Events_Loop.h>
 #include <Config_FeatureMessage.h>
@@ -58,6 +60,15 @@ void XGUI_MenuMgr::addFeature(const std::shared_ptr<Config_FeatureMessage>& theM
 #endif
     return;
   }
+  {
+    std::string aWchName = theMessage->workbenchId();
+    std::shared_ptr<XGUI_MenuWorkbench> aWorkbench = findWorkbench(aWchName);
+
+    std::string aGroupName = theMessage->groupId();
+    std::shared_ptr<XGUI_MenuGroup> aGroup = aWorkbench->findGroup(aGroupName);
+
+    aGroup->setFeatureInfo(theMessage);
+  }
 
   ActionInfo aFeatureInfo;
   aFeatureInfo.initFrom(theMessage);
@@ -126,3 +137,20 @@ void XGUI_MenuMgr::addFeature(const std::shared_ptr<Config_FeatureMessage>& theM
   myWorkshop->module()->actionCreated(aCommand);
 #endif
 }
+
+std::shared_ptr<XGUI_MenuWorkbench> XGUI_MenuMgr::findWorkbench(std::string& theWorkbenchName)
+{
+  std::list< std::shared_ptr<XGUI_MenuWorkbench> >::const_iterator anIt = myWorkbenches.begin(),
+                                                                   aLast = myWorkbenches.end();
+  std::shared_ptr<XGUI_MenuWorkbench> aResultWorkbench;
+  for (; anIt != aLast && !aResultWorkbench; anIt++) {
+    std::shared_ptr<XGUI_MenuWorkbench> aWorkbench = *anIt;
+    if (aWorkbench->getName() == theWorkbenchName)
+      aResultWorkbench = aWorkbench;
+  }
+  if (!aResultWorkbench) {
+    aResultWorkbench = std::shared_ptr<XGUI_MenuWorkbench>(new XGUI_MenuWorkbench(theWorkbenchName));
+    myWorkbenches.push_back(aResultWorkbench);
+  }
+  return aResultWorkbench;
+}