X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcreaDevManagerLib%2FwxCDMBlackBoxDescriptionPanel.cpp;h=d972925ac645b2de5e84b3eea9b2c9226e46aae7;hb=311bdcc514f85386f3bbbef9ff6a88bf69fd930f;hp=1303e9538ba0160a2ae4c4b44717e7c4b7245eef;hpb=9db3dcfa7151c22fb19fe0202ec03b4e8ac3f4b4;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp index 1303e95..d972925 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp @@ -41,8 +41,11 @@ BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn) -EVT_MENU(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx) -EVT_MENU(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx) +EVT_BUTTON(ID_BUTTON_SET_AUTHOR, wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor) +EVT_BUTTON(ID_BUTTON_SET_DESCRIPTION, wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription) +EVT_BUTTON(ID_BUTTON_SET_CATEGORY, wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories) +EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx) +EVT_BUTTON(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx) EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder) END_EVENT_TABLE() @@ -104,46 +107,35 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15); wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author")); - wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version")); wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description")); wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories")); // author wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors())); - wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors())); + wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change")); pAuthorbt->SetToolTip(wxT("Update the author/s of the package.")); - pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0); + pAuthorsz->Add(this->authortc, 0, wxALIGN_CENTER_VERTICAL, 0); pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10); - // version - wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetVersion())); - wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); - pVersionbt->SetToolTip(wxT("Update the version of the package.")); - pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0); - pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10); - // description wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription())); - wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription())); + wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change")); pDescriptionbt->SetToolTip(wxT("Update the description of the project.")); - pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pDescriptionsz->Add(this->descriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0); pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10); // categories wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pCategoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories())); - wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + this->categoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories())); + wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_CATEGORY, wxT("Change")); pCategoriesbt->SetToolTip(wxT("Update the categories of the project.")); - pCategoriessz->Add(pCategoriestc, 0, wxALIGN_CENTER_VERTICAL, 0); + pCategoriessz->Add(this->categoriestc, 0, wxALIGN_CENTER_VERTICAL, 0); pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10); propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND); - propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND); propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND); propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -164,14 +156,14 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() wxPanel* actionsPanel = new wxPanel(this); wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); - wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Cxx")); + wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open .cxx")); openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor.")); actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5); - wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Hxx")); - openHxxbt->SetToolTip(wxT("Open the .hxx file in the default text editor.")); + wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_HXX, _T("Open .h")); + openHxxbt->SetToolTip(wxT("Open the .h file in the default text editor.")); actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5); - wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder")); - openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer.")); + wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Source Folder")); + openFolderbt->SetToolTip(wxT("Open the source folder in the file explorer.")); actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5); actionsPanel->SetSizer(actionsPanelSizer); @@ -192,23 +184,104 @@ void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event) wxPostEvent(this->GetParent(), *newEvent); } +void wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor(wxCommandEvent& event) +{ + //get author from user + wxTextEntryDialog* authDlg = new wxTextEntryDialog( + this, + wxT("Enter the new authors name. Separate each author with a '/'."), + wxT("Change Black Box Author - creaDevManager"), + crea::std2wx(this->blackBox->GetAuthors()), + wxOK | wxCANCEL + ); + + if (authDlg->ShowModal() == wxID_OK) + { + std::string authorsStr = crea::wx2std(authDlg->GetValue()); + //check name + if(authorsStr.size() > 0) + { + std::string* result; + if(!this->blackBox->SetAuthors(authorsStr, result)) + wxMessageBox(crea::std2wx(*result),_T("Change Black Box Author - Error!"),wxOK | wxICON_ERROR); + + } + + this->authortc->SetLabel(crea::std2wx(this->blackBox->GetAuthors())); + this->authortc->GetParent()->GetSizer()->RecalcSizes(); + } + +} + +void wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event) +{ + //get author from user + wxTextEntryDialog* descDlg = new wxTextEntryDialog( + this, + wxT("Edit the black box description."), + wxT("Change Black Box Description - creaDevManager"), + crea::std2wx(this->blackBox->GetDescription()), + wxTE_MULTILINE | wxOK | wxCANCEL + ); + + if (descDlg->ShowModal() == wxID_OK) + { + std::string descriptionStr = crea::wx2std(descDlg->GetValue()); + //check name + if(descriptionStr.size() > 0) + { + std::string* result; + if(!this->blackBox->SetDescription(descriptionStr, result)) + wxMessageBox(crea::std2wx(*result),_T("Change Black Box Description - Error!"),wxOK | wxICON_ERROR); + } + this->descriptiontc->SetLabel(crea::std2wx(this->blackBox->GetDescription())); + this->descriptiontc->GetParent()->GetSizer()->RecalcSizes(); + } +} + +void wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories(wxCommandEvent& event) +{ + //get author from user + wxTextEntryDialog* catsDlg = new wxTextEntryDialog( + this, + wxT("Edit the black box categories separated by '/'."), + wxT("Change Black Box Categories - creaDevManager"), + crea::std2wx(this->blackBox->GetCategories()), + wxTE_MULTILINE | wxOK | wxCANCEL + ); + + if (catsDlg->ShowModal() == wxID_OK) + { + std::string categoriesStr = crea::wx2std(catsDlg->GetValue()); + //check name + if(categoriesStr.size() > 0) + { + std::string* result; + if(!this->blackBox->SetCategories(categoriesStr, result)) + wxMessageBox(crea::std2wx(*result),_T("Change Black Box Categories - Error!"),wxOK | wxICON_ERROR); + } + this->categoriestc->SetLabel(crea::std2wx(this->blackBox->GetCategories())); + this->categoriestc->GetParent()->GetSizer()->RecalcSizes(); + } +} + void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenCxx not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->blackBox->OpenCxx(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Source File - Error!"),wxOK | wxICON_ERROR); } void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenHxx not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->blackBox->OpenHxx(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Header File - Error!"),wxOK | wxICON_ERROR); } void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->blackBox->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); }