]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Mon, 14 Jan 2013 14:38:17 +0000 (15:38 +0100)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Mon, 14 Jan 2013 14:38:17 +0000 (15:38 +0100)
CreaDevManager application implementation

-Create class implemented in application

lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp

index 079a0932b9da01f6794595416c1980c22e1274f0..bf0acee23ae8a81143a51ecb8ebddb56fa4f06e7 100644 (file)
@@ -216,9 +216,38 @@ void wxCDMApplicationDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
 
 void wxCDMApplicationDescriptionPanel::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->application->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(this->application->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 wxCDMApplicationDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)
index 4bee166f5b2c922d69225b6b73c6306653df3b6c..8d72c28b8d47034d7b8cee0f4b4357bf02770296 100644 (file)
@@ -231,7 +231,7 @@ void wxCDMLibraryDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
 
           wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
           newEvent->SetId(0);
-          newEvent->SetInt(library->GetId());
+          newEvent->SetInt(this->library->GetId());
           wxPostEvent(this->GetParent(), *newEvent);
 
           wxMessageBox(crea::std2wx("The class has been created successfully."),_T("New Class - Success"),wxOK | wxICON_INFORMATION);