X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMPackageDescriptionPanel.cpp;h=00858bddbd9ccfb91596a91ac6b132a3bdcbba51;hb=311bdcc514f85386f3bbbef9ff6a88bf69fd930f;hp=4411c9eeb5cc9963864c7c8e4090aa35b64cd413;hpb=2c45094f8403883f8fb52c1801f1d96a35a471bf;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp index 4411c9e..00858bd 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp @@ -39,6 +39,7 @@ #include "creaDevManagerIds.h" #include "images/PkIcon64.xpm" +#include "wxCDMNewBlackBoxDialog.h" #include #include "CDMUtilities.h" @@ -325,9 +326,45 @@ void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event) 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)