From: Sergey Belash Date: Mon, 31 Mar 2014 13:12:17 +0000 (+0400) Subject: Set plugin's library name as field of feature message. X-Git-Tag: V_0.1~43^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a78a826e270a123f0857360bf0d2de19df7114c1;p=modules%2Fshaper.git Set plugin's library name as field of feature message. --- diff --git a/src/Config/Config_FeatureMessage.cpp b/src/Config/Config_FeatureMessage.cpp index 3146e37c5..85102857b 100644 --- a/src/Config/Config_FeatureMessage.cpp +++ b/src/Config/Config_FeatureMessage.cpp @@ -85,3 +85,13 @@ void Config_FeatureMessage::setTooltip(const std::string& tooltip) { myTooltip = tooltip; } + +const std::string& Config_FeatureMessage::pluginLibrary() const +{ + return myPluginLibrary; +} + +void Config_FeatureMessage::setPluginLibrary(const std::string& myPluginLibrary) +{ + this->myPluginLibrary = myPluginLibrary; +} diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 1a0f99477..8f5fc3354 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -6,17 +6,22 @@ #include #include +/* + * Class to pass a feature entry extracted from xml file. + * Example of the feature entry: + * + */ class CONFIG_EXPORT Config_FeatureMessage: public Event_Message { + std::string myId; //Feature unique id + std::string myText; //Represents action's text + std::string myTooltip; //Represents action's tooltip + std::string myIcon; //Represents action's icon + std::string myKeysequence; //Represents action's key sequence - std::string myId; - std::string myText; - std::string myTooltip; - std::string myIcon; - std::string myKeysequence; - - std::string myGroupId; - std::string myWorkbenchId; + std::string myGroupId; //Id of feature's group + std::string myWorkbenchId; //Id of feature's workbench + std::string myPluginLibrary; //Name of feature's library public: //const Event_ID theID, const void* theSender = 0 @@ -31,6 +36,7 @@ public: const std::string& groupId() const; const std::string& workbenchId() const; + const std::string& pluginLibrary() const; void setIcon(const std::string& icon); void setId(const std::string& id); @@ -40,6 +46,7 @@ public: void setGroupId(const std::string& groupId); void setWorkbenchId(const std::string& workbenchId); + void setPluginLibrary(const std::string& thePluginLibrary); }; #endif // CONFIG_MESSAGE_H \ No newline at end of file diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 03e5f3abd..524c881e6 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -33,12 +33,29 @@ const static char* FEATURE_ICON = "icon"; const static char* FEATURE_KEYSEQUENCE = "keysequence"; Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile) - : Config_XMLReader(theXmlFile), m_fetchWidgetCfg(false) + : Config_XMLReader(theXmlFile), + myFetchWidgetCfg(false) { + myLibraryName = ""; + #ifdef _DEBUG - if(!Event_Loop::Loop()) { + if (!Event_Loop::Loop()) { std::cout << "Config_FeatureReader::importWorkbench: " - << "No event loop registered" << std::endl; + << "No event loop registered" << std::endl; + } +#endif +} + +Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile, + const std::string& theLibraryName) + : Config_XMLReader(theXmlFile), + myLibraryName(theLibraryName), + myFetchWidgetCfg(false) +{ +#ifdef _DEBUG + if (!Event_Loop::Loop()) { + std::cout << "Config_FeatureReader::importWorkbench: " + << "No event loop registered" << std::endl; } #endif } @@ -49,19 +66,19 @@ Config_FeatureReader::~Config_FeatureReader() std::string Config_FeatureReader::featureWidgetCfg(std::string theFeatureName) { - m_fetchWidgetCfg = true; + myFetchWidgetCfg = true; readAll(); - m_fetchWidgetCfg = false; - return m_widgetCfg; + myFetchWidgetCfg = false; + return myWidgetCfg; } void Config_FeatureReader::processNode(xmlNodePtr theNode) { if (isNode(theNode, NODE_FEATURE, NULL)) { - if (m_fetchWidgetCfg) { + if (myFetchWidgetCfg) { xmlBufferPtr buffer = xmlBufferCreate(); int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1); - m_widgetCfg = std::string((char*) buffer->content); + myWidgetCfg = std::string((char*) buffer->content); } else { Event_Loop* aEvLoop = Event_Loop::Loop(); Config_FeatureMessage aMessage(aEvLoop->EventByName("menu_item"), this); @@ -71,10 +88,10 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) } //The m_last* variables always defined before fillFeature() call. XML is a tree. if (isNode(theNode, NODE_GROUP, NULL)) { - m_lastGroup = getProperty(theNode, _ID); + myLastGroup = getProperty(theNode, _ID); } if (isNode(theNode, NODE_WORKBENCH, NULL)) { - m_lastWorkbench = getProperty(theNode, _ID); + myLastWorkbench = getProperty(theNode, _ID); } } @@ -90,7 +107,7 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP)); outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON)); outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE)); - outFtMessage.setGroupId(m_lastGroup); - outFtMessage.setWorkbenchId(m_lastWorkbench); - + outFtMessage.setGroupId(myLastGroup); + outFtMessage.setWorkbenchId(myLastWorkbench); + outFtMessage.setPluginLibrary(myLibraryName); } diff --git a/src/Config/Config_FeatureReader.h b/src/Config/Config_FeatureReader.h index bbc25ba27..cb16d9ea2 100644 --- a/src/Config/Config_FeatureReader.h +++ b/src/Config/Config_FeatureReader.h @@ -14,6 +14,8 @@ class CONFIG_EXPORT Config_FeatureReader: public Config_XMLReader { public: Config_FeatureReader(const std::string& theXmlFile); + Config_FeatureReader(const std::string& theXmlFile, + const std::string& theLibraryName); virtual ~Config_FeatureReader(); std::string featureWidgetCfg(std::string theFeatureName); @@ -24,11 +26,12 @@ protected: void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage); - std::string m_lastWorkbench; - std::string m_lastGroup; + std::string myLastWorkbench; + std::string myLastGroup; + std::string myLibraryName; - bool m_fetchWidgetCfg; - std::string m_widgetCfg; + bool myFetchWidgetCfg; + std::string myWidgetCfg; }; #endif /* CONFIG_FEATUREREADER_H_ */ diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 5b536141d..85e653c7e 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -26,7 +26,7 @@ const static char* PLUGIN_CONFIG = "configuration"; const static char* PLUGIN_LIBRARY = "library"; Config_ModuleReader::Config_ModuleReader() - : Config_XMLReader("plugins.xml"), m_isAutoImport(false) + : Config_XMLReader("plugins.xml"), myIsAutoImport(false) { } @@ -50,10 +50,11 @@ std::string Config_ModuleReader::getModuleName() void Config_ModuleReader::processNode(xmlNodePtr theNode) { if (isNode(theNode, NODE_PLUGIN, NULL)) { - std::string aPluginName = getProperty(theNode, PLUGIN_CONFIG); - if (m_isAutoImport) - importPlugin(aPluginName); - m_pluginsList.push_back(aPluginName); + std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG); + std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY); + if (myIsAutoImport) + importPlugin(aPluginConf, aPluginLibrary); + myPluginsMap[aPluginLibrary] = aPluginConf; } } @@ -62,18 +63,24 @@ bool Config_ModuleReader::processChildren(xmlNodePtr theNode) return isNode(theNode, NODE_PLUGINS, NULL); } -void Config_ModuleReader::importPlugin(const std::string& thePluginName) +void Config_ModuleReader::importPlugin(const std::string& thePluginName, + const std::string& thePluginLibrary) { - Config_FeatureReader aReader(thePluginName); - aReader.readAll(); + Config_FeatureReader* aReader; + if(thePluginLibrary.empty()) { + aReader = new Config_FeatureReader(thePluginName); + } else { + aReader = new Config_FeatureReader(thePluginName, thePluginLibrary); + } + aReader->readAll(); } -void Config_ModuleReader::setAutoImport(bool enabled) +void Config_ModuleReader::setAutoImport(bool theEnabled) { - m_isAutoImport = enabled; + myIsAutoImport = theEnabled; } -const std::list& Config_ModuleReader::pluginsList() const +const std::map& Config_ModuleReader::plugins() const { - return m_pluginsList; + return myPluginsMap; } diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index 4bd958f51..4b59f622e 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -10,7 +10,7 @@ #include -#include +#include class CONFIG_EXPORT Config_ModuleReader: public Config_XMLReader { @@ -20,7 +20,7 @@ public: virtual ~Config_ModuleReader(); void setAutoImport(bool enabled); - const std::list& pluginsList() const; + const std::map& plugins() const; std::string getModuleName(); @@ -28,11 +28,13 @@ protected: void processNode(xmlNodePtr aNode); bool processChildren(xmlNodePtr aNode); - void importPlugin(const std::string& thePluginName); + void importPlugin(const std::string& thePluginName, + const std::string& thePluginLibrary = ""); private: - bool m_isAutoImport; - std::list m_pluginsList; + bool myIsAutoImport; + std::map myPluginsMap; + }; diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index e9a31e207..723ddf089 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -41,7 +41,7 @@ Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName) prefix = "../plugins/"; #endif - m_DocumentPath = prefix + theXmlFileName; + myDocumentPath = prefix + theXmlFileName; } Config_XMLReader::~Config_XMLReader() @@ -85,10 +85,10 @@ bool Config_XMLReader::processChildren(xmlNodePtr aNode) xmlNodePtr Config_XMLReader::findRoot() { xmlDocPtr aDoc; - aDoc = xmlParseFile(m_DocumentPath.c_str()); + aDoc = xmlParseFile(myDocumentPath.c_str()); if (aDoc == NULL) { #ifdef _DEBUG - std::cout << "Config_XMLReader::import: " << "Document " << m_DocumentPath + std::cout << "Config_XMLReader::import: " << "Document " << myDocumentPath << " is not parsed successfully." << std::endl; #endif return NULL; diff --git a/src/Config/Config_XMLReader.h b/src/Config/Config_XMLReader.h index 785dca9c2..bdff8a00e 100644 --- a/src/Config/Config_XMLReader.h +++ b/src/Config/Config_XMLReader.h @@ -45,7 +45,7 @@ protected: bool isNode(xmlNodePtr theNode, const char* name, ...); private: - std::string m_DocumentPath; + std::string myDocumentPath; }; #endif /* CONFIG_XMLREADER_H_ */ diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 908587d52..ba04d395c 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -45,9 +45,9 @@ void PartSet_Module::onCommandTriggered() { Config_ModuleReader aModuleReader = Config_ModuleReader(); aModuleReader.readAll(); - std::string aPluginName = aModuleReader.pluginsList().front(); - Config_FeatureReader* aReader = new Config_FeatureReader(aPluginName); - XGUI_Command* aCmd = dynamic_cast(sender()); - std::string aXMLWidgetCfg = aReader->featureWidgetCfg(aCmd->getId().toStdString()); - delete aReader; +// std::string aPluginName = aModuleReader.plugins().front(); +// Config_FeatureReader* aReader = new Config_FeatureReader(aPluginName); +// XGUI_Command* aCmd = dynamic_cast(sender()); +// std::string aXMLWidgetCfg = aReader->featureWidgetCfg(aCmd->getId().toStdString()); +// delete aReader; }