X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcreaDevManagerLib%2FwxCDMFolderDescriptionPanel.cpp;h=9db89c4bad481323853cc2ac700e1bbb17106c8e;hb=311bdcc514f85386f3bbbef9ff6a88bf69fd930f;hp=7ac3841eaaea595c32c52fe6485a2fd981a5a5ab;hpb=609d8d48cae96384e664ec6b000e8ecfcbad6459;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp index 7ac3841..9db89c4 100644 --- a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp @@ -35,6 +35,7 @@ #include "wxCDMFolderDescriptionPanel.h" #include "wxCDMMainFrame.h" +#include "CDMUtilities.h" #include "creaDevManagerIds.h" #include "images/FdIcon64.xpm" @@ -43,6 +44,7 @@ BEGIN_EVENT_TABLE(wxCDMFolderDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_PREV, wxCDMFolderDescriptionPanel::OnBtnReturn) EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMFolderDescriptionPanel::OnBtnCreateFolder) END_EVENT_TABLE() wxCDMFolderDescriptionPanel::wxCDMFolderDescriptionPanel( @@ -114,6 +116,10 @@ void wxCDMFolderDescriptionPanel::CreateControls() actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); } + wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder")); + createFolderbt->SetToolTip(wxT("Create a new folder inside this folder.")); + actionsPanelSizer->Add(createFolderbt, 0, wxALL, 5); + actionsPanel->SetSizer(actionsPanelSizer); actionsPanelSizer->Fit(actionsPanel); actionsBox->Add(actionsPanel, 0, wxEXPAND); @@ -135,8 +141,8 @@ void wxCDMFolderDescriptionPanel::OnBtnReturn(wxCommandEvent& event) void wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer(wxCommandEvent& event) { std::string* result; - if(!this->folder->OpenInFileExplorer(result)) - wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); + if(!this->folder->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } void wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) @@ -156,6 +162,37 @@ void wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) } } +void wxCDMFolderDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event) +{ + //get name + wxString folderName = wxGetTextFromUser( + wxT("Enter the name of the new folder:"), + wxT("Create Folder - creaDevManager") + ); + //check name + std::vector parts; + CDMUtilities::splitter::split(parts, crea::wx2std(folderName), " /\\\"", CDMUtilities::splitter::no_empties); + if(parts.size() > 0) + { + std::string* result; + modelCDMFolder* folderC = this->folder->CreateFolder(crea::wx2std(folderName), result); + if(folderC == NULL) + { + wxMessageBox(crea::std2wx(*result),_T("Create Folder - Error!"),wxOK | wxICON_ERROR); + return; + } + ((wxCDMMainFrame*)this->GetParent())->RefreshProject(); + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(folderC->GetId()); + wxPostEvent(this->GetParent(), *newEvent); + wxMessageBox(crea::std2wx("The folder was successfully created"),_T("Create Folder - Success"),wxOK | wxICON_INFORMATION); + } + else + { + wxMessageBox(crea::std2wx("No name specified"),_T("Create Folder - Error!"),wxOK | wxICON_ERROR); + } +} + void wxCDMFolderDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) { wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);