]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel@daniel.creatis>
Mon, 26 Nov 2012 19:11:51 +0000 (20:11 +0100)
committerDaniel Gonzalez <daniel@daniel.creatis>
Mon, 26 Nov 2012 19:11:51 +0000 (20:11 +0100)
CreaDevManager application implementation

New Project and open project implemented

21 files changed:
lib/creaDevManagerLib/ControlCreaDevManagerProject.cpp [deleted file]
lib/creaDevManagerLib/ControlCreaDevManagerProject.h [deleted file]
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMAppli.h
lib/creaDevManagerLib/modelCDMApplication.cpp
lib/creaDevManagerLib/modelCDMApplication.h
lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp [new file with mode: 0644]
lib/creaDevManagerLib/modelCDMIProjectTreeNode.h
lib/creaDevManagerLib/modelCDMLib.cpp
lib/creaDevManagerLib/modelCDMLib.h
lib/creaDevManagerLib/modelCDMLibrary.cpp
lib/creaDevManagerLib/modelCDMLibrary.h
lib/creaDevManagerLib/modelCDMMain.cpp
lib/creaDevManagerLib/modelCDMMain.h
lib/creaDevManagerLib/modelCDMPackage.cpp
lib/creaDevManagerLib/modelCDMPackage.h
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/modelCDMProject.h
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h

diff --git a/lib/creaDevManagerLib/ControlCreaDevManagerProject.cpp b/lib/creaDevManagerLib/ControlCreaDevManagerProject.cpp
deleted file mode 100644 (file)
index cc66abe..0000000
+++ /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 <creaWx.h>
-#include <wx/dirdlg.h>
-#include <stdlib.h> // 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 (file)
index ca4f8d0..0000000
+++ /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 <iostream>
-
-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_ */
index ee7edc1d54851f82279ce5cb791bbda2d7f820b0..002a38e5c9b0646b155cbec02688e59075743103 100644 (file)
@@ -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;
index 569fdb1e8a64f98d8733780b2016a19a947f2360..00f4d663e985ca9bede8055a68165622a80f1a95 100644 (file)
@@ -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<modelCDMApplication*> applications;
index c1e715e491db6b5efd204164be24f172293236ce..d87ec7543c5fda1ba8bbfb47810b2b68c780b8df 100644 (file)
@@ -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;
index a878c35d75ff1a0198276ef3f9f70cf2b6b88680..b2ad4a8032d6f0b732220d9e5ebc25ec28dbc922 100644 (file)
@@ -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 (file)
index 0000000..8026b41
--- /dev/null
@@ -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*>& modelCDMIProjectTreeNode::GetChildren() const
+{
+  return this->children;
+}
+
+void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id)
+{
+  this->id = id;
+}
+
+void modelCDMIProjectTreeNode::SetChildren(
+    const std::vector<modelCDMIProjectTreeNode*>& 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;
+}
index 4d06cb6209774713a9bdfc5f4954543841d0db8f..b74c6f11ccdbac6baaf6c19683f3ec73ff418df5 100644 (file)
 
 #include <iostream>
 #include <vector>
+#include <creaWx.h>
+#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<modelCDMIProjectTreeNode*>& GetChildren() const;
+  void SetId(const wxTreeItemId& id);
   void SetChildren(const std::vector<modelCDMIProjectTreeNode*>& 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;
index d22a6fee5f86ff6bfe4c0d5fd37bd0dbb5567d01..e8a4ac9b45270d602f0043e919aff5fded02c1ef 100644 (file)
@@ -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;
index 520822f09ab47d5b842bc80c923a98d1aa613586..2a7e16459b265953eef96c0c8c7b3cff77e76285 100644 (file)
@@ -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<modelCDMLibrary*> libraries;
index 7bf7373dd48163fd4562f3e61291493648bc6731..d3de6c00ce4f3263688150a5508a88831a5a9453 100644 (file)
@@ -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;
index 64ae1f863265189cc2d34d462dc141431041d144..4c7fdad33c8ac0de95fbe89b0de83497b7b7bb97 100644 (file)
@@ -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;
index e9df13ed38242c21fced54e9a490bdf032ea6ea5..25331dc7c1d1403dda1ee3cddbf04ad81a348438 100644 (file)
 #include <fstream>
 
 #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<std::string> 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;
 }
 
index 6a104704912fcd57bd2a7413ff27db38550be98d..83d86acaf4a3252a83a84d7045c05b989519eaaf 100644 (file)
@@ -45,7 +45,7 @@ public:
   modelCDMMain();
   ~modelCDMMain();
 
-  const modelCDMProject* GetProject() const;
+  modelCDMProject* GetProject() const;
 
   bool CreateProject(
       const std::string& name,
index 681c5a4369a54f344371ca10a7826cd12c4318e3..8d33e17c72b2c742c53838dee3ea39bf6073ac45 100644 (file)
@@ -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;
index b6202b54989183d840358c1e9ed9f6bb6521e6e7..5af92109b50611d289ab2c1f78c324c75633565a 100644 (file)
@@ -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;
index b7a0747506bd7ae94e456ce8b0a873bb66b1933c..25bba8d0b34c3838c5cea47dcc8b342cb93a8807 100644 (file)
 
 #include "modelCDMProject.h"
 
+#include <iostream>
+#include <vector>
+#include <fstream>
+
+#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<std::string> wordBits;
+      CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties);
+
+      if(wordBits[wordBits.size()-1] == "PROJECT")
+        {
+          std::getline(confFile,word,')');
+          std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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;
index 604cea59c5e6ee6ec432ed8d2a229b5539be8b99..059b6c408fd3acbe3c15f5c25e731409fc6c86b1 100644 (file)
@@ -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);
index d60b3173dc21433c11ce50cb26bd9f6e56fec003..ad645b9bffed49b1505e2a134fb2f13c0161d243 100755 (executable)
@@ -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();
     }
 
index 5ba578e77c5bbbb46d0aa872933cb6bccca3b850..8337e48c35da386e7f1e4989a2936d166fbcf3b4 100755 (executable)
@@ -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<modelCDMProjectsTreeNode>& projectsTree, wxTreeItemId parent)
+void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& 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<modelCDMProjectsTreeNode> 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<modelCDMIProjectTreeNode*> innerChildren = treeNodes[i]->GetChildren();
+          if(innerChildren.size() > 0)
+            {
+              this->BuildTree(innerChildren, parentNodeIndex);
+            }
+        }
+
     }
-  }
 }
index cb5fbda6d06806d8c81f47cd3b4454746a4cf269..7cf0887ca9d8e2d8197755c22b3d706348a8aec9 100755 (executable)
@@ -38,7 +38,8 @@
 
 #include <creaWx.h>
 #include <wx/treectrl.h>
-#include "modelCDMProjectsTree.h"
+#include "modelCDMProject.h"
+#include "modelCDMIProjectTreeNode.h"
 
 #include <vector>
 
@@ -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<modelCDMProjectsTreeNode>& tree, wxTreeItemId parent);
+  void BuildTree(const std::vector<modelCDMIProjectTreeNode*>& tree, wxTreeItemId parent);
 };
 
 #endif /* WXCDMPROJECTSTREECTRL_H_ */