From 35dd4d1ddf73a91d308cc49fc394104169936055 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Sat, 6 Apr 2013 17:12:41 +0200 Subject: [PATCH] Feature #1711 CreaDevManager application implementation Feature: Show included libraries (3rd Party) and checkboxes to include them in: Libraries, Applications, Packages. Now shows found libraries but doesn't include/exclude them. --- lib/creaDevManagerLib/modelCDMAppli.cpp | 2 +- lib/creaDevManagerLib/modelCDMApplication.cpp | 70 ++++++++++++++++++- lib/creaDevManagerLib/modelCDMLib.cpp | 2 +- lib/creaDevManagerLib/modelCDMLibrary.cpp | 70 ++++++++++++++++++- lib/creaDevManagerLib/modelCDMPackage.cpp | 58 ++++++++++++++- lib/creaDevManagerLib/modelCDMProject.cpp | 2 +- .../wxCDMPackageConfigurationDialog.cpp | 32 +++++---- .../wxCDMPackageConfigurationDialog.h | 2 +- 8 files changed, 218 insertions(+), 20 deletions(-) diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index 9e588df..7bcc4a2 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -496,7 +496,7 @@ bool modelCDMAppli::IsApplicationIncluded(const std::string& application_name) { std::getline(CMFile, line); while(line[0]==' ') - line.erase(0); + line.erase(0,1); if(line[0] != '#') { std::vector lineSeg; diff --git a/lib/creaDevManagerLib/modelCDMApplication.cpp b/lib/creaDevManagerLib/modelCDMApplication.cpp index 1a9c3ad..c15bedf 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.cpp +++ b/lib/creaDevManagerLib/modelCDMApplication.cpp @@ -517,8 +517,76 @@ void modelCDMApplication::CheckStructure(std::map& properties std::map modelCDMApplication::Get3rdPartyLibraries() { + std::map correspondence; + correspondence["${crea_LIBRARIES}"] = "Crea"; + correspondence["${WXWIDGETS_LIBRARIES}"] = "WxWidgets"; + correspondence["${KWWidgets_LIBRARIES}"] = "KWWidgets"; + correspondence["${VTK_LIBRARIES}"] = "VTK"; + correspondence["${ITK_LIBRARIES}"] = "ITK"; + correspondence["${GDCM_LIBRARIES}"] = "GDCM"; + correspondence["${BOOST_LIBRARIES}"] = "Boost"; std::map res; - res["Test"] = false; + res["Crea"] = false; + res["WxWidgets"] = false; + res["KWWidgets"] = false; + res["VTK"] = false; + res["ITK"] = false; + res["GDCM"] = false; + res["Boost"] = false; + + 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, '('); + + std::vector lineSeg; + CDMUtilities::splitter::split(lineSeg,line,"\n ",CDMUtilities::splitter::no_empties); + + if(lineSeg.size() > 0 && lineSeg[lineSeg.size()-1] == "SET") + { + //std::cout << "found set" << std::endl; + std::getline(CMFile, line, ')'); + //std::cout << line << std::endl; + CDMUtilities::splitter::split(lineSeg,line,"\n",CDMUtilities::splitter::no_empties); + if(lineSeg.size() > 0) + { + //std::cout << lineSeg[0] << std::endl; + for(int i = 0; i < lineSeg[0].size(); ++i) + if (lineSeg[0][i] == ' ') + { + lineSeg[0].erase(i,1); + --i; + } + //std::cout << lineSeg[0] << std::endl; + if (lineSeg[0] == "${EXE_NAME}_LINK_LIBRARIES") + { + //std::cout << "link" << std::endl; + for (int l = 1; l < lineSeg.size(); ++l) + { + for(int i = 0;i < lineSeg[l].size(); i++) + if (lineSeg[l][i] == ' ') + { + lineSeg[l].erase(i,1); + i--; + } + if(lineSeg[l].size() > 0 && lineSeg[l][0] == '$') + { + //std::cout << "found " << lineSeg[l] << std::endl; + res[correspondence[lineSeg[l]]] = true; + } + } + } + } + } + } + CMFile.close(); + } + } return res; } diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index 5cfc702..38cd30d 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -420,7 +420,7 @@ bool modelCDMLib::IsLibraryIncluded(const std::string& library_name) { std::getline(CMFile, line); while(line[0]==' ') - line.erase(0); + line.erase(0,1); if(line[0] != '#') { std::vector lineSeg; diff --git a/lib/creaDevManagerLib/modelCDMLibrary.cpp b/lib/creaDevManagerLib/modelCDMLibrary.cpp index 524f142..b124c93 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.cpp +++ b/lib/creaDevManagerLib/modelCDMLibrary.cpp @@ -436,8 +436,76 @@ void modelCDMLibrary::CheckStructure(std::map& properties) std::map modelCDMLibrary::Get3rdPartyLibraries() { + std::map correspondence; + correspondence["${crea_LIBRARIES}"] = "Crea"; + correspondence["${WXWIDGETS_LIBRARIES}"] = "WxWidgets"; + correspondence["${KWWidgets_LIBRARIES}"] = "KWWidgets"; + correspondence["${VTK_LIBRARIES}"] = "VTK"; + correspondence["${ITK_LIBRARIES}"] = "ITK"; + correspondence["${GDCM_LIBRARIES}"] = "GDCM"; + correspondence["${BOOST_LIBRARIES}"] = "Boost"; std::map res; - res["Test"] = false; + res["Crea"] = false; + res["WxWidgets"] = false; + res["KWWidgets"] = false; + res["VTK"] = false; + res["ITK"] = false; + res["GDCM"] = false; + res["Boost"] = false; + + 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, '('); + + std::vector lineSeg; + CDMUtilities::splitter::split(lineSeg,line,"\n ",CDMUtilities::splitter::no_empties); + + if(lineSeg.size() > 0 && lineSeg[lineSeg.size()-1] == "SET") + { + //std::cout << "found set" << std::endl; + std::getline(CMFile, line, ')'); + //std::cout << line << std::endl; + CDMUtilities::splitter::split(lineSeg,line,"\n",CDMUtilities::splitter::no_empties); + if(lineSeg.size() > 0) + { + //std::cout << lineSeg[0] << std::endl; + for(int i = 0; i < lineSeg[0].size(); ++i) + if (lineSeg[0][i] == ' ') + { + lineSeg[0].erase(i,1); + --i; + } + //std::cout << lineSeg[0] << std::endl; + if (lineSeg[0] == "${LIBRARY_NAME}_LINK_LIBRARIES") + { + //std::cout << "link" << std::endl; + for (int l = 1; l < lineSeg.size(); ++l) + { + for(int i = 0;i < lineSeg[l].size(); i++) + if (lineSeg[l][i] == ' ') + { + lineSeg[l].erase(i,1); + i--; + } + if(lineSeg[l].size() > 0 && lineSeg[l][0] == '$') + { + //std::cout << "found " << lineSeg[l] << std::endl; + res[correspondence[lineSeg[l]]] = true; + } + } + } + } + } + } + CMFile.close(); + } + } return res; } diff --git a/lib/creaDevManagerLib/modelCDMPackage.cpp b/lib/creaDevManagerLib/modelCDMPackage.cpp index 43d169a..81fb906 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.cpp +++ b/lib/creaDevManagerLib/modelCDMPackage.cpp @@ -692,8 +692,64 @@ void modelCDMPackage::CheckStructure(std::map& properties) std::map modelCDMPackage::Get3rdPartyLibraries() { + std::map correspondence; + correspondence["${BBTK_PACKAGE_NAME}_USE_VTKON"] = "VTK"; + correspondence["${BBTK_PACKAGE_NAME}_USE_ITKON"] = "ITK"; + correspondence["${BBTK_PACKAGE_NAME}_USE_GDCMON"] = "GDCM"; + correspondence["${BBTK_PACKAGE_NAME}_USE_GDCM_VTKON"] = "GDCM_VTK"; + correspondence["${BBTK_PACKAGE_NAME}_USE_GSMISON"] = "GSMIS"; + correspondence["${BBTK_PACKAGE_NAME}_USE_WXWIDGETSON"] = "WxWidgets"; + correspondence["${BBTK_PACKAGE_NAME}_USE_KWWIDGETSON"] = "KWWidgets"; std::map res; - res["Test"] = false; + res["VTK"] = false; + res["ITK"] = false; + res["GDCM"] = false; + res["GDCM_VTK"] = false; + res["GSMIS"] = false; + res["WxWidgets"] = false; + res["KWWidgets"] = false; + + 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, '('); + + std::vector lineSeg; + CDMUtilities::splitter::split(lineSeg,line,"\n",CDMUtilities::splitter::no_empties); + for(int i = 0; lineSeg.size() > 0 && i < lineSeg[lineSeg.size()-1].size(); ++i) + if (lineSeg[lineSeg.size()-1][i] == ' ') + { + lineSeg[lineSeg.size()-1].erase(i,1); + --i; + } + if(lineSeg.size() > 0 && lineSeg[lineSeg.size()-1][0]!='#' && lineSeg[lineSeg.size()-1] == "SET") + { + std::getline(CMFile, line, ')'); + CDMUtilities::splitter::split(lineSeg,line,"\t\n",CDMUtilities::splitter::no_empties); + if(lineSeg.size() > 0) + { + for(int i = 0; i < lineSeg[0].size(); ++i) + if (lineSeg[0][i] == ' ') + { + lineSeg[0].erase(i,1); + --i; + } + + if(lineSeg[0].size() > 0 && lineSeg[0][0] == '$' && correspondence.find(lineSeg[0]) != correspondence.end()) + { + res[correspondence[lineSeg[0]]] = true; + } + } + } + } + CMFile.close(); + } + } return res; } diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index 5bc14e4..d26932d 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -1022,7 +1022,7 @@ bool modelCDMProject::IsPackageIncluded(const std::string& package_name) { std::getline(CMFile, line); while(line[0]==' ') - line.erase(0); + line.erase(0,1); if(line[0] != '#') { std::vector lineSeg; diff --git a/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp b/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp index af407bf..07a1525 100644 --- a/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp @@ -53,8 +53,8 @@ wxCDMPackageConfigurationDialog::wxCDMPackageConfigurationDialog( long style ) { - wxCDMPackageConfigurationDialog::Create(parent, id, caption, position, size, style); this->package = package; + wxCDMPackageConfigurationDialog::Create(parent, id, caption, position, size, style); } wxCDMPackageConfigurationDialog::~wxCDMPackageConfigurationDialog() @@ -84,12 +84,16 @@ void wxCDMPackageConfigurationDialog::CreateControls() wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Please select the libraries that are used in this package."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY); - v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL, 5); + v_sizer1->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5); + + wxScrolledWindow* includesPanel = new wxScrolledWindow(this); + includesPanel->FitInside(); + includesPanel->SetScrollRate(5,5); wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL); //Third Party Libraries - wxStaticText* Title1 = new wxStaticText(this, wxID_ANY, wxT("Third Party Libraries:")); + wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:")); wxFont font = Title1->GetFont(); font.SetWeight(wxFONTWEIGHT_BOLD); Title1->SetFont(font); @@ -101,7 +105,7 @@ void wxCDMPackageConfigurationDialog::CreateControls() wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5); wxStaticText* ChBTitle = new wxStaticText( - this, + includesPanel, wxID_ANY, wxT("Included"), wxDefaultPosition, @@ -109,7 +113,7 @@ void wxCDMPackageConfigurationDialog::CreateControls() wxALIGN_CENTER ); wxStaticText* LNmTitle = new wxStaticText( - this, + includesPanel, wxID_ANY, wxT("Library Name"), wxDefaultPosition, @@ -122,14 +126,14 @@ void wxCDMPackageConfigurationDialog::CreateControls() for (std::map::iterator it = inclusions.begin(); it != inclusions.end(); ++it) { wxCheckBox* ChBIncl = new wxCheckBox( - this, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT + includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); ChBIncl->SetToolTip(crea::std2wx("When this box is checked the " + it->first + " library is included in the project configuration for this library.")); ChBIncl->SetName(crea::std2wx(it->first)); ChBIncl->SetValue(it->second); includesGridSizer->Add(ChBIncl, 1, wxEXPAND); - wxStaticText* LNmIncl = new wxStaticText(this, wxID_ANY, crea::std2wx(it->first)); + wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first)); includesGridSizer->Add(LNmIncl, 1, wxEXPAND); } @@ -138,7 +142,7 @@ void wxCDMPackageConfigurationDialog::CreateControls() includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND, 0); //Custom Libraries - wxStaticText* Title2 = new wxStaticText(this, wxID_ANY, wxT("Custom Libraries:")); + wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:")); font = Title2->GetFont(); font.SetWeight(wxFONTWEIGHT_BOLD); Title2->SetFont(font); @@ -150,7 +154,7 @@ void wxCDMPackageConfigurationDialog::CreateControls() wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5); wxStaticText* ChBTitle1 = new wxStaticText( - this, + includesPanel, wxID_ANY, wxT("Included"), wxDefaultPosition, @@ -158,7 +162,7 @@ void wxCDMPackageConfigurationDialog::CreateControls() wxALIGN_CENTER ); wxStaticText* LNmTitle1 = new wxStaticText( - this, + includesPanel, wxID_ANY, wxT("Library Name"), wxDefaultPosition, @@ -171,14 +175,14 @@ void wxCDMPackageConfigurationDialog::CreateControls() for (std::map::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) { wxCheckBox* ChBIncl = new wxCheckBox( - this, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT + includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); ChBIncl->SetToolTip(crea::std2wx("When this box is checked the " + it->first + " custom library is included in the project configuration for this library.")); ChBIncl->SetName(crea::std2wx(it->first)); ChBIncl->SetValue(it->second); includesLibGridSizer->Add(ChBIncl, 1, wxEXPAND); - wxStaticText* LNmIncl = new wxStaticText(this, wxID_ANY, crea::std2wx(it->first)); + wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first)); includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND); } @@ -186,7 +190,9 @@ void wxCDMPackageConfigurationDialog::CreateControls() includesPanelSizer->Add(includesLibGridSizer, 1, wxEXPAND, 0); - v_sizer1->Add(includesPanelSizer, 1, wxEXPAND); + includesPanel->SetSizer(includesPanelSizer); + + v_sizer1->Add(includesPanel, 1, wxEXPAND); v_sizer1->Add(new wxButton(this, wxID_OK, wxT("Close")), 0, wxALIGN_CENTER | wxRIGHT | wxBOTTOM, 30); diff --git a/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h b/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h index 03e02a3..a839430 100644 --- a/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h +++ b/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h @@ -65,7 +65,7 @@ public: const wxString& caption = wxT("Package Library Configuration"), const wxPoint& position = wxDefaultPosition, const wxSize& size = wxSize(350,370), - long style = wxDEFAULT_DIALOG_STYLE + long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ); /** * Destructor. -- 2.47.1