From: Daniel Gonzalez Date: Fri, 14 Dec 2012 15:19:57 +0000 (+0100) Subject: Feature #1711 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d8222afd6508f39bd37426842667de2e431cca4a;p=crea.git Feature #1711 CreaDevManager application implementation - Setting up links highlighting in appli, lib, package Descriptions, and package Manager. - Open Folder in Package implemented - Open CMakeLists file in Project implemented - Open Folder in Project implemented - Set Project Version implemented - Set Project Date implemented - Set Project Build path implemented --- diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index 0149e8d..d9ef9b7 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -36,6 +36,7 @@ #include #include +#include namespace CDMUtilities { @@ -92,4 +93,25 @@ namespace CDMUtilities return pathFixed; } + + int openTextEditor(const std::string& file) + { + std::string command = TEXT_EDITOR; + + if(file != "") + command += " \"" + file + "\" &"; + + return system(command.c_str()); + } + + int openFileExplorer(const std::string& file) + { + std::string command = FILE_EXPLORER; + + if(file != "") + command += " \"" + file + "\" &"; + + return system(command.c_str()); + } + } diff --git a/lib/creaDevManagerLib/CDMUtilities.h b/lib/creaDevManagerLib/CDMUtilities.h index 2b4f05b..16630d2 100644 --- a/lib/creaDevManagerLib/CDMUtilities.h +++ b/lib/creaDevManagerLib/CDMUtilities.h @@ -40,20 +40,46 @@ namespace CDMUtilities { + //text editor program +#ifdef _WIN32 + // ------ Windows + //TODO: implementation for windows +#elif __APPLE__ + // ------ Apple + //TODO: implementation for apple +#else + static std::string TEXT_EDITOR = "gedit"; +#endif + + //file explorer program +#ifdef _WIN32 + // ------ Windows + //TODO: implementation for windows +#elif __APPLE__ + // ------ Apple + //TODO: implementation for apple +#else + static std::string FILE_EXPLORER = "nautilus"; +#endif + + struct splitter { enum empties_t { empties_ok, no_empties }; template - static Container& split - ( - Container& result, - const typename Container::value_type& s, - const typename Container::value_type& delimiters, - empties_t empties = empties_ok - ); + static Container& split + ( + Container& result, + const typename Container::value_type& s, + const typename Container::value_type& delimiters, + empties_t empties = empties_ok + ); }; const std::string fixPath(const std::string& path); + + int openTextEditor(const std::string& file = ""); + int openFileExplorer(const std::string& file = ""); }; #endif /* CDMUTILITIES_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index d370a17..79c17ea 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -93,7 +93,7 @@ modelCDMApplication* modelCDMAppli::CreateApplication( const std::string& path ) { - //copy template library folder with new name + //copy template application folder with new name //TODO: fix for windows std::string copyCommand = "cp -r " + this->path + "/template_appli " + this->path + "/" + name; if(system(copyCommand.c_str())) diff --git a/lib/creaDevManagerLib/modelCDMFolder.cpp b/lib/creaDevManagerLib/modelCDMFolder.cpp index ed71874..73312b6 100644 --- a/lib/creaDevManagerLib/modelCDMFolder.cpp +++ b/lib/creaDevManagerLib/modelCDMFolder.cpp @@ -136,6 +136,16 @@ const bool modelCDMFolder::Refresh(std::string*& result) return true; } +modelCDMCMakeListsFile* modelCDMFolder::GetCMakeLists() const +{ + return this->CMakeLists; +} + +std::vector modelCDMFolder::GetFolders() const +{ + return this->folders; +} + bool modelCDMFolder::HasCMakeLists() { diff --git a/lib/creaDevManagerLib/modelCDMFolder.h b/lib/creaDevManagerLib/modelCDMFolder.h index f8cd26c..383f89d 100644 --- a/lib/creaDevManagerLib/modelCDMFolder.h +++ b/lib/creaDevManagerLib/modelCDMFolder.h @@ -48,6 +48,9 @@ public: modelCDMFolder(const std::string& path, const int& level = 3); ~modelCDMFolder(); + modelCDMCMakeListsFile* GetCMakeLists() const; + std::vector GetFolders() const; + bool CreateFolder( const std::string& name, std::string*& result, diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp index 1c9db62..8676627 100644 --- a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp @@ -34,6 +34,8 @@ #include "modelCDMIProjectTreeNode.h" #include +#include "CDMUtilities.h" + #include "wx/dir.h" bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y) @@ -142,6 +144,11 @@ const int& modelCDMIProjectTreeNode::GetLength() const bool modelCDMIProjectTreeNode::OpenInFileExplorer(std::string*& result) const { - //TODO: implement method - return false; + if (!CDMUtilities::openFileExplorer(this->GetPath())) + return true; + else + { + result = new std::string("Couldn't open file."); + return false; + } } diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index a961f62..7ebe67d 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -35,9 +35,11 @@ #include "modelCDMProject.h" #include +#include #include #include #include +#include #include "CDMUtilities.h" #include "creaWx.h" @@ -244,13 +246,70 @@ modelCDMLib* modelCDMProject::GetLib() const bool modelCDMProject::SetVersion(const std::string& version, std::string*& result) { - //TODO: implement method + + std::vector vers; + CDMUtilities::splitter::split(vers, version, " .", CDMUtilities::splitter::no_empties); + + time_t now = time(0); + tm* ltm = localtime(&now); + + std::stringstream date; + date << ltm->tm_mday << "/" << ltm->tm_mon << "/" << 1900 + ltm->tm_year; + + //set name of library in CMakeLists inside copied folder + std::string line; + std::ifstream in((this->path + "/CMakeLists.txt").c_str()); + if( !in.is_open()) + { + result = new std::string("CMakeLists.txt file failed to open."); + return false; + } + std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str()); + if( !out.is_open()) + { + result = new std::string("CMakeLists.txt.tmp file failed to open."); + return false; + } + while (getline(in, line)) + { + if(line.find("SET(PROJECT_MAJOR_VERSION") != std::string::npos) + line = "SET(PROJECT_MAJOR_VERSION " + vers[0] + ")"; + else if(line.find("SET(PROJECT_MINOR_VERSION") != std::string::npos) + line = "SET(PROJECT_MINOR_VERSION " + vers[1] + ")"; + else if(line.find("SET(PROJECT_BUILD_VERSION") != std::string::npos) + line = "SET(PROJECT_BUILD_VERSION " + vers[2] + ")"; + else if(line.find("SET(PROJECT_VERSION_DATE") != std::string::npos) + line = "SET(PROJECT_VERSION_DATE \"" + date.str() + "\")"; + out << line << std::endl; + } + in.close(); + out.close(); + //delete old file and rename new file + std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt"; + if(system(renameCommand.c_str())) + { + result = new std::string("An error occurred while running '" + renameCommand + "'."); + return false; + } + + this->version = vers[0] + "." + vers[1] + "." + vers[2]; + this->versionDate = date.str(); return true; } bool modelCDMProject::SetBuildPath(const std::string& path, std::string*& result) { - //TODO: implement method + if(path == "") + { + result = new std::string("The path cannot be empty"); + return false; + } + if(path == this->path) + { + result = new std::string("The path cannot be same as the project sources"); + return false; + } + this->buildPath = path; return true; } @@ -339,11 +398,11 @@ modelCDMIProjectTreeNode* modelCDMProject::CreateApplication( ) { if(this->appli != NULL) - { - return this->appli->CreateApplication(name, result); - } - result = new std::string("there is no appli folder in this project."); - return NULL; + { + return this->appli->CreateApplication(name, result); + } + result = new std::string("there is no appli folder in this project."); + return NULL; } modelCDMIProjectTreeNode* modelCDMProject::CreateBlackBox( @@ -361,8 +420,13 @@ modelCDMIProjectTreeNode* modelCDMProject::CreateBlackBox( bool modelCDMProject::OpenCMakeListsFile(std::string*& result) { - //TODO: implement method - return true; + if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath())) + return true; + else + { + result = new std::string("Couldn't open CMakeLists file."); + return false; + } } const bool modelCDMProject::Refresh(std::string*& result) diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp index 778525f..390af69 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp @@ -104,11 +104,13 @@ void wxCDMAppliDescriptionPanel::CreateControls() std::vector applications = this->appli->GetApplications(); for (int i = 0; i < applications.size(); i++) { - wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str())); + wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str())); std::string tt = "Name: " + applications[i]->GetName() + "\n"; tt += "Location: " + applications[i]->GetPath(); - pLibrarylk->SetToolTip(crea::std2wx(tt.c_str())); - propertiesPanelSizer -> Add(pLibrarylk, 0, wxALIGN_LEFT | wxALL, 5); + pApplicationlk->SetToolTip(crea::std2wx(tt.c_str())); + 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, 0, wxALIGN_LEFT | wxALL, 5); } propertiesPanel->SetSizer(propertiesPanelSizer); @@ -196,6 +198,10 @@ void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event) break; } } + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + newEvent1->SetInt(applicationId); + newEvent1->SetId(0); + wxPostEvent(this->GetParent(), *newEvent1); wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); newEvent->SetInt(applicationId); @@ -211,10 +217,50 @@ void wxCDMAppliDescriptionPanel::OnBtnReturn(wxCommandEvent& event) wxPostEvent(this->GetParent(), *newEvent); } -void -wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +void wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { //TODO: implement method std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; event.Skip(); } + +void wxCDMAppliDescriptionPanel::OnMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + std::string AppName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int appId = 0; + std::vector applications = this->appli->GetApplications(); + for (int i = 0; i < applications.size(); i++) + { + if(applications[i]->GetName() == AppName) + { + appId = applications[i]->GetId(); + break; + } + } + newEvent->SetInt(appId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + +void wxCDMAppliDescriptionPanel::OnMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + std::string AppName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int appId = 0; + std::vector applications = this->appli->GetApplications(); + for (int i = 0; i < applications.size(); i++) + { + if(applications[i]->GetName() == AppName) + { + appId = applications[i]->GetId(); + break; + } + } + newEvent->SetInt(appId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h index 01d4c78..dd44456 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h @@ -80,6 +80,9 @@ protected: void OnBtnReturn(wxCommandEvent& event); void OnBtnOpenFolder(wxCommandEvent& event); + void OnMouseEnter(wxMouseEvent& event); + void OnMouseExit(wxMouseEvent& event); + }; #endif /* WXCDMAPPLIDESCRIPTIONPANEL_H_ */ diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index 88d598b..313a720 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -202,6 +202,11 @@ void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event) newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + newEvent1->SetInt(libraryId); + newEvent1->SetId(0); + wxPostEvent(this->GetParent(), *newEvent1); + } void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event) diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp index 5a4f56a..d6271ba 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp @@ -158,6 +158,8 @@ void wxCDMPackageDescriptionPanel::CreateControls() 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); } @@ -177,6 +179,8 @@ void wxCDMPackageDescriptionPanel::CreateControls() actionsPanelSizer->Add(createBBbt, 0, wxALL, 5); wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the package's CMakeLists.txt file.")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseExit,NULL,this); actionsPanelSizer->Add(editCMakebt, 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.")); @@ -218,6 +222,11 @@ void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event) newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + newEvent1->SetInt(bbId); + newEvent1->SetId(0); + wxPostEvent(this->GetParent(), *newEvent1); + } void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event) @@ -241,3 +250,72 @@ void wxCDMPackageDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) event.Skip(); } +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 boxes = this->package->GetBlackBoxes(); + for (int i = 0; i < boxes.size(); i++) + { + if(boxes[i]->GetName() == BBName) + { + bbId = boxes[i]->GetId(); + break; + } + } + newEvent->SetInt(bbId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + +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 boxes = this->package->GetBlackBoxes(); + for (int i = 0; i < boxes.size(); i++) + { + if(boxes[i]->GetName() == BBName) + { + bbId = boxes[i]->GetId(); + break; + } + } + newEvent->SetInt(bbId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + +void wxCDMPackageDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->package->GetCMakeLists() != NULL) + { + int CMId = this->package->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMPackageDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->package->GetCMakeLists() != NULL) + { + int CMId = this->package->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + + diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h index a6688a2..41c2ba5 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h @@ -80,6 +80,12 @@ protected: void OnBtnEditCMakeLists(wxCommandEvent& event); void OnBtnOpenFolder(wxCommandEvent& event); + void OnMouseEnter(wxMouseEvent& event); + void OnMouseExit(wxMouseEvent& event); + + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); + }; #endif /* WXCDMPACKAGEDESCRIPTIONPANEL_H_ */ diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp index 8ace066..28b2fe1 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp @@ -166,6 +166,11 @@ void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event) newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + newEvent1->SetInt(packageId); + newEvent1->SetId(0); + wxPostEvent(this->GetParent(), *newEvent1); + } void wxCDMPackageManagerPanel::OnBtnCreatePackage(wxCommandEvent& event) @@ -242,7 +247,7 @@ void wxCDMPackageManagerPanel::OnMouseExit(wxMouseEvent& event) std::string PkgName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); int pkgId = 0; std::vector packages = this->project->GetPackages(); - project->GetPackages(); + project->GetPackages(); for (int i = 0; i < packages.size(); i++) { if(packages[i]->GetName() == PkgName) diff --git a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp index ecd4e89..e49e289 100644 --- a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp @@ -39,6 +39,7 @@ #include "creaDevManagerIds.h" #include "images/PrIcon64.xpm" +#include "CDMUtilities.h" BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages) @@ -114,13 +115,13 @@ void wxCDMProjectDescriptionPanel::CreateControls() //values // version wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion())); + this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion())); wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); pVersionbt->SetToolTip(wxT("Update the version of the project.")); - pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pVersionsz->Add(this->versiontc, 0, wxALIGN_CENTER_VERTICAL, 0); pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10); // versionDate - wxStaticText* pVersionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate())); + this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate())); // sourceLocation wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL); wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath())); @@ -131,17 +132,17 @@ void wxCDMProjectDescriptionPanel::CreateControls() pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); // buildLocation wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pBuildLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath())); - pBuildLocationtc->SetMaxSize(wxSize(350,-1)); + this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath())); + this->buildPathtc->SetMaxSize(wxSize(350,-1)); wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose")); pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project.")); - pBuildLocationsz->Add(pBuildLocationtc, 0, wxALIGN_CENTER, 0); + pBuildLocationsz->Add(this->buildPathtc, 0, wxALIGN_CENTER, 0); pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND); propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - propertiesGridSizer->Add(pVersionDatetc, 1, wxEXPAND); + propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND); propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND); propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -203,8 +204,7 @@ void wxCDMProjectDescriptionPanel::CreateControls() sizer->SetSizeHints(this); } -void -wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event) +void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event) { wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); newEvent->SetId(1); @@ -214,8 +214,7 @@ wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event) event.Skip(); } -void -wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event) +void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event) { wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); newEvent->SetId(1); @@ -224,8 +223,7 @@ wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event) event.Skip(); } -void -wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event) +void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event) { wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); newEvent->SetId(1); @@ -236,25 +234,30 @@ wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event) void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->project->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); } void wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnSetBuildPath not implemented" << std::endl; - event.Skip(); + wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project")); + if(dialog->ShowModal()) + { + std::string* result; + if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + } + this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath())); } void wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->project->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR); } void @@ -263,4 +266,27 @@ wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event) //TODO: implement method std::cerr << "Event OnBtnSetVersion not implemented" << std::endl; event.Skip(); + + //get name + wxString libraryName = wxGetTextFromUser( + wxT("Enter the new version name"), + wxT("New Library - creaDevManager"), + crea::std2wx(this->project->GetVersion()) + ); + //check name + std::vector parts; + CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties); + if(parts.size() == 3) + { + std::string* result; + if(!this->project->SetVersion(crea::wx2std(libraryName), result)) + wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR); + } + else + { + wxMessageBox(crea::std2wx("The version format is incorrect, please follow the following format:\nX.Y.Z\nX: Major Version\nY: Minor Version\nZ: Build Version"),_T("Set Project Version - Error!"),wxOK | wxICON_ERROR); + } + this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion())); + this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate())); + } diff --git a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h index 0c347d8..0ac8771 100644 --- a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h @@ -71,6 +71,9 @@ public: private: modelCDMProject* project; + wxStaticText* versiontc; + wxStaticText* versionDatetc; + wxStaticText* buildPathtc; //handlers protected: