+ std::cout << "refreshing project" << std::endl;
+ //open makelists file
+ std::string pathMakeLists = this->path + CDMUtilities::SLASH + "CMakeLists.txt";
+
+ std::ifstream confFile;
+ confFile.open((pathMakeLists).c_str());
+
+ std::string word;
+ while(confFile.is_open() && !confFile.eof())
+ {
+ //std::cout << "leyendo " << word << std::endl;
+ //get project name
+ std::getline(confFile,word,'(');
+ std::vector<std::string> wordBits;
+ CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties);
+
+ if(wordBits[wordBits.size()-1] == "PROJECT")
+ {
+ std::getline(confFile,word,')');
+ std::vector<std::string> nameBits;
+ CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties);
+
+ this->name = this->nameProject = "";
+ for (int i = 0; i < (int)(nameBits.size()); i++)
+ {
+ if(i != 0)
+ this->name += " ";
+ this->name += nameBits[i];
+ }
+ this->nameProject = this->name;
+
+ }
+
+
+ if(wordBits[wordBits.size()-1] == "SET")
+ {
+ //get project version
+ std::getline(confFile,word,')');
+ CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties);
+ if(wordBits[0] == "PROJECT_MAJOR_VERSION")
+ {
+ version = wordBits[1];
+ }
+ if(wordBits[0] == "PROJECT_MINOR_VERSION")
+ {
+ version += "." + wordBits[1];
+ }
+ if(wordBits[0] == "PROJECT_BUILD_VERSION")
+ {
+ version += "." + wordBits[1];
+ }
+
+ //get project versionDate
+ if(wordBits[0] == "PROJECT_VERSION_DATE")
+ {
+ std::vector<std::string> versionBits;
+ CDMUtilities::splitter::split(versionBits, wordBits[1], "\"", CDMUtilities::splitter::no_empties);
+ versionDate = versionBits[0];
+ }
+ }
+ }
+ confFile.close();
+
+ this->type = wxDIR_DIRS;
+ this->level = 0;
+
+ std::vector<bool> checked(this->children.size(), false);
+ std::vector<bool> checkedPackages(this->packages.size(), false);
+
+ //check all folders
+ wxDir dir(crea::std2wx((this->path).c_str()));
+ if (dir.IsOpened())
+ {
+ wxString fileName;
+ bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if appli, create appli
+ if(stdfileName == "appli")
+ {
+ if (this->appli == NULL)
+ {
+ this->appli = new modelCDMAppli(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->children.push_back(this->appli);
+ }
+ else
+ {
+ int pos = std::find(this->children.begin(), this->children.end(), this->appli) - this->children.begin();
+ checked[pos] = true;
+ if(!this->appli->Refresh(result))
+ return false;
+ }
+ }
+ //if lib, create lib
+ else if(stdfileName == "lib")
+ {
+ if (this->lib == NULL)
+ {
+ this->lib = new modelCDMLib(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->children.push_back(this->lib);
+ }
+ else
+ {
+ int pos = std::find(this->children.begin(), this->children.end(), this->lib) - this->children.begin();
+ checked[pos] = true;
+ if(!this->lib->Refresh(result))
+ return false;
+ }
+
+ }
+ //if package , create package
+ else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
+ {
+ bool found = false;
+ for (int i = 0; !found && i < (int)(this->packages.size()); i++)
+ {
+ if (this->packages[i]->GetName() == stdfileName)
+ {
+ found = true;
+ int pos = std::find(this->children.begin(), this->children.end(), this->packages[i]) - this->children.begin();
+ checked[pos] = true;
+ checkedPackages[i] = true;
+ if(!this->packages[i]->Refresh(result))
+ return false;
+ }
+ }
+ if(!found)
+ {
+ modelCDMPackage* package = new modelCDMPackage(this, this->path + 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
+ {
+ bool found = false;
+ for (int i = 0; !found && i < (int)(this->children.size()); i++)
+ {
+ if (this->children[i]->GetName() == stdfileName)
+ {
+ found = true;
+ checked[i] = true;
+ if(!this->children[i]->Refresh(result))
+ return false;
+ }
+ }
+
+ if(!found)
+ {
+ modelCDMFolder* folder = new modelCDMFolder(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->children.push_back(folder);
+ }
+ }
+
+ cont = dir.GetNext(&fileName);
+ }
+
+ cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if CMakeLists, create CMakeLists
+ if(stdfileName == "CMakeLists.txt")
+ {
+ if (this->CMakeLists == NULL)
+ {
+ this->CMakeLists = new modelCDMCMakeListsFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->children.push_back(this->CMakeLists);
+ }
+ else
+ {
+ int pos = std::find(this->children.begin(), this->children.end(), this->CMakeLists) - this->children.begin();
+ checked[pos] = true;
+ if(!this->CMakeLists->Refresh(result))
+ return false;
+ }
+ }
+ //if is an unknown file, create file
+ else
+ {
+ bool found = false;
+ for (int i = 0; !found && i < (int)(this->children.size()); i++)
+ {
+ if (this->children[i]->GetName() == stdfileName)
+ {
+ found = true;
+ checked[i] = true;
+ if(!this->children[i]->Refresh(result))
+ return false;
+ }
+ }
+
+ if(!found)
+ {
+ modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->children.push_back(file);
+ }
+ }
+
+ cont = dir.GetNext(&fileName);
+ }
+ }
+
+ for (int i = 0; i < (int)(checkedPackages.size()); i++)
+ {
+ if(!checkedPackages[i])
+ {
+ this->packages.erase(this->packages.begin()+i);
+ checkedPackages.erase(checkedPackages.begin()+i);
+ i--;
+ }
+ }
+ for (int i = 0; i < (int)(checked.size()); i++)
+ {
+ if(!checked[i])
+ {
+ delete this->children[i];
+ this->children.erase(this->children.begin()+i);
+ checked.erase(checked.begin()+i);
+ i--;
+ }
+ }
+
+ this->SortChildren();
+ std::sort(this->packages.begin(), this->packages.end(), CompareNodeItem);