]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMLibraryDescriptionPanel.cpp
index 62b5b930da28c8b3803447d01a45ed2002a8dad6..4bee166f5b2c922d69225b6b73c6306653df3b6c 100644 (file)
@@ -209,9 +209,38 @@ void wxCDMLibraryDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
 
 void wxCDMLibraryDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnCreateClass not implemented" << std::endl;
-  event.Skip();
+  //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->library->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(library->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 wxCDMLibraryDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)