]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMLibraryDescriptionPanel.cpp
index 61cec4d23a81460d13fd152cdcee4518460c4516..1c14b74cba6c48f405c6f22a89b0e364c1603115 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "wxCDMLibraryDescriptionPanel.h"
 
+#include "CDMUtilities.h"
 #include "wxCDMMainFrame.h"
 
 #include "creaDevManagerIds.h"
@@ -41,6 +42,7 @@
 
 BEGIN_EVENT_TABLE(wxCDMLibraryDescriptionPanel, wxPanel)
 EVT_BUTTON(ID_BUTTON_PREV, wxCDMLibraryDescriptionPanel::OnBtnReturn)
+EVT_BUTTON(ID_BUTTON_SET_NAME, wxCDMLibraryDescriptionPanel::OnBtnSetExeName)
 EVT_BUTTON(ID_BUTTON_CREATE_CLASS, wxCDMLibraryDescriptionPanel::OnBtnCreateClass)
 EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMLibraryDescriptionPanel::OnBtnCreateFolder)
 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibraryDescriptionPanel::OnBtnEditCMakeLists)
@@ -95,8 +97,34 @@ void wxCDMLibraryDescriptionPanel::CreateControls()
   //Image
   sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LIcon64)),0, wxALIGN_CENTER, 0);
 
-  //Project Name
-  sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->library->GetNameLibrary())),0, wxALIGN_CENTER, 0);
+  //Application Name
+  sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->library->GetName())),0, wxALIGN_CENTER, 0);
+
+  //Properties
+  wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
+  wxPanel* propertiesPanel = new wxPanel(this);
+  wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
+
+  wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
+
+  wxStaticText *pMainFile = new wxStaticText(propertiesPanel, -1, wxT("Library Name"));
+  wxBoxSizer* pMainFilesz = new wxBoxSizer(wxHORIZONTAL);
+  this->libraryNametc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->library->GetNameLibrary()));
+  wxButton* pMainFilebt = new wxButton(propertiesPanel, ID_BUTTON_SET_NAME, wxT("Set"));
+  pMainFilebt->SetToolTip(wxT("Set the name of the library for the project."));
+  pMainFilesz->Add(this->libraryNametc, 0, wxALIGN_CENTER_VERTICAL, 0);
+  pMainFilesz->Add(pMainFilebt, 0, wxALIGN_CENTER | wxLEFT, 10);
+
+  propertiesGridSizer->Add(pMainFile, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pMainFilesz, 1, wxEXPAND);
+
+  propertiesGridSizer->AddGrowableCol(1,1);
+
+  propertiesPanelSizer->Add(propertiesGridSizer, 0, wxEXPAND);
+  propertiesPanel->SetSizer(propertiesPanelSizer);
+  propertiesPanelSizer->Fit(propertiesPanel);
+  propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
+  sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
 
   //Actions
   wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
@@ -136,6 +164,30 @@ void wxCDMLibraryDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
   wxPostEvent(this->GetParent(), *newEvent);
 }
 
+void wxCDMLibraryDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
+{
+  //get name
+  wxString versionWx = wxGetTextFromUser(
+      wxT("Enter the new executable name"),
+      wxT("Change Library Name - creaDevManager"),
+      crea::std2wx(this->library->GetNameLibrary())
+  );
+  //check name
+  std::vector<std::string> parts;
+  CDMUtilities::splitter::split(parts, crea::wx2std(versionWx), " .", CDMUtilities::splitter::no_empties);
+  if(parts.size() > 0)
+    {
+      std::string* result;
+      if(!this->library->SetNameLibrary(crea::wx2std(versionWx), result))
+        wxMessageBox(crea::std2wx(*result),_T("Change Library Name - Error!"),wxOK | wxICON_ERROR);
+    }
+  else
+    {
+      wxMessageBox(crea::std2wx("No name specified"),_T("Set Library Name - Error!"),wxOK | wxICON_ERROR);
+    }
+  this->libraryNametc->SetLabel(crea::std2wx(this->library->GetNameLibrary()));
+}
+
 void wxCDMLibraryDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
 {
   //TODO: implement method
@@ -145,28 +197,52 @@ void wxCDMLibraryDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
 
 void wxCDMLibraryDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnCreateFolder not implemented" << std::endl;
-  event.Skip();
+  //get name
+  wxString folderName = wxGetTextFromUser(
+      wxT("Enter the name of the new folder:"),
+      wxT("Create Folder - creaDevManager")
+  );
+  //check name
+  std::vector<std::string> parts;
+  CDMUtilities::splitter::split(parts, crea::wx2std(folderName), " /\\\"", CDMUtilities::splitter::no_empties);
+  if(parts.size() > 0)
+    {
+      std::string* result;
+      modelCDMFolder* folderC = this->library->CreateFolder(crea::wx2std(folderName), result);
+      if(folderC == NULL)
+        {
+          wxMessageBox(crea::std2wx(*result),_T("Create Folder - Error!"),wxOK | wxICON_ERROR);
+          return;
+        }
+      ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
+      wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+      newEvent->SetInt(folderC->GetId());
+      wxPostEvent(this->GetParent(), *newEvent);
+      wxMessageBox(crea::std2wx("The folder was successfully created"),_T("Create Folder - Success"),wxOK | wxICON_INFORMATION);
+    }
+  else
+    {
+      wxMessageBox(crea::std2wx("No name specified"),_T("Create Folder - Error!"),wxOK | wxICON_ERROR);
+    }
 }
 
 void wxCDMLibraryDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
 {
   std::string* result;
-    if(!this->library->OpenCMakeListsFile(result))
-      wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+  if(!this->library->OpenCMakeListsFile(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
 
-    wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
 
-    if(this->library->GetCMakeLists() != NULL)
-      {
-        int CMId = this->library->GetCMakeLists()->GetId();
-        newEvent->SetInt(CMId);
-        newEvent->SetId(0);
-        wxPostEvent(this->GetParent(), *newEvent);
-      }
+  if(this->library->GetCMakeLists() != NULL)
+    {
+      int CMId = this->library->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
 
-    event.Skip();
+  event.Skip();
 }
 
 void wxCDMLibraryDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)