X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMAppliDescriptionPanel.cpp;h=94f0d0037d0740ba622763237dda98cda0d30fbe;hb=03aef77bacc41f53b1d21b88e683302e7e1600c2;hp=1378f60efb7da213b4c938143d1c0fac8b876f3d;hpb=327c33758d25e6ff1f90f9ab74ea219eaed934a9;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp index 1378f60..94f0d00 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp @@ -126,7 +126,7 @@ void wxCDMAppliDescriptionPanel::CreateControls() std::vector applications = this->appli->GetApplications(); for (int i = 0; i < (int)(applications.size()); i++) { - wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); pApplicationlk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER); std::string tt = "Name: " + applications[i]->GetName() + "\n"; tt += "Location: " + applications[i]->GetPath(); @@ -184,36 +184,59 @@ void wxCDMAppliDescriptionPanel::CreateControls() void wxCDMAppliDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event) { //get name - wxString applicationName = wxGetTextFromUser( - _T("Enter the new application name"), - _T("New Application - creaDevManager"), - _T("") - ); - //check name - if(applicationName.Len() > 0) - { - std::string* result; - //create library - modelCDMIProjectTreeNode* application = this->appli->CreateApplication(crea::wx2std(applicationName),result); - //check library created - if(application == NULL) - { - wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR); - event.Skip(); - return; - } - wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - 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->SetClientData(application); - wxPostEvent(this->GetParent(), *newEvent); - event.Skip(); - } + wxTextEntryDialog* appDlg = new wxTextEntryDialog( + this, + wxT("Enter the new application name (NO white spaces)"), + wxT("New Application - creaDevManager"), + wxT(""), + wxOK | wxCANCEL + ); + + if (appDlg->ShowModal() == wxID_OK) + { + std::string applicationName = crea::wx2std(appDlg->GetValue()); + //check name + if(applicationName.size() > 0) + { + wxArrayString types; + types.Add(wxT("Console Application")); + types.Add(wxT("GUI Application (wxWidgets)")); + int applicationType = wxGetSingleChoiceIndex( + wxT("Select the application type"), + wxT("New Application - creaDevManager"), + types + ); + + if (applicationType != -1) + { + std::string* result; + //create library + modelCDMIProjectTreeNode* application = this->appli->CreateApplication(applicationName, applicationType ,result); + //check library created + if(application == NULL) + { + wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; + } + wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - 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->SetClientData(application); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); + } + } + else + { + wxMessageBox(crea::std2wx("Invalid application name, please try again with a valid name."),_T("New Application - Error!"),wxOK | wxICON_INFORMATION); + } + } } void wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)