]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp
70a45fa6d7877a933e23cdf489efe917983ac067
[crea.git] / lib / creaDevManagerLib / wxCDMApplicationDescriptionPanel.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Sant�)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and
11 #  abiding by the rules of distribution of free software. You can  use,
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B
13 #  license as circulated by CEA, CNRS and INRIA at the following URL
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability.
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26  */
27
28 /*
29  * wxCDMApplicationDescriptionPanel.cpp
30  *
31  *  Created on: Nov 27, 2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #include "wxCDMApplicationDescriptionPanel.h"
36
37 #include "CDMUtilities.h"
38 #include "wxCDMMainFrame.h"
39
40 #include "wxCDMApplicationHelpDialog.h"
41
42 #include "creaDevManagerIds.h"
43 #include "images/AIcon64.xpm"
44
45 BEGIN_EVENT_TABLE(wxCDMApplicationDescriptionPanel, wxPanel)
46 EVT_BUTTON(ID_BUTTON_SET_NAME, wxCDMApplicationDescriptionPanel::OnBtnSetExeName)
47 EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMApplicationDescriptionPanel::OnBtnReturn)
48 EVT_BUTTON(ID_BUTTON_CREATE_CLASS, wxCDMApplicationDescriptionPanel::OnBtnCreateClass)
49 EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnCreateFolder)
50 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists)
51 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnOpenFolder)
52 EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMApplicationDescriptionPanel::OnBtnOpenMain)
53 EVT_CHECKBOX(ID_CHECK_INCLUDE_3RDLIBRARY, wxCDMApplicationDescriptionPanel::On3rdLibraryChBChange)
54 EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMApplicationDescriptionPanel::OnLibraryChBChange)
55 END_EVENT_TABLE()
56
57 wxCDMApplicationDescriptionPanel::wxCDMApplicationDescriptionPanel(
58     wxWindow* parent,
59     modelCDMApplication* application,
60     wxWindowID id,
61     const wxString& caption,
62     const wxPoint& pos,
63     const wxSize& size,
64     long style
65 )
66 {
67   wxCDMApplicationDescriptionPanel::Create(parent, application, id, caption, pos, size, style);
68 }
69
70 wxCDMApplicationDescriptionPanel::~wxCDMApplicationDescriptionPanel()
71 {
72 }
73
74 bool wxCDMApplicationDescriptionPanel::Create(
75     wxWindow* parent,
76     modelCDMApplication* application,
77     wxWindowID id,
78     const wxString& caption,
79     const wxPoint& pos,
80     const wxSize& size,
81     long style
82 )
83 {
84   wxPanel::Create(parent, id, pos, size, style);
85   this->application = application;
86   CreateControls();
87   // this part makes the scrollbars show up
88   this->FitInside(); // ask the sizer about the needed size
89   this->SetScrollRate(5, 5);
90   return TRUE;
91 }
92
93 void wxCDMApplicationDescriptionPanel::CreateControls()
94 {
95   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
96
97   //Links to return
98   wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
99   std::vector<modelCDMIProjectTreeNode*> parents = this->application->GetParents();
100   for (int i = 0; i < (int)(parents.size()); i++)
101     {
102                 wxHyperlinkCtrl* returnLnk = new wxHyperlinkCtrl(this, ID_BUTTON_PREV, crea::std2wx(parents[parents.size()-1-i]->GetName()), crea::std2wx(parents[parents.size()-1-i]->GetPath()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
103       returnLnk->SetWindowStyle(wxNO_BORDER);
104       returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
105       linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
106       linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
107     }
108   linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->application->GetName())), 0, wxALIGN_CENTER, 0);
109   sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
110
111   //Header
112   wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
113   {
114     //Image
115     headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(AIcon64)),0, wxALIGN_CENTER, 0);
116     wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
117     //Title
118     textSizer->Add(new wxStaticText(this, -1, _("Application")),0, wxALIGN_LEFT, 0);
119     //Application Name
120     textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->application->GetName())),0, wxALIGN_LEFT, 0);
121     headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
122   }
123   sizer->Add(headerSizer, 0, wxALIGN_CENTER);
124
125   /*  //Properties
126   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
127   wxPanel* propertiesPanel = new wxPanel(this);
128   wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
129
130   wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
131
132   wxStaticText *pMainFile = new wxStaticText(propertiesPanel, -1, wxT("Executable Name"));
133   wxBoxSizer* pMainFilesz = new wxBoxSizer(wxHORIZONTAL);
134   this->executableNametc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->application->GetExecutableName()));
135   wxButton* pMainFilebt = new wxButton(propertiesPanel, ID_BUTTON_SET_NAME, wxT("Set"));
136   pMainFilebt->SetToolTip(wxT("Set the name of the executable file for the application."));
137   pMainFilesz->Add(this->executableNametc, 0, wxALIGN_CENTER_VERTICAL, 0);
138   pMainFilesz->Add(pMainFilebt, 0, wxALIGN_CENTER | wxLEFT, 10);
139
140   propertiesGridSizer->Add(pMainFile, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
141   propertiesGridSizer->Add(pMainFilesz, 1, wxEXPAND);
142
143   propertiesGridSizer->AddGrowableCol(1,1);
144
145   propertiesPanelSizer->Add(propertiesGridSizer, 0, wxEXPAND);
146   propertiesPanel->SetSizer(propertiesPanelSizer);
147   propertiesPanelSizer->Fit(propertiesPanel);
148   propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
149   sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
150    */
151
152   //Includes
153   wxStaticBoxSizer* includesBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Used Libraries"));
154   includesBox->SetMinSize(250,250);
155   wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
156   wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
157
158   //Third Party Libraries
159   wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
160   wxFont font = Title1->GetFont();
161   font.SetWeight(wxFONTWEIGHT_BOLD);
162   Title1->SetFont(font);
163   includesPanelSizer->Add(Title1, 0, wxEXPAND);
164
165   //inclusion data
166   std::map<std::string, bool> inclusions = this->application->Get3rdPartyLibraries();
167   //includesGrid Sizer
168   wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
169
170   wxStaticText* ChBTitle = new wxStaticText(
171       includesPanel,
172       wxID_ANY,
173       wxT("Included"),
174       wxDefaultPosition,
175       wxDefaultSize,
176       wxALIGN_CENTER
177     );
178   wxStaticText* LNmTitle = new wxStaticText(
179       includesPanel,
180       wxID_ANY,
181       wxT("Library Name"),
182       wxDefaultPosition,
183       wxDefaultSize,
184       wxALIGN_LEFT
185     );
186
187   includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
188   includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
189
190   for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
191     wxCheckBox* ChBIncl = new wxCheckBox(
192         includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
193       );
194     ChBIncl->SetToolTip(crea::std2wx(
195         "When this box is checked the " + it->first + " library\n"
196         "is included in the project configuration for\n"
197         "this application including the following instruction\n"
198         "in the application's folder CMakeLists.txt file:\n"
199         "SET ( ${LIBRARY_NAME}_LINK_LIBRARIES\n"
200         "  ${" + it->first+ "_LIBRARIES}\n"
201         ")"));
202     ChBIncl->SetName(crea::std2wx(it->first));
203     ChBIncl->SetValue(it->second);
204     includesGridSizer->Add(ChBIncl, 1, wxEXPAND);
205
206     wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
207     includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
208   }
209
210   includesGridSizer->AddGrowableCol(1,1);
211
212   includesPanelSizer->Add(includesGridSizer, 0, wxEXPAND | wxLEFT, 5);
213
214   //Custom Libraries
215   wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
216   font = Title2->GetFont();
217   font.SetWeight(wxFONTWEIGHT_BOLD);
218   Title2->SetFont(font);
219   includesPanelSizer->Add(Title2, 0, wxEXPAND);
220
221   //inclusion data
222   std::map<std::string, bool> inclusionsLibs = this->application->GetCustomLibraries();
223   //includesGrid Sizer
224   wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
225
226   wxStaticText* ChBTitle1 = new wxStaticText(
227       includesPanel,
228       wxID_ANY,
229       wxT("Included"),
230       wxDefaultPosition,
231       wxDefaultSize,
232       wxALIGN_CENTER
233     );
234   wxStaticText* LNmTitle1 = new wxStaticText(
235       includesPanel,
236       wxID_ANY,
237       wxT("Library Name"),
238       wxDefaultPosition,
239       wxDefaultSize,
240       wxALIGN_LEFT
241     );
242
243   includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
244   includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
245
246   for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
247     wxCheckBox* ChBIncl = new wxCheckBox(
248         includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
249       );
250     ChBIncl->SetToolTip(crea::std2wx(
251         "When this box is checked the " + it->first + " custom\n"
252         "library is included in the project configuration for\n"
253         "this application including the following code in the\n"
254         "application's folder CMakeLists.txt file:\n"
255         "INCLUDE_DIRECTORIES (\n"
256         "  ../../lib/"+ it->first + "\n"
257         ")\n"
258         "SET ( ${EXE_NAME}_LINK_LIBRARIES\n"
259         "  " + it->first+ "\n"
260         ")"));
261     ChBIncl->SetName(crea::std2wx(it->first));
262     ChBIncl->SetValue(it->second);
263     includesLibGridSizer->Add(ChBIncl, 1, wxEXPAND);
264
265     wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
266     includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
267   }
268
269   includesLibGridSizer->AddGrowableCol(1,1);
270
271   includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
272
273   includesPanel->SetSizer(includesPanelSizer);
274   includesPanelSizer->Fit(includesPanel);
275
276   includesPanel->FitInside();
277   includesPanel->SetScrollRate(5,5);
278
279   includesBox->Add(includesPanel, 1, wxEXPAND);
280   sizer -> Add(includesBox, 0, wxALL | wxEXPAND, 10);
281
282
283   //Actions
284   //actions StaticBoxSizer
285   wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions"));
286   actionsBox->GetStaticBox()->SetToolTip(wxT("Create classes or edit them for this application, as well as editing the application's CMakeLists.txt file by selecting the desired action."));
287   //actions Panel
288   wxPanel* actionsPanel = new wxPanel(this);
289   //actions Sizer
290   wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
291   //actionsGrid Sizer
292   wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(3, 2, 9, 15);
293
294   wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("Create Class"));
295   createClassbt->SetToolTip(wxT("Create a new Class (.h and .cxx files)."));
296   wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder"));
297   createFolderbt->SetToolTip(wxT("Create a new Folder inside the application folder."));
298   wxButton* openMainbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("A. Open Main File"));
299   openMainbt->SetToolTip(wxT("Open the main file in the application folder with the default code editor."));
300   openMainbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseEnter,NULL,this);
301   openMainbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseExit,NULL,this);
302   wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
303   editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file inside this application."));
304   editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter,NULL,this);
305   editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseExit,NULL,this);
306   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Application Folder"));
307   openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer."));
308
309
310   actionsGridSizer->Add(openMainbt, 1, wxALL | wxEXPAND, 5);
311   actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
312   actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
313   actionsGridSizer->Add(createClassbt, 1, wxALL | wxEXPAND, 5);
314   actionsGridSizer->Add(createFolderbt, 1, wxALL | wxEXPAND, 5);
315
316   //SetPanel sizer and box
317   actionsGridSizer->AddGrowableCol(0,1);
318   actionsGridSizer->AddGrowableCol(1,1);
319
320   actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
321   actionsPanel->SetSizer(actionsPanelSizer);
322   actionsPanelSizer->Fit(actionsPanel);
323   actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
324   sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
325
326   //Assign sizer
327   SetSizer(sizer);
328   sizer->SetSizeHints(this);
329
330   if (((wxCDMMainFrame*)this->GetParent())->isHelp())
331     {
332       wxCDMApplicationHelpDialog* helpDialog = new wxCDMApplicationHelpDialog(this->GetParent(), this->application, wxID_ANY);
333       helpDialog->Show(true);
334     }
335 }
336
337 void wxCDMApplicationDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
338 {
339   std::vector<modelCDMIProjectTreeNode*> parents = this->application->GetParents();
340   std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
341   //std::cout << parentURL << std::endl;
342   for (int i = 0; i < (int)(parents.size()); i++)
343     {
344       if (parents[i]->GetPath() == parentURL)
345         {
346           wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
347           newEvent->SetClientData(parents[i]);
348           newEvent->SetId(0);
349           wxPostEvent(this->GetParent(), *newEvent);
350         }
351     }
352
353 }
354
355 void wxCDMApplicationDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
356 {
357   //get name
358   wxString versionWx = wxGetTextFromUser(
359       wxT("Enter the new executable name"),
360       wxT("Change Application Executable Name - creaDevManager"),
361       crea::std2wx(this->application->GetExecutableName())
362   );
363   //check name
364   std::vector<std::string> parts;
365   CDMUtilities::splitter::split(parts, crea::wx2std(versionWx), " .", CDMUtilities::splitter::no_empties);
366   if(parts.size() > 0)
367     {
368       std::string* result;
369       if(!this->application->SetExecutableName(crea::wx2std(versionWx), result))
370         wxMessageBox(crea::std2wx(*result),_T("Change Application Executable Name - Error!"),wxOK | wxICON_ERROR);
371     }
372   else
373     {
374       wxMessageBox(crea::std2wx("No name specified"),_T("Set Application Executable Name - Error!"),wxOK | wxICON_ERROR);
375     }
376   this->executableNametc->SetLabel(crea::std2wx(this->application->GetExecutableName()));
377 }
378
379 void wxCDMApplicationDescriptionPanel::On3rdLibraryChBChange(wxCommandEvent& event)
380 {
381   if(this->application->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
382     ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
383   else
384     ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
385 }
386
387 void wxCDMApplicationDescriptionPanel::OnLibraryChBChange(wxCommandEvent& event)
388 {
389   if(this->application->SetCustomLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
390       ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
391     else
392       ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
393 }
394
395 void wxCDMApplicationDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
396 {
397   //get class name from user
398   wxTextEntryDialog* newClassDlg = new wxTextEntryDialog(
399       this,
400       wxT("Please enter the new class name."),
401       wxT("New Class - creaDevManager"),
402       wxT(""),
403       wxOK | wxCANCEL
404   );
405
406   if (newClassDlg->ShowModal() == wxID_OK)
407     {
408       std::string className = crea::wx2std(newClassDlg->GetValue());
409       //check class name
410       if(className.size() > 0)
411         {
412           if(!this->application->CreateClass(className))
413             wxMessageBox(crea::std2wx("Something has gone wrong with the creation of the class."),_T("New Class - Error!"),wxOK | wxICON_ERROR);
414
415           ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
416
417           wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
418           newEvent->SetId(0);
419           newEvent->SetClientData(this->application);
420           wxPostEvent(this->GetParent(), *newEvent);
421
422           wxMessageBox(crea::std2wx("The class has been created successfully."),_T("New Class - Success"),wxOK | wxICON_INFORMATION);
423         }
424       else
425         {
426           wxMessageBox(crea::std2wx("The new class name cannot be empty."),_T("New Class - Error!"),wxOK | wxICON_ERROR);
427         }
428     }
429 }
430
431 void wxCDMApplicationDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)
432 {
433   //get name
434   wxString folderName = wxGetTextFromUser(
435       wxT("Enter the name of the new folder:"),
436       wxT("Create Folder - creaDevManager")
437   );
438   //check name
439   std::vector<std::string> parts;
440   CDMUtilities::splitter::split(parts, crea::wx2std(folderName), " /\\\"", CDMUtilities::splitter::no_empties);
441   if(parts.size() > 0)
442     {
443       std::string* result;
444       modelCDMFolder* folderC = this->application->CreateFolder(crea::wx2std(folderName), result);
445       if(folderC == NULL)
446         {
447           wxMessageBox(crea::std2wx(*result),_T("Create Folder - Error!"),wxOK | wxICON_ERROR);
448           return;
449         }
450       ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
451       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
452       newEvent->SetClientData(folderC);
453       wxPostEvent(this->GetParent(), *newEvent);
454       wxMessageBox(crea::std2wx("The folder was successfully created"),_T("Create Folder - Success"),wxOK | wxICON_INFORMATION);
455     }
456   else
457     {
458       wxMessageBox(crea::std2wx("No name specified"),_T("Create Folder - Error!"),wxOK | wxICON_ERROR);
459     }
460 }
461
462 void wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
463 {
464   std::string* result;
465   if(!this->application->OpenCMakeListsFile(result))
466     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
467
468   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
469
470   if(this->application->GetCMakeLists() != NULL)
471     {
472       newEvent->SetClientData(this->application->GetCMakeLists());
473       newEvent->SetId(0);
474       wxPostEvent(this->GetParent(), *newEvent);
475     }
476
477   event.Skip();
478 }
479
480 void wxCDMApplicationDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
481 {
482   std::string* result;
483   if(!this->application->OpenInFileExplorer(result))
484     wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
485 }
486
487 void wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
488 {
489   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
490
491   if(this->application->GetCMakeLists() != NULL)
492     {
493       newEvent->SetClientData(this->application->GetCMakeLists());
494       newEvent->SetId(0);
495       wxPostEvent(this->GetParent(), *newEvent);
496     }
497   event.Skip();
498 }
499
500 void wxCDMApplicationDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
501 {
502   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
503
504   if(this->application->GetCMakeLists() != NULL)
505     {
506       newEvent->SetClientData(this->application->GetCMakeLists());
507       newEvent->SetId(0);
508       wxPostEvent(this->GetParent(), *newEvent);
509     }
510   event.Skip();
511 }
512
513 void wxCDMApplicationDescriptionPanel::OnBtnOpenMain(wxCommandEvent& event)
514 {
515   if (this->application->GetMainFile() != NULL)
516     {
517       if (CDMUtilities::openTextEditor(this->application->GetMainFile()->GetPath()))
518       {
519         wxMessageBox(crea::std2wx("The main file couldn't be opened."),_T("Open Main File - Error!"),wxOK | wxICON_ERROR);
520       }
521
522       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
523
524       newEvent->SetClientData(this->application->GetMainFile());
525       newEvent->SetId(0);
526       wxPostEvent(this->GetParent(), *newEvent);
527
528       event.Skip();
529     }
530   else
531     {
532       wxMessageBox(crea::std2wx("There is no main file or it couldn't be detected."),_T("Open Main File - Error!"),wxOK | wxICON_ERROR);
533     }
534 }
535
536 void wxCDMApplicationDescriptionPanel::OnMainMouseEnter(wxMouseEvent& event)
537 {
538   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
539
540   if(this->application->GetMainFile() != NULL)
541     {
542       newEvent->SetClientData(this->application->GetMainFile());
543       newEvent->SetId(0);
544       wxPostEvent(this->GetParent(), *newEvent);
545     }
546   event.Skip();
547 }
548
549 void wxCDMApplicationDescriptionPanel::OnMainMouseExit(wxMouseEvent& event)
550 {
551   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
552
553   if(this->application->GetMainFile() != NULL)
554     {
555       newEvent->SetClientData(this->application->GetMainFile());
556       newEvent->SetId(0);
557       wxPostEvent(this->GetParent(), *newEvent);
558     }
559   event.Skip();
560 }