]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMPackageSrc.cpp
#3391 bug profile_creatools in Linux/Win32
[crea.git] / lib / creaDevManagerLib / modelCDMPackageSrc.cpp
index 5c10bba10b32c7c84b77d4fe44758204ec974536..f90def4fb604206c418ba8f90b2ba2ebc322a373 100644 (file)
@@ -88,11 +88,18 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
-          modelCDMFile* file;
+          std::size_t fileTypePos = stdfileName.find_last_of(".");
+          std::string fileType;
+          if(fileTypePos != std::string::npos)
+            fileType = stdfileName.substr(fileTypePos);
+          else
+            fileType = "";
+
+          modelCDMCodeFile* file;
 
           if(stdfileName.substr(0,2) == "bb")
             {
-              file = new modelCDMFile(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+              file = new modelCDMCodeFile(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(file);
               modelCDMBlackBox* blackBox = new modelCDMBlackBox(this, path, stdfileName.substr(2,stdfileName.size()-4), level + 1);
               blackBox->SetHeaderFile(file);
@@ -100,7 +107,7 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s
               cont = dir2.GetFirst(&fileName, crea::std2wx(stdfileName.substr(0,stdfileName.size()-2) + ".cxx"), wxDIR_FILES);
               if (cont)
                 {
-                  file = new modelCDMFile(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
+                  file = new modelCDMCodeFile(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
                   this->children.push_back(file);
                   blackBox->SetSourceFile(file);
                 }
@@ -224,7 +231,13 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox(
   command += " \"" + bbDescription + "\"";
   command += " \"" + bbCategories + "\"";
 
+    
+#ifdef __APPLE__
+    command = "source ~/.bbtk/profile_creatools ; " + command;
+#endif
+    
   //excecute command
+//  wxMessageBox(crea::std2wx("Command: ->" + command + "<-"),_T("Creating Black Box"),wxOK | wxICON_INFORMATION);
   if(system(command.c_str()))
     {
       result = new std::string("Error executing command '" + command + "'");
@@ -238,7 +251,7 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox(
   modelCDMFile* header = NULL;
   modelCDMFile* source = NULL;
   wxDir dir(crea::std2wx(path));
-  if (dir.IsOpened())
+    if (dir.IsOpened())
     {
       wxString fileName;
       bool cont = dir.GetFirst(&fileName, crea::std2wx("bb"+package+bbName+".h"), wxDIR_FILES);
@@ -255,6 +268,8 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox(
         }
     }
   //if source and header exist
+    
+    
   if (header != NULL && source != NULL)
     {
       //create black box
@@ -326,6 +341,12 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result)
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
+          std::size_t fileTypePos = stdfileName.find_last_of(".");
+          std::string fileType;
+          if(fileTypePos != std::string::npos)
+            fileType = stdfileName.substr(fileTypePos);
+          else
+            fileType = "";
 
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
@@ -360,8 +381,22 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
-                  this->children.push_back(file);
+                  //if is a code file, create modelCDMCodeFile
+                  if(
+                      fileType == ".c" ||
+                      fileType == ".cxx" ||
+                      fileType == ".h" ||
+                      fileType == ".cpp" ||
+                      fileType == ".txx" ||
+                      fileType == ".cmake" )
+                    {
+                      this->children.push_back(new modelCDMCodeFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
+                    }
+                  else
+                    {
+                      modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+                      this->children.push_back(file);
+                    }
                 }
             }