]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 28 Dec 2012 11:49:47 +0000 (12:49 +0100)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 28 Dec 2012 11:49:47 +0000 (12:49 +0100)
CreaDevManager application implementation

-Fixed windows path slash
-Name of classes passed as parameter in constructor
-Creation of New BlackBox Dialog

27 files changed:
lib/creaDevManagerLib/CDMUtilities.cpp
lib/creaDevManagerLib/CDMUtilities.h
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMAppli.h
lib/creaDevManagerLib/modelCDMApplication.cpp
lib/creaDevManagerLib/modelCDMApplication.h
lib/creaDevManagerLib/modelCDMBlackBox.cpp
lib/creaDevManagerLib/modelCDMBlackBox.h
lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp
lib/creaDevManagerLib/modelCDMCMakeListsFile.h
lib/creaDevManagerLib/modelCDMFile.cpp
lib/creaDevManagerLib/modelCDMFile.h
lib/creaDevManagerLib/modelCDMFolder.cpp
lib/creaDevManagerLib/modelCDMFolder.h
lib/creaDevManagerLib/modelCDMLib.cpp
lib/creaDevManagerLib/modelCDMLib.h
lib/creaDevManagerLib/modelCDMLibrary.cpp
lib/creaDevManagerLib/modelCDMLibrary.h
lib/creaDevManagerLib/modelCDMMain.cpp
lib/creaDevManagerLib/modelCDMPackage.cpp
lib/creaDevManagerLib/modelCDMPackage.h
lib/creaDevManagerLib/modelCDMPackageSrc.cpp
lib/creaDevManagerLib/modelCDMPackageSrc.h
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/modelCDMProject.h
lib/creaDevManagerLib/wxCDMNewBlackBoxDialog.cpp [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMNewBlackBoxDialog.h [new file with mode: 0644]

index 29a277fa2646cabfea5264d4323012e1295dbec2..f0a538e00ee124e2114a4a79cab2e0edc88c1864 100644 (file)
@@ -83,11 +83,11 @@ namespace CDMUtilities
     //break path into folders
     std::vector<std::string> pathSlpit;
 
-    splitter::split(pathSlpit, path, "/", splitter::no_empties);
+    splitter::split(pathSlpit, path, CDMUtilities::SLASH, splitter::no_empties);
 
     for (int i = 0; i < pathSlpit.size(); i++)
       {
-        pathFixed += "/" + pathSlpit[i];
+        pathFixed += CDMUtilities::SLASH + pathSlpit[i];
       }
 #endif
     return pathFixed;
index bed8ed9de7192eac91f73bfdc3bc15d3c69b7ece..9bfa1d98a144608e42dc1a78252c19bd9b206840 100644 (file)
 
 namespace CDMUtilities
 {
+  //path slash
+  #ifdef _WIN32
+    // ------ Windows
+    static std::string SLASH = "\\";
+  #elif __APPLE__
+    // ------ Apple
+    static std::string SLASH = "/";
+  #else
+    static std::string SLASH = "/";
+  #endif
+
   //text editor program
 #ifdef _WIN32
   // ------ Windows
index e35a9c50126c7a47a0b76b23ff03ed10d94e136d..d15bc4f554bdb5dcc1255824f38b6972e59688ec 100644 (file)
@@ -46,10 +46,10 @@ modelCDMAppli::modelCDMAppli()
 {
 }
 
-modelCDMAppli::modelCDMAppli(const std::string& path, const int& level)
+modelCDMAppli::modelCDMAppli(const std::string& path, const std::string& name, const int& level)
 {
   this->type = wxDIR_DIRS;
-  this->name = "appli";
+  this->name = name;
   this->level = level;
   this->path = path;
 
@@ -68,7 +68,7 @@ modelCDMAppli::modelCDMAppli(const std::string& path, const int& level)
         {
           std::string stdfileName = crea::wx2std(fileName);
 
-          modelCDMApplication* application = new modelCDMApplication(pathFixed + "/" + stdfileName, this->level + 1);
+          modelCDMApplication* application = new modelCDMApplication(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
           this->applications.push_back(application);
           this->children.push_back(application);
 
@@ -83,13 +83,13 @@ modelCDMAppli::modelCDMAppli(const std::string& path, const int& level)
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           //if is an unknown file, create file
           else
             {
-              this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
 
           cont = dir.GetNext(&fileName);
@@ -110,13 +110,11 @@ const std::vector<modelCDMApplication*>& modelCDMAppli::GetApplications() const
 
 modelCDMApplication* modelCDMAppli::CreateApplication(
     const std::string& name,
-    std::string*& result,
-    const std::string& path
+    std::string*& result
 )
 {
   //copy template application folder with new name
-  //TODO: fix for windows
-  std::string copyCommand = "cp -r " + this->path + "/template_appli " + this->path + "/" + name;
+  std::string copyCommand = "cp -r \"" + this->path + CDMUtilities::SLASH + "template_appli\" \"" + this->path + CDMUtilities::SLASH + name + "\"";
   if(system(copyCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + copyCommand + "'.");
@@ -124,13 +122,13 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
     }
   //set name of library in CMakeLists inside copied folder
   std::string line;
-  std::ifstream in((this->path + "/" + name + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return NULL;
     }
-  std::ofstream out((this->path + "/" + name + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   while (getline(in, line))
     {
       if(line == "SET ( EXE_NAME   MyExe  )")
@@ -140,7 +138,7 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/" + name + "/CMakeLists.txt.tmp " + this->path + "/" + name + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -148,14 +146,13 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
     }
 
   //add application to model
-  //TODO: fix for windows
-  modelCDMApplication* application = new modelCDMApplication(this->path + "/" + name, this->level + 1);
+  modelCDMApplication* application = new modelCDMApplication(this->path + CDMUtilities::SLASH + name, name, this->level + 1);
   this->applications.push_back(application);
   this->children.push_back(application);
 
   this->SortChildren();
 
-  result = new std::string(this->path + "/" + name);
+  result = new std::string(this->path + CDMUtilities::SLASH + name);
   return application;
 }
 
@@ -163,11 +160,6 @@ const bool modelCDMAppli::Refresh(std::string*& result)
 {
   std::cout << "refreshing appli" << std::endl;
   this->type = wxDIR_DIRS;
-  this->name = "appli";
-  this->level = level;
-  this->path = path;
-
-
 
   std::vector<bool> checked(this->children.size(), false);
   std::vector<bool> checkedApplications(this->applications.size(), false);
@@ -198,7 +190,7 @@ const bool modelCDMAppli::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMApplication* application= new modelCDMApplication(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMApplication* application= new modelCDMApplication(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->applications.push_back(application);
               this->children.push_back(application);
             }
@@ -215,7 +207,7 @@ const bool modelCDMAppli::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -243,7 +235,7 @@ const bool modelCDMAppli::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index c37924d246719c37b399cc344fed5b3d99fc5572..5d378b9e83519e8ebe913dd894c84c7396f9fd47 100644 (file)
@@ -45,15 +45,14 @@ class modelCDMAppli : public modelCDMFolder
 {
 public:
   modelCDMAppli();
-  modelCDMAppli(const std::string& path, const int& level = 1);
+  modelCDMAppli(const std::string& path, const std::string& name = "appli", const int& level = 1);
   ~modelCDMAppli();
 
   const std::vector<modelCDMApplication*>& GetApplications() const;
 
   modelCDMApplication* CreateApplication(
       const std::string& name,
-      std::string*& result,
-      const std::string& path = "/"
+      std::string*& result
   );
   virtual const bool Refresh(std::string*& result);
 
index c39b48d769677ca311727fe391180d14aa109244..e8af2cf6649aac6d578c2972aa63146c34aea20e 100644 (file)
@@ -45,25 +45,18 @@ modelCDMApplication::modelCDMApplication()
 {
 }
 
-modelCDMApplication::modelCDMApplication(const std::string& path, const int& level)
+modelCDMApplication::modelCDMApplication(const std::string& path, const std::string& name, const int& level)
 {
   //folder name
-  std::vector<std::string> words;
-  std::string delimiters;
-  //TODO::fix for windows
-  delimiters = "/";
-  CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
-  this->name = words[words.size()-1];
-
+  this->name = name;
   //path
   this->path = CDMUtilities::fixPath(path);
   //type
   this->type = wxDIR_DIRS;
   //level
   this->level = level;
-
   //open CMakeList
-  std::string pathMakeLists = path + "/CMakeLists.txt";
+  std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -89,7 +82,7 @@ modelCDMApplication::modelCDMApplication(const std::string& path, const int& lev
                   word += " " + wordBits[i];
                 }
 
-              this->nameApplication = this->executableName = word;
+              this->executableName = word;
             }
         }
     }
@@ -108,7 +101,7 @@ modelCDMApplication::modelCDMApplication(const std::string& path, const int& lev
         {
           std::string stdfileName = crea::wx2std(fileName);
 
-          modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+          modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
           this->folders.push_back(folder);
           this->children.push_back(folder);
 
@@ -123,13 +116,13 @@ modelCDMApplication::modelCDMApplication(const std::string& path, const int& lev
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           //if is an unknown file, create file
           else
             {
-              this->children.push_back(new modelCDMFile(this->path + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
 
           cont = dir.GetNext(&fileName);
@@ -142,11 +135,6 @@ modelCDMApplication::~modelCDMApplication()
 {
 }
 
-const std::string& modelCDMApplication::GetNameApplication() const
-{
-  return this->nameApplication;
-}
-
 const std::string& modelCDMApplication::GetExecutableName() const
 {
   return this->executableName;
@@ -164,14 +152,14 @@ bool modelCDMApplication::SetExecutableName(const std::string& fileName, std::st
 
   std::string line;
   //opening original cmakelists
-  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return false;
     }
   //opening temporal cmakelists
-  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   if( !out.is_open())
     {
       result = new std::string("CMakeLists.txt.tmp file failed to open.");
@@ -187,27 +175,27 @@ bool modelCDMApplication::SetExecutableName(const std::string& fileName, std::st
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
       return false;
     }
 
-  this->executableName = this->nameApplication = fileNameReal;
+  this->executableName = fileNameReal;
   return true;
 }
 
 modelCDMFolder* modelCDMApplication::CreateFolder(const std::string& name, std::string*& result)
 {
   //TODO:: mkdir depending on OS
-  std::string command = "mkdir " + path + "/" + name;
+  std::string command = "mkdir " + path + CDMUtilities::SLASH + name;
   if(system(command.c_str()))
     {
       result = new std::string("Error executing: " + command + ".");
       return NULL;
     }
-  modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+  modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
   this->folders.push_back(folder);
   this->children.push_back(folder);
 
@@ -220,7 +208,7 @@ const bool modelCDMApplication::Refresh(std::string*& result)
   this->type = wxDIR_DIRS;
 
   //open CMakeList
-  std::string pathMakeLists = path + "/CMakeLists.txt";
+  std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -235,10 +223,10 @@ const bool modelCDMApplication::Refresh(std::string*& result)
 
       if(wordBits[wordBits.size()-1] == "SET")
         {
-          //get library name
+          //get app name
           std::getline(confFile,word,')');
           CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties);
-          if(wordBits[0] == "LIBRARY_NAME")
+          if(wordBits[0] == "EXE_NAME")
             {
               word = wordBits[1];
               for (int i = 2; i < wordBits.size(); i++)
@@ -246,7 +234,7 @@ const bool modelCDMApplication::Refresh(std::string*& result)
                   word += " " + wordBits[i];
                 }
 
-              this->nameApplication = this->executableName = word;
+              this->executableName = word;
             }
         }
     }
@@ -283,7 +271,7 @@ const bool modelCDMApplication::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->folders.push_back(folder);
               this->children.push_back(folder);
             }
@@ -300,7 +288,7 @@ const bool modelCDMApplication::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -328,7 +316,7 @@ const bool modelCDMApplication::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index af3cbadf5910b74b48c8b87d78c0e3eedf983552..244ec736cdebf14e14bca49a850aeebe83c3a366 100644 (file)
@@ -44,10 +44,9 @@ class modelCDMApplication : public modelCDMFolder
 {
 public:
   modelCDMApplication();
-  modelCDMApplication(const std::string& path, const int& level = 2);
+  modelCDMApplication(const std::string& path, const std::string& name, const int& level = 2);
   ~modelCDMApplication();
 
-  const std::string& GetNameApplication() const;
   const std::string& GetExecutableName() const;
 
   bool SetExecutableName(const std::string& fileName, std::string*& result);
@@ -57,7 +56,6 @@ public:
   virtual const bool Refresh(std::string*& result);
 
 private:
-  std::string nameApplication;
   std::string executableName;
   std::vector<modelCDMFolder*> folders;
 };
index d177c88250b810f0cda829dddc451e124082363e..4d834927d61e08d6e3609d4b889ec595e5c732fe 100644 (file)
@@ -47,16 +47,16 @@ modelCDMBlackBox::modelCDMBlackBox()
   this->header = NULL;
 }
 
-modelCDMBlackBox::modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level)
+modelCDMBlackBox::modelCDMBlackBox(const std::string& path, const std::string& name, const int& level)
 {
-  this->name = hName.substr(2, hName.size()-4);
+  this->name = name;
   this->path = path;
   this->level = level;
   this->type = wxDIR_DIRS;
   this->source = NULL;
   this->header = NULL;
 
-  std::string pathHeader = path + "/" + "bb" + this->name + ".h";
+  std::string pathHeader = path + CDMUtilities::SLASH + "bb" + this->name + ".h";
 
   std::ifstream confFile;
   confFile.open((pathHeader).c_str());
@@ -101,6 +101,8 @@ modelCDMBlackBox::modelCDMBlackBox(const std::string& hName, const std::string&
 
 modelCDMBlackBox::~modelCDMBlackBox()
 {
+  this->header = NULL;
+  this->source = NULL;
 }
 
 const std::string& modelCDMBlackBox::GetNameBlackBox() const
@@ -126,11 +128,11 @@ const std::string& modelCDMBlackBox::GetDescription() const
 bool modelCDMBlackBox::SetAuthors(const std::string& authors, std::string*& result)
 {
   std::vector<std::string> words;
-  CDMUtilities::splitter::split(words, authors, ",\"\n", CDMUtilities::splitter::no_empties);
+  CDMUtilities::splitter::split(words, authors, "/\\\"\n", CDMUtilities::splitter::no_empties);
   std::string authorsReal = words[0];
   for (int i = 1; i < words.size(); i++)
     {
-      authorsReal += "/" + words[i];
+      authorsReal += "," + words[i];
     }
 
   //opening original header
@@ -168,7 +170,7 @@ bool modelCDMBlackBox::SetAuthors(const std::string& authors, std::string*& resu
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+  std::string renameCommand = "mv \"" + pathHeader + ".tmp\" \"" + pathHeader + "\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -186,57 +188,57 @@ bool modelCDMBlackBox::SetCategories(
 )
 {
   std::vector<std::string> words;
-    CDMUtilities::splitter::split(words, categories, "\"", CDMUtilities::splitter::no_empties);
-    std::string catsReal = words[0];
-    for (int i = 1; i < words.size(); i++)
-      {
-        catsReal += "-" + words[i];
-      }
-
-    //opening original header
-    std::string pathHeader = this->header->GetPath();
-    std::ifstream in(pathHeader.c_str());
-    if( !in.is_open())
-      {
-        result = new std::string(pathHeader + " file failed to open.");
-        return false;
-      }
-    //opening temporal header
-    std::ofstream out((pathHeader + ".tmp").c_str());
-    if( !out.is_open())
-      {
-        result = new std::string(pathHeader + ".tmp file failed to open.");
-        return false;
-      }
-    //copying contents from original to temporal and making changes
-    std::string reading;
-    while (getline(in, reading, '('))
-      {
-        CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
-        if(words[words.size() - 1] == "BBTK_CATEGORY")
-          {
-            out << reading << "(\"" << catsReal << "\")";
-            getline(in, reading, ')');
-          }
-        else
-          {
-            out << reading;
-            if (!in.eof())
-              out << "(";
-          }
-      }
-    in.close();
-    out.close();
-    //delete old file and rename new file
-    std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
-    if(system(renameCommand.c_str()))
-      {
-        result = new std::string("An error occurred while running '" + renameCommand + "'.");
-        return false;
-      }
-
-    this->categories = catsReal;
-    return true;
+  CDMUtilities::splitter::split(words, categories, "\"\\/", CDMUtilities::splitter::no_empties);
+  std::string catsReal = words[0];
+  for (int i = 1; i < words.size(); i++)
+    {
+      catsReal += "," + words[i];
+    }
+
+  //opening original header
+  std::string pathHeader = this->header->GetPath();
+  std::ifstream in(pathHeader.c_str());
+  if( !in.is_open())
+    {
+      result = new std::string(pathHeader + " file failed to open.");
+      return false;
+    }
+  //opening temporal header
+  std::ofstream out((pathHeader + ".tmp").c_str());
+  if( !out.is_open())
+    {
+      result = new std::string(pathHeader + ".tmp file failed to open.");
+      return false;
+    }
+  //copying contents from original to temporal and making changes
+  std::string reading;
+  while (getline(in, reading, '('))
+    {
+      CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
+      if(words[words.size() - 1] == "BBTK_CATEGORY")
+        {
+          out << reading << "(\"" << catsReal << "\")";
+          getline(in, reading, ')');
+        }
+      else
+        {
+          out << reading;
+          if (!in.eof())
+            out << "(";
+        }
+    }
+  in.close();
+  out.close();
+  //delete old file and rename new file
+  std::string renameCommand = "mv \"" + pathHeader + ".tmp\" \"" + pathHeader + "\"";
+  if(system(renameCommand.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + renameCommand + "'.");
+      return false;
+    }
+
+  this->categories = catsReal;
+  return true;
 }
 
 bool modelCDMBlackBox::SetDescription(
@@ -245,11 +247,11 @@ bool modelCDMBlackBox::SetDescription(
 )
 {
   std::vector<std::string> words;
-  CDMUtilities::splitter::split(words, description, "\"", CDMUtilities::splitter::no_empties);
+  CDMUtilities::splitter::split(words, description, "\"\n\\/", CDMUtilities::splitter::no_empties);
   std::string descReal = words[0];
   for (int i = 1; i < words.size(); i++)
     {
-      descReal += "\\\"" + words[i];
+      descReal += "-" + words[i];
     }
 
   //opening original header
@@ -287,7 +289,7 @@ bool modelCDMBlackBox::SetDescription(
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+  std::string renameCommand = "mv \"" + pathHeader + ".tmp\" \"" + pathHeader + "\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -330,6 +332,49 @@ modelCDMFile* modelCDMBlackBox::GetSourceFile() const
 
 const bool modelCDMBlackBox::Refresh(std::string*& result)
 {
-  //TODO: implement method
+  std::string pathHeader = path + CDMUtilities::SLASH + "bb" + this->name + ".h";
+
+  std::ifstream confFile;
+  confFile.open((pathHeader).c_str());
+  std::string word;
+
+  if(!confFile.is_open())
+    return false;
+
+  while(confFile.is_open() && !confFile.eof())
+    {
+      //get BBTK's
+      std::getline(confFile,word,'(');
+      std::vector<std::string> wordBits;
+      CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
+
+      if(wordBits[wordBits.size()-1] == "BBTK_NAME")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->nameBlackBox = word;
+        }
+      else if(wordBits[wordBits.size()-1] == "BBTK_AUTHOR")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->authors = word;
+        }
+      else if(wordBits[wordBits.size()-1] == "BBTK_DESCRIPTION")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->description = word;
+        }
+      else if(wordBits[wordBits.size()-1] == "BBTK_CATEGORY")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->categories = word;
+          if (this->categories == "")
+            this->categories = "empty";
+        }
+    }
+  confFile.close();
   return true;
 }
index e1021b82b70eea66b164867820ef2ea07b4f3d28..c58b16739dbbe887fea211dc7ffcc1a22393d4c7 100644 (file)
@@ -43,7 +43,7 @@ class modelCDMBlackBox : public modelCDMFolder
 {
 public:
   modelCDMBlackBox();
-  modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level = 1);
+  modelCDMBlackBox(const std::string& path, const std::string& name, const int& level = 1);
   ~modelCDMBlackBox();
 
   const std::string& GetNameBlackBox() const;
index 2b9cb2af8817fcf03bbef22ec0a6b78d797a5c27..dfbb99958af7655d8cfb22f3c34a8125dd205a00 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "modelCDMCMakeListsFile.h"
 
+#include <fstream>
+
 #include<creaWx.h>
 #include<wx/dir.h>
 
@@ -43,14 +45,18 @@ modelCDMCMakeListsFile::modelCDMCMakeListsFile()
 {
 }
 
-modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path,
-    const int& level)
+modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path, const std::string& name, const int& level)
 {
   this->children.clear();
   this->level = level;
   this->type = wxDIR_FILES;
-  this->name = "CMakeFileLists.txt";
+  this->name = name;
   this->path = path;
+
+  std::ifstream in(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in.seekg(0, std::ifstream::end);
+  this->length = in.tellg();
+  in.close();
 }
 
 modelCDMCMakeListsFile::~modelCDMCMakeListsFile()
@@ -71,6 +77,15 @@ bool modelCDMCMakeListsFile::OpenFile(std::string*& result)
 
 const bool modelCDMCMakeListsFile::Refresh(std::string*& result)
 {
-  //TODO: implement method
+  std::ifstream in((this->path).c_str());
+  if(!in.is_open())
+    {
+      in.close();
+      return false;
+    }
+  std::ifstream in2(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in2.seekg(0, std::ifstream::end);
+  this->length = in2.tellg();
+  in2.close();
   return true;
 }
index ef66a29d6bc7f4381ea7b7c85f57e58d2cce824b..65f034fb86b3b6bd22888392ba84f32496ad58d6 100644 (file)
@@ -41,7 +41,7 @@ class modelCDMCMakeListsFile : public modelCDMFile
 {
 public:
   modelCDMCMakeListsFile();
-  modelCDMCMakeListsFile(const std::string& path, const int& level = 1);
+  modelCDMCMakeListsFile(const std::string& path, const std::string& name = "CMakeLists.txt", const int& level = 1);
   ~modelCDMCMakeListsFile();
 
   bool OpenFile(std::string*& result);
index 6767b98e8895a5f87dc5edb7e2153de58a7360b9..039de4784d1e55e029e84429a73f7b6ea8a0d98b 100644 (file)
@@ -44,24 +44,18 @@ modelCDMFile::modelCDMFile()
 {
 }
 
-modelCDMFile::modelCDMFile(const std::string& path, const int& level)
+modelCDMFile::modelCDMFile(const std::string& path, const std::string& name, const int& level)
 {
   this->children.clear();
   this->level = level;
-
-  std::vector<std::string> words;
-  std::string delimiters;
-  //TODO::fix for windows
-  delimiters = "/";
-  CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
-  this->name = words[words.size()-1];
-
+  this->name = name;
   this->path = path;
   this->type = wxDIR_FILES;
 
   std::ifstream in(path.c_str(), std::ifstream::in | std::ifstream::binary);
   in.seekg(0, std::ifstream::end);
   this->length = in.tellg();
+  in.close();
 
 }
 
@@ -88,6 +82,10 @@ const bool modelCDMFile::Refresh(std::string*& result)
       in.close();
       return false;
     }
+  std::ifstream in2(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in2.seekg(0, std::ifstream::end);
+  this->length = in2.tellg();
+  in2.close();
   return true;
 }
 
index 228447f661a09aa42e3b7f39a4981908ec86b49e..f521608ea8060ee4eeefd6ed1138cce60d8f2009 100644 (file)
@@ -44,7 +44,7 @@ class modelCDMFile : public modelCDMIProjectTreeNode
 {
 public:
   modelCDMFile();
-  modelCDMFile(const std::string& path, const int& level = 3);
+  modelCDMFile(const std::string& path, const std::string& name, const int& level = 3);
   ~modelCDMFile();
 
   bool OpenFile(std::string* & result, const std::string& command = "");
index 28d7a9581e7a96479c013b2dc444e60012393c25..c1ef911dfd0b9efce843b402adc4529efd1dea1a 100644 (file)
@@ -47,21 +47,14 @@ modelCDMFolder::modelCDMFolder()
   this->CMakeLists = NULL;
 }
 
-modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
+modelCDMFolder::modelCDMFolder(const std::string& path, const std::string& name, const int& level)
 {
   //set attributes
   this->children.clear();
   this->level = level;
   this->CMakeLists = NULL;
   this->length = 0;
-
-  std::vector<std::string> words;
-  std::string delimiters;
-  //TODO::fix for windows
-  delimiters = "/";
-  CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
-  this->name = words[words.size()-1];
-
+  this->name = name;
   this->path = path;
   this->type = wxDIR_DIRS;
 
@@ -77,7 +70,7 @@ modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
           std::string stdfileName = crea::wx2std(fileName);
 
           //if is an unknown folder, create folder
-          this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+          this->children.push_back(new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
 
           cont = dir.GetNext(&fileName);
         }
@@ -90,12 +83,12 @@ modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           else
             {
-              this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
           //if is an unknown file, create file
           cont = dir.GetNext(&fileName);
@@ -123,13 +116,13 @@ modelCDMFolder::~modelCDMFolder()
 modelCDMFolder* modelCDMFolder::CreateFolder(const std::string& name, std::string*& result)
 {
   //TODO:: mkdir depending on OS
-  std::string command = "mkdir " + path + "/" + name;
+  std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\"";
   if(system(command.c_str()))
     {
       result = new std::string("Error executing: " + command + ".");
       return NULL;
     }
-  modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+  modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
   this->folders.push_back(folder);
   this->children.push_back(folder);
 
@@ -187,7 +180,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->folders.push_back(folder);
               this->children.push_back(folder);
             }
@@ -204,7 +197,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -215,6 +208,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
                     return false;
                 }
             }
+
           //if is an unknown file, create file
           else
             {
@@ -232,7 +226,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index 2bda7074de4cbeae6df0cb95868ed6b4a107cefd..a4ea6e721197be8cc7515830fee21a58226adb8f 100644 (file)
@@ -45,7 +45,7 @@ class modelCDMFolder : public modelCDMIProjectTreeNode
 {
 public:
   modelCDMFolder();
-  modelCDMFolder(const std::string& path, const int& level = 3);
+  modelCDMFolder(const std::string& path, const std::string& name, const int& level = 3);
   ~modelCDMFolder();
 
   modelCDMCMakeListsFile* GetCMakeLists() const;
index a0ece82362622b9caabf644a03420d571ae0d88e..416c1ff5230050f9bbf21726e2358c6929db00f9 100644 (file)
@@ -45,10 +45,10 @@ modelCDMLib::modelCDMLib()
 {
 }
 
-modelCDMLib::modelCDMLib(const std::string& path, const int& level)
+modelCDMLib::modelCDMLib(const std::string& path, const std::string& name, const int& level)
 {
   this->type = wxDIR_DIRS;
-  this->name = "lib";
+  this->name = name;
   this->level = level;
   this->path = path;
 
@@ -69,7 +69,7 @@ modelCDMLib::modelCDMLib(const std::string& path, const int& level)
         {
           std::string stdfileName = crea::wx2std(fileName);
 
-          modelCDMLibrary* library = new modelCDMLibrary(pathFixed + "/" + stdfileName, this->level + 1);
+          modelCDMLibrary* library = new modelCDMLibrary(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
           this->libraries.push_back(library);
           this->children.push_back(library);
 
@@ -84,13 +84,13 @@ modelCDMLib::modelCDMLib(const std::string& path, const int& level)
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           //if is an unknown file, create file
           else
             {
-              this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
 
           cont = dir.GetNext(&fileName);
@@ -110,13 +110,11 @@ const std::vector<modelCDMLibrary*>& modelCDMLib::GetLibraries() const
 
 modelCDMLibrary* modelCDMLib::CreateLibrary(
     const std::string& name,
-    std::string*& result,
-    const std::string& path
+    std::string*& result
 )
 {
   //copy template library folder with new name
-  //TODO: fix for windows
-  std::string copyCommand = "cp -r " + this->path + "/template_lib " + this->path + "/" + name;
+  std::string copyCommand = "cp -r \"" + this->path + CDMUtilities::SLASH + "template_lib\" \"" + this->path + CDMUtilities::SLASH + name + "\"";
   if(system(copyCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + copyCommand + "'.");
@@ -124,13 +122,13 @@ modelCDMLibrary* modelCDMLib::CreateLibrary(
     }
   //set name of library in CMakeLists inside copied folder
   std::string line;
-  std::ifstream in((this->path + "/" + name + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return NULL;
     }
-  std::ofstream out((this->path + "/" + name + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   while (getline(in, line))
     {
       if(line == "SET ( LIBRARY_NAME   MyLib  )")
@@ -140,7 +138,7 @@ modelCDMLibrary* modelCDMLib::CreateLibrary(
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/" + name + "/CMakeLists.txt.tmp " + this->path + "/" + name + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -148,14 +146,13 @@ modelCDMLibrary* modelCDMLib::CreateLibrary(
     }
 
   //add library to model
-  //TODO: fix for windows
-  modelCDMLibrary* library = new modelCDMLibrary(this->path + "/" + name, this->level + 1);
+  modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + name, name, this->level + 1);
   this->libraries.push_back(library);
   this->children.push_back(library);
 
   this->SortChildren();
 
-  result = new std::string(this->path + "/" + name);
+  result = new std::string(this->path + CDMUtilities::SLASH + name);
   return library;
 }
 
@@ -163,9 +160,6 @@ const bool modelCDMLib::Refresh(std::string*& result)
 {
   std::cout << "refreshing lib" << std::endl;
   this->type = wxDIR_DIRS;
-  this->name = "lib";
-  this->level = level;
-  this->path = path;
 
 
 
@@ -198,7 +192,7 @@ const bool modelCDMLib::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMLibrary* library = new modelCDMLibrary(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->libraries.push_back(library);
               this->children.push_back(library);
             }
@@ -215,7 +209,7 @@ const bool modelCDMLib::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -243,7 +237,7 @@ const bool modelCDMLib::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index 47de063adfb86cef46810d0db15c2aa1c242aceb..59d11964afa0b8550c995a421c14f7891090658f 100644 (file)
@@ -45,15 +45,14 @@ class modelCDMLib : public modelCDMFolder
 {
 public:
   modelCDMLib();
-  modelCDMLib(const std::string& path, const int& level = 1);
+  modelCDMLib(const std::string& path, const std::string& name = "lib", const int& level = 1);
   ~modelCDMLib();
 
   const std::vector<modelCDMLibrary*>& GetLibraries() const;
 
   modelCDMLibrary* CreateLibrary(
       const std::string& name,
-      std::string*& result,
-      const std::string& path = "/"
+      std::string*& result
   );
 
   virtual const bool Refresh(std::string*& result);
index 560759e02a300eea0aeb851863020623b0ac2508..e16eeae0d0d32e4f1f053dde796ada9f0276abb3 100644 (file)
@@ -45,16 +45,10 @@ modelCDMLibrary::modelCDMLibrary()
 {
 }
 
-modelCDMLibrary::modelCDMLibrary(const std::string& path, const int& level)
+modelCDMLibrary::modelCDMLibrary(const std::string& path, const std::string& name, const int& level)
 {
   //folder name
-  std::vector<std::string> words;
-  std::string delimiters;
-  //TODO::fix for windows
-  delimiters = "/";
-  CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
-  this->name = words[words.size()-1];
-
+  this->name = name;
   //path
   this->path = CDMUtilities::fixPath(path);
   //type
@@ -63,7 +57,7 @@ modelCDMLibrary::modelCDMLibrary(const std::string& path, const int& level)
   this->level = level;
 
   //open CMakeList
-  std::string pathMakeLists = path + "/CMakeLists.txt";
+  std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -109,7 +103,7 @@ modelCDMLibrary::modelCDMLibrary(const std::string& path, const int& level)
         {
           std::string stdfileName = crea::wx2std(fileName);
 
-          modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+          modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
           this->folders.push_back(folder);
           this->children.push_back(folder);
 
@@ -124,13 +118,13 @@ modelCDMLibrary::modelCDMLibrary(const std::string& path, const int& level)
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           //if is an unknown file, create file
           else
             {
-              this->children.push_back(new modelCDMFile(this->path + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
 
           cont = dir.GetNext(&fileName);
@@ -160,14 +154,14 @@ bool modelCDMLibrary::SetNameLibrary(const std::string& fileName, std::string*&
 
   std::string line;
   //opening original cmakelists
-  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return false;
     }
   //opening temporal cmakelists
-  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   if( !out.is_open())
     {
       result = new std::string("CMakeLists.txt.tmp file failed to open.");
@@ -183,7 +177,7 @@ bool modelCDMLibrary::SetNameLibrary(const std::string& fileName, std::string*&
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -197,13 +191,13 @@ bool modelCDMLibrary::SetNameLibrary(const std::string& fileName, std::string*&
 modelCDMFolder* modelCDMLibrary::CreateFolder(const std::string& name, std::string*& result)
 {
   //TODO:: mkdir depending on OS
-    std::string command = "mkdir " + path + "/" + name;
+    std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\"";
     if(system(command.c_str()))
       {
         result = new std::string("Error executing: " + command + ".");
         return NULL;
       }
-    modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+    modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
     this->folders.push_back(folder);
     this->children.push_back(folder);
 
@@ -216,7 +210,7 @@ const bool modelCDMLibrary::Refresh(std::string*& result)
   this->type = wxDIR_DIRS;
 
   //open CMakeList
-  std::string pathMakeLists = path + "/CMakeLists.txt";
+  std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -279,7 +273,7 @@ const bool modelCDMLibrary::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->folders.push_back(folder);
               this->children.push_back(folder);
             }
@@ -296,7 +290,7 @@ const bool modelCDMLibrary::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -324,7 +318,7 @@ const bool modelCDMLibrary::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index 6bcee75dea9ca3917e28c1d8736b0742971070ac..728b5c93970703cccb7b833a1e85924dc5943914 100644 (file)
@@ -44,7 +44,7 @@ class modelCDMLibrary : public modelCDMFolder
 {
 public:
   modelCDMLibrary();
-  modelCDMLibrary(const std::string& path, const int& level=2);
+  modelCDMLibrary(const std::string& path, const std::string& name, const int& level = 2);
   ~modelCDMLibrary();
 
   const std::string& GetNameLibrary() const;
index bb37b3d93acb0a7b94a02c0a6b84779f09d5ac43..7537c467087aa819e3d804f167e574ada9dddbe0 100644 (file)
@@ -83,8 +83,8 @@ bool modelCDMMain::CreateProject(
   std::string command2("del ");
 
   command  += "\"" + locationFixed + "\" \"" + name + "\"";
-  command1 += "\"" + locationFixed +"\\"+name+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + locationFixed + "\\" + name + "\\CMakeLists.txt\"";
-  command2 += "\"" + locationFixed +"\\"+name+"\\CMakeLists.txt.in\"";
+  command1 += "\"" + locationFixed +CDMUtilities::SLASH+name+CDMUtilities::SLASH+"CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + locationFixed + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
+  command2 += "\"" + locationFixed +CDMUtilities::SLASH+name+CDMUtilities::SLASH+"CMakeLists.txt.in\"";
 
 
   if (system (command.c_str()))
@@ -97,21 +97,21 @@ bool modelCDMMain::CreateProject(
   system ( command2.c_str() );
 
   char *author = author.c_str();
-  std::string nomDirectory = locationFixed + "\\" + name;
-  std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + name + "_PKG";
+  std::string nomDirectory = locationFixed + CDMUtilities::SLASH + name;
+  std::string nomPackageDirectory = nomDirectory + CDMUtilities::SLASH + "bbtk_" + name + "_PKG";
   std::string bbCreatePackage("bbCreatePackage ");
-  bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description;
+  bbCreatePackage += "\"" + nomDirectory + "\" \"" + name + "\" \"" + author + "\" \"" + description + "\"";
   system (bbCreatePackage.c_str());
   std::string add;
-  add = "echo ADD_SUBDIRECTORY(bbtk_" + name  + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
+  add = "echo ADD_SUBDIRECTORY(bbtk_" + name  + "_PKG) >> \"" + nomDirectory + CDMUtilities::SLASH + "CMakeLists.txt\"";
   system(add.c_str());
 
-  this->project = new modelCDMProject(nomDirectory);
+  this->project = new modelCDMProject(nomDirectory, name);
 
 #else
   // ------ LINUX / MacOS
   std::string command("creaNewProject.sh ");
-  command += "\"" + locationFixed + "\"" +" " + name;
+  command += "\"" + locationFixed + "\"" +" \"" + name + "\"";
   //std::cout << "executing " << command << std::endl;
   if (system ( command.c_str() ) )
     {
@@ -119,16 +119,16 @@ bool modelCDMMain::CreateProject(
       return false;
     }
 
-  std::string nomDirectory = locationFixed + "/" + name;
-  std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + name + "_PKG";
+  std::string nomDirectory = locationFixed + CDMUtilities::SLASH + name;
+  std::string nomPackageDirectory = nomDirectory + CDMUtilities::SLASH + "bbtk_" + name + "_PKG";
 
   std::string bbCreatePackage("bbCreatePackage ");
-  bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description;
+  bbCreatePackage += "\"" + nomDirectory + "\" \"" + name + "\" \"" + author + "\" \"" + description + "\"";
   //std::cout << "executing " << bbCreatePackage << std::endl;
   system (bbCreatePackage.c_str());
 
   std::string add;
-  add = "echo 'ADD_SUBDIRECTORY(bbtk_" + name  + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
+  add = "echo 'ADD_SUBDIRECTORY(bbtk_" + name  + "_PKG)' >> \"" + nomDirectory + CDMUtilities::SLASH + "CMakeLists.txt\"";
 
   //std::cout << "executing " << add << std::endl;
   system(add.c_str());
@@ -139,7 +139,7 @@ bool modelCDMMain::CreateProject(
         return false;
     }
 
-  this->project = new modelCDMProject(nomDirectory);
+  this->project = new modelCDMProject(nomDirectory, name);
 
 #endif
 
@@ -161,7 +161,7 @@ bool modelCDMMain::OpenProject(
   std::string pathBuild = "";
 
   //check if Makefile file exists
-  std::string pathMakefile = pathFixed + "/Makefile";
+  std::string pathMakefile = pathFixed + CDMUtilities::SLASH + "Makefile";
   FILE* pFile = fopen(pathMakefile.c_str(), "r");
 
   //is the binary folder
@@ -191,7 +191,7 @@ bool modelCDMMain::OpenProject(
   bool isSource = false;
   std::string pathSource = "";
   //check if CMakeLists file exists
-  std::string pathCMakeLists = pathFixed + "/CMakeLists.txt";
+  std::string pathCMakeLists = pathFixed + CDMUtilities::SLASH + "CMakeLists.txt";
   pFile = fopen(pathCMakeLists.c_str(), "r");
 
   //is the source folder
@@ -226,16 +226,19 @@ bool modelCDMMain::OpenProject(
           if (!CloseProject(result))
             return false;
         }
+      std::vector<std::string> words;
+      CDMUtilities::splitter::split(words, pathSource, CDMUtilities::SLASH, CDMUtilities::splitter::no_empties);
 
       std::cout << "Project sources at: " << pathSource << std::endl;
       if(isBinary)
         {
           std::cout << ", and built in: " << pathBuild << std::endl;
-          this->project = new modelCDMProject(pathSource, pathBuild);
+
+          this->project = new modelCDMProject(pathSource, words[words.size()-1], pathBuild);
         }
       else
         {
-          this->project = new modelCDMProject(pathSource);
+          this->project = new modelCDMProject(pathSource, words[words.size()-1]);
         }
     }
   else
index 097c360c11265b9db3b73dcbfae25cf744925516..a2ee6c8669d8e7b7f1f890e3c33e24990e758b56 100644 (file)
@@ -46,13 +46,13 @@ modelCDMPackage::modelCDMPackage()
   this->src = NULL;
 }
 
-modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
+modelCDMPackage::modelCDMPackage(const std::string& path, const std::string& name, const int& level)
 {
   this->type = wxDIR_DIRS;
+  this->name = name;
   //Get Package Name
 
-  //TODO: set pathMakeLists for windows
-  std::string pathMakeLists = path + "/CMakeLists.txt";
+  std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -121,12 +121,6 @@ modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
         }
     }
 
-  std::vector<std::string> words;
-  std::string delimiters;
-  //TODO::fix for windows
-  delimiters = "/";
-  CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
-  this->name = words[words.size()-1];
   this->level = level;
   this->path = path;
 
@@ -144,28 +138,12 @@ modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
           //if src, check for black boxes
           if(stdfileName == "src")
             {
-              this->src = new modelCDMPackageSrc(path + delimiters + "src", this->level + 1);
+              this->src = new modelCDMPackageSrc(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->src);
-              /*wxDir srcF(crea::std2wx((path + delimiters + "src").c_str()));
-              if (srcF.IsOpened())
-                {
-                  wxString srcName;
-                  bool innerCont = srcF.GetFirst(&srcName, wxT("*.h"), wxDIR_FILES);
-                  while (innerCont)
-                    {
-                      if(crea::wx2std(srcName.substr(0,2)) == "bb")
-                        {
-                          modelCDMBlackBox* blackbox = new modelCDMBlackBox(crea::wx2std(srcName), path + delimiters + "src", this->level + 1);
-                          this->blackBoxes.push_back(blackbox);
-                          this->children.push_back(blackbox);
-                        }
-                      innerCont = srcF.GetNext(&srcName);
-                    }
-                }*/
             }
           else
             {
-              this->children.push_back(new modelCDMFolder(path + delimiters + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFolder(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
 
           cont = dir.GetNext(&fileName);
@@ -180,12 +158,12 @@ modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(path + delimiters + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           else
             {
-              this->children.push_back(new modelCDMFile(path + delimiters + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
           //if is an unknown file, create file
           cont = dir.GetNext(&fileName);
@@ -240,14 +218,14 @@ bool modelCDMPackage::SetAuthors(const std::string& authors, std::string*& resul
 
   std::string line;
   //opening original cmakelists
-  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return false;
     }
   //opening temporal cmakelists
-  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   if( !out.is_open())
     {
       result = new std::string("CMakeLists.txt.tmp file failed to open.");
@@ -263,7 +241,7 @@ bool modelCDMPackage::SetAuthors(const std::string& authors, std::string*& resul
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -288,14 +266,14 @@ bool modelCDMPackage::SetVersion(const std::string& version, std::string*& resul
 
   std::string line;
   //opening original cmakelists
-  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return false;
     }
   //opening temporal cmakelists
-  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   if( !out.is_open())
     {
       result = new std::string("CMakeLists.txt.tmp file failed to open.");
@@ -315,7 +293,7 @@ bool modelCDMPackage::SetVersion(const std::string& version, std::string*& resul
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -338,14 +316,14 @@ bool modelCDMPackage::SetDescription(const std::string& description, std::string
 
   std::string line;
   //opening original cmakelists
-  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return false;
     }
   //opening temporal cmakelists
-  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   if( !out.is_open())
     {
       result = new std::string("CMakeLists.txt.tmp file failed to open.");
@@ -361,7 +339,7 @@ bool modelCDMPackage::SetDescription(const std::string& description, std::string
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -372,8 +350,10 @@ bool modelCDMPackage::SetDescription(const std::string& description, std::string
   return true;
 }
 
-bool modelCDMPackage::CreateBlackBox(
+modelCDMBlackBox* modelCDMPackage::CreateBlackBox(
     const std::string& name,
+    const std::string& type,
+    const std::string& format,
     const std::string& authors,
     const std::string& authorsEmail,
     const std::string& categories,
@@ -381,21 +361,17 @@ bool modelCDMPackage::CreateBlackBox(
 )
 {
   //TODO: implement method
-  return true;
+  return NULL;
 }
 
 const bool modelCDMPackage::Refresh(std::string*& result)
 {
   std::cout << "refreshing package" << std::endl;
   this->type = wxDIR_DIRS;
-  this->name = name;
-  this->level = level;
-  this->path = path;
 
   //Get Package Name
 
-  //TODO: set pathMakeLists for windows
-  std::string pathMakeLists = path + "/CMakeLists.txt";
+  std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -496,44 +472,9 @@ const bool modelCDMPackage::Refresh(std::string*& result)
                 }
               else
                 {
-                  this->src = new modelCDMPackageSrc(path + "/" + "src", this->level +1);
+                  this->src = new modelCDMPackageSrc(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level +1);
                   this->children.push_back(this->src);
                 }
-              /*wxDir srcF(crea::std2wx((path + "/" + "src").c_str()));
-              if (srcF.IsOpened())
-                {
-                  wxString srcName;
-                  bool innerCont = srcF.GetFirst(&srcName, wxT("*.h"), wxDIR_FILES);
-                  while (innerCont)
-                    {
-                      std::string blackBoxName = crea::wx2std(srcName);
-                      if(crea::wx2std(srcName.substr(0,2)) == "bb")
-                        {
-                          //check if box already exist
-                          bool found = false;
-                          for (int i = 0;!found && i < this->blackBoxes.size(); i++)
-                            {
-                              if (this->blackBoxes[i]->GetName() == blackBoxName)
-                                {
-                                  found = true;
-                                  int pos = std::find(this->children.begin(), this->children.end(), this->blackBoxes[i]) - this->children.begin();
-                                  checked[pos] = true;
-                                  checkedBlackBoxes[i] = true;
-                                  if(!this->blackBoxes[i]->Refresh(result))
-                                    return false;
-                                }
-                            }
-                          if(!found)
-                            {
-                              modelCDMBlackBox* blackBox = new modelCDMBlackBox(blackBoxName, path + "/" + "src", this->level +1);
-                              this->blackBoxes.push_back(blackBox);
-                              this->children.push_back(blackBox);
-                            }
-                        }
-                      innerCont = srcF.GetNext(&srcName);
-                    }
-                }*/
-
             }
           else
             {
@@ -552,7 +493,7 @@ const bool modelCDMPackage::Refresh(std::string*& result)
                 }
               if(!found)
                 {
-                  modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(folder);
                 }
             }
@@ -570,7 +511,7 @@ const bool modelCDMPackage::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -598,7 +539,7 @@ const bool modelCDMPackage::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index d79db954decff87a9da28034772a1bc2cfa13167..3745fb2154c41227c5cace3c99502350c3a00afc 100644 (file)
@@ -45,7 +45,7 @@ class modelCDMPackage : public modelCDMFolder
 {
 public:
   modelCDMPackage();
-  modelCDMPackage(const std::string& path, const int& level = 1);
+  modelCDMPackage(const std::string& path, const std::string& name, const int& level = 1);
   ~modelCDMPackage();
 
   const std::string& GetNamePackage() const;
@@ -61,8 +61,10 @@ public:
   bool SetDescription(const std::string& description, std::string*& result);
 
 
-  bool CreateBlackBox(
+  modelCDMBlackBox* CreateBlackBox(
       const std::string& name,
+      const std::string& type = "std",
+      const std::string& format = "C++",
       const std::string& authors = "unknown",
       const std::string& authorsEmail = "",
       const std::string& categories = "empty",
index b758cc4795d561c49e968d6282f01a87615ed7ed..16e7e59b0b65cd67829cec8f41cabbd4eaad3d75 100644 (file)
@@ -47,14 +47,14 @@ modelCDMPackageSrc::modelCDMPackageSrc()
   this->CMakeLists = NULL;
 }
 
-modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level)
+modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const std::string& name, const int& level)
 {
   //set attributes
   this->children.clear();
   this->level = level;
   this->CMakeLists = NULL;
   this->length = 0;
-  this->name = "src";
+  this->name = name;
   this->path = CDMUtilities::fixPath(path);
   this->type = wxDIR_DIRS;
 
@@ -69,7 +69,7 @@ modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level
           std::string stdfileName = crea::wx2std(fileName);
 
           //if is an unknown folder, create folder
-          this->children.push_back(new modelCDMFolder(path + "/" + stdfileName, this->level + 1));
+          this->children.push_back(new modelCDMFolder(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
 
           cont = dir.GetNext(&fileName);
         }
@@ -78,7 +78,7 @@ modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level
       if (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
-          this->CMakeLists = new modelCDMCMakeListsFile(path + "/" + stdfileName, this->level + 1);
+          this->CMakeLists = new modelCDMCMakeListsFile(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
           this->children.push_back(this->CMakeLists);
         }
 
@@ -90,14 +90,15 @@ modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level
 
           if(stdfileName.substr(0,2) == "bb")
             {
-              file = new modelCDMFile(path + "/" + stdfileName, this->level + 1);
+              file = new modelCDMFile(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(file);
-              modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path, level + 1);
+              modelCDMBlackBox* blackBox = new modelCDMBlackBox(path, stdfileName.substr(2,stdfileName.size()-4), level + 1);
               blackBox->SetHeaderFile(file);
-              cont = dir.GetFirst(&fileName, crea::std2wx(stdfileName.substr(0,stdfileName.size()-2) + ".cxx"), wxDIR_FILES);
+              wxDir dir2(crea::std2wx(path));
+              cont = dir2.GetFirst(&fileName, crea::std2wx(stdfileName.substr(0,stdfileName.size()-2) + ".cxx"), wxDIR_FILES);
               if (cont)
                 {
-                  file = new modelCDMFile(path + "/" + crea::wx2std(fileName), this->level + 1);
+                  file = new modelCDMFile(path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
                   this->children.push_back(file);
                   blackBox->SetSourceFile(file);
                 }
@@ -128,6 +129,20 @@ const std::vector<modelCDMBlackBox*>& modelCDMPackageSrc::GetBlackBoxes() const
   return this->blackBoxes;
 }
 
+modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox(
+    const std::string& name,
+    const std::string& package,
+    const std::string& type,
+    const std::string& format,
+    const std::string& authors,
+    const std::string& authorsEmail,
+    const std::string& categories,
+    const std::string& description)
+{
+  //TODO: implement method
+  return NULL;
+}
+
 const bool modelCDMPackageSrc::Refresh(std::string*& result)
 {
   //set attributes
@@ -161,7 +176,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(folder);
             }
           cont = dir.GetNext(&fileName);
@@ -177,7 +192,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -205,7 +220,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
@@ -228,7 +243,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result)
 
               if (!found)
                 {
-                  modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path + "/" + stdfileName, level + 1);
+                  modelCDMBlackBox* blackBox = new modelCDMBlackBox(path, stdfileName.substr(2,stdfileName.size()-4), level + 1);
                   this->blackBoxes.push_back(blackBox);
                 }
 
index 14de2d74a7a8701baba224f8fc3c596b54ad400e..d94afbdd5b0c208788e1286c4d56dfd04c6911db 100644 (file)
@@ -45,11 +45,22 @@ class modelCDMPackageSrc : public modelCDMFolder
 {
 public:
   modelCDMPackageSrc();
-  modelCDMPackageSrc(const std::string& path, const int& level = 3);
+  modelCDMPackageSrc(const std::string& path, const std::string& name = "src", const int& level = 3);
   ~modelCDMPackageSrc();
 
   const std::vector<modelCDMBlackBox*>& GetBlackBoxes() const;
 
+  modelCDMBlackBox* CreateBlackBox(
+      const std::string& name,
+      const std::string& package,
+      const std::string& type = "std",
+      const std::string& format = "C++",
+      const std::string& authors = "unknown",
+      const std::string& authorsEmail = "",
+      const std::string& categories = "empty",
+      const std::string& description = "no description"
+  );
+
   virtual const bool Refresh(std::string*& result);
 
 private:
index 7ebe67d8d5685e11b7407fb342d2621a44bdd4ee..8206a75bae273f9ed7d20538a73a1ecbbbce0909 100644 (file)
@@ -55,6 +55,7 @@ modelCDMProject::modelCDMProject()
 
 modelCDMProject::modelCDMProject(
     const std::string& path,
+    const std::string& name,
     const std::string& buildPath
 )
 {
@@ -62,8 +63,7 @@ modelCDMProject::modelCDMProject(
   //open makelists file
   std::string pathFixed(CDMUtilities::fixPath(path));
 
-  //TODO: set pathMakeLists for windows
-  std::string pathMakeLists = pathFixed + "/CMakeLists.txt";
+  std::string pathMakeLists = pathFixed + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -156,26 +156,26 @@ modelCDMProject::modelCDMProject(
           //if appli, create appli
           if(stdfileName == "appli")
             {
-              this->appli = new modelCDMAppli(pathFixed + "/appli", this->level + 1);
+              this->appli = new modelCDMAppli(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->appli);
             }
           //if lib, create lib
           else if(stdfileName == "lib")
             {
-              this->lib = new modelCDMLib(pathFixed + "/lib", this->level + 1);
+              this->lib = new modelCDMLib(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->lib);
             }
           //if package , create package
           else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
             {
-              modelCDMPackage* package = new modelCDMPackage(pathFixed + "/" + stdfileName, this->level + 1);
+              modelCDMPackage* package = new modelCDMPackage(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->packages.push_back(package);
               this->children.push_back(package);
             }
           //if is an unknown folder, create folder
           else
             {
-              this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
 
           cont = dir.GetNext(&fileName);
@@ -189,12 +189,12 @@ modelCDMProject::modelCDMProject(
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           else
             {
-              this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
           //if is an unknown file, create file
           cont = dir.GetNext(&fileName);
@@ -254,17 +254,17 @@ bool modelCDMProject::SetVersion(const std::string& version, std::string*& resul
   tm* ltm = localtime(&now);
 
   std::stringstream date;
-  date << ltm->tm_mday << "/" << ltm->tm_mon << "/" << 1900 + ltm->tm_year;
+  date << ltm->tm_mday << "/" << 1 + ltm->tm_mon << "/" << 1900 + ltm->tm_year;
 
   //set name of library in CMakeLists inside copied folder
   std::string line;
-  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
   if( !in.is_open())
     {
       result = new std::string("CMakeLists.txt file failed to open.");
       return false;
     }
-  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
   if( !out.is_open())
     {
       result = new std::string("CMakeLists.txt.tmp file failed to open.");
@@ -285,7 +285,7 @@ bool modelCDMProject::SetVersion(const std::string& version, std::string*& resul
   in.close();
   out.close();
   //delete old file and rename new file
-  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
   if(system(renameCommand.c_str()))
     {
       result = new std::string("An error occurred while running '" + renameCommand + "'.");
@@ -355,7 +355,7 @@ modelCDMIProjectTreeNode* modelCDMProject::CreatePackage(
     }
 
   //call project to create package : use bbCreatePackage <path> <name> [author] [description]
-  std::string creationCommand = "bbCreatePackage \"" + this->path + "\" " + nameFixed + " " + authorFixed + " " + descriptionFixed;
+  std::string creationCommand = "bbCreatePackage \"" + this->path + "\" \"" + nameFixed + "\" \"" + authorFixed + "\" \"" + descriptionFixed + "\"";
   //TODO: bbCreatePackage script always returning 0. It should return 1 or greater if any error
   if(system(creationCommand.c_str()))
     {
@@ -364,8 +364,7 @@ modelCDMIProjectTreeNode* modelCDMProject::CreatePackage(
     }
 
   //add library to model
-  //TODO: fix for windows
-  modelCDMPackage* package = new modelCDMPackage(this->path + "/bbtk_" + nameFixed + "_PKG", this->level + 1);
+  modelCDMPackage* package = new modelCDMPackage(this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
   this->packages.push_back(package);
   this->children.push_back(package);
 
@@ -373,7 +372,7 @@ modelCDMIProjectTreeNode* modelCDMProject::CreatePackage(
 
   this->SortChildren();
 
-  result = new std::string(this->path + "/" + name);
+  result = new std::string(this->path + CDMUtilities::SLASH + name);
   return package;
 }
 
@@ -433,8 +432,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
 {
   std::cout << "refreshing project" << std::endl;
   //open makelists file
-  //TODO: set pathMakeLists for windows
-  std::string pathMakeLists = this->path + "/CMakeLists.txt";
+  std::string pathMakeLists = this->path + CDMUtilities::SLASH + "CMakeLists.txt";
 
   std::ifstream confFile;
   confFile.open((pathMakeLists).c_str());
@@ -516,7 +514,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
             {
               if (this->appli == NULL)
                 {
-                  this->appli = new modelCDMAppli(this->path + "/appli", this->level + 1);
+                  this->appli = new modelCDMAppli(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->appli);
                 }
               else
@@ -532,7 +530,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
             {
               if (this->lib == NULL)
                 {
-                  this->lib = new modelCDMLib(this->path + "/lib", this->level + 1);
+                  this->lib = new modelCDMLib(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->lib);
                 }
               else
@@ -563,7 +561,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
                 }
               if(!found)
                 {
-                  modelCDMPackage* package = new modelCDMPackage(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMPackage* package = new modelCDMPackage(this->path + CDMUtilities::SLASH + stdfileName, stdfileName,this->level + 1);
                   this->packages.push_back(package);
                   this->children.push_back(package);
                 }
@@ -586,7 +584,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(folder);
                 }
             }
@@ -604,7 +602,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -632,7 +630,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }
index e3ba19a69d56eaa3a082a5dcd11f577b67dbec80..b2a2a11a44498c5d39242cd35409f23fa95e4b2c 100644 (file)
@@ -61,7 +61,7 @@ public:
    * @param path The source path.
    * @param buildPath The build path. By default it's an empty string.
    */
-  modelCDMProject(const std::string& path, const std::string& buildPath = "");
+  modelCDMProject(const std::string& path, const std::string& name, const std::string& buildPath = "");
 
   /**
    * Destructor.
diff --git a/lib/creaDevManagerLib/wxCDMNewBlackBoxDialog.cpp b/lib/creaDevManagerLib/wxCDMNewBlackBoxDialog.cpp
new file mode 100644 (file)
index 0000000..166ba83
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and 
+#  abiding by the rules of distribution of free software. You can  use, 
+#  modify and/ or redistribute the software under the terms of the CeCILL-B 
+#  license as circulated by CEA, CNRS and INRIA at the following URL 
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability. 
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ 
+ */
+
+
+/*
+ * wxCDMNewBlackBoxDialog.cpp
+ *
+ *  Created on: 26/12/2012
+ *      Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "wxCDMNewBlackBoxDialog.h"
+
+#include "creaDevManagerIds.h"
+
+BEGIN_EVENT_TABLE(wxCDMNewBlackBoxDialog, wxDialog)
+EVT_BUTTON(ID_BUTTON_NEXT, wxCDMNewBlackBoxDialog::OnCreateBlackBox)
+EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMNewBlackBoxDialog::OnCancel)
+END_EVENT_TABLE()
+
+wxCDMNewBlackBoxDialog::wxCDMNewBlackBoxDialog(
+    wxWindow* parent,
+    wxWindowID id,
+    const wxString& caption,
+    const wxPoint& position,
+    const wxSize& size,
+    long style
+)
+{
+  wxCDMNewBlackBoxDialog::Create(parent, id, caption, position, size, style);
+}
+
+wxCDMNewBlackBoxDialog::~wxCDMNewBlackBoxDialog()
+{
+}
+
+bool wxCDMNewBlackBoxDialog::Create(
+    wxWindow* parent,
+    wxWindowID id,
+    const wxString& caption,
+    const wxPoint& position,
+    const wxSize& size,
+    long int style
+)
+{
+  wxDialog::Create(parent, id, caption, position, size, style);
+
+  this->CreateControls();
+
+  return TRUE;
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxName() const
+{
+  return this->blackBoxName->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxAuthor() const
+{
+  return this->blackBoxAuthor->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxAuthorEmail() const
+{
+  return this->blackBoxAuthorEmail->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxDescription() const
+{
+  return this->blackBoxDescription->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxCategories() const
+{
+  return this->blackBoxCategories->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxType() const
+{
+  return this->blackBoxType->GetString(this->blackBoxType->GetCurrentSelection());
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxFormat() const
+{
+  return this->blackBoxFormat->GetString(this->blackBoxFormat->GetCurrentSelection());
+}
+
+void wxCDMNewBlackBoxDialog::CreateControls()
+{
+  wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
+
+
+  wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Create a new black box"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+  v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+  wxStaticText* instruction = new wxStaticText(this, wxID_ANY, wxT("Please fill the following details."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+  v_sizer1->Add(instruction, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+  wxFlexGridSizer* formItems = new wxFlexGridSizer(4,2,9,15);
+
+  wxStaticText *stxtPrjName = new wxStaticText(this, -1, wxT("Black Box Name"));
+  wxStaticText *stxtPrjAuth = new wxStaticText(this, -1, wxT("Black Box Authors (separated by ',')"));
+  wxStaticText *stxtPrjAuthEmail = new wxStaticText(this, -1, wxT("Black Box Authors' Email"));
+  wxStaticText *stxtPrjDsc = new wxStaticText(this, -1, wxT("Black Box Description"));
+  wxStaticText *stxtPrjCat = new wxStaticText(this, -1, wxT("Black Box Categories (separated by ',')"));
+  wxStaticText *stxtPrjTyp = new wxStaticText(this, -1, wxT("Black Box Type"));
+  wxStaticText *stxtPrjFmt = new wxStaticText(this, -1, wxT("Black Box Format"));
+
+  this->blackBoxName = new wxTextCtrl(this, -1);
+  this->blackBoxAuthor = new wxTextCtrl(this, -1);
+  this->blackBoxAuthorEmail = new wxTextCtrl(this, -1);
+  this->blackBoxDescription = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
+  this->blackBoxCategories = new wxTextCtrl(this, -1);
+  wxString BBTypes[] =
+      {
+          wxT("std"),
+          wxT("VTK-ImageAlgorithm"),
+          wxT("VTK-PolyAlgorithm"),
+          wxT("widget")
+      };
+  this->blackBoxType = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, BBTypes);
+
+  wxString BBFormats[] =
+      {
+          wxT("C++"),
+          wxT("XML")
+      };
+  this->blackBoxFormat = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 2, BBFormats);
+
+  formItems->Add(stxtPrjName, 0, wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxName, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+  formItems->Add(stxtPrjAuth, 0, wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxAuthor, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+  formItems->Add(stxtPrjAuthEmail, 0, wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxAuthorEmail, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+  formItems->Add(stxtPrjDsc, 0, wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxDescription, 1, wxEXPAND);
+  formItems->Add(stxtPrjCat,0 , wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxCategories, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+  formItems->Add(stxtPrjTyp, 0, wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxType, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+  formItems->Add(stxtPrjFmt, 0, wxALIGN_CENTER_VERTICAL);
+  formItems->Add(this->blackBoxFormat, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+
+  formItems->AddGrowableCol(1,1);
+  formItems->AddGrowableRow(3,1);
+
+  v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
+
+  wxBoxSizer* h_sizer2 = new wxBoxSizer(wxHORIZONTAL);
+  h_sizer2->Add(new wxButton(this, ID_BUTTON_NEXT, wxT("Create Black Box")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+  h_sizer2->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Cancel")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+  v_sizer1->Add(h_sizer2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
+
+  SetSizer(v_sizer1);
+}
+
+void wxCDMNewBlackBoxDialog::OnCreateBlackBox(wxCommandEvent& event)
+{
+  bool ready = true;
+
+  if(ready && this->blackBoxName->GetValue() == wxT(""))
+    {
+      wxMessageBox(wxT("The black box name cannot be empty"),_T("Error"),wxOK | wxICON_ERROR);
+      ready = false;
+    }
+  if(ready && this->blackBoxAuthor->GetValue() == wxT(""))
+    {
+      wxMessageBox(wxT("The black box author has to be specified"),_T("Error"),wxOK | wxICON_ERROR);
+      ready = false;
+    }
+
+  if(ready)
+    {
+      this->EndModal(wxID_FORWARD);
+    }
+  event.Skip();
+}
+
+void wxCDMNewBlackBoxDialog::OnCancel(wxCommandEvent& event)
+{
+  this->EndModal(wxID_CANCEL);
+  event.Skip();
+}
diff --git a/lib/creaDevManagerLib/wxCDMNewBlackBoxDialog.h b/lib/creaDevManagerLib/wxCDMNewBlackBoxDialog.h
new file mode 100644 (file)
index 0000000..9d5a7fc
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and 
+#  abiding by the rules of distribution of free software. You can  use, 
+#  modify and/ or redistribute the software under the terms of the CeCILL-B 
+#  license as circulated by CEA, CNRS and INRIA at the following URL 
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability. 
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ 
+*/ 
+
+
+/*
+ * wxCDMNewBlackBoxDialog.h
+ *
+ *  Created on: 26/12/2012
+ *      Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef WXCDMNEWBLACKBOXDIALOG_H_
+#define WXCDMNEWBLACKBOXDIALOG_H_
+
+#include <creaWx.h>
+#include <wx/dialog.h>
+#include <wx/choice.h>
+
+class wxCDMNewBlackBoxDialog : public wxDialog
+{
+  DECLARE_EVENT_TABLE()
+public:
+  wxCDMNewBlackBoxDialog(
+      wxWindow* parent,
+      wxWindowID id = wxID_ANY,
+      const wxString& caption = wxT("New Black Box"),
+      const wxPoint& position = wxDefaultPosition,
+      const wxSize& size = wxSize(500,500),
+      long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
+  );
+  ~wxCDMNewBlackBoxDialog();
+  bool Create(
+      wxWindow* parent,
+      wxWindowID id = wxID_ANY,
+      const wxString& caption = wxT("New Black Box"),
+      const wxPoint& position = wxDefaultPosition,
+      const wxSize& size = wxSize(500,500),
+      long style = wxDEFAULT_DIALOG_STYLE
+  );
+
+  const wxString GetBlackBoxName() const;
+  const wxString GetBlackBoxAuthor() const;
+  const wxString GetBlackBoxAuthorEmail() const;
+  const wxString GetBlackBoxDescription() const ;
+  const wxString GetBlackBoxCategories() const ;
+  const wxString GetBlackBoxType() const;
+  const wxString GetBlackBoxFormat() const;
+
+protected:
+  void CreateControls();
+
+private:
+  wxTextCtrl* blackBoxName;
+  wxTextCtrl* blackBoxAuthor;
+  wxTextCtrl* blackBoxAuthorEmail;
+  wxTextCtrl* blackBoxDescription;
+  wxTextCtrl* blackBoxCategories;
+  wxChoice* blackBoxType;
+  wxChoice* blackBoxFormat;
+
+//handlers
+protected:
+  void OnCreateBlackBox(wxCommandEvent& event);
+  void OnCancel(wxCommandEvent& event);
+};
+
+#endif /* WXCDMNEWBLACKBOXDIALOG_H_ */