this->CMakeLists = NULL;
}
-modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level)
+modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating package src: " + path + "\n";
+ this->parent = parent;
//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;
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(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
cont = dir.GetNext(&fileName);
}
if (cont)
{
std::string stdfileName = crea::wx2std(fileName);
- this->CMakeLists = new modelCDMCMakeListsFile(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(stdfileName.substr(0,2) == "bb")
{
- file = new modelCDMFile(path + "/" + stdfileName, this->level + 1);
+ file = new modelCDMFile(this, 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(this, 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(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
this->children.push_back(file);
blackBox->SetSourceFile(file);
}
}
this->SortChildren();
+ std::sort(this->blackBoxes.begin(), this->blackBoxes.end(), CompareNodeItem);
}
modelCDMPackageSrc::~modelCDMPackageSrc()
{
- for (int i = 0; i < this->blackBoxes.size(); i++)
+ for (int i = 0; i < (int)(this->blackBoxes.size()); i++)
{
if(this->blackBoxes[i] != NULL)
{
return this->blackBoxes;
}
+modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox(
+ std::string*& result,
+ const std::string& name,
+ const std::string& package,
+ const std::string& type,
+ const std::string& format,
+ const std::string& categories,
+ const std::string& authors,
+ const std::string& authorsEmail,
+ const std::string& description)
+{
+ //parse name
+ std::vector<std::string> words;
+ CDMUtilities::splitter::split(words, name, " \n\",/\\'", CDMUtilities::splitter::no_empties);
+ std::string bbName;
+ for (int i = 0; i < (int)(words.size()); i++)
+ {
+ bbName += words[i];
+ }
+
+ //parse categories
+ CDMUtilities::splitter::split(words, categories, " \n\",/\\'", CDMUtilities::splitter::no_empties);
+ std::string bbCategories;
+ if(words.size() > 0)
+ {
+ bbCategories = words[0];
+ for (int i = 1; i < (int)(words.size()); i++)
+ {
+ bbCategories += "," + words[i];
+ }
+ }
+ if(bbCategories == "")
+ bbCategories = "empty";
+
+ //parse authors
+ CDMUtilities::splitter::split(words, authors, "\n\",/\\'", CDMUtilities::splitter::no_empties);
+ std::string bbAuthors;
+ if(words.size() > 0)
+ {
+ bbAuthors = words[0];
+ for (int i = 1; i < (int)(words.size()); i++)
+ {
+ bbAuthors += "," + words[i];
+ }
+ }
+ if(bbAuthors == "")
+ bbAuthors = "Unknown";
+
+ //parse description
+ CDMUtilities::splitter::split(words, authorsEmail, " \n\"/\\'", CDMUtilities::splitter::no_empties);
+ std::string bbDescription;
+ if(words.size() > 0)
+ {
+ bbDescription = words[0];
+ for (int i = 1; i < (int)(words.size()); i++)
+ {
+ bbDescription += "," + words[i];
+ }
+ bbDescription += " - ";
+ }
+ CDMUtilities::splitter::split(words, description, "\n\"/\\'", CDMUtilities::splitter::no_empties);
+ if(words.size() > 0)
+ {
+ bbDescription += words[0];
+ for (int i = 1; i < (int)(words.size()); i++)
+ {
+ bbDescription += words[i];
+ }
+ }
+
+ if(bbDescription == "")
+ bbDescription = "No Description.";
+
+
+ //create command
+ std::string command = "bbCreateBlackBox";
+ command += " \"" + this->path + "\"";
+#ifdef _WIN32
+ command += " " + package;
+ command += " " + bbName;
+ command += " " + type;
+ command += " " + format;
+#else
+ command += " \"" + package + "\"";
+ command += " \"" + bbName + "\"";
+ command += " \"" + type + "\"";
+ command += " \"" + format + "\"";
+#endif
+ command += " \"" + bbAuthors + "\"";
+ command += " \"" + bbDescription + "\"";
+ command += " \"" + bbCategories + "\"";
+
+ //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 + "'");
+ return NULL;
+ }
+
+ //if command succeed
+
+ //create header
+ //create source
+ modelCDMFile* header = NULL;
+ modelCDMFile* source = NULL;
+ wxDir dir(crea::std2wx(path));
+ if (dir.IsOpened())
+ {
+ wxString fileName;
+ bool cont = dir.GetFirst(&fileName, crea::std2wx("bb"+package+bbName+".h"), wxDIR_FILES);
+ if (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+ header = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level+1);
+ }
+ cont = dir.GetFirst(&fileName, crea::std2wx("bb"+package+bbName+".cxx"), wxDIR_FILES);
+ if (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+ source = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level+1);
+ }
+ }
+ //if source and header exist
+ if (header != NULL && source != NULL)
+ {
+ //create black box
+ modelCDMBlackBox* blackBox = new modelCDMBlackBox(this, this->path, package+bbName);
+
+ //associate header and source
+ blackBox->SetHeaderFile(header);
+ blackBox->SetSourceFile(source);
+
+ this->children.push_back(header);
+ this->children.push_back(source);
+
+ this->blackBoxes.push_back(blackBox);
+
+ //sort children
+ std::sort(this->blackBoxes.begin(), this->blackBoxes.end(), CompareNodeItem);
+ this->SortChildren();
+
+ return blackBox;
+ }
+ else
+ {
+ result = new std::string("The header and source files were not found. Black box not created.");
+ return NULL;
+ }
+}
+
const bool modelCDMPackageSrc::Refresh(std::string*& result)
{
+ std::cout << "refreshing package src" << std::endl;
//set attributes
this->type = wxDIR_DIRS;
std::string folderName = stdfileName;
//check if they already exist
bool found = false;
- for (int i = 0;!found && i < this->children.size(); i++)
+ for (int i = 0; !found && i < (int)(this->children.size()); i++)
{
if (this->children[i]->GetName() == folderName)
{
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(folder);
}
cont = dir.GetNext(&fileName);
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < (int)(this->children.size()); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
if(stdfileName.substr(stdfileName.size() - 2, 2) == ".h" && stdfileName.substr(0,2) == "bb")
{
bool found = false;
- for (int i = 0; i < this->blackBoxes.size(); i++)
+ for (int i = 0; i < (int)(this->blackBoxes.size()); i++)
{
if(this->blackBoxes[i]->GetHeaderFile()->GetName() == stdfileName)
{
if (!found)
{
- modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path + "/" + stdfileName, level + 1);
+ modelCDMBlackBox* blackBox = new modelCDMBlackBox(this, path, stdfileName.substr(2,stdfileName.size()-4), level + 1);
this->blackBoxes.push_back(blackBox);
}
}
}
- for (int i = 0; i < checkedBoxes.size(); i++)
+ for (int i = 0; i < (int)(checkedBoxes.size()); i++)
{
if(!checkedBoxes[i])
{
}
}
- for (int i = 0; i < checked.size(); i++)
+ for (int i = 0; i < (int)(checked.size()); i++)
{
if(!checked[i])
{
}
}
this->SortChildren();
+ std::sort(this->blackBoxes.begin(), this->blackBoxes.end(), CompareNodeItem);
return true;
}