]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.cpp
index 11d91ef7684e8691910bea242fd4c62ccf4f60f0..2d3aa8e24a214c648c9ef1c419a4adada54ac052 100644 (file)
 
 #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;
+
+}