X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMProjectDescriptionPanel.cpp;fp=lib%2FcreaDevManagerLib%2FwxCDMProjectDescriptionPanel.cpp;h=2d3aa8e24a214c648c9ef1c419a4adada54ac052;hb=73787c5a26e6b218b9e6c716dafc7d16330441e7;hp=11d91ef7684e8691910bea242fd4c62ccf4f60f0;hpb=5dc4f3d992f59df3b049458a00d8d3071f434a50;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp index 11d91ef..2d3aa8e 100644 --- a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp @@ -34,15 +34,18 @@ #include "wxCDMProjectDescriptionPanel.h" +#include "wxCDMMainFrame.h" + #include "creaDevManagerIds.h" #include "images/PrIcon.xpm" BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel) -EVT_MENU(ID_BUTTON_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage) -EVT_MENU(ID_BUTTON_CREATE_BLACKBOX, wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox) -EVT_MENU(ID_BUTTON_CREATE_LIBRARY, wxCDMProjectDescriptionPanel::OnBtnCreateLibrary) -EVT_MENU(ID_BUTTON_CREATE_APPLICATION, wxCDMProjectDescriptionPanel::OnBtnCreateApplication) -EVT_MENU(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage) +EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox) +EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMProjectDescriptionPanel::OnBtnCreateLibrary) +EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMProjectDescriptionPanel::OnBtnCreateApplication) +EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists) +EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMProjectDescriptionPanel::OnCreationComplete) END_EVENT_TABLE() wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel( @@ -154,8 +157,29 @@ void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event) void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event) { - //TODO: implement method + //implement method std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl; + wxString libraryName = wxGetTextFromUser( + _T("Enter the new library name"), + _T("New Library - creaDevManager"), + _T("") + ); + std::string* result; + modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result); + if(library == NULL) + { + wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; + } + wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION); + + //send event instead of calling parent to avoid crashing + ((wxCDMMainFrame*)this->GetParent())->RefreshProject(); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(library->GetId()); + wxPostEvent(this->GetParent(), *newEvent); event.Skip(); } @@ -172,3 +196,9 @@ void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl; event.Skip(); } + +void wxCDMProjectDescriptionPanel::OnCreationComplete(wxCommandEvent& event) +{ + std::cout << "catched" << std::endl; + +}