From 2c45094f8403883f8fb52c1801f1d96a35a471bf Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Fri, 21 Dec 2012 14:51:26 +0100 Subject: [PATCH] Black Box view and folder structure implemented still doesn't create boxes --- lib/creaDevManagerLib/creaDevManagerIds.h | 21 +- lib/creaDevManagerLib/modelCDMAppli.cpp | 20 ++ lib/creaDevManagerLib/modelCDMBlackBox.cpp | 256 +++++++++++++++-- lib/creaDevManagerLib/modelCDMBlackBox.h | 16 +- lib/creaDevManagerLib/modelCDMPackage.cpp | 54 ++-- lib/creaDevManagerLib/modelCDMPackage.h | 6 +- lib/creaDevManagerLib/modelCDMPackageSrc.cpp | 264 ++++++++++++++++++ lib/creaDevManagerLib/modelCDMPackageSrc.h | 60 ++++ .../wxCDMBlackBoxDescriptionPanel.cpp | 141 +++++++--- .../wxCDMBlackBoxDescriptionPanel.h | 6 + lib/creaDevManagerLib/wxCDMMainFrame.cpp | 14 + .../wxCDMNewPackageDialog.cpp | 1 - lib/creaDevManagerLib/wxCDMNewPackageDialog.h | 4 +- .../wxCDMNewProjectDialog.cpp | 2 +- lib/creaDevManagerLib/wxCDMNewProjectDialog.h | 4 +- .../wxCDMPackageDescriptionPanel.cpp | 44 +-- 16 files changed, 787 insertions(+), 126 deletions(-) create mode 100644 lib/creaDevManagerLib/modelCDMPackageSrc.cpp create mode 100644 lib/creaDevManagerLib/modelCDMPackageSrc.h diff --git a/lib/creaDevManagerLib/creaDevManagerIds.h b/lib/creaDevManagerLib/creaDevManagerIds.h index ab662fa..fe1b1a0 100644 --- a/lib/creaDevManagerLib/creaDevManagerIds.h +++ b/lib/creaDevManagerLib/creaDevManagerIds.h @@ -94,19 +94,20 @@ #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_ */ diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index ebd4de0..e35a9c5 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -74,6 +74,26 @@ modelCDMAppli::modelCDMAppli(const std::string& path, const int& level) 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(); diff --git a/lib/creaDevManagerLib/modelCDMBlackBox.cpp b/lib/creaDevManagerLib/modelCDMBlackBox.cpp index 5ea4a26..d177c88 100644 --- a/lib/creaDevManagerLib/modelCDMBlackBox.cpp +++ b/lib/creaDevManagerLib/modelCDMBlackBox.cpp @@ -34,19 +34,69 @@ #include "modelCDMBlackBox.h" +#include + +#include "CDMUtilities.h" + #include #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 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() @@ -63,11 +113,6 @@ const std::string& modelCDMBlackBox::GetAuthors() const return this->authors; } -const std::string& modelCDMBlackBox::GetAuthorsEmail() const -{ - return this->authorsEmail; -} - const std::string& modelCDMBlackBox::GetCategories() const { return this->categories; @@ -78,33 +123,120 @@ const std::string& modelCDMBlackBox::GetDescription() const 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 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 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( @@ -112,26 +244,88 @@ bool modelCDMBlackBox::SetDescription( std::string*& result ) { - //TODO: implement method + std::vector 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) diff --git a/lib/creaDevManagerLib/modelCDMBlackBox.h b/lib/creaDevManagerLib/modelCDMBlackBox.h index f3d986a..e1021b8 100644 --- a/lib/creaDevManagerLib/modelCDMBlackBox.h +++ b/lib/creaDevManagerLib/modelCDMBlackBox.h @@ -48,17 +48,20 @@ public: 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); @@ -67,10 +70,11 @@ public: 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_ */ diff --git a/lib/creaDevManagerLib/modelCDMPackage.cpp b/lib/creaDevManagerLib/modelCDMPackage.cpp index 82a514c..097c360 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.cpp +++ b/lib/creaDevManagerLib/modelCDMPackage.cpp @@ -43,6 +43,7 @@ modelCDMPackage::modelCDMPackage() { + this->src = NULL; } modelCDMPackage::modelCDMPackage(const std::string& path, const int& level) @@ -143,7 +144,9 @@ 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; @@ -158,13 +161,13 @@ modelCDMPackage::modelCDMPackage(const std::string& path, const int& level) } 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); } @@ -220,9 +223,9 @@ const std::string& modelCDMPackage::GetDescription() const return this->description; } -const std::vector& modelCDMPackage::GetBlackBoxes() const +modelCDMPackageSrc* modelCDMPackage::GetSrc() const { - return this->blackBoxes; + return this->src; } bool modelCDMPackage::SetAuthors(const std::string& authors, std::string*& result) @@ -464,7 +467,7 @@ const bool modelCDMPackage::Refresh(std::string*& result) std::vector checked(this->children.size(), false); - std::vector checkedBlackBoxes(this->blackBoxes.size(), false); + bool checkedSrc = false; //check all folders wxDir dir(crea::std2wx((this->path).c_str())); @@ -477,10 +480,26 @@ const bool modelCDMPackage::Refresh(std::string*& result) 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; @@ -513,13 +532,13 @@ const bool modelCDMPackage::Refresh(std::string*& result) } 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++) { @@ -536,8 +555,9 @@ const bool modelCDMPackage::Refresh(std::string*& result) 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); @@ -587,15 +607,11 @@ const bool modelCDMPackage::Refresh(std::string*& result) } } - 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]) diff --git a/lib/creaDevManagerLib/modelCDMPackage.h b/lib/creaDevManagerLib/modelCDMPackage.h index 632b2ef..d79db95 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.h +++ b/lib/creaDevManagerLib/modelCDMPackage.h @@ -39,7 +39,7 @@ #include #include"modelCDMFolder.h" -#include"modelCDMBlackBox.h" +#include"modelCDMPackageSrc.h" class modelCDMPackage : public modelCDMFolder { @@ -53,7 +53,7 @@ public: const std::string& GetAuthorsEmail() const; const std::string& GetVersion() const; const std::string& GetDescription() const; - const std::vector& GetBlackBoxes() const; + modelCDMPackageSrc* GetSrc() const; bool SetAuthors(const std::string& authors, std::string*& result); bool SetAuthorsEmail(const std::string& email, std::string*& result); @@ -76,7 +76,7 @@ private: std::string authorsEmail; std::string version; std::string description; - std::vector blackBoxes; + modelCDMPackageSrc* src; }; diff --git a/lib/creaDevManagerLib/modelCDMPackageSrc.cpp b/lib/creaDevManagerLib/modelCDMPackageSrc.cpp new file mode 100644 index 0000000..b758cc4 --- /dev/null +++ b/lib/creaDevManagerLib/modelCDMPackageSrc.cpp @@ -0,0 +1,264 @@ +/* +# --------------------------------------------------------------------- +# +# 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 +#include + +#include +#include + +#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& modelCDMPackageSrc::GetBlackBoxes() const +{ + return this->blackBoxes; +} + +const bool modelCDMPackageSrc::Refresh(std::string*& result) +{ + //set attributes + this->type = wxDIR_DIRS; + + //check children + std::vector checked(this->children.size(), false); + std::vector 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 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; +} diff --git a/lib/creaDevManagerLib/modelCDMPackageSrc.h b/lib/creaDevManagerLib/modelCDMPackageSrc.h new file mode 100644 index 0000000..14de2d7 --- /dev/null +++ b/lib/creaDevManagerLib/modelCDMPackageSrc.h @@ -0,0 +1,60 @@ +/* +# --------------------------------------------------------------------- +# +# 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 +#include + +#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& GetBlackBoxes() const; + + virtual const bool Refresh(std::string*& result); + +private: + std::vector blackBoxes; + +}; + +#endif /* MODELCDMPACKAGESRC_H_ */ diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp index b53d919..d972925 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp @@ -41,6 +41,9 @@ 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) @@ -104,46 +107,35 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() 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); @@ -164,14 +156,14 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() 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); @@ -192,23 +184,104 @@ void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event) 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); } diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h index eb32dc1..c4be2fb 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h @@ -70,10 +70,16 @@ public: 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); diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 414d88b..ed3b6de 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -897,6 +897,19 @@ void wxCDMMainFrame::OnCreationComplete(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(); @@ -923,6 +936,7 @@ void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) 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); diff --git a/lib/creaDevManagerLib/wxCDMNewPackageDialog.cpp b/lib/creaDevManagerLib/wxCDMNewPackageDialog.cpp index 8b0efff..f648d65 100644 --- a/lib/creaDevManagerLib/wxCDMNewPackageDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMNewPackageDialog.cpp @@ -135,7 +135,6 @@ void wxCDMNewPackageDialog::CreateControls() 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) diff --git a/lib/creaDevManagerLib/wxCDMNewPackageDialog.h b/lib/creaDevManagerLib/wxCDMNewPackageDialog.h index 1c76552..1f0e55f 100644 --- a/lib/creaDevManagerLib/wxCDMNewPackageDialog.h +++ b/lib/creaDevManagerLib/wxCDMNewPackageDialog.h @@ -48,7 +48,7 @@ public: 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(); @@ -57,7 +57,7 @@ public: 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 ); diff --git a/lib/creaDevManagerLib/wxCDMNewProjectDialog.cpp b/lib/creaDevManagerLib/wxCDMNewProjectDialog.cpp index e0ad6d4..c3066a7 100644 --- a/lib/creaDevManagerLib/wxCDMNewProjectDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMNewProjectDialog.cpp @@ -142,7 +142,7 @@ void wxCDMNewProjectDialog::CreateControls() 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) diff --git a/lib/creaDevManagerLib/wxCDMNewProjectDialog.h b/lib/creaDevManagerLib/wxCDMNewProjectDialog.h index ce99eab..22dec24 100644 --- a/lib/creaDevManagerLib/wxCDMNewProjectDialog.h +++ b/lib/creaDevManagerLib/wxCDMNewProjectDialog.h @@ -48,7 +48,7 @@ public: 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(); @@ -57,7 +57,7 @@ public: 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 ); diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp index 99367d7..4411c9e 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp @@ -160,15 +160,21 @@ void wxCDMPackageDescriptionPanel::CreateControls() wxPanel* BBPanel = new wxPanel(this); wxBoxSizer* BBPanelSizer = new wxBoxSizer(wxVERTICAL); - std::vector blackBoxes = this->package->GetBlackBoxes(); + + std::vector 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); @@ -265,7 +271,7 @@ void wxCDMPackageDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event) void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event) { - //get author from user + //get description from user wxTextEntryDialog* descDlg = new wxTextEntryDialog( this, wxT("Edit the package description."), @@ -277,7 +283,7 @@ void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event) if (descDlg->ShowModal() == wxID_OK) { std::string descriptionStr = crea::wx2std(descDlg->GetValue()); - //check name + //check desc if(descriptionStr.size() > 0) { std::string* result; @@ -292,19 +298,22 @@ void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event) void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event) { int bbId = 0; - std::vector bbs = this->package->GetBlackBoxes(); + modelCDMBlackBox* bb; + std::vector 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); @@ -351,13 +360,14 @@ void wxCDMPackageDescriptionPanel::OnMouseEnter(wxMouseEvent& event) { wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int bbId = 0; - std::vector boxes = this->package->GetBlackBoxes(); + std::vector 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; } } @@ -372,12 +382,12 @@ void wxCDMPackageDescriptionPanel::OnMouseExit(wxMouseEvent& event) wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); int bbId = 0; - std::vector boxes = this->package->GetBlackBoxes(); + std::vector 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; } } -- 2.47.1