]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.cpp
index ecd4e894b9ed75029418effb088dc6d31e176515..e49e2899feaa4375c5264feec4bb603fd7ceeabd 100644 (file)
@@ -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<std::string> 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()));
+
 }