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)
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);