]> Creatis software - crea.git/blob - appli/creaNewProject/creaNewProject.cpp
no message
[crea.git] / appli / creaNewProject / creaNewProject.cpp
1 #include <creaWx.h>
2 #include <wx/dirdlg.h>
3 class myApp : public wxApp
4 {
5 public:
6   bool OnInit( );
7   int  OnExit() { return true; }
8 };
9
10 IMPLEMENT_APP(myApp);
11 CREA_WXMAIN_WITH_CONSOLE
12
13 bool myApp::OnInit( )
14 {        
15   wxApp::OnInit();
16 #ifdef __WXGTK__
17   //See http://www.wxwindows.org/faqgtk.htm#locale
18   setlocale(LC_NUMERIC, "C");
19 #endif
20    wxInitAllImageHandlers();
21
22    wxString dir = wxDirSelector(_T("Select directory in which to create the project"), _T(""), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
23                                 
24    if (dir.IsEmpty()) return false;
25
26    wxString name = wxGetTextFromUser(_T("Enter project name"),
27                                      _T("creaNewProject"),
28                                      _T("New"));
29    if (name.IsEmpty()) return false;
30    
31 #if(_WIN32)
32    std::string command("creaNewProject.bat ");
33     std::string command1("creaSed.exe ");
34         std::string command2("del ");
35 #else
36    std::string command("creaNewProject.sh ");
37 #endif
38 <<<<<<< creaNewProject.cpp
39    command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
40 =======
41    command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\"";
42    command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "PROJECT_NAME " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\"";
43    command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\"";
44 >>>>>>> 1.3
45
46    if ( ! system ( command.c_str() ) )
47      {
48                  
49                  system ( command1.c_str() );
50                  system ( command2.c_str() );
51        wxMessageBox(_T("Done !"),_T("creaNewProject"),
52                     wxOK | wxICON_INFORMATION);
53      }
54    else 
55      {
56        wxString err(_T("An error occured while running '"));
57        err +=  crea::std2wx(command) + _T("'");
58        wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);      
59      }
60
61    return false;
62 }
63