]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.cpp
index 2d3aa8e24a214c648c9ef1c419a4adada54ac052..2d8b0c1a5c1d2588903f2cbe95edfa63895b5622 100644 (file)
@@ -37,7 +37,7 @@
 #include "wxCDMMainFrame.h"
 
 #include "creaDevManagerIds.h"
-#include "images/PrIcon.xpm"
+#include "images/PrIcon64.xpm"
 
 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
 EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage)
@@ -89,7 +89,7 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
 
   //Image
-  sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon)),0, wxALIGN_CENTER, 0);
+  sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
 
   //Project Name
   sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
@@ -157,30 +157,37 @@ void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
 {
-  //implement method
-  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  //get name
   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)
+  //check name
+  if(libraryName.Len() > 0)
     {
-      wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
+      std::string* result;
+      //create library
+      modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
+      //check library created
+      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);
+
+      //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(library->GetId());
+      wxPostEvent(this->GetParent(), *newEvent);
       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();
 }
 
 void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)