//break path into folders
std::vector<std::string> pathSlpit;
- splitter::split(pathSlpit, path, "/", splitter::no_empties);
+ splitter::split(pathSlpit, path, CDMUtilities::SLASH, splitter::no_empties);
for (int i = 0; i < pathSlpit.size(); i++)
{
- pathFixed += "/" + pathSlpit[i];
+ pathFixed += CDMUtilities::SLASH + pathSlpit[i];
}
#endif
return pathFixed;
namespace CDMUtilities
{
+ //path slash
+ #ifdef _WIN32
+ // ------ Windows
+ static std::string SLASH = "\\";
+ #elif __APPLE__
+ // ------ Apple
+ static std::string SLASH = "/";
+ #else
+ static std::string SLASH = "/";
+ #endif
+
//text editor program
#ifdef _WIN32
// ------ Windows
{
}
-modelCDMAppli::modelCDMAppli(const std::string& path, const int& level)
+modelCDMAppli::modelCDMAppli(const std::string& path, const std::string& name, const int& level)
{
this->type = wxDIR_DIRS;
- this->name = "appli";
+ this->name = name;
this->level = level;
this->path = path;
{
std::string stdfileName = crea::wx2std(fileName);
- modelCDMApplication* application = new modelCDMApplication(pathFixed + "/" + stdfileName, this->level + 1);
+ modelCDMApplication* application = new modelCDMApplication(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->applications.push_back(application);
this->children.push_back(application);
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
//if is an unknown file, create file
else
{
- this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
cont = dir.GetNext(&fileName);
modelCDMApplication* modelCDMAppli::CreateApplication(
const std::string& name,
- std::string*& result,
- const std::string& path
+ std::string*& result
)
{
//copy template application folder with new name
- //TODO: fix for windows
- std::string copyCommand = "cp -r " + this->path + "/template_appli " + this->path + "/" + name;
+ std::string copyCommand = "cp -r \"" + this->path + CDMUtilities::SLASH + "template_appli\" \"" + this->path + CDMUtilities::SLASH + name + "\"";
if(system(copyCommand.c_str()))
{
result = new std::string("An error occurred while running '" + copyCommand + "'.");
}
//set name of library in CMakeLists inside copied folder
std::string line;
- std::ifstream in((this->path + "/" + name + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return NULL;
}
- std::ofstream out((this->path + "/" + name + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
while (getline(in, line))
{
if(line == "SET ( EXE_NAME MyExe )")
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/" + name + "/CMakeLists.txt.tmp " + this->path + "/" + name + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
}
//add application to model
- //TODO: fix for windows
- modelCDMApplication* application = new modelCDMApplication(this->path + "/" + name, this->level + 1);
+ modelCDMApplication* application = new modelCDMApplication(this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->applications.push_back(application);
this->children.push_back(application);
this->SortChildren();
- result = new std::string(this->path + "/" + name);
+ result = new std::string(this->path + CDMUtilities::SLASH + name);
return application;
}
{
std::cout << "refreshing appli" << std::endl;
this->type = wxDIR_DIRS;
- this->name = "appli";
- this->level = level;
- this->path = path;
-
-
std::vector<bool> checked(this->children.size(), false);
std::vector<bool> checkedApplications(this->applications.size(), false);
}
if(!found)
{
- modelCDMApplication* application= new modelCDMApplication(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMApplication* application= new modelCDMApplication(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->applications.push_back(application);
this->children.push_back(application);
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
{
public:
modelCDMAppli();
- modelCDMAppli(const std::string& path, const int& level = 1);
+ modelCDMAppli(const std::string& path, const std::string& name = "appli", const int& level = 1);
~modelCDMAppli();
const std::vector<modelCDMApplication*>& GetApplications() const;
modelCDMApplication* CreateApplication(
const std::string& name,
- std::string*& result,
- const std::string& path = "/"
+ std::string*& result
);
virtual const bool Refresh(std::string*& result);
{
}
-modelCDMApplication::modelCDMApplication(const std::string& path, const int& level)
+modelCDMApplication::modelCDMApplication(const std::string& path, const std::string& name, const int& level)
{
//folder name
- std::vector<std::string> words;
- std::string delimiters;
- //TODO::fix for windows
- delimiters = "/";
- CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
- this->name = words[words.size()-1];
-
+ this->name = name;
//path
this->path = CDMUtilities::fixPath(path);
//type
this->type = wxDIR_DIRS;
//level
this->level = level;
-
//open CMakeList
- std::string pathMakeLists = path + "/CMakeLists.txt";
+ std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
word += " " + wordBits[i];
}
- this->nameApplication = this->executableName = word;
+ this->executableName = word;
}
}
}
{
std::string stdfileName = crea::wx2std(fileName);
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->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 is an unknown file, create file
else
{
- this->children.push_back(new modelCDMFile(this->path + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
cont = dir.GetNext(&fileName);
{
}
-const std::string& modelCDMApplication::GetNameApplication() const
-{
- return this->nameApplication;
-}
-
const std::string& modelCDMApplication::GetExecutableName() const
{
return this->executableName;
std::string line;
//opening original cmakelists
- std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return false;
}
//opening temporal cmakelists
- std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
if( !out.is_open())
{
result = new std::string("CMakeLists.txt.tmp file failed to open.");
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
return false;
}
- this->executableName = this->nameApplication = fileNameReal;
+ this->executableName = fileNameReal;
return true;
}
modelCDMFolder* modelCDMApplication::CreateFolder(const std::string& name, std::string*& result)
{
//TODO:: mkdir depending on OS
- std::string command = "mkdir " + path + "/" + name;
+ std::string command = "mkdir " + path + CDMUtilities::SLASH + name;
if(system(command.c_str()))
{
result = new std::string("Error executing: " + command + ".");
return NULL;
}
- modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
this->type = wxDIR_DIRS;
//open CMakeList
- std::string pathMakeLists = path + "/CMakeLists.txt";
+ std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
if(wordBits[wordBits.size()-1] == "SET")
{
- //get library name
+ //get app name
std::getline(confFile,word,')');
CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties);
- if(wordBits[0] == "LIBRARY_NAME")
+ if(wordBits[0] == "EXE_NAME")
{
word = wordBits[1];
for (int i = 2; i < wordBits.size(); i++)
word += " " + wordBits[i];
}
- this->nameApplication = this->executableName = word;
+ this->executableName = word;
}
}
}
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
{
public:
modelCDMApplication();
- modelCDMApplication(const std::string& path, const int& level = 2);
+ modelCDMApplication(const std::string& path, const std::string& name, const int& level = 2);
~modelCDMApplication();
- const std::string& GetNameApplication() const;
const std::string& GetExecutableName() const;
bool SetExecutableName(const std::string& fileName, std::string*& result);
virtual const bool Refresh(std::string*& result);
private:
- std::string nameApplication;
std::string executableName;
std::vector<modelCDMFolder*> folders;
};
this->header = NULL;
}
-modelCDMBlackBox::modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level)
+modelCDMBlackBox::modelCDMBlackBox(const std::string& path, const std::string& name, const int& level)
{
- this->name = hName.substr(2, hName.size()-4);
+ this->name = name;
this->path = path;
this->level = level;
this->type = wxDIR_DIRS;
this->source = NULL;
this->header = NULL;
- std::string pathHeader = path + "/" + "bb" + this->name + ".h";
+ std::string pathHeader = path + CDMUtilities::SLASH + "bb" + this->name + ".h";
std::ifstream confFile;
confFile.open((pathHeader).c_str());
modelCDMBlackBox::~modelCDMBlackBox()
{
+ this->header = NULL;
+ this->source = NULL;
}
const std::string& modelCDMBlackBox::GetNameBlackBox() const
bool modelCDMBlackBox::SetAuthors(const std::string& authors, std::string*& result)
{
std::vector<std::string> words;
- CDMUtilities::splitter::split(words, authors, ",\"\n", CDMUtilities::splitter::no_empties);
+ CDMUtilities::splitter::split(words, authors, "/\\\"\n", CDMUtilities::splitter::no_empties);
std::string authorsReal = words[0];
for (int i = 1; i < words.size(); i++)
{
- authorsReal += "/" + words[i];
+ authorsReal += "," + words[i];
}
//opening original header
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+ std::string renameCommand = "mv \"" + pathHeader + ".tmp\" \"" + pathHeader + "\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
)
{
std::vector<std::string> words;
- CDMUtilities::splitter::split(words, categories, "\"", CDMUtilities::splitter::no_empties);
- std::string catsReal = words[0];
- for (int i = 1; i < words.size(); i++)
- {
- catsReal += "-" + words[i];
- }
-
- //opening original header
- std::string pathHeader = this->header->GetPath();
- std::ifstream in(pathHeader.c_str());
- if( !in.is_open())
- {
- result = new std::string(pathHeader + " file failed to open.");
- return false;
- }
- //opening temporal header
- std::ofstream out((pathHeader + ".tmp").c_str());
- if( !out.is_open())
- {
- result = new std::string(pathHeader + ".tmp file failed to open.");
- return false;
- }
- //copying contents from original to temporal and making changes
- std::string reading;
- while (getline(in, reading, '('))
- {
- CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
- if(words[words.size() - 1] == "BBTK_CATEGORY")
- {
- out << reading << "(\"" << catsReal << "\")";
- getline(in, reading, ')');
- }
- else
- {
- out << reading;
- if (!in.eof())
- out << "(";
- }
- }
- in.close();
- out.close();
- //delete old file and rename new file
- std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
- if(system(renameCommand.c_str()))
- {
- result = new std::string("An error occurred while running '" + renameCommand + "'.");
- return false;
- }
-
- this->categories = catsReal;
- return true;
+ CDMUtilities::splitter::split(words, categories, "\"\\/", CDMUtilities::splitter::no_empties);
+ std::string catsReal = words[0];
+ for (int i = 1; i < words.size(); i++)
+ {
+ catsReal += "," + words[i];
+ }
+
+ //opening original header
+ std::string pathHeader = this->header->GetPath();
+ std::ifstream in(pathHeader.c_str());
+ if( !in.is_open())
+ {
+ result = new std::string(pathHeader + " file failed to open.");
+ return false;
+ }
+ //opening temporal header
+ std::ofstream out((pathHeader + ".tmp").c_str());
+ if( !out.is_open())
+ {
+ result = new std::string(pathHeader + ".tmp file failed to open.");
+ return false;
+ }
+ //copying contents from original to temporal and making changes
+ std::string reading;
+ while (getline(in, reading, '('))
+ {
+ CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
+ if(words[words.size() - 1] == "BBTK_CATEGORY")
+ {
+ out << reading << "(\"" << catsReal << "\")";
+ getline(in, reading, ')');
+ }
+ else
+ {
+ out << reading;
+ if (!in.eof())
+ out << "(";
+ }
+ }
+ in.close();
+ out.close();
+ //delete old file and rename new file
+ std::string renameCommand = "mv \"" + pathHeader + ".tmp\" \"" + pathHeader + "\"";
+ if(system(renameCommand.c_str()))
+ {
+ result = new std::string("An error occurred while running '" + renameCommand + "'.");
+ return false;
+ }
+
+ this->categories = catsReal;
+ return true;
}
bool modelCDMBlackBox::SetDescription(
)
{
std::vector<std::string> words;
- CDMUtilities::splitter::split(words, description, "\"", CDMUtilities::splitter::no_empties);
+ CDMUtilities::splitter::split(words, description, "\"\n\\/", CDMUtilities::splitter::no_empties);
std::string descReal = words[0];
for (int i = 1; i < words.size(); i++)
{
- descReal += "\\\"" + words[i];
+ descReal += "-" + words[i];
}
//opening original header
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+ std::string renameCommand = "mv \"" + pathHeader + ".tmp\" \"" + pathHeader + "\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
const bool modelCDMBlackBox::Refresh(std::string*& result)
{
- //TODO: implement method
+ std::string pathHeader = path + CDMUtilities::SLASH + "bb" + this->name + ".h";
+
+ std::ifstream confFile;
+ confFile.open((pathHeader).c_str());
+ std::string word;
+
+ if(!confFile.is_open())
+ return false;
+
+ while(confFile.is_open() && !confFile.eof())
+ {
+ //get BBTK's
+ std::getline(confFile,word,'(');
+ std::vector<std::string> wordBits;
+ CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
+
+ if(wordBits[wordBits.size()-1] == "BBTK_NAME")
+ {
+ std::getline(confFile,word,'"');
+ std::getline(confFile,word,'"');
+ this->nameBlackBox = word;
+ }
+ else if(wordBits[wordBits.size()-1] == "BBTK_AUTHOR")
+ {
+ std::getline(confFile,word,'"');
+ std::getline(confFile,word,'"');
+ this->authors = word;
+ }
+ else if(wordBits[wordBits.size()-1] == "BBTK_DESCRIPTION")
+ {
+ std::getline(confFile,word,'"');
+ std::getline(confFile,word,'"');
+ this->description = word;
+ }
+ else if(wordBits[wordBits.size()-1] == "BBTK_CATEGORY")
+ {
+ std::getline(confFile,word,'"');
+ std::getline(confFile,word,'"');
+ this->categories = word;
+ if (this->categories == "")
+ this->categories = "empty";
+ }
+ }
+ confFile.close();
return true;
}
{
public:
modelCDMBlackBox();
- modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level = 1);
+ modelCDMBlackBox(const std::string& path, const std::string& name, const int& level = 1);
~modelCDMBlackBox();
const std::string& GetNameBlackBox() const;
#include "modelCDMCMakeListsFile.h"
+#include <fstream>
+
#include<creaWx.h>
#include<wx/dir.h>
{
}
-modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path,
- const int& level)
+modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path, const std::string& name, const int& level)
{
this->children.clear();
this->level = level;
this->type = wxDIR_FILES;
- this->name = "CMakeFileLists.txt";
+ this->name = name;
this->path = path;
+
+ std::ifstream in(path.c_str(), std::ifstream::in | std::ifstream::binary);
+ in.seekg(0, std::ifstream::end);
+ this->length = in.tellg();
+ in.close();
}
modelCDMCMakeListsFile::~modelCDMCMakeListsFile()
const bool modelCDMCMakeListsFile::Refresh(std::string*& result)
{
- //TODO: implement method
+ std::ifstream in((this->path).c_str());
+ if(!in.is_open())
+ {
+ in.close();
+ return false;
+ }
+ std::ifstream in2(path.c_str(), std::ifstream::in | std::ifstream::binary);
+ in2.seekg(0, std::ifstream::end);
+ this->length = in2.tellg();
+ in2.close();
return true;
}
{
public:
modelCDMCMakeListsFile();
- modelCDMCMakeListsFile(const std::string& path, const int& level = 1);
+ modelCDMCMakeListsFile(const std::string& path, const std::string& name = "CMakeLists.txt", const int& level = 1);
~modelCDMCMakeListsFile();
bool OpenFile(std::string*& result);
{
}
-modelCDMFile::modelCDMFile(const std::string& path, const int& level)
+modelCDMFile::modelCDMFile(const std::string& path, const std::string& name, const int& level)
{
this->children.clear();
this->level = level;
-
- std::vector<std::string> words;
- std::string delimiters;
- //TODO::fix for windows
- delimiters = "/";
- CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
- this->name = words[words.size()-1];
-
+ this->name = name;
this->path = path;
this->type = wxDIR_FILES;
std::ifstream in(path.c_str(), std::ifstream::in | std::ifstream::binary);
in.seekg(0, std::ifstream::end);
this->length = in.tellg();
+ in.close();
}
in.close();
return false;
}
+ std::ifstream in2(path.c_str(), std::ifstream::in | std::ifstream::binary);
+ in2.seekg(0, std::ifstream::end);
+ this->length = in2.tellg();
+ in2.close();
return true;
}
{
public:
modelCDMFile();
- modelCDMFile(const std::string& path, const int& level = 3);
+ modelCDMFile(const std::string& path, const std::string& name, const int& level = 3);
~modelCDMFile();
bool OpenFile(std::string* & result, const std::string& command = "");
this->CMakeLists = NULL;
}
-modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
+modelCDMFolder::modelCDMFolder(const std::string& path, const std::string& name, const int& level)
{
//set attributes
this->children.clear();
this->level = level;
this->CMakeLists = NULL;
this->length = 0;
-
- std::vector<std::string> words;
- std::string delimiters;
- //TODO::fix for windows
- delimiters = "/";
- CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
- this->name = words[words.size()-1];
-
+ this->name = name;
this->path = path;
this->type = wxDIR_DIRS;
std::string stdfileName = crea::wx2std(fileName);
//if is an unknown folder, create folder
- this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
cont = dir.GetNext(&fileName);
}
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
{
- this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
//if is an unknown file, create file
cont = dir.GetNext(&fileName);
modelCDMFolder* modelCDMFolder::CreateFolder(const std::string& name, std::string*& result)
{
//TODO:: mkdir depending on OS
- std::string command = "mkdir " + path + "/" + name;
+ std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\"";
if(system(command.c_str()))
{
result = new std::string("Error executing: " + command + ".");
return NULL;
}
- modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
return false;
}
}
+
//if is an unknown file, create file
else
{
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
{
public:
modelCDMFolder();
- modelCDMFolder(const std::string& path, const int& level = 3);
+ modelCDMFolder(const std::string& path, const std::string& name, const int& level = 3);
~modelCDMFolder();
modelCDMCMakeListsFile* GetCMakeLists() const;
{
}
-modelCDMLib::modelCDMLib(const std::string& path, const int& level)
+modelCDMLib::modelCDMLib(const std::string& path, const std::string& name, const int& level)
{
this->type = wxDIR_DIRS;
- this->name = "lib";
+ this->name = name;
this->level = level;
this->path = path;
{
std::string stdfileName = crea::wx2std(fileName);
- modelCDMLibrary* library = new modelCDMLibrary(pathFixed + "/" + stdfileName, this->level + 1);
+ modelCDMLibrary* library = new modelCDMLibrary(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->libraries.push_back(library);
this->children.push_back(library);
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
//if is an unknown file, create file
else
{
- this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
cont = dir.GetNext(&fileName);
modelCDMLibrary* modelCDMLib::CreateLibrary(
const std::string& name,
- std::string*& result,
- const std::string& path
+ std::string*& result
)
{
//copy template library folder with new name
- //TODO: fix for windows
- std::string copyCommand = "cp -r " + this->path + "/template_lib " + this->path + "/" + name;
+ std::string copyCommand = "cp -r \"" + this->path + CDMUtilities::SLASH + "template_lib\" \"" + this->path + CDMUtilities::SLASH + name + "\"";
if(system(copyCommand.c_str()))
{
result = new std::string("An error occurred while running '" + copyCommand + "'.");
}
//set name of library in CMakeLists inside copied folder
std::string line;
- std::ifstream in((this->path + "/" + name + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return NULL;
}
- std::ofstream out((this->path + "/" + name + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
while (getline(in, line))
{
if(line == "SET ( LIBRARY_NAME MyLib )")
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/" + name + "/CMakeLists.txt.tmp " + this->path + "/" + name + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
}
//add library to model
- //TODO: fix for windows
- modelCDMLibrary* library = new modelCDMLibrary(this->path + "/" + name, this->level + 1);
+ modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->libraries.push_back(library);
this->children.push_back(library);
this->SortChildren();
- result = new std::string(this->path + "/" + name);
+ result = new std::string(this->path + CDMUtilities::SLASH + name);
return library;
}
{
std::cout << "refreshing lib" << std::endl;
this->type = wxDIR_DIRS;
- this->name = "lib";
- this->level = level;
- this->path = path;
}
if(!found)
{
- modelCDMLibrary* library = new modelCDMLibrary(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->libraries.push_back(library);
this->children.push_back(library);
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
{
public:
modelCDMLib();
- modelCDMLib(const std::string& path, const int& level = 1);
+ modelCDMLib(const std::string& path, const std::string& name = "lib", const int& level = 1);
~modelCDMLib();
const std::vector<modelCDMLibrary*>& GetLibraries() const;
modelCDMLibrary* CreateLibrary(
const std::string& name,
- std::string*& result,
- const std::string& path = "/"
+ std::string*& result
);
virtual const bool Refresh(std::string*& result);
{
}
-modelCDMLibrary::modelCDMLibrary(const std::string& path, const int& level)
+modelCDMLibrary::modelCDMLibrary(const std::string& path, const std::string& name, const int& level)
{
//folder name
- std::vector<std::string> words;
- std::string delimiters;
- //TODO::fix for windows
- delimiters = "/";
- CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
- this->name = words[words.size()-1];
-
+ this->name = name;
//path
this->path = CDMUtilities::fixPath(path);
//type
this->level = level;
//open CMakeList
- std::string pathMakeLists = path + "/CMakeLists.txt";
+ std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
{
std::string stdfileName = crea::wx2std(fileName);
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->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 is an unknown file, create file
else
{
- this->children.push_back(new modelCDMFile(this->path + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
cont = dir.GetNext(&fileName);
std::string line;
//opening original cmakelists
- std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return false;
}
//opening temporal cmakelists
- std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
if( !out.is_open())
{
result = new std::string("CMakeLists.txt.tmp file failed to open.");
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
modelCDMFolder* modelCDMLibrary::CreateFolder(const std::string& name, std::string*& result)
{
//TODO:: mkdir depending on OS
- std::string command = "mkdir " + path + "/" + name;
+ std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\"";
if(system(command.c_str()))
{
result = new std::string("Error executing: " + command + ".");
return NULL;
}
- modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
this->type = wxDIR_DIRS;
//open CMakeList
- std::string pathMakeLists = path + "/CMakeLists.txt";
+ std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->folders.push_back(folder);
this->children.push_back(folder);
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
{
public:
modelCDMLibrary();
- modelCDMLibrary(const std::string& path, const int& level=2);
+ modelCDMLibrary(const std::string& path, const std::string& name, const int& level = 2);
~modelCDMLibrary();
const std::string& GetNameLibrary() const;
std::string command2("del ");
command += "\"" + locationFixed + "\" \"" + name + "\"";
- command1 += "\"" + locationFixed +"\\"+name+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + locationFixed + "\\" + name + "\\CMakeLists.txt\"";
- command2 += "\"" + locationFixed +"\\"+name+"\\CMakeLists.txt.in\"";
+ command1 += "\"" + locationFixed +CDMUtilities::SLASH+name+CDMUtilities::SLASH+"CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + locationFixed + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
+ command2 += "\"" + locationFixed +CDMUtilities::SLASH+name+CDMUtilities::SLASH+"CMakeLists.txt.in\"";
if (system (command.c_str()))
system ( command2.c_str() );
char *author = author.c_str();
- std::string nomDirectory = locationFixed + "\\" + name;
- std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + name + "_PKG";
+ std::string nomDirectory = locationFixed + CDMUtilities::SLASH + name;
+ std::string nomPackageDirectory = nomDirectory + CDMUtilities::SLASH + "bbtk_" + name + "_PKG";
std::string bbCreatePackage("bbCreatePackage ");
- bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description;
+ bbCreatePackage += "\"" + nomDirectory + "\" \"" + name + "\" \"" + author + "\" \"" + description + "\"";
system (bbCreatePackage.c_str());
std::string add;
- add = "echo ADD_SUBDIRECTORY(bbtk_" + name + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
+ add = "echo ADD_SUBDIRECTORY(bbtk_" + name + "_PKG) >> \"" + nomDirectory + CDMUtilities::SLASH + "CMakeLists.txt\"";
system(add.c_str());
- this->project = new modelCDMProject(nomDirectory);
+ this->project = new modelCDMProject(nomDirectory, name);
#else
// ------ LINUX / MacOS
std::string command("creaNewProject.sh ");
- command += "\"" + locationFixed + "\"" +" " + name;
+ command += "\"" + locationFixed + "\"" +" \"" + name + "\"";
//std::cout << "executing " << command << std::endl;
if (system ( command.c_str() ) )
{
return false;
}
- std::string nomDirectory = locationFixed + "/" + name;
- std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + name + "_PKG";
+ std::string nomDirectory = locationFixed + CDMUtilities::SLASH + name;
+ std::string nomPackageDirectory = nomDirectory + CDMUtilities::SLASH + "bbtk_" + name + "_PKG";
std::string bbCreatePackage("bbCreatePackage ");
- bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description;
+ bbCreatePackage += "\"" + nomDirectory + "\" \"" + name + "\" \"" + author + "\" \"" + description + "\"";
//std::cout << "executing " << bbCreatePackage << std::endl;
system (bbCreatePackage.c_str());
std::string add;
- add = "echo 'ADD_SUBDIRECTORY(bbtk_" + name + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
+ add = "echo 'ADD_SUBDIRECTORY(bbtk_" + name + "_PKG)' >> \"" + nomDirectory + CDMUtilities::SLASH + "CMakeLists.txt\"";
//std::cout << "executing " << add << std::endl;
system(add.c_str());
return false;
}
- this->project = new modelCDMProject(nomDirectory);
+ this->project = new modelCDMProject(nomDirectory, name);
#endif
std::string pathBuild = "";
//check if Makefile file exists
- std::string pathMakefile = pathFixed + "/Makefile";
+ std::string pathMakefile = pathFixed + CDMUtilities::SLASH + "Makefile";
FILE* pFile = fopen(pathMakefile.c_str(), "r");
//is the binary folder
bool isSource = false;
std::string pathSource = "";
//check if CMakeLists file exists
- std::string pathCMakeLists = pathFixed + "/CMakeLists.txt";
+ std::string pathCMakeLists = pathFixed + CDMUtilities::SLASH + "CMakeLists.txt";
pFile = fopen(pathCMakeLists.c_str(), "r");
//is the source folder
if (!CloseProject(result))
return false;
}
+ std::vector<std::string> words;
+ CDMUtilities::splitter::split(words, pathSource, CDMUtilities::SLASH, CDMUtilities::splitter::no_empties);
std::cout << "Project sources at: " << pathSource << std::endl;
if(isBinary)
{
std::cout << ", and built in: " << pathBuild << std::endl;
- this->project = new modelCDMProject(pathSource, pathBuild);
+
+ this->project = new modelCDMProject(pathSource, words[words.size()-1], pathBuild);
}
else
{
- this->project = new modelCDMProject(pathSource);
+ this->project = new modelCDMProject(pathSource, words[words.size()-1]);
}
}
else
this->src = NULL;
}
-modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
+modelCDMPackage::modelCDMPackage(const std::string& path, const std::string& name, const int& level)
{
this->type = wxDIR_DIRS;
+ this->name = name;
//Get Package Name
- //TODO: set pathMakeLists for windows
- std::string pathMakeLists = path + "/CMakeLists.txt";
+ std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
}
}
- std::vector<std::string> words;
- std::string delimiters;
- //TODO::fix for windows
- delimiters = "/";
- CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
- this->name = words[words.size()-1];
this->level = level;
this->path = path;
//if src, check for black boxes
if(stdfileName == "src")
{
- this->src = new modelCDMPackageSrc(path + delimiters + "src", this->level + 1);
+ this->src = new modelCDMPackageSrc(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->src);
- /*wxDir srcF(crea::std2wx((path + delimiters + "src").c_str()));
- if (srcF.IsOpened())
- {
- wxString srcName;
- bool innerCont = srcF.GetFirst(&srcName, wxT("*.h"), wxDIR_FILES);
- while (innerCont)
- {
- if(crea::wx2std(srcName.substr(0,2)) == "bb")
- {
- modelCDMBlackBox* blackbox = new modelCDMBlackBox(crea::wx2std(srcName), path + delimiters + "src", this->level + 1);
- this->blackBoxes.push_back(blackbox);
- this->children.push_back(blackbox);
- }
- innerCont = srcF.GetNext(&srcName);
- }
- }*/
}
else
{
- this->children.push_back(new modelCDMFolder(path + delimiters + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFolder(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
cont = dir.GetNext(&fileName);
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(path + delimiters + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
{
- this->children.push_back(new modelCDMFile(path + delimiters + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
//if is an unknown file, create file
cont = dir.GetNext(&fileName);
std::string line;
//opening original cmakelists
- std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return false;
}
//opening temporal cmakelists
- std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
if( !out.is_open())
{
result = new std::string("CMakeLists.txt.tmp file failed to open.");
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
std::string line;
//opening original cmakelists
- std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return false;
}
//opening temporal cmakelists
- std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
if( !out.is_open())
{
result = new std::string("CMakeLists.txt.tmp file failed to open.");
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
std::string line;
//opening original cmakelists
- std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return false;
}
//opening temporal cmakelists
- std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
if( !out.is_open())
{
result = new std::string("CMakeLists.txt.tmp file failed to open.");
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
return true;
}
-bool modelCDMPackage::CreateBlackBox(
+modelCDMBlackBox* modelCDMPackage::CreateBlackBox(
const std::string& name,
+ const std::string& type,
+ const std::string& format,
const std::string& authors,
const std::string& authorsEmail,
const std::string& categories,
)
{
//TODO: implement method
- return true;
+ return NULL;
}
const bool modelCDMPackage::Refresh(std::string*& result)
{
std::cout << "refreshing package" << std::endl;
this->type = wxDIR_DIRS;
- this->name = name;
- this->level = level;
- this->path = path;
//Get Package Name
- //TODO: set pathMakeLists for windows
- std::string pathMakeLists = path + "/CMakeLists.txt";
+ std::string pathMakeLists = path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
}
else
{
- this->src = new modelCDMPackageSrc(path + "/" + "src", this->level +1);
+ this->src = new modelCDMPackageSrc(path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level +1);
this->children.push_back(this->src);
}
- /*wxDir srcF(crea::std2wx((path + "/" + "src").c_str()));
- if (srcF.IsOpened())
- {
- wxString srcName;
- bool innerCont = srcF.GetFirst(&srcName, wxT("*.h"), wxDIR_FILES);
- while (innerCont)
- {
- std::string blackBoxName = crea::wx2std(srcName);
- if(crea::wx2std(srcName.substr(0,2)) == "bb")
- {
- //check if box already exist
- bool found = false;
- for (int i = 0;!found && i < this->blackBoxes.size(); i++)
- {
- if (this->blackBoxes[i]->GetName() == blackBoxName)
- {
- found = true;
- int pos = std::find(this->children.begin(), this->children.end(), this->blackBoxes[i]) - this->children.begin();
- checked[pos] = true;
- checkedBlackBoxes[i] = true;
- if(!this->blackBoxes[i]->Refresh(result))
- return false;
- }
- }
- if(!found)
- {
- modelCDMBlackBox* blackBox = new modelCDMBlackBox(blackBoxName, path + "/" + "src", this->level +1);
- this->blackBoxes.push_back(blackBox);
- this->children.push_back(blackBox);
- }
- }
- innerCont = srcF.GetNext(&srcName);
- }
- }*/
-
}
else
{
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(folder);
}
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
{
public:
modelCDMPackage();
- modelCDMPackage(const std::string& path, const int& level = 1);
+ modelCDMPackage(const std::string& path, const std::string& name, const int& level = 1);
~modelCDMPackage();
const std::string& GetNamePackage() const;
bool SetDescription(const std::string& description, std::string*& result);
- bool CreateBlackBox(
+ modelCDMBlackBox* CreateBlackBox(
const std::string& name,
+ const std::string& type = "std",
+ const std::string& format = "C++",
const std::string& authors = "unknown",
const std::string& authorsEmail = "",
const std::string& categories = "empty",
this->CMakeLists = NULL;
}
-modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level)
+modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const std::string& name, const int& level)
{
//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(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(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(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(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(path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
this->children.push_back(file);
blackBox->SetSourceFile(file);
}
return this->blackBoxes;
}
+modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox(
+ const std::string& name,
+ const std::string& package,
+ const std::string& type,
+ const std::string& format,
+ const std::string& authors,
+ const std::string& authorsEmail,
+ const std::string& categories,
+ const std::string& description)
+{
+ //TODO: implement method
+ return NULL;
+}
+
const bool modelCDMPackageSrc::Refresh(std::string*& result)
{
//set attributes
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(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->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
if (!found)
{
- modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path + "/" + stdfileName, level + 1);
+ modelCDMBlackBox* blackBox = new modelCDMBlackBox(path, stdfileName.substr(2,stdfileName.size()-4), level + 1);
this->blackBoxes.push_back(blackBox);
}
{
public:
modelCDMPackageSrc();
- modelCDMPackageSrc(const std::string& path, const int& level = 3);
+ modelCDMPackageSrc(const std::string& path, const std::string& name = "src", const int& level = 3);
~modelCDMPackageSrc();
const std::vector<modelCDMBlackBox*>& GetBlackBoxes() const;
+ modelCDMBlackBox* CreateBlackBox(
+ const std::string& name,
+ const std::string& package,
+ const std::string& type = "std",
+ const std::string& format = "C++",
+ 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);
private:
modelCDMProject::modelCDMProject(
const std::string& path,
+ const std::string& name,
const std::string& buildPath
)
{
//open makelists file
std::string pathFixed(CDMUtilities::fixPath(path));
- //TODO: set pathMakeLists for windows
- std::string pathMakeLists = pathFixed + "/CMakeLists.txt";
+ std::string pathMakeLists = pathFixed + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
//if appli, create appli
if(stdfileName == "appli")
{
- this->appli = new modelCDMAppli(pathFixed + "/appli", this->level + 1);
+ this->appli = new modelCDMAppli(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->appli);
}
//if lib, create lib
else if(stdfileName == "lib")
{
- this->lib = new modelCDMLib(pathFixed + "/lib", this->level + 1);
+ this->lib = new modelCDMLib(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->lib);
}
//if package , create package
else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
{
- modelCDMPackage* package = new modelCDMPackage(pathFixed + "/" + stdfileName, this->level + 1);
+ modelCDMPackage* package = new modelCDMPackage(pathFixed + 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
{
- this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
cont = dir.GetNext(&fileName);
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
- this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
{
- this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+ this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
}
//if is an unknown file, create file
cont = dir.GetNext(&fileName);
tm* ltm = localtime(&now);
std::stringstream date;
- date << ltm->tm_mday << "/" << ltm->tm_mon << "/" << 1900 + ltm->tm_year;
+ date << ltm->tm_mday << "/" << 1 + ltm->tm_mon << "/" << 1900 + ltm->tm_year;
//set name of library in CMakeLists inside copied folder
std::string line;
- std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
if( !in.is_open())
{
result = new std::string("CMakeLists.txt file failed to open.");
return false;
}
- std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
if( !out.is_open())
{
result = new std::string("CMakeLists.txt.tmp file failed to open.");
in.close();
out.close();
//delete old file and rename new file
- std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
if(system(renameCommand.c_str()))
{
result = new std::string("An error occurred while running '" + renameCommand + "'.");
}
//call project to create package : use bbCreatePackage <path> <name> [author] [description]
- std::string creationCommand = "bbCreatePackage \"" + this->path + "\" " + nameFixed + " " + authorFixed + " " + descriptionFixed;
+ std::string creationCommand = "bbCreatePackage \"" + this->path + "\" \"" + nameFixed + "\" \"" + authorFixed + "\" \"" + descriptionFixed + "\"";
//TODO: bbCreatePackage script always returning 0. It should return 1 or greater if any error
if(system(creationCommand.c_str()))
{
}
//add library to model
- //TODO: fix for windows
- modelCDMPackage* package = new modelCDMPackage(this->path + "/bbtk_" + nameFixed + "_PKG", this->level + 1);
+ modelCDMPackage* package = new modelCDMPackage(this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
this->packages.push_back(package);
this->children.push_back(package);
this->SortChildren();
- result = new std::string(this->path + "/" + name);
+ result = new std::string(this->path + CDMUtilities::SLASH + name);
return package;
}
{
std::cout << "refreshing project" << std::endl;
//open makelists file
- //TODO: set pathMakeLists for windows
- std::string pathMakeLists = this->path + "/CMakeLists.txt";
+ std::string pathMakeLists = this->path + CDMUtilities::SLASH + "CMakeLists.txt";
std::ifstream confFile;
confFile.open((pathMakeLists).c_str());
{
if (this->appli == NULL)
{
- this->appli = new modelCDMAppli(this->path + "/appli", this->level + 1);
+ this->appli = new modelCDMAppli(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->appli);
}
else
{
if (this->lib == NULL)
{
- this->lib = new modelCDMLib(this->path + "/lib", this->level + 1);
+ this->lib = new modelCDMLib(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->lib);
}
else
}
if(!found)
{
- modelCDMPackage* package = new modelCDMPackage(this->path + "/" + 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);
}
if(!found)
{
- modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(folder);
}
}
{
if (this->CMakeLists == NULL)
{
- this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(this->CMakeLists);
}
else
if(!found)
{
- modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
this->children.push_back(file);
}
}
* @param path The source path.
* @param buildPath The build path. By default it's an empty string.
*/
- modelCDMProject(const std::string& path, const std::string& buildPath = "");
+ modelCDMProject(const std::string& path, const std::string& name, const std::string& buildPath = "");
/**
* Destructor.
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+# pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+# This software is governed by the CeCILL-B license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL-B
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+# or in the file LICENSE.txt.
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+
+/*
+ * wxCDMNewBlackBoxDialog.cpp
+ *
+ * Created on: 26/12/2012
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "wxCDMNewBlackBoxDialog.h"
+
+#include "creaDevManagerIds.h"
+
+BEGIN_EVENT_TABLE(wxCDMNewBlackBoxDialog, wxDialog)
+EVT_BUTTON(ID_BUTTON_NEXT, wxCDMNewBlackBoxDialog::OnCreateBlackBox)
+EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMNewBlackBoxDialog::OnCancel)
+END_EVENT_TABLE()
+
+wxCDMNewBlackBoxDialog::wxCDMNewBlackBoxDialog(
+ wxWindow* parent,
+ wxWindowID id,
+ const wxString& caption,
+ const wxPoint& position,
+ const wxSize& size,
+ long style
+)
+{
+ wxCDMNewBlackBoxDialog::Create(parent, id, caption, position, size, style);
+}
+
+wxCDMNewBlackBoxDialog::~wxCDMNewBlackBoxDialog()
+{
+}
+
+bool wxCDMNewBlackBoxDialog::Create(
+ wxWindow* parent,
+ wxWindowID id,
+ const wxString& caption,
+ const wxPoint& position,
+ const wxSize& size,
+ long int style
+)
+{
+ wxDialog::Create(parent, id, caption, position, size, style);
+
+ this->CreateControls();
+
+ return TRUE;
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxName() const
+{
+ return this->blackBoxName->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxAuthor() const
+{
+ return this->blackBoxAuthor->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxAuthorEmail() const
+{
+ return this->blackBoxAuthorEmail->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxDescription() const
+{
+ return this->blackBoxDescription->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxCategories() const
+{
+ return this->blackBoxCategories->GetValue();
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxType() const
+{
+ return this->blackBoxType->GetString(this->blackBoxType->GetCurrentSelection());
+}
+
+const wxString wxCDMNewBlackBoxDialog::GetBlackBoxFormat() const
+{
+ return this->blackBoxFormat->GetString(this->blackBoxFormat->GetCurrentSelection());
+}
+
+void wxCDMNewBlackBoxDialog::CreateControls()
+{
+ wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
+
+
+ wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Create a new black box"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+ v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+ wxStaticText* instruction = new wxStaticText(this, wxID_ANY, wxT("Please fill the following details."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+ v_sizer1->Add(instruction, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+ wxFlexGridSizer* formItems = new wxFlexGridSizer(4,2,9,15);
+
+ wxStaticText *stxtPrjName = new wxStaticText(this, -1, wxT("Black Box Name"));
+ wxStaticText *stxtPrjAuth = new wxStaticText(this, -1, wxT("Black Box Authors (separated by ',')"));
+ wxStaticText *stxtPrjAuthEmail = new wxStaticText(this, -1, wxT("Black Box Authors' Email"));
+ wxStaticText *stxtPrjDsc = new wxStaticText(this, -1, wxT("Black Box Description"));
+ wxStaticText *stxtPrjCat = new wxStaticText(this, -1, wxT("Black Box Categories (separated by ',')"));
+ wxStaticText *stxtPrjTyp = new wxStaticText(this, -1, wxT("Black Box Type"));
+ wxStaticText *stxtPrjFmt = new wxStaticText(this, -1, wxT("Black Box Format"));
+
+ this->blackBoxName = new wxTextCtrl(this, -1);
+ this->blackBoxAuthor = new wxTextCtrl(this, -1);
+ this->blackBoxAuthorEmail = new wxTextCtrl(this, -1);
+ this->blackBoxDescription = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
+ this->blackBoxCategories = new wxTextCtrl(this, -1);
+ wxString BBTypes[] =
+ {
+ wxT("std"),
+ wxT("VTK-ImageAlgorithm"),
+ wxT("VTK-PolyAlgorithm"),
+ wxT("widget")
+ };
+ this->blackBoxType = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, BBTypes);
+
+ wxString BBFormats[] =
+ {
+ wxT("C++"),
+ wxT("XML")
+ };
+ this->blackBoxFormat = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 2, BBFormats);
+
+ formItems->Add(stxtPrjName, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxName, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtPrjAuth, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxAuthor, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtPrjAuthEmail, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxAuthorEmail, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtPrjDsc, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxDescription, 1, wxEXPAND);
+ formItems->Add(stxtPrjCat,0 , wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxCategories, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtPrjTyp, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxType, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtPrjFmt, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->blackBoxFormat, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+
+ formItems->AddGrowableCol(1,1);
+ formItems->AddGrowableRow(3,1);
+
+ v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
+
+ wxBoxSizer* h_sizer2 = new wxBoxSizer(wxHORIZONTAL);
+ h_sizer2->Add(new wxButton(this, ID_BUTTON_NEXT, wxT("Create Black Box")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+ h_sizer2->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Cancel")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+ v_sizer1->Add(h_sizer2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
+
+ SetSizer(v_sizer1);
+}
+
+void wxCDMNewBlackBoxDialog::OnCreateBlackBox(wxCommandEvent& event)
+{
+ bool ready = true;
+
+ if(ready && this->blackBoxName->GetValue() == wxT(""))
+ {
+ wxMessageBox(wxT("The black box name cannot be empty"),_T("Error"),wxOK | wxICON_ERROR);
+ ready = false;
+ }
+ if(ready && this->blackBoxAuthor->GetValue() == wxT(""))
+ {
+ wxMessageBox(wxT("The black box author has to be specified"),_T("Error"),wxOK | wxICON_ERROR);
+ ready = false;
+ }
+
+ if(ready)
+ {
+ this->EndModal(wxID_FORWARD);
+ }
+ event.Skip();
+}
+
+void wxCDMNewBlackBoxDialog::OnCancel(wxCommandEvent& event)
+{
+ this->EndModal(wxID_CANCEL);
+ event.Skip();
+}
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+# pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+# This software is governed by the CeCILL-B license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL-B
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+# or in the file LICENSE.txt.
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+*/
+
+
+/*
+ * wxCDMNewBlackBoxDialog.h
+ *
+ * Created on: 26/12/2012
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef WXCDMNEWBLACKBOXDIALOG_H_
+#define WXCDMNEWBLACKBOXDIALOG_H_
+
+#include <creaWx.h>
+#include <wx/dialog.h>
+#include <wx/choice.h>
+
+class wxCDMNewBlackBoxDialog : public wxDialog
+{
+ DECLARE_EVENT_TABLE()
+public:
+ wxCDMNewBlackBoxDialog(
+ wxWindow* parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& caption = wxT("New Black Box"),
+ const wxPoint& position = wxDefaultPosition,
+ const wxSize& size = wxSize(500,500),
+ long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
+ );
+ ~wxCDMNewBlackBoxDialog();
+ bool Create(
+ wxWindow* parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& caption = wxT("New Black Box"),
+ const wxPoint& position = wxDefaultPosition,
+ const wxSize& size = wxSize(500,500),
+ long style = wxDEFAULT_DIALOG_STYLE
+ );
+
+ const wxString GetBlackBoxName() const;
+ const wxString GetBlackBoxAuthor() const;
+ const wxString GetBlackBoxAuthorEmail() const;
+ const wxString GetBlackBoxDescription() const ;
+ const wxString GetBlackBoxCategories() const ;
+ const wxString GetBlackBoxType() const;
+ const wxString GetBlackBoxFormat() const;
+
+protected:
+ void CreateControls();
+
+private:
+ wxTextCtrl* blackBoxName;
+ wxTextCtrl* blackBoxAuthor;
+ wxTextCtrl* blackBoxAuthorEmail;
+ wxTextCtrl* blackBoxDescription;
+ wxTextCtrl* blackBoxCategories;
+ wxChoice* blackBoxType;
+ wxChoice* blackBoxFormat;
+
+//handlers
+protected:
+ void OnCreateBlackBox(wxCommandEvent& event);
+ void OnCancel(wxCommandEvent& event);
+};
+
+#endif /* WXCDMNEWBLACKBOXDIALOG_H_ */