#include "creaDevManagerIds.h"
#include "images/PkIcon64.xpm"
+#include "wxCDMNewBlackBoxDialog.h"
#include <wx/textdlg.h>
#include "CDMUtilities.h"
void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnCreateBlackBox not implemented" << std::endl;
- event.Skip();
+
+ wxCDMNewBlackBoxDialog* dialog = new wxCDMNewBlackBoxDialog(this);
+ long userResponse;
+ userResponse = dialog->ShowModal();
+
+ if(userResponse == wxID_FORWARD)
+ {
+ std::string* result;
+ //create black box
+ modelCDMIProjectTreeNode* blackBox = this->package->CreateBlackBox(
+ result,
+ crea::wx2std(dialog->GetBlackBoxName()),
+ crea::wx2std(dialog->GetBlackBoxType()),
+ crea::wx2std(dialog->GetBlackBoxFormat()),
+ crea::wx2std(dialog->GetBlackBoxCategories()),
+ crea::wx2std(dialog->GetBlackBoxAuthor()),
+ crea::wx2std(dialog->GetBlackBoxAuthorEmail()),
+ crea::wx2std(dialog->GetBlackBoxDescription())
+ );
+ //check black box created
+ if(blackBox == NULL)
+ {
+ wxMessageBox(crea::std2wx(*result),_T("New Black Box - Error!"),wxOK | wxICON_ERROR);
+ return;
+ }
+ wxMessageBox(crea::std2wx("Black box successfully created."),_T("New Black Box - 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->SetId(1);
+ newEvent->SetInt(blackBox->GetId());
+ newEvent->SetString(wxT("blackbox"));
+ newEvent->SetClientData(blackBox);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
}
void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)