+ std::cout << "refreshing appli" << std::endl;
+ this->type = wxDIR_DIRS;
+
+ std::vector<bool> checked(this->children.size(), false);
+ std::vector<bool> checkedApplications(this->applications.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(stdfileName != "template_appli" && stdfileName != "template_wx_appli")
+ {
+ std::string applicationName = stdfileName;
+ //check if application already exist
+ bool found = false;
+ for (int i = 0; !found && i < (int)(this->applications.size()); i++)
+ {
+ if (this->applications[i]->GetName() == applicationName)
+ {
+ found = true;
+ int pos = std::find(this->children.begin(), this->children.end(), this->applications[i]) - this->children.begin();
+ checked[pos] = true;
+ checkedApplications[i] = true;
+ if(!this->applications[i]->Refresh(result))
+ return false;
+ }
+ }
+ if(!found)
+ {
+ modelCDMApplication* application= new modelCDMApplication(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->applications.push_back(application);
+ this->children.push_back(application);
+ }
+ }
+ else
+ {
+ //check if folder already exist
+ 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)(checkedApplications.size()); i++)
+ {
+ if(!checkedApplications[i])
+ {
+ this->applications.erase(this->applications.begin()+i);
+ checkedApplications.erase(checkedApplications.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->applications.begin(), this->applications.end(), CompareNodeItem);