#include "wxCDMLibDescriptionPanel.h"
+#include "wxCDMMainFrame.h"
+
#include "creaDevManagerIds.h"
-#include "images/LbIcon.xpm"
+#include "images/LbIcon64.xpm"
BEGIN_EVENT_TABLE(wxCDMLibDescriptionPanel, wxPanel)
-EVT_MENU(ID_BUTTON_CREATE_LIBRARY, wxCDMLibDescriptionPanel::OnBtnCreateLibrary)
-EVT_MENU(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibDescriptionPanel::OnBtnEditCMakeLists)
+EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMLibDescriptionPanel::OnBtnCreateLibrary)
+EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibDescriptionPanel::OnBtnEditCMakeLists)
END_EVENT_TABLE()
wxCDMLibDescriptionPanel::wxCDMLibDescriptionPanel(
sizer->Add(new wxStaticText(this, -1, _("Libraries")),0, wxALIGN_CENTER, 0);
//Image
- sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon)),0, wxALIGN_CENTER, 0);
+ sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon64)),0, wxALIGN_CENTER, 0);
//Actions
wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
//TODO: implement method
std::cerr << "Event OnBtnCreateLibrary not implemented" << std::endl;
event.Skip();
+
+
+ //get name
+ wxString libraryName = wxGetTextFromUser(
+ _T("Enter the new library name"),
+ _T("New Library - creaDevManager"),
+ _T("")
+ );
+ //check name
+ if(libraryName.Len() > 0)
+ {
+ std::string* result;
+ //create library
+ modelCDMIProjectTreeNode* library = this->lib->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();
+ }
}
void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)