return getProperty(aRoot, PLUGINS_MODULE);
}
+
+void Config_ModuleReader::addFeature(const std::string& theFeatureName,
+ const std::string& thePluginConfig)
+{
+ if (myFeaturesInFiles.count(theFeatureName)) {
+ std::string anErrorMsg = "Can not register feature '" + theFeatureName + "' in plugin '"
+ + thePluginConfig + "'. There is a feature with the same ID.";
+ Events_Error::send(anErrorMsg);
+ return;
+ }
+
+ myFeaturesInFiles[theFeatureName] = thePluginConfig;
+}
+
void Config_ModuleReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_PLUGIN, NULL)) {
if (!hasRequiredModules(theNode))
return;
std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG);
- if (!aPluginConf.empty()) myPluginFiles.insert(aPluginConf);
+ if (!aPluginConf.empty())
+ myPluginFiles.insert(aPluginConf);
std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
std::string aPluginScript = getProperty(theNode, PLUGIN_SCRIPT);
std::string aPluginName = addPlugin(aPluginLibrary, aPluginScript, aPluginConf);
std::list<std::string> aFeatures = importPlugin(aPluginName, aPluginConf);
std::list<std::string>::iterator it = aFeatures.begin();
for (; it != aFeatures.end(); it++) {
- myFeaturesInFiles[*it] = aPluginConf;
+ addFeature(*it, aPluginConf);
}
}
}
std::string addPlugin(const std::string& aPluginLibrary,
const std::string& aPluginScript,
const std::string& aPluginConf);
+ /// Save feature in myFeaturesInFiles. Generates an error if the feature name is already registered.
+ void addFeature(const std::string& theFeatureName, const std::string& thePluginConfig);
private:
std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
showPropertyPanel();
QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
- ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
- myModuleConnector);
+ ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
myPropertyPanel->cleanContent();
aFactory.createWidget(myPropertyPanel->contentWidget());
QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+
+ // check compatibility of feature and widgets
+ FeaturePtr aFeature = aFOperation->feature();
+ foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+ if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) {
+ std::string anErrorMsg = "The feature '" + aFeature->getKind() + "' has no attribute '"
+ + aWidget->attributeID() + "' used by widget '"
+ + aWidget->metaObject()->className() + "'.";
+ Events_Error::send(anErrorMsg);
+ myPropertyPanel->cleanContent();
+ return;
+ }
+ }
+
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
bool isStoreValue = !aFOperation->isEditOperation() &&
!aWidget->getDefaultValue().empty() &&