#include "wxCDMAppliDescriptionPanel.h"
#include "creaDevManagerIds.h"
+
+#include "wxCDMMainFrame.h"
#include "images/ApIcon64.xpm"
BEGIN_EVENT_TABLE(wxCDMAppliDescriptionPanel, wxPanel)
-EVT_MENU(ID_BUTTON_CREATE_APPLICATION, wxCDMAppliDescriptionPanel::OnBtnCreateApplication)
-EVT_MENU(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists)
+EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMAppliDescriptionPanel::OnBtnCreateApplication)
+EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists)
END_EVENT_TABLE()
wxCDMAppliDescriptionPanel::wxCDMAppliDescriptionPanel(
void wxCDMAppliDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnCreateApplication not implemented" << std::endl;
- event.Skip();
+ //get name
+ wxString applicationName = wxGetTextFromUser(
+ _T("Enter the new application name"),
+ _T("New Application - creaDevManager"),
+ _T("")
+ );
+ //check name
+ if(applicationName.Len() > 0)
+ {
+ std::string* result;
+ //create library
+ modelCDMIProjectTreeNode* application = this->appli->CreateApplication(crea::wx2std(applicationName),result);
+ //check library created
+ if(application == NULL)
+ {
+ wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR);
+ event.Skip();
+ return;
+ }
+ wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - Success!"),wxOK | wxICON_INFORMATION);
+
+ //refreshing tree and description
+ //send event instead of calling parent to avoid crashing
+
+ ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
+
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+ newEvent->SetInt(application->GetId());
+ wxPostEvent(this->GetParent(), *newEvent);
+ event.Skip();
+ }
}
void wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)