]> Creatis software - crea.git/commitdiff
Feature #1711 CreaDevManager application implementation
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 5 Apr 2013 15:09:44 +0000 (17:09 +0200)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 5 Apr 2013 15:09:44 +0000 (17:09 +0200)
Feature: Auto include in corresponding CMakeLists files when creating: Libraries, Applications, Packages.
Feature: Checkboxes to include in CMakeLists files for: Libraries, Application, Packages.

13 files changed:
lib/creaDevManagerLib/creaDevManagerIds.h
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMAppli.h
lib/creaDevManagerLib/modelCDMLib.cpp
lib/creaDevManagerLib/modelCDMLib.h
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/modelCDMProject.h
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h
lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp
lib/creaDevManagerLib/wxCDMPackageManagerPanel.h

index a73f569ac6ddf63120ad0792b03a7e711c054f44..2bf0dba68bb356634ad3f33818fb9ed226182fc2 100644 (file)
 #define ID_LINK_SELECT_APPLICATION      10332
 #define ID_LINK_SELECT_BLACKBOX         10333
 
-#define ID_CHECKBOX_ENABLE_HELP         10334
-#define ID_CHECKBOX_DISABLE_HELP        10335
-#define ID_CHECKBOX_TOGGLE_HELP         10335
+#define ID_CHECK_INCLUDE_LIBRARY        10334
+#define ID_CHECK_INCLUDE_PACKAGE        10335
+#define ID_CHECK_INCLUDE_APPLICATION    10336
 
-#define ID_BUTTON_CHECK_PROJECT         10336
+#define ID_CHECKBOX_ENABLE_HELP         10337
+#define ID_CHECKBOX_DISABLE_HELP        10338
+#define ID_CHECKBOX_TOGGLE_HELP         10339
+
+#define ID_BUTTON_CHECK_PROJECT         10340
 
 #endif /* CREADEVMANAGERIDS_H_ */
index bcb0876ae6fcef9063820a0f535a8206ecb3875a..62d02a9c0191fdcf0276644de409673479924388 100644 (file)
@@ -183,6 +183,14 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
           return NULL;
         }
 
+      //add application to appli CMakeLists
+      std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+      if (out1.is_open())
+        {
+          out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+          out1.close();
+        }
+
       //add application to model
       modelCDMApplication* application = new modelCDMApplication(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
       this->applications.push_back(application);
@@ -237,6 +245,14 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
           return NULL;
         }
 
+      //add application to appli CMakeLists
+      std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+      if (out1.is_open())
+        {
+          out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+          out1.close();
+        }
+
       //add application to model
       modelCDMApplication* application = new modelCDMApplication(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
       this->applications.push_back(application);
@@ -467,3 +483,118 @@ void modelCDMAppli::CheckStructure(std::map<std::string, bool>& properties)
       this->applications[i]->CheckStructure(properties);
     }
 }
+
+bool modelCDMAppli::IsApplicationIncluded(const std::string& application_name)
+{
+  if(this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::string line;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line);
+              while(line[0]==' ')
+                line.erase(0);
+              if(line[0] != '#')
+                {
+                  std::vector<std::string> lineSeg;
+                  CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+                  if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == application_name)
+                    {
+                      CMFile.close();
+                      return true;
+                    }
+                }
+            }
+          CMFile.close();
+        }
+    }
+  return false;
+}
+
+bool modelCDMAppli::SetApplicationInclude(const std::string& application_name, const bool& toInclude)
+{
+  if (this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::stringstream outs;
+          std::string line;
+          bool found = false;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line);
+              if(line != "")
+                {
+                  std::vector<std::string> segs;
+                  CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+                  //is comment
+                  if(segs.size() > 0 && segs[0][0] == '#')
+                    {
+                      if(toInclude)
+                        {
+                          CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == application_name)
+                            {
+                              found = true;
+                              outs << "ADD_SUBDIRECTORY(" << application_name << ")\n";
+                            }
+                          else
+                            outs << line << "\n";
+                        }
+                      else
+                        {
+                          outs << line << "\n";
+                        }
+                    }
+                  //is not comment
+                  else
+                    {
+                      if (segs.size() > 0 && !toInclude)
+                        {
+                          CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == application_name)
+                            {
+                              outs << "#" << line << "\n";
+                            }
+                          else
+                            {
+                              outs << line << "\n";
+                            }
+                        }
+                      else
+                        {
+                          CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == application_name)
+                            {
+                              found = true;
+                            }
+                          outs << line << "\n";
+                        }
+                    }
+                }
+              else
+                {
+                  outs << "\n";
+                }
+            }
+
+          CMFile.close();
+
+          if(!found && toInclude)
+            outs << "ADD_SUBDIRECTORY(" << application_name << ")\n";
+
+          std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+          if (CMFileOut.is_open())
+            {
+              CMFileOut << outs.rdbuf();
+              CMFileOut.close();
+              return true;
+            }
+        }
+    }
+  return false;
+}
index 579f12a2105e859710a5898c6e6cda0b783466ce..c3bce223b4798b2dc0a6c4c9efc22ca656783ca5 100644 (file)
@@ -72,7 +72,7 @@ public:
   const std::vector<modelCDMApplication*>& GetApplications() const;
 
   /**
-   * Creates a new application in the system and creates an application node. This node is stored in the applications attribute and returned.
+   * Creates a new application in the system and creates an application node. This node is stored in the applications attribute and returned. The created application is included in the appli's CMakeLists file.
    * @param name Name of the new application.
    * @param type 0=console application, 1=GUI Application (wxWidgets).
    * @param result Result message of the operation.
@@ -96,6 +96,21 @@ public:
    */
   void CheckStructure(std::map<std::string, bool>& properties);
 
+  /**
+   * Checks if the given application is included in the CMakeLists file.
+   * @param application_name Name of the library to check.
+   * @return True if the library is included, otherwise returns False.
+   */
+  bool IsApplicationIncluded(const std::string& application_name);
+
+  /**
+   * Sets the inclusion of the application in the lib's CMakeLists file. If the application inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the application inclusion doesn't exist yet, then it is included if the request is an inclusion.
+   * @param application_name Name of the application to include/exclude.
+   * @param toInclude True if the request is an inclusion, False otherwise.
+   * @return True if the request was processed successfully.
+   */
+  bool SetApplicationInclude(const std::string& application_name, const bool& toInclude);
+
 private:
   /**
    * application in the appli folder node.
index e3c29023fffc04797962496f86d7f948d1fb2a00..69bfcff7d3f92a023c8c8590bdf341b39ecf7ccc 100644 (file)
@@ -177,6 +177,15 @@ modelCDMLibrary* modelCDMLib::CreateLibrary(
       return NULL;
     }
 
+  //add library to lib CMakeLists
+  std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+  if (out1.is_open())
+    {
+      out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+      out1.close();
+    }
+
+
   //add library to model
   modelCDMLibrary* library = new modelCDMLibrary(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
   this->libraries.push_back(library);
@@ -398,3 +407,118 @@ void modelCDMLib::CheckStructure(std::map<std::string, bool>& properties)
       this->libraries[i]->CheckStructure(properties);
     }
 }
+
+bool modelCDMLib::IsLibraryIncluded(const std::string& library_name)
+{
+  if(this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::string line;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line);
+              while(line[0]==' ')
+                line.erase(0);
+              if(line[0] != '#')
+                {
+                  std::vector<std::string> lineSeg;
+                  CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+                  if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == library_name)
+                    {
+                      CMFile.close();
+                      return true;
+                    }
+                }
+            }
+          CMFile.close();
+        }
+    }
+  return false;
+}
+
+bool modelCDMLib::SetLibraryInclude(const std::string& library_name, const bool& toInclude)
+{
+  if (this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::stringstream outs;
+          std::string line;
+          bool found = false;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line);
+              if(line != "")
+                {
+                  std::vector<std::string> segs;
+                  CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+                  //is comment
+                  if(segs.size() > 0 && segs[0][0] == '#')
+                    {
+                      if(toInclude)
+                        {
+                          CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == library_name)
+                            {
+                              found = true;
+                              outs << "ADD_SUBDIRECTORY(" << library_name << ")\n";
+                            }
+                          else
+                            outs << line << "\n";
+                        }
+                      else
+                        {
+                          outs << line << "\n";
+                        }
+                    }
+                  //is not comment
+                  else
+                    {
+                      if (segs.size() > 0 && !toInclude)
+                        {
+                          CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == library_name)
+                            {
+                              outs << "#" << line << "\n";
+                            }
+                          else
+                            {
+                              outs << line << "\n";
+                            }
+                        }
+                      else
+                        {
+                          CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == library_name)
+                            {
+                              found = true;
+                            }
+                          outs << line << "\n";
+                        }
+                    }
+                }
+              else
+                {
+                  outs << "\n";
+                }
+            }
+
+          CMFile.close();
+
+          if(!found && toInclude)
+            outs << "ADD_SUBDIRECTORY(" << library_name << ")\n";
+
+          std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+          if (CMFileOut.is_open())
+            {
+              CMFileOut << outs.rdbuf();
+              CMFileOut.close();
+              return true;
+            }
+        }
+    }
+  return false;
+}
index e372e5f887f9455e7ed3d36e7f09e46f332eca66..d8b8c27fbf0110292d652249de370b0a29d82905 100644 (file)
@@ -72,7 +72,7 @@ public:
   const std::vector<modelCDMLibrary*>& GetLibraries() const;
 
   /**
-   * Creates a new library node for the actual project and registers it. It modifies the project model as well as the system.
+   * Creates a new library node for the actual project and registers it. It modifies the project model as well as the system. The created library is included in the lib's CMakeLists file.
    * @param name Name of the new library.
    * @param result Result message.
    * @return New library reference.
@@ -95,6 +95,21 @@ public:
    */
   void CheckStructure(std::map<std::string, bool>& properties);
 
+  /**
+   * Checks if the given library is included in the CMakeLists file.
+   * @param library_name Name of the library to check.
+   * @return True if the library is included, otherwise returns False.
+   */
+  bool IsLibraryIncluded(const std::string& library_name);
+
+  /**
+   * Sets the inclusion of the library in the lib's CMakeLists file. If the library inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the library inclusion doesn't exist yet, then it is included if the request is an inclusion.
+   * @param library_name Name of the library to include/exclude.
+   * @param toInclude True if the request is an inclusion, False otherwise.
+   * @return True if the request was processed successfully.
+   */
+  bool SetLibraryInclude(const std::string& library_name, const bool& toInclude);
+
 private:
   /**
    * Libraries references.
index aa6fdebcfe45432d06dce302ce0a4e05a4064dfe..30203265940ccf2d3f005ce0bf01035bcc19ebbd 100644 (file)
@@ -387,6 +387,14 @@ modelCDMIProjectTreeNode* modelCDMProject::CreatePackage(
       return NULL;
     }
 
+  //add library to project CMakeLists
+  std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+  if (out1.is_open())
+    {
+      out1 << "ADD_SUBDIRECTORY(bbtk_" << nameFixed << "_PKG)" << std::endl;
+      out1.close();
+    }
+
   //add library to model
   modelCDMPackage* package = new modelCDMPackage(this, this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
   this->packages.push_back(package);
@@ -1001,3 +1009,118 @@ void modelCDMProject::CheckStructure(std::map<std::string, bool>& properties)
       this->packages[i]->CheckStructure(properties);
     }
 }
+
+bool modelCDMProject::IsPackageIncluded(const std::string& package_name)
+{
+  if(this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::string line;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line);
+              while(line[0]==' ')
+                line.erase(0);
+              if(line[0] != '#')
+                {
+                  std::vector<std::string> lineSeg;
+                  CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+                  if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == package_name)
+                    {
+                      CMFile.close();
+                      return true;
+                    }
+                }
+            }
+          CMFile.close();
+        }
+    }
+  return false;
+}
+
+bool modelCDMProject::SetPackageInclude(const std::string& package_name, const bool& toInclude)
+{
+  if (this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::stringstream outs;
+          std::string line;
+          bool found = false;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line);
+              if(line != "")
+                {
+                  std::vector<std::string> segs;
+                  CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+                  //is comment
+                  if(segs.size() > 0 && segs[0][0] == '#')
+                    {
+                      if(toInclude)
+                        {
+                          CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+                            {
+                              found = true;
+                              outs << "ADD_SUBDIRECTORY(" << package_name << ")\n";
+                            }
+                          else
+                            outs << line << "\n";
+                        }
+                      else
+                        {
+                          outs << line << "\n";
+                        }
+                    }
+                  //is not comment
+                  else
+                    {
+                      if (segs.size() > 0 && !toInclude)
+                        {
+                          CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+                            {
+                              outs << "#" << line << "\n";
+                            }
+                          else
+                            {
+                              outs << line << "\n";
+                            }
+                        }
+                      else
+                        {
+                          CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+                          if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+                            {
+                              found = true;
+                            }
+                          outs << line << "\n";
+                        }
+                    }
+                }
+              else
+                {
+                  outs << "\n";
+                }
+            }
+
+          CMFile.close();
+
+          if(!found && toInclude)
+            outs << "ADD_SUBDIRECTORY(" << package_name << ")\n";
+
+          std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+          if (CMFileOut.is_open())
+            {
+              CMFileOut << outs.rdbuf();
+              CMFileOut.close();
+              return true;
+            }
+        }
+    }
+  return false;
+}
index 5df1550a28c11c0fafe6b146472bdba5342a8336..f354db9e51c6e3e56aa73f82a79a8b1204b93524 100644 (file)
@@ -142,7 +142,7 @@ public:
 
   //Creations
   /**
-   * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model.
+   * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model. The created package is included in the project's CMakeLists file.
    * @param name Name of the package.
    * @param result Result of the operation.
    * @param authors Authors of the operation. If any space is found, it will be replaced by '_'.
@@ -252,6 +252,21 @@ public:
    */
   void CheckStructure(std::map<std::string, bool>& properties);
 
+  /**
+   * Checks if the given package is included in the CMakeLists file.
+   * @param package_name Name of the package to check.
+   * @return True if the package is included, otherwise returns False.
+   */
+  bool IsPackageIncluded(const std::string& package_name);
+
+  /**
+   * Sets the inclusion of the package in the project's CMakeLists file. If the package inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the package inclusion doesn't exist yet, then it is included if the request is an inclusion.
+   * @param package_name Name of the package to include/exclude.
+   * @param toInclude True if the request is an inclusion, False otherwise.
+   * @return True if the request was processed successfully.
+   */
+  bool SetPackageInclude(const std::string& package_name, const bool& toInclude);
+
 
 private:
 
index 49904c2524caac65fe4655a846657c75d52f8111..00488bafd21ff7a3383e2e0019179352a48f59cf 100644 (file)
@@ -49,6 +49,7 @@ EVT_HYPERLINK(ID_LINK_SELECT_APPLICATION, wxCDMAppliDescriptionPanel::OnLnkAppli
 EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMAppliDescriptionPanel::OnBtnCreateApplication)
 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists)
 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMAppliDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_APPLICATION, wxCDMAppliDescriptionPanel::OnChBApplicationChange)
 END_EVENT_TABLE()
 
 wxCDMAppliDescriptionPanel::wxCDMAppliDescriptionPanel(
@@ -120,23 +121,48 @@ void wxCDMAppliDescriptionPanel::CreateControls()
   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Applications"));
   propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available applications to see its details or the modify them."));
   wxPanel* propertiesPanel = new wxPanel(this);
-  wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
 
   std::vector<modelCDMApplication*> applications = this->appli->GetApplications();
+  wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(applications.size()+1, 3, 9, 5);
+
+  wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+  wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Application Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+  wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+  propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+  propertiesGridSizer -> Add(LkTitle,  0, wxEXPAND | wxALL, 5);
+  propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
   for (int i = 0; i < (int)(applications.size()); i++)
     {
-      wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+      //checkbox for cmake inclusion
+      wxCheckBox* pApplicationChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_APPLICATION, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+      pApplicationChB->SetName(crea::std2wx(applications[i]->GetName()));
+      std::string tt = "if this box is checked the the " + applications[i]->GetName() + " application is included in the project compilation.";
+      pApplicationChB->SetToolTip(crea::std2wx(tt));
+      pApplicationChB->SetValue(this->appli->IsApplicationIncluded(applications[i]->GetName()));
+      propertiesGridSizer -> Add(pApplicationChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+      //link to library with description
+      wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
       pApplicationlk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
-      std::string tt = "Name: " + applications[i]->GetName() + "\n";
+      tt = "Name: " + applications[i]->GetName() + "\n";
       tt += "Location: " + applications[i]->GetPath();
-      pApplicationlk->SetToolTip(crea::std2wx(tt.c_str()));
+      pApplicationlk->SetToolTip(crea::std2wx(tt));
       pApplicationlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseEnter,NULL,this);
       pApplicationlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseExit,NULL,this);
-      propertiesPanelSizer -> Add(pApplicationlk, 1, wxEXPAND | wxALL, 5);
+      propertiesGridSizer -> Add(pApplicationlk, 0, wxEXPAND);
+
+      //help icon
+      wxButton* pApplicationHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+      propertiesGridSizer -> Add(pApplicationHlp, 0, wxEXPAND | wxALIGN_CENTER);
     }
 
-  propertiesPanel->SetSizer(propertiesPanelSizer);
-  propertiesPanelSizer->Fit(propertiesPanel);
+  propertiesGridSizer->AddGrowableCol(1,1);
+
+  propertiesPanel->SetSizer(propertiesGridSizer);
+  propertiesGridSizer->Fit(propertiesPanel);
+
   propertiesBox->Add(propertiesPanel, 1, wxEXPAND | wxALL, 5);
   sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
 
@@ -254,6 +280,14 @@ void wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
     }
 }
 
+void wxCDMAppliDescriptionPanel::OnChBApplicationChange(wxCommandEvent& event)
+{
+  this->appli->SetApplicationInclude(
+      crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+      ((wxCheckBox*)event.GetEventObject())->GetValue()
+    );
+}
+
 void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event)
 {
   modelCDMApplication* applicationFound = NULL;
index 88c2cf94b3333c1afa091b57dcc95b7f5dfc911e..99c8f59944c4b2c0967a2ae6442717f137d97111 100644 (file)
@@ -112,6 +112,11 @@ protected:
    * Handles when the open package cmakelists file button is pressed.
    */
   void OnBtnEditCMakeLists(wxCommandEvent& event);
+  /**
+   * Handles when a application checkbox is (un)checked.
+   * @param event Has the link reference to know which application was selected.
+   */
+  void OnChBApplicationChange(wxCommandEvent& event);
   /**
    * Handles when an application link is pressed.
    * @param event Has the link reference to know which application was selected.
index d31dd06395c3b77557cd0b29570fa4ccb6137ee0..cc635285c15fa9d6b082e7e862a7b06abc5f8b31 100644 (file)
@@ -47,6 +47,7 @@ EVT_HYPERLINK(ID_LINK_SELECT_LIBRARY, wxCDMLibDescriptionPanel::OnLnkLibrarySele
 EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMLibDescriptionPanel::OnBtnCreateLibrary)
 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibDescriptionPanel::OnBtnEditCMakeLists)
 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMLibDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMLibDescriptionPanel::OnChBLibraryChange)
 END_EVENT_TABLE()
 
 wxCDMLibDescriptionPanel::wxCDMLibDescriptionPanel(
@@ -118,23 +119,47 @@ void wxCDMLibDescriptionPanel::CreateControls()
   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Libraries"));
   propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available libraries to see its details or modify them."));
   wxPanel* propertiesPanel = new wxPanel(this);
-  wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
 
   std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
+  wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(libraries.size()+1, 3, 9, 5);
+
+  wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+  wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Library Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+  wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+  propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+  propertiesGridSizer -> Add(LkTitle,  0, wxEXPAND | wxALL, 5);
+  propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
   for (int i = 0; i < (int)(libraries.size()); i++)
     {
-               wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+      //checkbox for cmake inclusion
+      wxCheckBox* pLibraryChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+      pLibraryChB->SetName(crea::std2wx(libraries[i]->GetName()));
+      std::string tt = "if this box is checked the the " + libraries[i]->GetName() + " library is included in the project compilation.";
+      pLibraryChB->SetToolTip(crea::std2wx(tt));
+      pLibraryChB->SetValue(this->lib->IsLibraryIncluded(libraries[i]->GetName()));
+      propertiesGridSizer -> Add(pLibraryChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+      //link to library with description
+      wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
       pLibrarylk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
-      std::string tt = "Name: " + libraries[i]->GetName() + "\n";
+      tt = "Name: " + libraries[i]->GetName() + "\n";
       tt += "Location: " + libraries[i]->GetPath();
-      pLibrarylk->SetToolTip(crea::std2wx(tt.c_str()));
+      pLibrarylk->SetToolTip(crea::std2wx(tt));
       pLibrarylk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseEnter,NULL,this);
       pLibrarylk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseExit,NULL,this);
-      propertiesPanelSizer -> Add(pLibrarylk, 0, wxEXPAND | wxALL, 5);
+      propertiesGridSizer -> Add(pLibrarylk, 0, wxEXPAND);
+
+      //help icon
+      wxButton* pLibraryHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+      propertiesGridSizer -> Add(pLibraryHlp, 0, wxEXPAND | wxALIGN_CENTER);
     }
 
-  propertiesPanel->SetSizer(propertiesPanelSizer);
-  propertiesPanelSizer->Fit(propertiesPanel);
+  propertiesGridSizer->AddGrowableCol(1,1);
+
+  propertiesPanel->SetSizer(propertiesGridSizer);
+  propertiesGridSizer->Fit(propertiesPanel);
   propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
   sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
 
@@ -229,6 +254,14 @@ void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
     }
 }
 
+void wxCDMLibDescriptionPanel::OnChBLibraryChange(wxCommandEvent& event)
+{
+  this->lib->SetLibraryInclude(
+      crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+      ((wxCheckBox*)event.GetEventObject())->GetValue()
+    );
+}
+
 void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
 {
   modelCDMLibrary* theLibrary = NULL;
index 2483c9aaec3d299bc97ee23c7c6111fa683f4ad3..630c7b402291c33c28cec307ba8acc9ae7479912 100644 (file)
@@ -115,6 +115,11 @@ protected:
    * Handles when the open package cmakelists file button is pressed.
    */
   void OnBtnEditCMakeLists(wxCommandEvent& event);
+  /**
+   * Handles when a library checkbox is (un)checked.
+   * @param event Has the link reference to know which library was selected.
+   */
+  void OnChBLibraryChange(wxCommandEvent& event);
   /**
    * Handles when a library link is pressed.
    * @param event Has the link reference to know which library was selected.
index 543ac596fc53364f088baf6d3161d0649b21c828..871b20b98d715f8861facd2fda7b2ed6011115bf 100644 (file)
@@ -49,6 +49,7 @@ EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMPackageManagerPanel::OnBtnCreatePackag
 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCDMPackageManagerPanel::OnBtnCreatePackage)
 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageManagerPanel::OnBtnEditCMakeLists)
 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_ENTER, wxCDMPackageManagerPanel::OnBtnEditCMakeLists)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_PACKAGE, wxCDMPackageManagerPanel::OnChBPackageChange)
 END_EVENT_TABLE()
 
 wxCDMPackageManagerPanel::wxCDMPackageManagerPanel(
@@ -111,22 +112,49 @@ void wxCDMPackageManagerPanel::CreateControls()
   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Packages"));
   propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available packages to see its details or modify them. Remember that black boxes are created inside packages, any of these packages is available."));
   wxPanel* propertiesPanel = new wxPanel(this);
-  wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
 
   std::vector<modelCDMPackage*> packages = this->project->GetPackages();
+  wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(packages.size()+1, 3, 9, 5);
+
+  wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+  wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Package Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+  wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+  propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+  propertiesGridSizer -> Add(LkTitle,  0, wxEXPAND | wxALL, 5);
+  propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
   for (int i = 0; i < (int)(packages.size()); i++)
     {
-               wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
-               pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
-      std::string tt = "Author: " + packages[i]->GetAuthors() + "\nDescription: " + packages[i]->GetDescription();
+      //checkbox for cmake inclusion
+      wxCheckBox* pPackageChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_PACKAGE, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+      pPackageChB->SetName(crea::std2wx(packages[i]->GetName()));
+      std::string tt = "if this box is checked the the " + packages[i]->GetName() + " package is included in the project compilation.";
+      pPackageChB->SetToolTip(crea::std2wx(tt));
+      pPackageChB->SetValue(this->project->IsPackageIncluded(packages[i]->GetName()));
+      propertiesGridSizer -> Add(pPackageChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+      //link to package with description
+      wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+      pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
+      tt = "Name: " + packages[i]->GetName() + "\n";
+      tt += "Location: " + packages[i]->GetPath();
       pPackagelk->SetToolTip(crea::std2wx(tt));
-      propertiesPanelSizer -> Add(pPackagelk, 0, wxEXPAND | wxALL, 5);
       pPackagelk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseEnter,NULL,this);
       pPackagelk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseExit,NULL,this);
+      propertiesGridSizer -> Add(pPackagelk, 0, wxEXPAND);
+
+      //help icon
+      wxButton* pPackageHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+      propertiesGridSizer -> Add(pPackageHlp, 0, wxEXPAND | wxALIGN_CENTER);
     }
 
-  propertiesPanel->SetSizer(propertiesPanelSizer);
-  propertiesPanelSizer->Fit(propertiesPanel);
+  propertiesGridSizer->AddGrowableCol(1,1);
+
+  propertiesPanel->SetSizer(propertiesGridSizer);
+  propertiesGridSizer->Fit(propertiesPanel);
+
+
   propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
 
   sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
@@ -181,6 +209,14 @@ void wxCDMPackageManagerPanel::OnBtnReturn(wxHyperlinkEvent& event)
   wxPostEvent(this->GetParent(), *newEvent);
 }
 
+void wxCDMPackageManagerPanel::OnChBPackageChange(wxCommandEvent& event)
+{
+  this->project->SetPackageInclude(
+      crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+      ((wxCheckBox*)event.GetEventObject())->GetValue()
+    );
+}
+
 void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event)
 {
   modelCDMPackage* thePackage = NULL;
index 66a1d1c54228d390ed5420b5ec2a9fec1fd4f8fd..3c5dc99e274d0e40f0b5f059a1cf02e49f260d82 100644 (file)
@@ -119,6 +119,11 @@ protected:
    * @param event Has the link reference to know where to return
    */
   void OnBtnReturn(wxHyperlinkEvent& event);
+  /**
+   * Handles when a package checkbox is (un)checked.
+   * @param event Has the link reference to know which package was selected.
+   */
+  void OnChBPackageChange(wxCommandEvent& event);
   /**
    * Handles when a packages link is pressed.
    * @param event Has the link reference to know which package was selected.