]> Creatis software - crea.git/commitdiff
Black Box view and folder structure implemented
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 21 Dec 2012 13:51:26 +0000 (14:51 +0100)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 21 Dec 2012 13:51:26 +0000 (14:51 +0100)
still doesn't create boxes

16 files changed:
lib/creaDevManagerLib/creaDevManagerIds.h
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMBlackBox.cpp
lib/creaDevManagerLib/modelCDMBlackBox.h
lib/creaDevManagerLib/modelCDMPackage.cpp
lib/creaDevManagerLib/modelCDMPackage.h
lib/creaDevManagerLib/modelCDMPackageSrc.cpp [new file with mode: 0644]
lib/creaDevManagerLib/modelCDMPackageSrc.h [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMNewPackageDialog.cpp
lib/creaDevManagerLib/wxCDMNewPackageDialog.h
lib/creaDevManagerLib/wxCDMNewProjectDialog.cpp
lib/creaDevManagerLib/wxCDMNewProjectDialog.h
lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp

index ab662fa0d3d79f84cc9b655107ea9a9cfef907cf..fe1b1a0ca662e4512b3380e59883a3786594396f 100644 (file)
 #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_ */
index ebd4de0170deefe08dd3e8d453bf5739a1325c44..e35a9c50126c7a47a0b76b23ff03ed10d94e136d 100644 (file)
@@ -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();
index 5ea4a26cbfae621fd360a674a0044f096b5b17f5..d177c88250b810f0cda829dddc451e124082363e 100644 (file)
 
 #include "modelCDMBlackBox.h"
 
+#include<fstream>
+
+#include "CDMUtilities.h"
+
 #include<creaWx.h>
 #include"wx/dir.h"
 
 modelCDMBlackBox::modelCDMBlackBox()
 {
+  this->source = NULL;
+  this->header = NULL;
 }
 
 modelCDMBlackBox::modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level)
 {
-  this->name = this->nameBlackBox = hName.substr(2, hName.size()-4);
+  this->name = hName.substr(2, hName.size()-4);
   this->path = path;
   this->level = level;
   this->type = wxDIR_DIRS;
+  this->source = NULL;
+  this->header = NULL;
+
+  std::string pathHeader = path + "/" + "bb" + this->name + ".h";
+
+  std::ifstream confFile;
+  confFile.open((pathHeader).c_str());
+  std::string word;
+  while(confFile.is_open() && !confFile.eof())
+    {
+      //get BBTK's
+      std::getline(confFile,word,'(');
+      std::vector<std::string> wordBits;
+      CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
+
+      if(wordBits[wordBits.size()-1] == "BBTK_NAME")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->nameBlackBox = word;
+        }
+      else if(wordBits[wordBits.size()-1] == "BBTK_AUTHOR")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->authors = word;
+        }
+      else if(wordBits[wordBits.size()-1] == "BBTK_DESCRIPTION")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->description = word;
+        }
+      else if(wordBits[wordBits.size()-1] == "BBTK_CATEGORY")
+        {
+          std::getline(confFile,word,'"');
+          std::getline(confFile,word,'"');
+          this->categories = word;
+          if (this->categories == "")
+            this->categories = "empty";
+        }
+    }
+  confFile.close();
+
 }
 
 modelCDMBlackBox::~modelCDMBlackBox()
@@ -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<std::string> words;
+  CDMUtilities::splitter::split(words, authors, ",\"\n", CDMUtilities::splitter::no_empties);
+  std::string authorsReal = words[0];
+  for (int i = 1; i < words.size(); i++)
+    {
+      authorsReal += "/" + words[i];
+    }
 
-bool modelCDMBlackBox::SetAuthorsEmail(
-    const std::string& email,
-    std::string*& result
-)
-{
-  //TODO: implement method
+  //opening original header
+  std::string pathHeader = this->header->GetPath();
+  std::ifstream in(pathHeader.c_str());
+  if( !in.is_open())
+    {
+      result = new std::string(pathHeader + " file failed to open.");
+      return false;
+    }
+  //opening temporal header
+  std::ofstream out((pathHeader + ".tmp").c_str());
+  if( !out.is_open())
+    {
+      result = new std::string(pathHeader + ".tmp file failed to open.");
+      return false;
+    }
+  //copying contents from original to temporal and making changes
+  std::string reading;
+  while (getline(in, reading, '('))
+    {
+      CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
+      if(words[words.size() - 1] == "BBTK_AUTHOR")
+        {
+          out << reading << "(\"" << authorsReal << "\")";
+          getline(in, reading, ')');
+        }
+      else
+        {
+          out << reading;
+          if (!in.eof())
+            out << "(";
+        }
+    }
+  in.close();
+  out.close();
+  //delete old file and rename new file
+  std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+  if(system(renameCommand.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + renameCommand + "'.");
+      return false;
+    }
+
+  this->authors = authorsReal;
   return true;
+
 }
 
 bool modelCDMBlackBox::SetCategories(
-    const std::string& version,
+    const std::string& categories,
     std::string*& result
 )
 {
-  //TODO: implement method
-  return true;
+  std::vector<std::string> words;
+    CDMUtilities::splitter::split(words, categories, "\"", CDMUtilities::splitter::no_empties);
+    std::string catsReal = words[0];
+    for (int i = 1; i < words.size(); i++)
+      {
+        catsReal += "-" + words[i];
+      }
+
+    //opening original header
+    std::string pathHeader = this->header->GetPath();
+    std::ifstream in(pathHeader.c_str());
+    if( !in.is_open())
+      {
+        result = new std::string(pathHeader + " file failed to open.");
+        return false;
+      }
+    //opening temporal header
+    std::ofstream out((pathHeader + ".tmp").c_str());
+    if( !out.is_open())
+      {
+        result = new std::string(pathHeader + ".tmp file failed to open.");
+        return false;
+      }
+    //copying contents from original to temporal and making changes
+    std::string reading;
+    while (getline(in, reading, '('))
+      {
+        CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
+        if(words[words.size() - 1] == "BBTK_CATEGORY")
+          {
+            out << reading << "(\"" << catsReal << "\")";
+            getline(in, reading, ')');
+          }
+        else
+          {
+            out << reading;
+            if (!in.eof())
+              out << "(";
+          }
+      }
+    in.close();
+    out.close();
+    //delete old file and rename new file
+    std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+    if(system(renameCommand.c_str()))
+      {
+        result = new std::string("An error occurred while running '" + renameCommand + "'.");
+        return false;
+      }
+
+    this->categories = catsReal;
+    return true;
 }
 
 bool modelCDMBlackBox::SetDescription(
@@ -112,26 +244,88 @@ bool modelCDMBlackBox::SetDescription(
     std::string*& result
 )
 {
-  //TODO: implement method
+  std::vector<std::string> words;
+  CDMUtilities::splitter::split(words, description, "\"", CDMUtilities::splitter::no_empties);
+  std::string descReal = words[0];
+  for (int i = 1; i < words.size(); i++)
+    {
+      descReal += "\\\"" + words[i];
+    }
+
+  //opening original header
+  std::string pathHeader = this->header->GetPath();
+  std::ifstream in(pathHeader.c_str());
+  if( !in.is_open())
+    {
+      result = new std::string(pathHeader + " file failed to open.");
+      return false;
+    }
+  //opening temporal header
+  std::ofstream out((pathHeader + ".tmp").c_str());
+  if( !out.is_open())
+    {
+      result = new std::string(pathHeader + ".tmp file failed to open.");
+      return false;
+    }
+  //copying contents from original to temporal and making changes
+  std::string reading;
+  while (getline(in, reading, '('))
+    {
+      CDMUtilities::splitter::split(words, reading, "\n ", CDMUtilities::splitter::no_empties);
+      if(words[words.size() - 1] == "BBTK_DESCRIPTION")
+        {
+          out << reading << "(\"" << descReal << "\")";
+          getline(in, reading, ')');
+        }
+      else
+        {
+          out << reading;
+          if (!in.eof())
+            out << "(";
+        }
+    }
+  in.close();
+  out.close();
+  //delete old file and rename new file
+  std::string renameCommand = "mv " + pathHeader + ".tmp " + pathHeader;
+  if(system(renameCommand.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + renameCommand + "'.");
+      return false;
+    }
+
+  this->description = descReal;
   return true;
 }
 
-bool modelCDMBlackBox::SetVersion(const std::string& version, std::string*& result)
+void modelCDMBlackBox::SetHeaderFile(modelCDMFile* file)
 {
-  //TODO: implement method
-    return true;
+  this->header = file;
+}
+
+void modelCDMBlackBox::SetSourceFile(modelCDMFile* file)
+{
+  this->source = file;
 }
 
 bool modelCDMBlackBox::OpenCxx(std::string*& result)
 {
-  //TODO: implement method
-  return true;
+  return !CDMUtilities::openTextEditor(this->source->GetPath());
 }
 
 bool modelCDMBlackBox::OpenHxx(std::string*& result)
 {
-  //TODO: implement method
-  return true;
+  return !CDMUtilities::openTextEditor(this->header->GetPath());
+}
+
+modelCDMFile* modelCDMBlackBox::GetHeaderFile() const
+{
+  return this->header;
+}
+
+modelCDMFile* modelCDMBlackBox::GetSourceFile() const
+{
+  return this->source;
 }
 
 const bool modelCDMBlackBox::Refresh(std::string*& result)
index f3d986a7ba4519b204b6e687a81f8f17e415c0da..e1021b82b70eea66b164867820ef2ea07b4f3d28 100644 (file)
@@ -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_ */
index 82a514c3f0d354d32af72758108fd201ad364dad..097c360c11265b9db3b73dcbfae25cf744925516 100644 (file)
@@ -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<modelCDMBlackBox*>& 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<bool> checked(this->children.size(), false);
-  std::vector<bool> checkedBlackBoxes(this->blackBoxes.size(), false);
+  bool checkedSrc = false;
 
   //check all folders
   wxDir dir(crea::std2wx((this->path).c_str()));
@@ -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])
index 632b2ef768e88d000eca07b3949b9a896d52edc5..d79db954decff87a9da28034772a1bc2cfa13167 100644 (file)
@@ -39,7 +39,7 @@
 #include<vector>
 
 #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<modelCDMBlackBox*>& 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<modelCDMBlackBox*> blackBoxes;
+  modelCDMPackageSrc* src;
 
 };
 
diff --git a/lib/creaDevManagerLib/modelCDMPackageSrc.cpp b/lib/creaDevManagerLib/modelCDMPackageSrc.cpp
new file mode 100644 (file)
index 0000000..b758cc4
--- /dev/null
@@ -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 <fstream>
+#include <algorithm>
+
+#include <creaWx.h>
+#include <wx/dir.h>
+
+#include "CDMUtilities.h"
+
+modelCDMPackageSrc::modelCDMPackageSrc()
+{
+  this->CMakeLists = NULL;
+}
+
+modelCDMPackageSrc::modelCDMPackageSrc(const std::string& path, const int& level)
+{
+  //set attributes
+  this->children.clear();
+  this->level = level;
+  this->CMakeLists = NULL;
+  this->length = 0;
+  this->name = "src";
+  this->path = CDMUtilities::fixPath(path);
+  this->type = wxDIR_DIRS;
+
+  //check all folders
+  wxDir dir(crea::std2wx(path));
+  if (dir.IsOpened())
+    {
+      wxString fileName;
+      bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+
+          //if is an unknown folder, create folder
+          this->children.push_back(new modelCDMFolder(path + "/" + stdfileName, this->level + 1));
+
+          cont = dir.GetNext(&fileName);
+        }
+
+      cont = dir.GetFirst(&fileName, wxT("CMakeLists.txt"), wxDIR_FILES);
+      if (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+          this->CMakeLists = new modelCDMCMakeListsFile(path + "/" + stdfileName, this->level + 1);
+          this->children.push_back(this->CMakeLists);
+        }
+
+      cont = dir.GetFirst(&fileName, wxT("*.h"), wxDIR_FILES);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+          modelCDMFile* file;
+
+          if(stdfileName.substr(0,2) == "bb")
+            {
+              file = new modelCDMFile(path + "/" + stdfileName, this->level + 1);
+              this->children.push_back(file);
+              modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path, level + 1);
+              blackBox->SetHeaderFile(file);
+              cont = dir.GetFirst(&fileName, crea::std2wx(stdfileName.substr(0,stdfileName.size()-2) + ".cxx"), wxDIR_FILES);
+              if (cont)
+                {
+                  file = new modelCDMFile(path + "/" + crea::wx2std(fileName), this->level + 1);
+                  this->children.push_back(file);
+                  blackBox->SetSourceFile(file);
+                }
+              this->blackBoxes.push_back(blackBox);
+            }
+          cont = dir.GetNext(&fileName);
+        }
+    }
+
+  this->SortChildren();
+}
+
+modelCDMPackageSrc::~modelCDMPackageSrc()
+{
+  for (int i = 0; i < this->blackBoxes.size(); i++)
+    {
+      if(this->blackBoxes[i] != NULL)
+        {
+          delete this->blackBoxes[i];
+          this->blackBoxes[i] = NULL;
+        }
+    }
+  this->blackBoxes.clear();
+}
+
+const std::vector<modelCDMBlackBox*>& modelCDMPackageSrc::GetBlackBoxes() const
+{
+  return this->blackBoxes;
+}
+
+const bool modelCDMPackageSrc::Refresh(std::string*& result)
+{
+  //set attributes
+  this->type = wxDIR_DIRS;
+
+  //check children
+  std::vector<bool> checked(this->children.size(), false);
+  std::vector<bool> checkedBoxes(this->blackBoxes.size(), false);
+
+  //check all boxes
+  wxDir dir(crea::std2wx((this->path).c_str()));
+  if (dir.IsOpened())
+    {
+      wxString fileName;
+      bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+          std::string folderName = stdfileName;
+          //check if they already exist
+          bool found = false;
+          for (int i = 0;!found && i < this->children.size(); i++)
+            {
+              if (this->children[i]->GetName() == folderName)
+                {
+                  found = true;
+                  checked[i] = true;
+                  if(!this->children[i]->Refresh(result))
+                    return false;
+                }
+            }
+          if(!found)
+            {
+              modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+              this->children.push_back(folder);
+            }
+          cont = dir.GetNext(&fileName);
+        }
+
+      cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+
+          //if CMakeLists, create CMakeLists
+          if(stdfileName == "CMakeLists.txt")
+            {
+              if (this->CMakeLists == NULL)
+                {
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->children.push_back(this->CMakeLists);
+                }
+              else
+                {
+                  int pos = std::find(this->children.begin(), this->children.end(), this->CMakeLists) - this->children.begin();
+                  checked[pos] = true;
+                  if(!this->CMakeLists->Refresh(result))
+                    return false;
+                }
+            }
+          //if is an unknown file, create file
+          else
+            {
+              bool found = false;
+              for (int i = 0; i <!found && this->children.size(); i++)
+                {
+                  if (this->children[i]->GetName() == stdfileName)
+                    {
+                      found = true;
+                      checked[i] = true;
+                      if(!this->children[i]->Refresh(result))
+                        return false;
+                    }
+                }
+
+              if(!found)
+                {
+                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->children.push_back(file);
+                }
+            }
+
+          //if is a Black Box header, check in black boxes
+          if(stdfileName.substr(stdfileName.size() - 2, 2) == ".h" && stdfileName.substr(0,2) == "bb")
+            {
+              bool found = false;
+              for (int i = 0; i < this->blackBoxes.size(); i++)
+                {
+                  if(this->blackBoxes[i]->GetHeaderFile()->GetName() == stdfileName)
+                    {
+                      checkedBoxes[i] = true;
+                      found = true;
+                      if(!this->blackBoxes[i]->Refresh(result))
+                        return false;
+                      break;
+                    }
+                }
+
+              if (!found)
+                {
+                  modelCDMBlackBox* blackBox = new modelCDMBlackBox(stdfileName, path + "/" + stdfileName, level + 1);
+                  this->blackBoxes.push_back(blackBox);
+                }
+
+            }
+
+          cont = dir.GetNext(&fileName);
+        }
+    }
+
+  for (int i = 0; i < checkedBoxes.size(); i++)
+    {
+      if(!checkedBoxes[i])
+        {
+          delete this->blackBoxes[i];
+          this->blackBoxes.erase(this->blackBoxes.begin()+i);
+          checkedBoxes.erase(checkedBoxes.begin()+i);
+          i--;
+        }
+    }
+
+  for (int i = 0; i < checked.size(); i++)
+    {
+      if(!checked[i])
+        {
+          delete this->children[i];
+          this->children.erase(this->children.begin()+i);
+          checked.erase(checked.begin()+i);
+          i--;
+        }
+    }
+  this->SortChildren();
+  return true;
+}
diff --git a/lib/creaDevManagerLib/modelCDMPackageSrc.h b/lib/creaDevManagerLib/modelCDMPackageSrc.h
new file mode 100644 (file)
index 0000000..14de2d7
--- /dev/null
@@ -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<iostream>
+#include<vector>
+
+#include "modelCDMFolder.h"
+#include "modelCDMBlackBox.h"
+
+class modelCDMPackageSrc : public modelCDMFolder
+{
+public:
+  modelCDMPackageSrc();
+  modelCDMPackageSrc(const std::string& path, const int& level = 3);
+  ~modelCDMPackageSrc();
+
+  const std::vector<modelCDMBlackBox*>& GetBlackBoxes() const;
+
+  virtual const bool Refresh(std::string*& result);
+
+private:
+  std::vector<modelCDMBlackBox*> blackBoxes;
+
+};
+
+#endif /* MODELCDMPACKAGESRC_H_ */
index b53d919c2c6e1ede37a550a25a4004dbf79562cd..d972925ac645b2de5e84b3eea9b2c9226e46aae7 100644 (file)
@@ -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);
 }
index eb32dc1ab1dedf32fb55e29d452e5318b02e2710..c4be2fb6076593d369b8d5579d61ae676df473d2 100644 (file)
@@ -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);
index 414d88b2791d24f16a586cf98e09791e4b54484e..ed3b6de98c8dd075705a8255d8b84b3ef2c9e308 100755 (executable)
@@ -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);
index 8b0efff932578fdb5fdba80923b68b9761d20929..f648d6579c07603cc3aa0fbf7c42e3a8c95cca63 100644 (file)
@@ -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)
index 1c76552d73a7126a1f76a5e21db03735e0716fe5..1f0e55f84c6c3d513f4eb5ae545106d691f80df9 100644 (file)
@@ -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
   );
 
index e0ad6d437bd4c23ec3d25a2599002928d358fdac..c3066a79be64f2741c28682a0db193f2d8cecca0 100644 (file)
@@ -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)
index ce99eab10831ad25258679ae824a645f60f2ef65..22dec24e9d4a303b19f78d1c4c9bb667511fc47b 100644 (file)
@@ -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
   );
 
index 99367d7eeb3487a1392295d71317439538e2d2d0..4411c9eeb5cc9963864c7c8e4090aa35b64cd413 100644 (file)
@@ -160,15 +160,21 @@ void wxCDMPackageDescriptionPanel::CreateControls()
   wxPanel* BBPanel = new wxPanel(this);
   wxBoxSizer* BBPanelSizer = new wxBoxSizer(wxVERTICAL);
 
-  std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetBlackBoxes();
+
+  std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < blackBoxes.size(); i++)
     {
-      wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str()));
-      std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories();
-      pBBlk->SetToolTip(crea::std2wx(tt));
-      pBBlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseEnter,NULL,this);
-      pBBlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseExit,NULL,this);
-      BBPanelSizer -> Add(pBBlk, 0, wxALIGN_LEFT | wxALL, 5);
+
+      if(blackBoxes[i] != NULL)
+        {
+
+          wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str()));
+          std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories();
+          pBBlk->SetToolTip(crea::std2wx(tt));
+          pBBlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseEnter,NULL,this);
+          pBBlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseExit,NULL,this);
+          BBPanelSizer -> Add(pBBlk, 0, wxALIGN_LEFT | wxALL, 5);
+        }
     }
 
   BBPanel->SetSizer(BBPanelSizer);
@@ -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<modelCDMBlackBox*> bbs = this->package->GetBlackBoxes();
+  modelCDMBlackBox* bb;
+  std::vector<modelCDMBlackBox*> bbs = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < bbs.size(); i++)
     {
       if(bbs[i]->GetName() == crea::wx2std(event.GetURL()))
         {
-          bbId = bbs[i]->GetId();
+          bbId = bbs[i]->GetHeaderFile()->GetId();
+          bb = bbs[i];
           break;
         }
     }
 
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
-  newEvent->SetInt(bbId);
-  newEvent->SetId(0);
+  newEvent->SetClientData(bb);
+  newEvent->SetId(1);
+  newEvent->SetString(wxT("blackbox"));
   wxPostEvent(this->GetParent(), *newEvent);
 
   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
@@ -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<modelCDMBlackBox*> boxes = this->package->GetBlackBoxes();
+  std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < boxes.size(); i++)
     {
       if(boxes[i]->GetName() == BBName)
         {
-          bbId = boxes[i]->GetId();
+          bbId = boxes[i]->GetHeaderFile()->GetId();
           break;
         }
     }
@@ -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<modelCDMBlackBox*> boxes = this->package->GetBlackBoxes();
+  std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < boxes.size(); i++)
     {
       if(boxes[i]->GetName() == BBName)
         {
-          bbId = boxes[i]->GetId();
+          bbId = boxes[i]->GetHeaderFile()->GetId();
           break;
         }
     }