]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMFolderDescriptionPanel.cpp
index d3ca77b579bf59a7bad12108ac63ba2784b5c968..e0669cfc00718a79804cce55a63022a16188f2de 100644 (file)
@@ -44,6 +44,7 @@ BEGIN_EVENT_TABLE(wxCDMFolderDescriptionPanel, wxPanel)
 EVT_BUTTON(ID_BUTTON_PREV, wxCDMFolderDescriptionPanel::OnBtnReturn)
 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer)
 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists)
+EVT_BUTTON(ID_BUTTON_CREATE_CLASS, wxCDMFolderDescriptionPanel::OnBtnCreateClass)
 EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMFolderDescriptionPanel::OnBtnCreateFolder)
 END_EVENT_TABLE()
 
@@ -177,6 +178,42 @@ void wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
     }
 }
 
+void wxCDMFolderDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
+{
+  //get class name from user
+  wxTextEntryDialog* newClassDlg = new wxTextEntryDialog(
+      this,
+      wxT("Please enter the new class name."),
+      wxT("New Class - creaDevManager"),
+      wxT(""),
+      wxOK | wxCANCEL
+  );
+
+  if (newClassDlg->ShowModal() == wxID_OK)
+    {
+      std::string className = crea::wx2std(newClassDlg->GetValue());
+      //check class name
+      if(className.size() > 0)
+        {
+          if(!this->folder->CreateClass(className))
+            wxMessageBox(crea::std2wx("Something has gone wrong with the creation of the class."),_T("New Class - Error!"),wxOK | wxICON_ERROR);
+
+          ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
+
+          wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+          newEvent->SetId(0);
+          newEvent->SetInt(folder->GetId());
+          wxPostEvent(this->GetParent(), *newEvent);
+
+          wxMessageBox(crea::std2wx("The class has been created successfully."),_T("New Class - Success"),wxOK | wxICON_INFORMATION);
+        }
+      else
+        {
+          wxMessageBox(crea::std2wx("The new class name cannot be empty."),_T("New Class - Error!"),wxOK | wxICON_ERROR);
+        }
+    }
+}
+
 void wxCDMFolderDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)
 {
   //get name