Salome HOME
Issue #1005: To improve user-friendship of error-messages for features and attributes
[modules/shaper.git] / src / Config / Config_WidgetAPI.cpp
index bcf543bd17e21d93e81cfa832545a3672d594d8c..c95c03b4d01a00e793852234cbbc66547f5d1c94 100644 (file)
@@ -20,6 +20,7 @@ Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
 {
   myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
   myCurrentNode = xmlDocGetRootElement(myDoc);
+  myFeatureId = getProperty(_ID);
 }
 
 Config_WidgetAPI::~Config_WidgetAPI()
@@ -46,11 +47,18 @@ bool Config_WidgetAPI::toNextWidget()
 bool Config_WidgetAPI::toChildWidget()
 {
   if (myCurrentNode && hasChild(myCurrentNode)) {
-    myCurrentNode = myCurrentNode->children;
-    while (myCurrentNode && !isElementNode(myCurrentNode)) {
-      myCurrentNode = myCurrentNode->next;
+    xmlNodePtr aChildNode = myCurrentNode->children;
+    // it is possible that among child nodes, there is no an element node, so
+    // we should not change the current node until not-zero node is found
+    // otherwise, it may happens that the current node is null and the node tree information
+    // is lost
+    while (aChildNode && !isElementNode(aChildNode)) {
+      aChildNode = aChildNode->next;
+    }
+    if (aChildNode != NULL) {
+      myCurrentNode = aChildNode;
+      return true;
     }
-    return myCurrentNode != NULL;
   }
   return false;
 }
@@ -72,16 +80,16 @@ std::string Config_WidgetAPI::widgetType() const
   return result;
 }
 
-bool Config_WidgetAPI::isContainerWidget() const
+bool Config_WidgetAPI::isGroupBoxWidget() const
 {
-  return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
-  NULL);
+  return isNode(myCurrentNode, WDG_GROUP, WDG_OPTIONALBOX,
+                NULL);
 }
 
 bool Config_WidgetAPI::isPagedWidget() const
 {
   return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
-  NULL);
+                NULL);
 }
 
 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
@@ -94,6 +102,11 @@ bool Config_WidgetAPI::getBooleanAttribute(const char* theAttributeName, bool th
   return ::getBooleanAttribute(myCurrentNode, theAttributeName, theDefault);
 }
 
+std::string Config_WidgetAPI::featureId() const
+{
+  return myFeatureId;
+}
+
 std::string Config_WidgetAPI::widgetId() const
 {
   return getProperty(_ID);