#define ID_BUTTON_SET_AUTHOR 10320
#define ID_BUTTON_SET_DESCRIPTION 10321
#define ID_BUTTON_SET_NAME 10322
+#define ID_BUTTON_SET_CATEGORY 10323
-#define ID_BUTTON_BUILD_PROJECT 10323
-#define ID_BUTTON_CONFIGURE_BUILD 10324
-#define ID_BUTTON_CONNECT_PROJECT 10325
+#define ID_BUTTON_BUILD_PROJECT 10324
+#define ID_BUTTON_CONFIGURE_BUILD 10325
+#define ID_BUTTON_CONNECT_PROJECT 10326
-#define ID_BUTTON_GOTO_PACKAGE_MANAGER 10326
-#define ID_BUTTON_GOTO_APPLI_MANAGER 10327
-#define ID_BUTTON_GOTO_LIB_MANAGER 10328
+#define ID_BUTTON_GOTO_PACKAGE_MANAGER 10327
+#define ID_BUTTON_GOTO_APPLI_MANAGER 10328
+#define ID_BUTTON_GOTO_LIB_MANAGER 10329
-#define ID_LINK_SELECT_PACKAGE 10329
-#define ID_LINK_SELECT_LIBRARY 10330
-#define ID_LINK_SELECT_APPLICATION 10331
-#define ID_LINK_SELECT_BLACKBOX 10332
+#define ID_LINK_SELECT_PACKAGE 10330
+#define ID_LINK_SELECT_LIBRARY 10331
+#define ID_LINK_SELECT_APPLICATION 10332
+#define ID_LINK_SELECT_BLACKBOX 10333
#endif /* CREADEVMANAGERIDS_H_ */
cont = dir.GetNext(&fileName);
}
+ //files
+ cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if CMakeLists, create CMakeLists
+ if(stdfileName == "CMakeLists.txt")
+ {
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + 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));
+ }
+
+ cont = dir.GetNext(&fileName);
+ }
}
this->SortChildren();
#include "modelCDMBlackBox.h"
+#include<fstream>
+
+#include "CDMUtilities.h"
+
#include<creaWx.h>
#include"wx/dir.h"
modelCDMBlackBox::modelCDMBlackBox()
{
+ this->source = NULL;
+ this->header = NULL;
}
modelCDMBlackBox::modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level)
{
- this->name = this->nameBlackBox = hName.substr(2, hName.size()-4);
+ this->name = hName.substr(2, hName.size()-4);
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::ifstream confFile;
+ confFile.open((pathHeader).c_str());
+ std::string word;
+ 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();
+
}
modelCDMBlackBox::~modelCDMBlackBox()
return this->authors;
}
-const std::string& modelCDMBlackBox::GetAuthorsEmail() const
-{
- return this->authorsEmail;
-}
-
const std::string& modelCDMBlackBox::GetCategories() const
{
return this->categories;
return this->description;
}
-const std::string& modelCDMBlackBox::GetVersion() const
-{
- return this->version;
-}
-
bool modelCDMBlackBox::SetAuthors(const std::string& authors, std::string*& result)
{
- //TODO: implement method
- return true;
-}
+ std::vector<std::string> words;
+ 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];
+ }
-bool modelCDMBlackBox::SetAuthorsEmail(
- const std::string& email,
- std::string*& result
-)
-{
- //TODO: implement method
+ //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_AUTHOR")
+ {
+ out << reading << "(\"" << authorsReal << "\")";
+ 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->authors = authorsReal;
return true;
+
}
bool modelCDMBlackBox::SetCategories(
- const std::string& version,
+ const std::string& categories,
std::string*& result
)
{
- //TODO: implement method
- return true;
+ 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;
}
bool modelCDMBlackBox::SetDescription(
std::string*& result
)
{
- //TODO: implement method
+ std::vector<std::string> words;
+ CDMUtilities::splitter::split(words, description, "\"", CDMUtilities::splitter::no_empties);
+ std::string descReal = words[0];
+ for (int i = 1; i < words.size(); i++)
+ {
+ descReal += "\\\"" + 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_DESCRIPTION")
+ {
+ out << reading << "(\"" << descReal << "\")";
+ 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->description = descReal;
return true;
}
-bool modelCDMBlackBox::SetVersion(const std::string& version, std::string*& result)
+void modelCDMBlackBox::SetHeaderFile(modelCDMFile* file)
{
- //TODO: implement method
- return true;
+ this->header = file;
+}
+
+void modelCDMBlackBox::SetSourceFile(modelCDMFile* file)
+{
+ this->source = file;
}
bool modelCDMBlackBox::OpenCxx(std::string*& result)
{
- //TODO: implement method
- return true;
+ return !CDMUtilities::openTextEditor(this->source->GetPath());
}
bool modelCDMBlackBox::OpenHxx(std::string*& result)
{
- //TODO: implement method
- return true;
+ return !CDMUtilities::openTextEditor(this->header->GetPath());
+}
+
+modelCDMFile* modelCDMBlackBox::GetHeaderFile() const
+{
+ return this->header;
+}
+
+modelCDMFile* modelCDMBlackBox::GetSourceFile() const
+{
+ return this->source;
}
const bool modelCDMBlackBox::Refresh(std::string*& result)
const std::string& GetNameBlackBox() const;
const std::string& GetAuthors() const;
- const std::string& GetAuthorsEmail() const;
const std::string& GetCategories() const;
- const std::string& GetVersion() const;
const std::string& GetDescription() const;
+ modelCDMFile* GetHeaderFile() const;
+ modelCDMFile* GetSourceFile() const;
+
+ bool SetNameBlackBox(const std::string& name, std::string*& result);
bool SetAuthors(const std::string& authors, std::string*& result);
- bool SetAuthorsEmail(const std::string& email, std::string*& result);
bool SetCategories(const std::string& version, std::string*& result);
- bool SetVersion(const std::string& version, std::string*& result);
bool SetDescription(const std::string& description, std::string*& result);
+ void SetHeaderFile(modelCDMFile* file);
+ void SetSourceFile(modelCDMFile* file);
+
bool OpenCxx(std::string*& result);
bool OpenHxx(std::string*& result);
private:
std::string nameBlackBox;
std::string authors;
- std::string authorsEmail;
std::string categories;
std::string description;
- std::string version;
+
+ modelCDMFile* header;
+ modelCDMFile* source;
};
#endif /* MODELCDMBLACKBOX_H_ */
modelCDMPackage::modelCDMPackage()
{
+ this->src = NULL;
}
modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
//if src, check for black boxes
if(stdfileName == "src")
{
- wxDir srcF(crea::std2wx((path + delimiters + "src").c_str()));
+ this->src = new modelCDMPackageSrc(path + delimiters + "src", this->level + 1);
+ this->children.push_back(this->src);
+ /*wxDir srcF(crea::std2wx((path + delimiters + "src").c_str()));
if (srcF.IsOpened())
{
wxString srcName;
}
innerCont = srcF.GetNext(&srcName);
}
- }
+ }*/
}
- //if is an unknown folder, create folder
else
{
this->children.push_back(new modelCDMFolder(path + delimiters + stdfileName, this->level + 1));
}
+
cont = dir.GetNext(&fileName);
}
return this->description;
}
-const std::vector<modelCDMBlackBox*>& modelCDMPackage::GetBlackBoxes() const
+modelCDMPackageSrc* modelCDMPackage::GetSrc() const
{
- return this->blackBoxes;
+ return this->src;
}
bool modelCDMPackage::SetAuthors(const std::string& authors, std::string*& result)
std::vector<bool> checked(this->children.size(), false);
- std::vector<bool> checkedBlackBoxes(this->blackBoxes.size(), false);
+ bool checkedSrc = false;
//check all folders
wxDir dir(crea::std2wx((this->path).c_str()));
std::string stdfileName = crea::wx2std(fileName);
-
+ //detect black boxes in src
if(stdfileName == "src")
{
- wxDir srcF(crea::std2wx((path + "/" + "src").c_str()));
+ //check if box already exist
+ bool found = false;
+ if (this->src != NULL)
+ {
+ found = true;
+ int pos = std::find(this->children.begin(), this->children.end(), this->src) - this->children.begin();
+ checked[pos] = true;
+ checkedSrc = true;
+ if(!this->src->Refresh(result))
+ return false;
+ }
+ else
+ {
+ this->src = new modelCDMPackageSrc(path + "/" + "src", this->level +1);
+ this->children.push_back(this->src);
+ }
+ /*wxDir srcF(crea::std2wx((path + "/" + "src").c_str()));
if (srcF.IsOpened())
{
wxString srcName;
}
innerCont = srcF.GetNext(&srcName);
}
- }
+ }*/
}
- //if not src
else
{
- //check if they already exist
+
+ //check if folder already exist
bool found = false;
for (int i = 0;!found && i < this->children.size(); i++)
{
modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
this->children.push_back(folder);
}
- cont = dir.GetNext(&fileName);
}
+ cont = dir.GetNext(&fileName);
+
}
cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
}
}
- for (int i = 0; i < checkedBlackBoxes.size(); i++)
+ if(!checkedSrc)
{
- if(!checkedBlackBoxes[i])
- {
- this->blackBoxes.erase(this->blackBoxes.begin()+i);
- checkedBlackBoxes.erase(checkedBlackBoxes.begin()+i);
- i--;
- }
+ this->src = NULL;
}
+
for (int i = 0; i < checked.size(); i++)
{
if(!checked[i])
#include<vector>
#include"modelCDMFolder.h"
-#include"modelCDMBlackBox.h"
+#include"modelCDMPackageSrc.h"
class modelCDMPackage : public modelCDMFolder
{
const std::string& GetAuthorsEmail() const;
const std::string& GetVersion() const;
const std::string& GetDescription() const;
- const std::vector<modelCDMBlackBox*>& GetBlackBoxes() const;
+ modelCDMPackageSrc* GetSrc() const;
bool SetAuthors(const std::string& authors, std::string*& result);
bool SetAuthorsEmail(const std::string& email, std::string*& result);
std::string authorsEmail;
std::string version;
std::string description;
- std::vector<modelCDMBlackBox*> blackBoxes;
+ modelCDMPackageSrc* src;
};
--- /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.
+# ------------------------------------------------------------------------
+ */
+
+/*
+ * modelCDMFolder.cpp
+ *
+ * Created on: Nov 28, 2012
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "modelCDMPackageSrc.h"
+
+#include <fstream>
+#include <algorithm>
+
+#include <creaWx.h>
+#include <wx/dir.h>
+
+#include "CDMUtilities.h"
+
+modelCDMPackageSrc::modelCDMPackageSrc()
+{
+ this->CMakeLists = NULL;
+}
+
+modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level)
+{
+ //set attributes
+ this->children.clear();
+ this->level = level;
+ this->CMakeLists = NULL;
+ this->length = 0;
+ this->name = "src";
+ this->path = CDMUtilities::fixPath(path);
+ this->type = wxDIR_DIRS;
+
+ //check all folders
+ wxDir dir(crea::std2wx(path));
+ if (dir.IsOpened())
+ {
+ wxString fileName;
+ bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if is an unknown folder, create folder
+ this->children.push_back(new modelCDMFolder(path + "/" + stdfileName, this->level + 1));
+
+ cont = dir.GetNext(&fileName);
+ }
+
+ cont = dir.GetFirst(&fileName, wxT("CMakeLists.txt"), wxDIR_FILES);
+ if (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+ this->CMakeLists = new modelCDMCMakeListsFile(path + "/" + stdfileName, this->level + 1);
+ this->children.push_back(this->CMakeLists);
+ }
+
+ cont = dir.GetFirst(&fileName, wxT("*.h"), wxDIR_FILES);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+ modelCDMFile* file;
+
+ if(stdfileName.substr(0,2) == "bb")
+ {
+ file = new modelCDMFile(path + "/" + stdfileName, this->level + 1);
+ this->children.push_back(file);
+ modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path, level + 1);
+ blackBox->SetHeaderFile(file);
+ cont = dir.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);
+ this->children.push_back(file);
+ blackBox->SetSourceFile(file);
+ }
+ this->blackBoxes.push_back(blackBox);
+ }
+ cont = dir.GetNext(&fileName);
+ }
+ }
+
+ this->SortChildren();
+}
+
+modelCDMPackageSrc::~modelCDMPackageSrc()
+{
+ for (int i = 0; i < this->blackBoxes.size(); i++)
+ {
+ if(this->blackBoxes[i] != NULL)
+ {
+ delete this->blackBoxes[i];
+ this->blackBoxes[i] = NULL;
+ }
+ }
+ this->blackBoxes.clear();
+}
+
+const std::vector<modelCDMBlackBox*>& modelCDMPackageSrc::GetBlackBoxes() const
+{
+ return this->blackBoxes;
+}
+
+const bool modelCDMPackageSrc::Refresh(std::string*& result)
+{
+ //set attributes
+ this->type = wxDIR_DIRS;
+
+ //check children
+ std::vector<bool> checked(this->children.size(), false);
+ std::vector<bool> checkedBoxes(this->blackBoxes.size(), false);
+
+ //check all boxes
+ wxDir dir(crea::std2wx((this->path).c_str()));
+ if (dir.IsOpened())
+ {
+ wxString fileName;
+ bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+ std::string folderName = stdfileName;
+ //check if they already exist
+ bool found = false;
+ for (int i = 0;!found && i < this->children.size(); i++)
+ {
+ if (this->children[i]->GetName() == folderName)
+ {
+ found = true;
+ checked[i] = true;
+ if(!this->children[i]->Refresh(result))
+ return false;
+ }
+ }
+ if(!found)
+ {
+ modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+ this->children.push_back(folder);
+ }
+ cont = dir.GetNext(&fileName);
+ }
+
+ cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if CMakeLists, create CMakeLists
+ if(stdfileName == "CMakeLists.txt")
+ {
+ if (this->CMakeLists == NULL)
+ {
+ this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+ this->children.push_back(this->CMakeLists);
+ }
+ else
+ {
+ int pos = std::find(this->children.begin(), this->children.end(), this->CMakeLists) - this->children.begin();
+ checked[pos] = true;
+ if(!this->CMakeLists->Refresh(result))
+ return false;
+ }
+ }
+ //if is an unknown file, create file
+ else
+ {
+ bool found = false;
+ for (int i = 0; i <!found && this->children.size(); i++)
+ {
+ if (this->children[i]->GetName() == stdfileName)
+ {
+ found = true;
+ checked[i] = true;
+ if(!this->children[i]->Refresh(result))
+ return false;
+ }
+ }
+
+ if(!found)
+ {
+ modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+ this->children.push_back(file);
+ }
+ }
+
+ //if is a Black Box header, check in black boxes
+ 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++)
+ {
+ if(this->blackBoxes[i]->GetHeaderFile()->GetName() == stdfileName)
+ {
+ checkedBoxes[i] = true;
+ found = true;
+ if(!this->blackBoxes[i]->Refresh(result))
+ return false;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path + "/" + stdfileName, level + 1);
+ this->blackBoxes.push_back(blackBox);
+ }
+
+ }
+
+ cont = dir.GetNext(&fileName);
+ }
+ }
+
+ for (int i = 0; i < checkedBoxes.size(); i++)
+ {
+ if(!checkedBoxes[i])
+ {
+ delete this->blackBoxes[i];
+ this->blackBoxes.erase(this->blackBoxes.begin()+i);
+ checkedBoxes.erase(checkedBoxes.begin()+i);
+ i--;
+ }
+ }
+
+ for (int i = 0; i < checked.size(); i++)
+ {
+ if(!checked[i])
+ {
+ delete this->children[i];
+ this->children.erase(this->children.begin()+i);
+ checked.erase(checked.begin()+i);
+ i--;
+ }
+ }
+ this->SortChildren();
+ return true;
+}
--- /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.
+# ------------------------------------------------------------------------
+ */
+
+/*
+ * modelCDMPackageSrc.h
+ *
+ * Created on: Dic 19, 2012
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef MODELCDMPACKAGESRC_H_
+#define MODELCDMPACKAGESRC_H_
+
+#include<iostream>
+#include<vector>
+
+#include "modelCDMFolder.h"
+#include "modelCDMBlackBox.h"
+
+class modelCDMPackageSrc : public modelCDMFolder
+{
+public:
+ modelCDMPackageSrc();
+ modelCDMPackageSrc(const std::string& path, const int& level = 3);
+ ~modelCDMPackageSrc();
+
+ const std::vector<modelCDMBlackBox*>& GetBlackBoxes() const;
+
+ virtual const bool Refresh(std::string*& result);
+
+private:
+ std::vector<modelCDMBlackBox*> blackBoxes;
+
+};
+
+#endif /* MODELCDMPACKAGESRC_H_ */
BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel)
EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn)
+EVT_BUTTON(ID_BUTTON_SET_AUTHOR, wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor)
+EVT_BUTTON(ID_BUTTON_SET_DESCRIPTION, wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription)
+EVT_BUTTON(ID_BUTTON_SET_CATEGORY, wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories)
EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx)
EVT_BUTTON(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder)
wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author"));
- wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version"));
wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description"));
wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories"));
// author
wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors()));
- wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
+ this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors()));
+ wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change"));
pAuthorbt->SetToolTip(wxT("Update the author/s of the package."));
- pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0);
+ pAuthorsz->Add(this->authortc, 0, wxALIGN_CENTER_VERTICAL, 0);
pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10);
- // version
- wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetVersion()));
- wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
- pVersionbt->SetToolTip(wxT("Update the version of the package."));
- pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
- pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
-
// description
wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription()));
- wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
+ this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription()));
+ wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change"));
pDescriptionbt->SetToolTip(wxT("Update the description of the project."));
- pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
+ pDescriptionsz->Add(this->descriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
// categories
wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText* pCategoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories()));
- wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
+ this->categoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories()));
+ wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_CATEGORY, wxT("Change"));
pCategoriesbt->SetToolTip(wxT("Update the categories of the project."));
- pCategoriessz->Add(pCategoriestc, 0, wxALIGN_CENTER_VERTICAL, 0);
+ pCategoriessz->Add(this->categoriestc, 0, wxALIGN_CENTER_VERTICAL, 0);
pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10);
propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND);
- propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
- propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND);
propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
wxPanel* actionsPanel = new wxPanel(this);
wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
- wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Cxx"));
+ wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open .cxx"));
openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor."));
actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5);
- wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Hxx"));
- openHxxbt->SetToolTip(wxT("Open the .hxx file in the default text editor."));
+ wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_HXX, _T("Open .h"));
+ openHxxbt->SetToolTip(wxT("Open the .h file in the default text editor."));
actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder"));
- openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer."));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Source Folder"));
+ openFolderbt->SetToolTip(wxT("Open the source folder in the file explorer."));
actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
actionsPanel->SetSizer(actionsPanelSizer);
wxPostEvent(this->GetParent(), *newEvent);
}
+void wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor(wxCommandEvent& event)
+{
+ //get author from user
+ wxTextEntryDialog* authDlg = new wxTextEntryDialog(
+ this,
+ wxT("Enter the new authors name. Separate each author with a '/'."),
+ wxT("Change Black Box Author - creaDevManager"),
+ crea::std2wx(this->blackBox->GetAuthors()),
+ wxOK | wxCANCEL
+ );
+
+ if (authDlg->ShowModal() == wxID_OK)
+ {
+ std::string authorsStr = crea::wx2std(authDlg->GetValue());
+ //check name
+ if(authorsStr.size() > 0)
+ {
+ std::string* result;
+ if(!this->blackBox->SetAuthors(authorsStr, result))
+ wxMessageBox(crea::std2wx(*result),_T("Change Black Box Author - Error!"),wxOK | wxICON_ERROR);
+
+ }
+
+ this->authortc->SetLabel(crea::std2wx(this->blackBox->GetAuthors()));
+ this->authortc->GetParent()->GetSizer()->RecalcSizes();
+ }
+
+}
+
+void wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
+{
+ //get author from user
+ wxTextEntryDialog* descDlg = new wxTextEntryDialog(
+ this,
+ wxT("Edit the black box description."),
+ wxT("Change Black Box Description - creaDevManager"),
+ crea::std2wx(this->blackBox->GetDescription()),
+ wxTE_MULTILINE | wxOK | wxCANCEL
+ );
+
+ if (descDlg->ShowModal() == wxID_OK)
+ {
+ std::string descriptionStr = crea::wx2std(descDlg->GetValue());
+ //check name
+ if(descriptionStr.size() > 0)
+ {
+ std::string* result;
+ if(!this->blackBox->SetDescription(descriptionStr, result))
+ wxMessageBox(crea::std2wx(*result),_T("Change Black Box Description - Error!"),wxOK | wxICON_ERROR);
+ }
+ this->descriptiontc->SetLabel(crea::std2wx(this->blackBox->GetDescription()));
+ this->descriptiontc->GetParent()->GetSizer()->RecalcSizes();
+ }
+}
+
+void wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories(wxCommandEvent& event)
+{
+ //get author from user
+ wxTextEntryDialog* catsDlg = new wxTextEntryDialog(
+ this,
+ wxT("Edit the black box categories separated by '/'."),
+ wxT("Change Black Box Categories - creaDevManager"),
+ crea::std2wx(this->blackBox->GetCategories()),
+ wxTE_MULTILINE | wxOK | wxCANCEL
+ );
+
+ if (catsDlg->ShowModal() == wxID_OK)
+ {
+ std::string categoriesStr = crea::wx2std(catsDlg->GetValue());
+ //check name
+ if(categoriesStr.size() > 0)
+ {
+ std::string* result;
+ if(!this->blackBox->SetCategories(categoriesStr, result))
+ wxMessageBox(crea::std2wx(*result),_T("Change Black Box Categories - Error!"),wxOK | wxICON_ERROR);
+ }
+ this->categoriestc->SetLabel(crea::std2wx(this->blackBox->GetCategories()));
+ this->categoriestc->GetParent()->GetSizer()->RecalcSizes();
+ }
+}
+
void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnOpenCxx not implemented" << std::endl;
- event.Skip();
+ std::string* result;
+ if(!this->blackBox->OpenCxx(result))
+ wxMessageBox(crea::std2wx(*result),_T("Open Source File - Error!"),wxOK | wxICON_ERROR);
}
void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnOpenHxx not implemented" << std::endl;
- event.Skip();
+ std::string* result;
+ if(!this->blackBox->OpenHxx(result))
+ wxMessageBox(crea::std2wx(*result),_T("Open Header File - Error!"),wxOK | wxICON_ERROR);
}
void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
- event.Skip();
+ std::string* result;
+ if(!this->blackBox->OpenInFileExplorer(result))
+ wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
}
private:
modelCDMBlackBox* blackBox;
+ wxStaticText* authortc;
+ wxStaticText* descriptiontc;
+ wxStaticText* categoriestc;
//handlers
protected:
void OnBtnReturn(wxCommandEvent& event);
+ void OnBtnSetAuthor(wxCommandEvent& event);
+ void OnBtnSetDescription(wxCommandEvent& event);
+ void OnBtnSetCategories(wxCommandEvent& event);
void OnBtnOpenCxx(wxCommandEvent& event);
void OnBtnOpenHxx(wxCommandEvent& event);
void OnBtnOpenFolder(wxCommandEvent& event);
this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId());
break;
}
+ else if(event.GetString() == wxT("blackbox"))
+ {
+ modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
+ description = new wxCDMBlackBoxDescriptionPanel(
+ this,
+ bb,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
if(this->panel_Properties!= NULL)
this->panel_Properties->Hide();
void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
{
//std::cout << "element " << event.GetInt() << std::endl;
+ this->tree_Projects->EnsureVisible(event.GetInt());
this->tree_Projects->SetItemBold(event.GetInt(), true);
this->tree_Projects->SetItemTextColour(event.GetInt(), wxColour(0,0,255));
this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
v_sizer1->Add(h_sizer2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
SetSizer(v_sizer1);
- v_sizer1->SetSizeHints(this);
}
void wxCDMNewPackageDialog::OnCreatePackage(wxCommandEvent& event)
wxWindowID id = wxID_ANY,
const wxString& caption = wxT("New Package"),
const wxPoint& position = wxDefaultPosition,
- const wxSize& size = wxSize(400,300),
+ const wxSize& size = wxSize(500,400),
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
);
~wxCDMNewPackageDialog();
wxWindowID id = wxID_ANY,
const wxString& caption = wxT("New Package"),
const wxPoint& position = wxDefaultPosition,
- const wxSize& size = wxSize(400,300),
+ const wxSize& size = wxSize(500,400),
long style = wxDEFAULT_DIALOG_STYLE
);
v_sizer1->Add(h_sizer2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
SetSizer(v_sizer1);
- v_sizer1->SetSizeHints(this);
+ //v_sizer1->RecalcSizes();
}
void wxCDMNewProjectDialog::OnCreateProject(wxCommandEvent& event)
wxWindowID id = wxID_ANY,
const wxString& caption = wxT("New Project"),
const wxPoint& position = wxDefaultPosition,
- const wxSize& size = wxSize(400,300),
+ const wxSize& size = wxSize(700,400),
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
);
~wxCDMNewProjectDialog();
wxWindowID id = wxID_ANY,
const wxString& caption = wxT("New Project"),
const wxPoint& position = wxDefaultPosition,
- const wxSize& size = wxSize(400,300),
+ const wxSize& size = wxSize(700,400),
long style = wxDEFAULT_DIALOG_STYLE
);
wxPanel* BBPanel = new wxPanel(this);
wxBoxSizer* BBPanelSizer = new wxBoxSizer(wxVERTICAL);
- std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetBlackBoxes();
+
+ std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetSrc()->GetBlackBoxes();
for (int i = 0; i < blackBoxes.size(); i++)
{
- wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str()));
- std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories();
- pBBlk->SetToolTip(crea::std2wx(tt));
- pBBlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseEnter,NULL,this);
- pBBlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseExit,NULL,this);
- BBPanelSizer -> Add(pBBlk, 0, wxALIGN_LEFT | wxALL, 5);
+
+ if(blackBoxes[i] != NULL)
+ {
+
+ wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str()));
+ std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories();
+ pBBlk->SetToolTip(crea::std2wx(tt));
+ pBBlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseEnter,NULL,this);
+ pBBlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseExit,NULL,this);
+ BBPanelSizer -> Add(pBBlk, 0, wxALIGN_LEFT | wxALL, 5);
+ }
}
BBPanel->SetSizer(BBPanelSizer);
void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
{
- //get author from user
+ //get description from user
wxTextEntryDialog* descDlg = new wxTextEntryDialog(
this,
wxT("Edit the package description."),
if (descDlg->ShowModal() == wxID_OK)
{
std::string descriptionStr = crea::wx2std(descDlg->GetValue());
- //check name
+ //check desc
if(descriptionStr.size() > 0)
{
std::string* result;
void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event)
{
int bbId = 0;
- std::vector<modelCDMBlackBox*> bbs = this->package->GetBlackBoxes();
+ modelCDMBlackBox* bb;
+ std::vector<modelCDMBlackBox*> bbs = this->package->GetSrc()->GetBlackBoxes();
for (int i = 0; i < bbs.size(); i++)
{
if(bbs[i]->GetName() == crea::wx2std(event.GetURL()))
{
- bbId = bbs[i]->GetId();
+ bbId = bbs[i]->GetHeaderFile()->GetId();
+ bb = bbs[i];
break;
}
}
wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
- newEvent->SetInt(bbId);
- newEvent->SetId(0);
+ newEvent->SetClientData(bb);
+ newEvent->SetId(1);
+ newEvent->SetString(wxT("blackbox"));
wxPostEvent(this->GetParent(), *newEvent);
wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
{
wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+
int bbId = 0;
- std::vector<modelCDMBlackBox*> boxes = this->package->GetBlackBoxes();
+ std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
for (int i = 0; i < boxes.size(); i++)
{
if(boxes[i]->GetName() == BBName)
{
- bbId = boxes[i]->GetId();
+ bbId = boxes[i]->GetHeaderFile()->GetId();
break;
}
}
wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
int bbId = 0;
- std::vector<modelCDMBlackBox*> boxes = this->package->GetBlackBoxes();
+ std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
for (int i = 0; i < boxes.size(); i++)
{
if(boxes[i]->GetName() == BBName)
{
- bbId = boxes[i]->GetId();
+ bbId = boxes[i]->GetHeaderFile()->GetId();
break;
}
}