From: Daniel Gonzalez Date: Fri, 5 Apr 2013 15:09:44 +0000 (+0200) Subject: Feature #1711 CreaDevManager application implementation X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9f11db34cb1acacf545f819d6b552a95835d93bd;p=crea.git Feature #1711 CreaDevManager application implementation Feature: Auto include in corresponding CMakeLists files when creating: Libraries, Applications, Packages. Feature: Checkboxes to include in CMakeLists files for: Libraries, Application, Packages. --- diff --git a/lib/creaDevManagerLib/creaDevManagerIds.h b/lib/creaDevManagerLib/creaDevManagerIds.h index a73f569..2bf0dba 100644 --- a/lib/creaDevManagerLib/creaDevManagerIds.h +++ b/lib/creaDevManagerLib/creaDevManagerIds.h @@ -111,10 +111,14 @@ #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_ */ diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index bcb0876..62d02a9 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -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& 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 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 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; +} diff --git a/lib/creaDevManagerLib/modelCDMAppli.h b/lib/creaDevManagerLib/modelCDMAppli.h index 579f12a..c3bce22 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.h +++ b/lib/creaDevManagerLib/modelCDMAppli.h @@ -72,7 +72,7 @@ public: const std::vector& 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& 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. diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index e3c2902..69bfcff 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -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& 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 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 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; +} diff --git a/lib/creaDevManagerLib/modelCDMLib.h b/lib/creaDevManagerLib/modelCDMLib.h index e372e5f..d8b8c27 100644 --- a/lib/creaDevManagerLib/modelCDMLib.h +++ b/lib/creaDevManagerLib/modelCDMLib.h @@ -72,7 +72,7 @@ public: const std::vector& 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& 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. diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index aa6fdeb..3020326 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -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& 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 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 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; +} diff --git a/lib/creaDevManagerLib/modelCDMProject.h b/lib/creaDevManagerLib/modelCDMProject.h index 5df1550..f354db9 100644 --- a/lib/creaDevManagerLib/modelCDMProject.h +++ b/lib/creaDevManagerLib/modelCDMProject.h @@ -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& 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: diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp index 49904c2..00488ba 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp @@ -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 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; diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h index 88c2cf9..99c8f59 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h @@ -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. diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index d31dd06..cc63528 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -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 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; diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h index 2483c9a..630c7b4 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h @@ -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. diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp index 543ac59..871b20b 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp @@ -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 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; diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h index 66a1d1c..3c5dc99 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h @@ -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.