From: Daniel Gonzalez Date: Mon, 26 Nov 2012 19:11:51 +0000 (+0100) Subject: Feature #1711 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=07de43de26544771a25b4edb25cbbf878bf32de3;p=crea.git Feature #1711 CreaDevManager application implementation New Project and open project implemented --- diff --git a/lib/creaDevManagerLib/ControlCreaDevManagerProject.cpp b/lib/creaDevManagerLib/ControlCreaDevManagerProject.cpp deleted file mode 100644 index cc66abe..0000000 --- a/lib/creaDevManagerLib/ControlCreaDevManagerProject.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* -# --------------------------------------------------------------------- -# -# 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. -# ------------------------------------------------------------------------ -*/ - - -/* - * ControlCreaDevManagerProject.cpp - * - * Created on: 5/11/2012 - * Author: Daniel Felipe Gonzalez Obando - */ - -#include "ControlCreaDevManagerProject.h" - -#include -#include -#include // for getenv - -ControlCreaDevManagerProject::ControlCreaDevManagerProject() -{ - // TODO Auto-generated constructor stub - -} - -ControlCreaDevManagerProject::~ControlCreaDevManagerProject() -{ - // TODO Auto-generated destructor stub -} - -bool ControlCreaDevManagerProject::CreateProject(const std::string& name, const std::string& dir, const std::string& author, const std::string& description) -{ - // ------ Windows -#if(_WIN32) - - std::string command("creaNewProject.bat "); - std::string command1("creaSed.exe "); - std::string command2("del "); - - command += "\"" + dir + "\" \"" + name + "\""; - command1 += "\"" + dir+"\\"+name+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + dir + "\\" + name + "\\CMakeLists.txt\""; - command2 += "\"" + dir+"\\"+name+"\\CMakeLists.txt.in\""; - if ( ! system ( command.c_str() ) ) - { - system ( command1.c_str() ); - system ( command2.c_str() ); - - // Create a Package at the same time. JPR - char *author = author.c_str(); - std::string nomDirectory = dir + "\\" + name; - std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + name + "_PKG"; - std::string bbCreatePackage("bbCreatePackage "); - bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description; - system (bbCreatePackage.c_str()); - std::string add; - add = "echo ADD_SUBDIRECTORY(bbtk_" + name + "_PKG) >> " + nomDirectory + "/CMakeLists.txt"; - system(add.c_str()); - - wxMessageBox(_T("New Project created !"),_T("creaNewProject"), wxOK | wxICON_INFORMATION); - } - else - { - wxString err(_T("An error occured while running '")); - err += crea::std2wx(command) + _T("'"); - wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR); - return false; - } - -#else - // ------ LINUX / MacOS - std::string command("creaNewProject.sh "); - command += "\"" + dir + "\"" +" " + name; - std::cout << "executing " << command << std::endl; - if ( ! system ( command.c_str() ) ) - { - //wxMessageBox(_T("New Project created !"),_T("creaNewProject"), wxOK | wxICON_INFORMATION); - - std::string nomDirectory = dir + "/" + name; - std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + name + "_PKG"; - - std::string bbCreatePackage("bbCreatePackage "); - 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"; - //std::cout << add << std::endl; - std::cout << "executing " << add << std::endl; - system(add.c_str()); - - } - else - { - wxString err(_T("An error occured while running '")); - err += crea::std2wx(command) + _T("'"); - wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR); - return false; - } - -#endif - - return true; -} diff --git a/lib/creaDevManagerLib/ControlCreaDevManagerProject.h b/lib/creaDevManagerLib/ControlCreaDevManagerProject.h deleted file mode 100644 index ca4f8d0..0000000 --- a/lib/creaDevManagerLib/ControlCreaDevManagerProject.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -# --------------------------------------------------------------------- -# -# 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. -# ------------------------------------------------------------------------ -*/ - - -/* - * ControlCreaDevManagerProject.h - * - * Created on: 5/11/2012 - * Author: Daniel Felipe Gonzalez Obando - */ - -#ifndef CONTROLCREADEVMANAGERPROJECT_H_ -#define CONTROLCREADEVMANAGERPROJECT_H_ - -#include - -class ControlCreaDevManagerProject -{ -public: - ControlCreaDevManagerProject(); - ~ControlCreaDevManagerProject(); - static bool CreateProject(const std::string& name, const std::string& location, const std::string& author, const std::string& description); -}; - -#endif /* CONTROLCREADEVMANAGERPROJECT_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index ee7edc1..002a38e 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -58,7 +58,7 @@ bool modelCDMAppli::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMAppli::Refresh(std::string*& result) +const bool modelCDMAppli::Refresh(std::string*& result) { //TODO: implement method return true; diff --git a/lib/creaDevManagerLib/modelCDMAppli.h b/lib/creaDevManagerLib/modelCDMAppli.h index 569fdb1..00f4d66 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.h +++ b/lib/creaDevManagerLib/modelCDMAppli.h @@ -53,7 +53,7 @@ public: const std::string& path = "/" ); bool OpenCMakeListsFile(std::string*& result); - bool Refresh(std::string*& result); + virtual const bool Refresh(std::string*& result); private: std::vector applications; diff --git a/lib/creaDevManagerLib/modelCDMApplication.cpp b/lib/creaDevManagerLib/modelCDMApplication.cpp index c1e715e..d87ec75 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.cpp +++ b/lib/creaDevManagerLib/modelCDMApplication.cpp @@ -72,7 +72,7 @@ bool modelCDMApplication::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMApplication::Refresh(std::string*& result) +const bool modelCDMApplication::Refresh(std::string*& result) { //TODO: implement method return true; diff --git a/lib/creaDevManagerLib/modelCDMApplication.h b/lib/creaDevManagerLib/modelCDMApplication.h index a878c35..b2ad4a8 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.h +++ b/lib/creaDevManagerLib/modelCDMApplication.h @@ -57,7 +57,7 @@ public: const std::string& path = "/" ); bool OpenCMakeListsFile(std::string* & result); - bool Refresh(std::string*& result); + virtual const bool Refresh(std::string*& result); private: std::string name; diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp new file mode 100644 index 0000000..8026b41 --- /dev/null +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp @@ -0,0 +1,134 @@ +/* +# --------------------------------------------------------------------- +# +# 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. +# ------------------------------------------------------------------------ +*/ + +/* + * modelCDMIProjectTreeNode.cpp + * + * Created on: Nov 26, 2012 + * Author: Daniel Felipe Gonzalez Obando + */ +#include "modelCDMIProjectTreeNode.h" + +bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode& x, const modelCDMIProjectTreeNode& y) +{ + bool returnValue; + bool noWinner = true; + unsigned int i = 0; + std::string xName = x.GetName(); + std::string yName = y.GetName(); + unsigned char xType = x.GetType(); + unsigned char yType = y.GetType(); + + while ((i < xName.length()) && (i < yName.length())) + { + if (tolower (xName[i]) < tolower (yName[i])) + { + noWinner = false; + returnValue = true; + break; + } + else if (tolower (xName[i]) > tolower (yName[i])) + { + noWinner = false; + returnValue = false; + break; + } + i++; + } + + if(noWinner) + { + if (xName.length() < yName.length()) + returnValue = true; + else + returnValue = false; + } + + if(xType != yType) + { + if(xType == DT_DIR) + returnValue = true; + else + returnValue = false; + } + + return returnValue; +} + +const wxTreeItemId& modelCDMIProjectTreeNode::GetId() const +{ + return this->id; +} + +const std::string& modelCDMIProjectTreeNode::GetPath() const +{ + return this->path; +} + +const std::string& modelCDMIProjectTreeNode::GetName() const +{ + return this->name; +} + +const unsigned char& modelCDMIProjectTreeNode::GetType() const +{ + return this->type; +} + +const int& modelCDMIProjectTreeNode::GetLevel() const +{ + return this->level; +} + +const std::vector& modelCDMIProjectTreeNode::GetChildren() const +{ + return this->children; +} + +void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id) +{ + this->id = id; +} + +void modelCDMIProjectTreeNode::SetChildren( + const std::vector& children) +{ + this->children.clear(); + this->children = children; +} + +const bool modelCDMIProjectTreeNode::Refresh(std::string*& result) +{ + //TODO: implement method + return false; +} + +const bool modelCDMIProjectTreeNode::OpenInFileExplorer(std::string*& result) const +{ + //TODO: implement method + return false; +} diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h index 4d06cb6..b74c6f1 100644 --- a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h @@ -37,23 +37,30 @@ #include #include +#include +#include "wx/treectrl.h" class modelCDMIProjectTreeNode { public: - virtual ~modelCDMIProjectTreeNode(){} + virtual ~modelCDMIProjectTreeNode() {} + static bool CompareNodeItem(const modelCDMIProjectTreeNode& x, const modelCDMIProjectTreeNode& y); + + const wxTreeItemId& GetId() const; const std::string& GetPath() const; const std::string& GetName() const; const unsigned char& GetType() const; const int& GetLevel() const; const std::vector& GetChildren() const; + void SetId(const wxTreeItemId& id); void SetChildren(const std::vector& children); - const bool& Refresh(std::string*& result); - const bool& OpenInFileExplorer(std::string*& result) const; + virtual const bool Refresh(std::string*& result); + const bool OpenInFileExplorer(std::string*& result) const; protected: + wxTreeItemId id; std::string path; std::string name; unsigned char type; diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index d22a6fe..e8a4ac9 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -58,7 +58,7 @@ bool modelCDMLib::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMLib::Refresh(std::string*& result) +const bool modelCDMLib::Refresh(std::string*& result) { //TODO: implement method return true; diff --git a/lib/creaDevManagerLib/modelCDMLib.h b/lib/creaDevManagerLib/modelCDMLib.h index 520822f..2a7e164 100644 --- a/lib/creaDevManagerLib/modelCDMLib.h +++ b/lib/creaDevManagerLib/modelCDMLib.h @@ -53,7 +53,7 @@ public: const std::string& path = "/" ); bool OpenCMakeListsFile(std::string*& result); - bool Refresh(std::string*& result); + virtual const bool Refresh(std::string*& result); private: std::vector libraries; diff --git a/lib/creaDevManagerLib/modelCDMLibrary.cpp b/lib/creaDevManagerLib/modelCDMLibrary.cpp index 7bf7373..d3de6c0 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.cpp +++ b/lib/creaDevManagerLib/modelCDMLibrary.cpp @@ -62,7 +62,7 @@ bool modelCDMLibrary::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMLibrary::Refresh(std::string*& result) +const bool modelCDMLibrary::Refresh(std::string*& result) { //TODO: implement method return true; diff --git a/lib/creaDevManagerLib/modelCDMLibrary.h b/lib/creaDevManagerLib/modelCDMLibrary.h index 64ae1f8..4c7fdad 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.h +++ b/lib/creaDevManagerLib/modelCDMLibrary.h @@ -54,7 +54,7 @@ public: const std::string& path = "/" ); bool OpenCMakeListsFile(std::string*& result); - bool Refresh(std::string*& result); + virtual const bool Refresh(std::string*& result); private: std::string name; diff --git a/lib/creaDevManagerLib/modelCDMMain.cpp b/lib/creaDevManagerLib/modelCDMMain.cpp index e9df13e..25331dc 100644 --- a/lib/creaDevManagerLib/modelCDMMain.cpp +++ b/lib/creaDevManagerLib/modelCDMMain.cpp @@ -42,20 +42,24 @@ #include #include "CDMUtilities.h" +#include "modelCDMProject.h" modelCDMMain::modelCDMMain() { - //TODO: implement method + this->project = NULL; } modelCDMMain::~modelCDMMain() { - //TODO: implement method + if(project != NULL) + { + delete this->project; + this->project = NULL; + } } -const modelCDMProject* modelCDMMain::GetProject() const +modelCDMProject* modelCDMMain::GetProject() const { - //TODO: implement method return this->project; } @@ -71,8 +75,7 @@ bool modelCDMMain::CreateProject( std::string locationFixed = CDMUtilities::fixPath(location); std::cout << "Opening path: "<< locationFixed << std::endl; - //TODO: create Project given the source folder - + //creates project in disk #if(_WIN32) std::string command("creaNewProject.bat "); @@ -82,58 +85,58 @@ bool modelCDMMain::CreateProject( command += "\"" + locationFixed + "\" \"" + name + "\""; command1 += "\"" + locationFixed +"\\"+name+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + locationFixed + "\\" + name + "\\CMakeLists.txt\""; command2 += "\"" + locationFixed +"\\"+name+"\\CMakeLists.txt.in\""; - if ( ! system ( command.c_str() ) ) - { - system ( command1.c_str() ); - system ( command2.c_str() ); - - // Create a Package at the same time. JPR - char *author = author.c_str(); - std::string nomDirectory = locationFixed + "\\" + name; - std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + name + "_PKG"; - std::string bbCreatePackage("bbCreatePackage "); - bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description; - system (bbCreatePackage.c_str()); - std::string add; - add = "echo ADD_SUBDIRECTORY(bbtk_" + name + "_PKG) >> " + nomDirectory + "/CMakeLists.txt"; - system(add.c_str()); - } - else + + + if (system (command.c_str())) { result = new std::string("An error occured while running '" + command + "'."); return false; } + system ( command1.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 bbCreatePackage("bbCreatePackage "); + bbCreatePackage += nomDirectory + " " + name + " " + author + " " + description; + system (bbCreatePackage.c_str()); + std::string add; + add = "echo ADD_SUBDIRECTORY(bbtk_" + name + "_PKG) >> " + nomDirectory + "/CMakeLists.txt"; + system(add.c_str()); + + this->project = new modelCDMProject(nomDirectory); + #else // ------ LINUX / MacOS std::string command("creaNewProject.sh "); command += "\"" + locationFixed + "\"" +" " + name; - std::cout << "executing " << command << std::endl; - if ( ! system ( command.c_str() ) ) - { - std::string nomDirectory = locationFixed + "/" + name; - std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + name + "_PKG"; - - std::string bbCreatePackage("bbCreatePackage "); - 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"; - //std::cout << add << std::endl; - std::cout << "executing " << add << std::endl; - system(add.c_str()); - } - else + //std::cout << "executing " << command << std::endl; + if (system ( command.c_str() ) ) { result = new std::string("An error occured while running '" + command + "'."); return false; } -#endif + std::string nomDirectory = locationFixed + "/" + name; + std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + name + "_PKG"; + + std::string bbCreatePackage("bbCreatePackage "); + 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"; + + //std::cout << "executing " << add << std::endl; + system(add.c_str()); + + this->project = new modelCDMProject(nomDirectory); +#endif return true; } @@ -143,7 +146,7 @@ bool modelCDMMain::OpenProject( std::string*& result ) { - std::cout << "Open selection path: "<< path << std::endl; + //std::cout << "Open selection path: "<< path << std::endl; //get fixed path std::string pathFixed = CDMUtilities::fixPath(path); std::cout << "Opening path: "<< pathFixed << std::endl; @@ -172,7 +175,7 @@ bool modelCDMMain::OpenProject( readFile.ignore(); getline(readFile, word, '\n'); pathBuild = pathFixed; - pathFixed = word; + pathFixed = CDMUtilities::fixPath(word); isBinary = true; } } @@ -197,12 +200,14 @@ bool modelCDMMain::OpenProject( while(!isSource && !readFile.eof()) { - std::getline(readFile,word,'\n'); - int pos = word.find("PROJECT"); - if(pos != std::string::npos) + std::getline(readFile,word,'('); + std::vector wordBits; + CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties); + + if(wordBits[wordBits.size()-1] == "PROJECT") { - pathSource = pathFixed; isSource = true; + pathSource = pathFixed; } } readFile.close(); @@ -211,12 +216,16 @@ bool modelCDMMain::OpenProject( //if is source folder if(isSource) { - std::cout << "Project sources at: " << pathSource; + std::cout << "Project sources at: " << pathSource << std::endl; if(isBinary) { - std::cout << ", and built in: " << pathBuild; + std::cout << ", and built in: " << pathBuild << std::endl; + this->project = new modelCDMProject(pathSource, pathBuild); + } + else + { + this->project = new modelCDMProject(pathSource); } - std::cout << std::endl; } else { @@ -224,7 +233,6 @@ bool modelCDMMain::OpenProject( return false; } - //TODO: create Project given the source folder return true; } diff --git a/lib/creaDevManagerLib/modelCDMMain.h b/lib/creaDevManagerLib/modelCDMMain.h index 6a10470..83d86ac 100644 --- a/lib/creaDevManagerLib/modelCDMMain.h +++ b/lib/creaDevManagerLib/modelCDMMain.h @@ -45,7 +45,7 @@ public: modelCDMMain(); ~modelCDMMain(); - const modelCDMProject* GetProject() const; + modelCDMProject* GetProject() const; bool CreateProject( const std::string& name, diff --git a/lib/creaDevManagerLib/modelCDMPackage.cpp b/lib/creaDevManagerLib/modelCDMPackage.cpp index 681c5a4..8d33e17 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.cpp +++ b/lib/creaDevManagerLib/modelCDMPackage.cpp @@ -109,7 +109,7 @@ bool modelCDMPackage::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMPackage::Refresh(std::string*& result) +const bool modelCDMPackage::Refresh(std::string*& result) { //TODO: implement method return true; diff --git a/lib/creaDevManagerLib/modelCDMPackage.h b/lib/creaDevManagerLib/modelCDMPackage.h index b6202b5..5af9210 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.h +++ b/lib/creaDevManagerLib/modelCDMPackage.h @@ -67,7 +67,7 @@ public: const std::string& description = "no description" ); bool OpenCMakeListsFile(std::string*& result); - bool Refresh(std::string*& result); + virtual const bool Refresh(std::string*& result); private: std::string name; diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index b7a0747..25bba8d 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -34,19 +34,139 @@ #include "modelCDMProject.h" +#include +#include +#include + +#include "CDMUtilities.h" +#include "creaWx.h" +#include "wx/dir.h" + modelCDMProject::modelCDMProject() { - //TODO: implement method + std::cout << "in constructor1" << std::endl; + this->appli = NULL; + this->lib = NULL; } modelCDMProject::modelCDMProject( - const std::string& name, const std::string& path, - const unsigned char& type, - const int& level + const std::string& buildPath ) { + this->path = CDMUtilities::fixPath(path); + //open makelists file + std::string pathFixed(CDMUtilities::fixPath(path)); + + //TODO: set pathMakeLists for windows + std::string pathMakeLists = pathFixed + "/CMakeLists.txt"; + + std::ifstream confFile; + confFile.open((pathMakeLists).c_str()); + + std::string word; + while(confFile.is_open() && !confFile.eof()) + { + //std::cout << "leyendo " << word << std::endl; + //get project name + std::getline(confFile,word,'('); + std::vector wordBits; + CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties); + + if(wordBits[wordBits.size()-1] == "PROJECT") + { + std::getline(confFile,word,')'); + std::vector nameBits; + CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties); + + this->name = ""; + for (int i = 0; i < nameBits.size(); i++) + { + if(i != 0) + this->name += " "; + this->name += nameBits[i]; + } + + } + + + if(wordBits[wordBits.size()-1] == "SET") + { + //get project version + std::getline(confFile,word,')'); + if(word.find("PROJECT_MAJOR_VERSION") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " ", CDMUtilities::splitter::no_empties); + version = versionBits[versionBits.size()-1]; + } + if(word.find("PROJECT_MINOR_VERSION") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " ", CDMUtilities::splitter::no_empties); + version += "." + versionBits[versionBits.size()-1]; + } + if(word.find("PROJECT_BUILD_VERSION") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " ", CDMUtilities::splitter::no_empties); + version += "." + versionBits[versionBits.size()-1]; + } + + //get project versionDate + if(word.find("PROJECT_VERSION_DATE") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " \"", CDMUtilities::splitter::no_empties); + versionDate = versionBits[versionBits.size()-1]; + } + //get project buildPath + + if (buildPath != "") + { + this->buildPath = buildPath; + } + else + { + this->buildPath = this->path + "Bin"; + } + } + } + confFile.close(); + + this->type = wxDIR_DIRS; + this->level = 0; + //TODO: implement method + //if appli exist create Appli + this->appli = NULL; + //if lib exist create Lib + this->lib = NULL; + //if bbtk_* exist create Packages + + +} + +modelCDMProject::~modelCDMProject() +{ + if(this->appli != NULL) + { + delete this->appli; + this->appli = NULL; + } + if(this->lib != NULL) + { + delete this->lib; + this->lib = NULL; + } + for (int i = 0; i < this->packages.size(); i++) + { + if(this->packages[i] != NULL) + { + delete this->packages[i]; + this->packages[i] = NULL; + } + } } const std::string& @@ -137,7 +257,7 @@ bool modelCDMProject::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMProject::Refresh(std::string*& result) +const bool modelCDMProject::Refresh(std::string*& result) { //TODO: implement method return true; diff --git a/lib/creaDevManagerLib/modelCDMProject.h b/lib/creaDevManagerLib/modelCDMProject.h index 604cea5..059b6c4 100644 --- a/lib/creaDevManagerLib/modelCDMProject.h +++ b/lib/creaDevManagerLib/modelCDMProject.h @@ -47,8 +47,10 @@ class modelCDMProject : public modelCDMIProjectTreeNode { public: modelCDMProject(); - modelCDMProject(const std::string& name, const std::string& path, const unsigned char& type, const int& level); - ~modelCDMProject(){} + modelCDMProject(const std::string& path, const std::string& buildPath = ""); + ~modelCDMProject(); + + void PopulateProject(); const std::string& GetName() const; const std::string& GetVersion() const; @@ -85,7 +87,7 @@ public: const std::string& description = "no description" ); bool OpenCMakeListsFile(std::string*& result); - bool Refresh(std::string*& result); + virtual const bool Refresh(std::string*& result); bool ConfigureBuild(std::string*& result); bool Build(std::string*& result); bool Connect(std::string*& result); diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index d60b317..ad645b9 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -216,6 +216,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) if(userResponse == wxID_FORWARD) { + //create project std::string* result; if(!this->model->CreateProject( crea::wx2std(dialog->GetProjectName()), @@ -227,13 +228,12 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) { wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR); } - wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION); - - //TODO: populate model - //TODO: populate tree control - //tree_Projects->BuildTree(this->model->GetActiveProjects()); + //populate tree control + tree_Projects->BuildTree(this->model->GetProject()); auiManager.Update(); + + wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION); } event.Skip(); @@ -242,24 +242,25 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) { long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style); - long userResponse; - userResponse = FD->ShowModal(); + long userResponse = FD->ShowModal(); if(userResponse == wxID_OK) { - std::cout << "Selection to open: " << crea::wx2std (FD->GetPath()) << std::endl; std::string path = crea::wx2std (FD->GetPath()); + FD -> Destroy(); + FD = NULL; + + std::cout << "Selection to open: " << path << std::endl; + + //populate model std::string* result; if (!this->model->OpenProject(path, result)) { wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR); - event.Skip(); }; - //TODO: populate model - //TODO: populate tree control - - //((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects()); + //populate tree control + tree_Projects->BuildTree(this->model->GetProject()); auiManager.Update(); } diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx index 5ba578e..8337e48 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx @@ -23,7 +23,7 @@ # 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. # ------------------------------------------------------------------------ -*/ + */ /* @@ -70,32 +70,42 @@ bool wxCDMProjectsTreeCtrl::Create( return TRUE; } -void wxCDMProjectsTreeCtrl::BuildTree(const modelCDMProjectsTree& projectsTree) +void wxCDMProjectsTreeCtrl::BuildTree(modelCDMProject* projectTree) { - this->DeleteAllItems(); - wxTreeItemId rootIndex = this-> AddRoot(_("Open Projects")); - std::cout << "Building TreeCtrl for " << projectsTree.projectRoot.GetName() << std::endl; - wxTreeItemId parentIndex = this-> AppendItem(rootIndex, wxString(projectsTree.projectRoot.GetName().c_str(), wxConvUTF8)); - this->BuildTree(projectsTree.projectRoot.GetChildren(), parentIndex); + if(projectTree != NULL) + { + this->DeleteAllItems(); + wxTreeItemId rootIndex; + rootIndex= this-> AddRoot(crea::std2wx(projectTree->GetName())); + projectTree->SetId(rootIndex); - this->Expand(rootIndex); + std::cout << "Building TreeCtrl for " << projectTree->GetName() << std::endl; + this->BuildTree(projectTree->GetChildren(), rootIndex); - this->Update(); + this->Expand(rootIndex); + + this->Update(); + } } -void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& projectsTree, wxTreeItemId parent) +void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, wxTreeItemId parent) { - for (int i = 0; i < projectsTree.size(); i++) - { - //cout << projectsTree[i].GetName() << endl; - wxTreeItemId parentNodeIndex; - wxString nodeName((projectsTree[i].GetName()).c_str(), wxConvUTF8); - parentNodeIndex = this->AppendItem(parent, nodeName); - - std::vector innerChildren = projectsTree[i].GetChildren(); - if(innerChildren.size() > 0) + for (int i = 0; i < treeNodes.size(); i++) { - this->BuildTree(innerChildren, parentNodeIndex); + //cout << projectsTree[i].GetName() << endl; + wxTreeItemId parentNodeIndex; + if(treeNodes[i] != NULL) + { + wxString nodeName((treeNodes[i]->GetName()).c_str(), wxConvUTF8); + parentNodeIndex = this->AppendItem(parent, nodeName); + treeNodes[i]->SetId(parentNodeIndex); + + std::vector innerChildren = treeNodes[i]->GetChildren(); + if(innerChildren.size() > 0) + { + this->BuildTree(innerChildren, parentNodeIndex); + } + } + } - } } diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h index cb5fbda..7cf0887 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h @@ -38,7 +38,8 @@ #include #include -#include "modelCDMProjectsTree.h" +#include "modelCDMProject.h" +#include "modelCDMIProjectTreeNode.h" #include @@ -65,9 +66,9 @@ public: const wxString &name=_("Projects tree") ); - void BuildTree(const modelCDMProjectsTree& tree); + void BuildTree(modelCDMProject* tree = NULL); private: - void BuildTree(const std::vector& tree, wxTreeItemId parent); + void BuildTree(const std::vector& tree, wxTreeItemId parent); }; #endif /* WXCDMPROJECTSTREECTRL_H_ */