modelCDMAppli::modelCDMAppli(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating appli\n";
this->type = wxDIR_DIRS;
this->name = name;
this->level = level;
}
this->SortChildren();
+ std::sort(this->applications.begin(), this->applications.end(), CompareNodeItem);
}
modelCDMAppli::~modelCDMAppli()
std::string applicationName = stdfileName;
//check if they already exist
bool found = false;
- for (int i = 0;!found && i < this->applications.size(); i++)
+ for (int i = 0; !found && i < this->applications.size(); i++)
{
if (this->applications[i]->GetName() == applicationName)
{
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
}
}
this->SortChildren();
+ std::sort(this->applications.begin(), this->applications.end(), CompareNodeItem);
return true;
}
modelCDMApplication::modelCDMApplication(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating application: " + path + "\n";
//folder name
this->name = name;
//path
}
}
this->SortChildren();
+ std::sort(this->folders.begin(), this->folders.end(), CompareNodeItem);
}
modelCDMApplication::~modelCDMApplication()
const bool modelCDMApplication::Refresh(std::string*& result)
{
+ std::cout << "refreshing application: " << this->executableName << std::endl;
//set attributes
this->type = wxDIR_DIRS;
std::string applicationName = stdfileName;
//check if they already exist
bool found = false;
- for (int i = 0;!found && i < this->folders.size(); i++)
+ for (int i = 0; !found && i < this->folders.size(); i++)
{
if (this->folders[i]->GetName() == applicationName)
{
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
modelCDMBlackBox::modelCDMBlackBox(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating black box: " + name + " in " + path + "\n";
this->name = name;
this->path = path;
this->level = level;
const bool modelCDMBlackBox::Refresh(std::string*& result)
{
+ std::cout << "refreshing black box: " << this->nameBlackBox << std::endl;
std::string pathHeader = path + CDMUtilities::SLASH + "bb" + this->name + ".h";
std::ifstream confFile;
modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating cmakelist file: " + path + "\n";
this->children.clear();
this->level = level;
this->type = wxDIR_FILES;
const bool modelCDMCMakeListsFile::Refresh(std::string*& result)
{
+ //std::cout << "refreshing cmakelists" << std::endl;
std::ifstream in((this->path).c_str());
if(!in.is_open())
{
modelCDMFile::modelCDMFile(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating file: " + path + "\n";
this->children.clear();
this->level = level;
this->name = name;
const bool modelCDMFile::Refresh(std::string*& result)
{
+ //std::cout << "refreshing file " << this->name << std::endl;
std::ifstream in((this->path).c_str());
if(!in.is_open())
{
modelCDMFolder::modelCDMFolder(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating folder: " + path + "\n";
//set attributes
this->children.clear();
this->level = level;
std::string stdfileName = crea::wx2std(fileName);
//if is an unknown folder, create folder
- this->children.push_back(new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
+ modelCDMFolder* folder = new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ this->children.push_back(folder);
+ this->folders.push_back(folder);
cont = dir.GetNext(&fileName);
}
}
this->SortChildren();
+ std::sort(this->folders.begin(), this->folders.end(), CompareNodeItem);
}
modelCDMFolder::~modelCDMFolder()
const bool modelCDMFolder::Refresh(std::string*& result)
{
+ //std::cout << "refreshing folder " << this->name << std::endl;
//set attributes
this->type = wxDIR_DIRS;
while (cont)
{
std::string stdfileName = crea::wx2std(fileName);
- std::string folderName = stdfileName;
//check if they already exist
bool found = false;
- for (int i = 0;!found && i < this->folders.size(); i++)
+ for (int i = 0; !found && i < this->folders.size(); i++)
{
- if (this->folders[i]->GetName() == folderName)
+ if (this->folders[i]->GetName() == stdfileName)
{
found = true;
int pos = std::find(this->children.begin(), this->children.end(), this->folders[i]) - this->children.begin();
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0;!found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
}
}
this->SortChildren();
+ std::sort(this->folders.begin(), this->folders.end(), CompareNodeItem);
return true;
}
modelCDMLib::modelCDMLib(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating lib\n";
this->type = wxDIR_DIRS;
this->name = name;
this->level = level;
}
}
this->SortChildren();
+ std::sort(this->libraries.begin(), this->libraries.end(), CompareNodeItem);
}
modelCDMLib::~modelCDMLib()
std::string libraryName = stdfileName;
//check if they already exist
bool found = false;
- for (int i = 0;!found && i < this->libraries.size(); i++)
+ for (int i = 0; !found && i < this->libraries.size(); i++)
{
if (this->libraries[i]->GetName() == libraryName)
{
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
}
}
this->SortChildren();
+ std::sort(this->libraries.begin(), this->libraries.end(), CompareNodeItem);
return true;
}
modelCDMLibrary::modelCDMLibrary(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating library: " + path + "\n";
//folder name
this->name = name;
//path
}
}
this->SortChildren();
+ std::sort(this->folders.begin(), this->folders.end(), CompareNodeItem);
}
modelCDMLibrary::~modelCDMLibrary()
const bool modelCDMLibrary::Refresh(std::string*& result)
{
+ std::cout << "refreshing library: " << this->nameLibrary << std::endl;
//set attributes
this->type = wxDIR_DIRS;
while (cont)
{
std::string stdfileName = crea::wx2std(fileName);
- std::string folderName = stdfileName;
//check if they already exist
bool found = false;
- for (int i = 0;!found && i < this->folders.size(); i++)
+ for (int i = 0; !found && i < this->folders.size(); i++)
{
- if (this->folders[i]->GetName() == folderName)
+ if (this->folders[i]->GetName() == stdfileName)
{
found = true;
int pos = std::find(this->children.begin(), this->children.end(), this->folders[i]) - this->children.begin();
return false;
}
}
- //if is an unknown file, create file
+ //if is an unknown file, check if exist in children
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
}
}
this->SortChildren();
+ std::sort(this->folders.begin(), this->folders.end(), CompareNodeItem);
return true;
}
modelCDMPackage::modelCDMPackage(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating package: " + path + "\n";
this->type = wxDIR_DIRS;
this->name = name;
//Get Package Name
}
modelCDMBlackBox* modelCDMPackage::CreateBlackBox(
+ std::string*& result,
const std::string& name,
const std::string& type,
const std::string& format,
+ const std::string& categories,
const std::string& authors,
const std::string& authorsEmail,
- const std::string& categories,
const std::string& description
)
{
- //TODO: implement method
- return NULL;
+ return this->src->CreateBlackBox(result,name, this->namePackage, type,format,categories,authors,authorsEmail,description);
}
const bool modelCDMPackage::Refresh(std::string*& result)
{
- std::cout << "refreshing package" << std::endl;
+ std::cout << "refreshing package " << this->namePackage << std::endl;
this->type = wxDIR_DIRS;
//Get Package Name
//check if folder already exist
bool found = false;
- for (int i = 0;!found && i < this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
modelCDMBlackBox* CreateBlackBox(
+ std::string*& result,
const std::string& name,
const std::string& type = "std",
const std::string& format = "C++",
+ const std::string& categories = "empty",
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);
modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const std::string& name, const int& level)
{
+ std::cout << "creating package src: " + path + "\n";
//set attributes
this->children.clear();
this->level = level;
}
this->SortChildren();
+ std::sort(this->blackBoxes.begin(), this->blackBoxes.end(), CompareNodeItem);
}
modelCDMPackageSrc::~modelCDMPackageSrc()
}
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& categories,
const std::string& description)
{
- //TODO: implement method
- return NULL;
+ //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 < 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 < 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 < 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 < 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 < words.size(); i++)
+ {
+ bbDescription += words[i];
+ }
+ }
+
+ if(bbDescription == "")
+ bbDescription = "No Description.";
+
+
+ //create command
+ std::string command = "bbCreateBlackBox";
+ command += " \"" + this->path + "\"";
+ command += " \"" + package + "\"";
+ command += " \"" + bbName + "\"";
+ command += " \"" + type + "\"";
+ command += " \"" + format + "\"";
+ command += " \"" + bbAuthors + "\"";
+ command += " \"" + bbDescription + "\"";
+ command += " \"" + bbCategories + "\"";
+
+ //excecute command
+ 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->path + 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->path + stdfileName, stdfileName, this->level+1);
+ }
+ }
+ //if source and header exist
+ if (header != NULL && source != NULL)
+ {
+ //create black box
+ modelCDMBlackBox* blackBox = new modelCDMBlackBox(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 < this->children.size(); i++)
{
if (this->children[i]->GetName() == folderName)
{
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
}
}
this->SortChildren();
+ std::sort(this->blackBoxes.begin(), this->blackBoxes.end(), CompareNodeItem);
return true;
}
const std::vector<modelCDMBlackBox*>& GetBlackBoxes() const;
modelCDMBlackBox* CreateBlackBox(
+ std::string*& result,
const std::string& name,
const std::string& package,
const std::string& type = "std",
const std::string& buildPath
)
{
+ std::cout << "creating project: " + name + " in " + path + "\n";
this->path = CDMUtilities::fixPath(path);
//open makelists file
std::string pathFixed(CDMUtilities::fixPath(path));
}
this->SortChildren();
+ std::sort(this->packages.begin(), this->packages.end(), CompareNodeItem);
}
//if package , create package
else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
{
- std::string packageName = stdfileName.substr(5, stdfileName.size()-9);
bool found = false;
- for (int i = 0;!found && i < this->packages.size(); i++)
+ for (int i = 0; !found && i < this->packages.size(); i++)
{
- if (this->packages[i]->GetName() == packageName)
+ if (this->packages[i]->GetName() == stdfileName)
{
found = true;
int pos = std::find(this->children.begin(), this->children.end(), this->packages[i]) - this->children.begin();
}
if(!found)
{
- modelCDMPackage* package = new modelCDMPackage(this->path + CDMUtilities::SLASH + stdfileName, 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);
}
else
{
bool found = false;
- for (int i = 0; i <!found && this->children.size(); i++)
+ for (int i = 0; !found && i < this->children.size(); i++)
{
if (this->children[i]->GetName() == stdfileName)
{
i--;
}
}
+
this->SortChildren();
+ std::sort(this->packages.begin(), this->packages.end(), CompareNodeItem);
return true;
}
}
else if(event.GetString() == wxT("blackbox"))
{
+ this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), false);
modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
description = new wxCDMBlackBoxDescriptionPanel(
this,
#include "creaDevManagerIds.h"
#include "images/PkIcon64.xpm"
+#include "wxCDMNewBlackBoxDialog.h"
#include <wx/textdlg.h>
#include "CDMUtilities.h"
void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnCreateBlackBox not implemented" << std::endl;
- event.Skip();
+
+ wxCDMNewBlackBoxDialog* dialog = new wxCDMNewBlackBoxDialog(this);
+ long userResponse;
+ userResponse = dialog->ShowModal();
+
+ if(userResponse == wxID_FORWARD)
+ {
+ std::string* result;
+ //create black box
+ modelCDMIProjectTreeNode* blackBox = this->package->CreateBlackBox(
+ result,
+ crea::wx2std(dialog->GetBlackBoxName()),
+ crea::wx2std(dialog->GetBlackBoxType()),
+ crea::wx2std(dialog->GetBlackBoxFormat()),
+ crea::wx2std(dialog->GetBlackBoxCategories()),
+ crea::wx2std(dialog->GetBlackBoxAuthor()),
+ crea::wx2std(dialog->GetBlackBoxAuthorEmail()),
+ crea::wx2std(dialog->GetBlackBoxDescription())
+ );
+ //check black box created
+ if(blackBox == NULL)
+ {
+ wxMessageBox(crea::std2wx(*result),_T("New Black Box - Error!"),wxOK | wxICON_ERROR);
+ return;
+ }
+ wxMessageBox(crea::std2wx("Black box successfully created."),_T("New Black Box - Success!"),wxOK | wxICON_INFORMATION);
+
+ //refreshing tree and description
+ //send event instead of calling parent to avoid crashing
+
+ ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
+
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+ newEvent->SetId(1);
+ newEvent->SetInt(blackBox->GetId());
+ newEvent->SetString(wxT("blackbox"));
+ newEvent->SetClientData(blackBox);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
}
void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)