From: Daniel Gonzalez Date: Mon, 14 Jan 2013 14:38:17 +0000 (+0100) Subject: Feature #1711 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=752294dd30e2ee94f38be513d441f4716509ce13;p=crea.git Feature #1711 CreaDevManager application implementation -Create class implemented in application --- diff --git a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp index 079a093..bf0acee 100644 --- a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp @@ -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) diff --git a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp index 4bee166..8d72c28 100644 --- a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp @@ -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);