]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp
Feature #1711 CreaDevManager application implementation
[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
86   // this part makes the scrollbars show up
87   this->FitInside(); // ask the sizer about the needed size
88   this->SetScrollRate(5, 5);
89
90   this->application = application;
91   CreateControls();
92   return TRUE;
93 }
94
95 void wxCDMApplicationDescriptionPanel::CreateControls()
96 {
97   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
98
99   //Links to return
100   wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
101   std::vector<modelCDMIProjectTreeNode*> parents = this->application->GetParents();
102   for (int i = 0; i < (int)(parents.size()); i++)
103     {
104                 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);
105       returnLnk->SetWindowStyle(wxNO_BORDER);
106       returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
107       linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
108       linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
109     }
110   linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->application->GetName())), 0, wxALIGN_CENTER, 0);
111   sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
112
113   //Header
114   wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
115   {
116     //Image
117     headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(AIcon64)),0, wxALIGN_CENTER, 0);
118     wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
119     //Title
120     textSizer->Add(new wxStaticText(this, -1, _("Application")),0, wxALIGN_LEFT, 0);
121     //Application Name
122     textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->application->GetName())),0, wxALIGN_LEFT, 0);
123     headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
124   }
125   sizer->Add(headerSizer, 0, wxALIGN_CENTER);
126
127   /*  //Properties
128   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
129   wxPanel* propertiesPanel = new wxPanel(this);
130   wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
131
132   wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
133
134   wxStaticText *pMainFile = new wxStaticText(propertiesPanel, -1, wxT("Executable Name"));
135   wxBoxSizer* pMainFilesz = new wxBoxSizer(wxHORIZONTAL);
136   this->executableNametc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->application->GetExecutableName()));
137   wxButton* pMainFilebt = new wxButton(propertiesPanel, ID_BUTTON_SET_NAME, wxT("Set"));
138   pMainFilebt->SetToolTip(wxT("Set the name of the executable file for the application."));
139   pMainFilesz->Add(this->executableNametc, 0, wxALIGN_CENTER_VERTICAL, 0);
140   pMainFilesz->Add(pMainFilebt, 0, wxALIGN_CENTER | wxLEFT, 10);
141
142   propertiesGridSizer->Add(pMainFile, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
143   propertiesGridSizer->Add(pMainFilesz, 1, wxEXPAND);
144
145   propertiesGridSizer->AddGrowableCol(1,1);
146
147   propertiesPanelSizer->Add(propertiesGridSizer, 0, wxEXPAND);
148   propertiesPanel->SetSizer(propertiesPanelSizer);
149   propertiesPanelSizer->Fit(propertiesPanel);
150   propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
151   sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
152    */
153
154   //Includes
155   wxStaticBoxSizer* includesBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Used Libraries"));
156   includesBox->SetMinSize(250,250);
157   wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
158   wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
159
160   //Third Party Libraries
161   wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
162   wxFont font = Title1->GetFont();
163   font.SetWeight(wxFONTWEIGHT_BOLD);
164   Title1->SetFont(font);
165   includesPanelSizer->Add(Title1, 0, wxEXPAND);
166
167   //inclusion data
168   std::map<std::string, bool> inclusions = this->application->Get3rdPartyLibraries();
169   //includesGrid Sizer
170   wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
171
172   wxStaticText* ChBTitle = new wxStaticText(
173       includesPanel,
174       wxID_ANY,
175       wxT("Included"),
176       wxDefaultPosition,
177       wxDefaultSize,
178       wxALIGN_CENTER
179     );
180   wxStaticText* LNmTitle = new wxStaticText(
181       includesPanel,
182       wxID_ANY,
183       wxT("Library Name"),
184       wxDefaultPosition,
185       wxDefaultSize,
186       wxALIGN_LEFT
187     );
188
189   includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
190   includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
191
192   for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
193     wxCheckBox* ChBIncl = new wxCheckBox(
194         includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
195       );
196     ChBIncl->SetToolTip(crea::std2wx("When this box is checked the " + it->first + " library is included in the project configuration for this application."));
197     ChBIncl->SetName(crea::std2wx(it->first));
198     ChBIncl->SetValue(it->second);
199     includesGridSizer->Add(ChBIncl, 1, wxEXPAND);
200
201     wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
202     includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
203   }
204
205   includesGridSizer->AddGrowableCol(1,1);
206
207   includesPanelSizer->Add(includesGridSizer, 0, wxEXPAND | wxLEFT, 5);
208
209   //Custom Libraries
210   wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
211   font = Title2->GetFont();
212   font.SetWeight(wxFONTWEIGHT_BOLD);
213   Title2->SetFont(font);
214   includesPanelSizer->Add(Title2, 0, wxEXPAND);
215
216   //inclusion data
217   std::map<std::string, bool> inclusionsLibs = this->application->GetCustomLibraries();
218   //includesGrid Sizer
219   wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
220
221   wxStaticText* ChBTitle1 = new wxStaticText(
222       includesPanel,
223       wxID_ANY,
224       wxT("Included"),
225       wxDefaultPosition,
226       wxDefaultSize,
227       wxALIGN_CENTER
228     );
229   wxStaticText* LNmTitle1 = new wxStaticText(
230       includesPanel,
231       wxID_ANY,
232       wxT("Library Name"),
233       wxDefaultPosition,
234       wxDefaultSize,
235       wxALIGN_LEFT
236     );
237
238   includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
239   includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
240
241   for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
242     wxCheckBox* ChBIncl = new wxCheckBox(
243         includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
244       );
245     ChBIncl->SetToolTip(crea::std2wx("When this box is checked the " + it->first + " custom library is included in the project configuration for this application."));
246     ChBIncl->SetName(crea::std2wx(it->first));
247     ChBIncl->SetValue(it->second);
248     includesLibGridSizer->Add(ChBIncl, 1, wxEXPAND);
249
250     wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
251     includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
252   }
253
254   includesLibGridSizer->AddGrowableCol(1,1);
255
256   includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
257
258   includesPanel->SetSizer(includesPanelSizer);
259   includesPanelSizer->Fit(includesPanel);
260
261   includesPanel->FitInside();
262   includesPanel->SetScrollRate(5,5);
263
264   includesBox->Add(includesPanel, 1, wxEXPAND);
265   sizer -> Add(includesBox, 0, wxALL | wxEXPAND, 10);
266
267
268   //Actions
269   //actions StaticBoxSizer
270   wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions"));
271   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."));
272   //actions Panel
273   wxPanel* actionsPanel = new wxPanel(this);
274   //actions Sizer
275   wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
276   //actionsGrid Sizer
277   wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(3, 2, 9, 15);
278
279   wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("Create Class"));
280   createClassbt->SetToolTip(wxT("Create a new Class (.h and .cxx files)."));
281   wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder"));
282   createFolderbt->SetToolTip(wxT("Create a new Folder inside the application folder."));
283   wxButton* openMainbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("A. Open Main File"));
284   openMainbt->SetToolTip(wxT("Open the main file in the application folder with the default code editor."));
285   openMainbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseEnter,NULL,this);
286   openMainbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseExit,NULL,this);
287   wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
288   editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file inside this application."));
289   editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter,NULL,this);
290   editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseExit,NULL,this);
291   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Application Folder"));
292   openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer."));
293
294
295   actionsGridSizer->Add(openMainbt, 1, wxALL | wxEXPAND, 5);
296   actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
297   actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
298   actionsGridSizer->Add(createClassbt, 1, wxALL | wxEXPAND, 5);
299   actionsGridSizer->Add(createFolderbt, 1, wxALL | wxEXPAND, 5);
300
301   //SetPanel sizer and box
302   actionsGridSizer->AddGrowableCol(0,1);
303   actionsGridSizer->AddGrowableCol(1,1);
304
305   actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
306   actionsPanel->SetSizer(actionsPanelSizer);
307   actionsPanelSizer->Fit(actionsPanel);
308   actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
309   sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
310
311   //Assign sizer
312   SetSizer(sizer);
313   sizer->SetSizeHints(this);
314
315   if (((wxCDMMainFrame*)this->GetParent())->isHelp())
316     {
317       wxCDMApplicationHelpDialog* helpDialog = new wxCDMApplicationHelpDialog(this->GetParent(), this->application, wxID_ANY);
318       helpDialog->Show(true);
319     }
320 }
321
322 void wxCDMApplicationDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
323 {
324   std::vector<modelCDMIProjectTreeNode*> parents = this->application->GetParents();
325   std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
326   //std::cout << parentURL << std::endl;
327   for (int i = 0; i < (int)(parents.size()); i++)
328     {
329       if (parents[i]->GetPath() == parentURL)
330         {
331           wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
332           newEvent->SetClientData(parents[i]);
333           newEvent->SetId(0);
334           wxPostEvent(this->GetParent(), *newEvent);
335         }
336     }
337
338 }
339
340 void wxCDMApplicationDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
341 {
342   //get name
343   wxString versionWx = wxGetTextFromUser(
344       wxT("Enter the new executable name"),
345       wxT("Change Application Executable Name - creaDevManager"),
346       crea::std2wx(this->application->GetExecutableName())
347   );
348   //check name
349   std::vector<std::string> parts;
350   CDMUtilities::splitter::split(parts, crea::wx2std(versionWx), " .", CDMUtilities::splitter::no_empties);
351   if(parts.size() > 0)
352     {
353       std::string* result;
354       if(!this->application->SetExecutableName(crea::wx2std(versionWx), result))
355         wxMessageBox(crea::std2wx(*result),_T("Change Application Executable Name - Error!"),wxOK | wxICON_ERROR);
356     }
357   else
358     {
359       wxMessageBox(crea::std2wx("No name specified"),_T("Set Application Executable Name - Error!"),wxOK | wxICON_ERROR);
360     }
361   this->executableNametc->SetLabel(crea::std2wx(this->application->GetExecutableName()));
362 }
363
364 void wxCDMApplicationDescriptionPanel::On3rdLibraryChBChange(wxCommandEvent& event)
365 {
366   this->application->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue());
367 }
368
369 void wxCDMApplicationDescriptionPanel::OnLibraryChBChange(wxCommandEvent& event)
370 {
371   this->application->SetCustomLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue());
372 }
373
374 void wxCDMApplicationDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
375 {
376   //get class name from user
377   wxTextEntryDialog* newClassDlg = new wxTextEntryDialog(
378       this,
379       wxT("Please enter the new class name."),
380       wxT("New Class - creaDevManager"),
381       wxT(""),
382       wxOK | wxCANCEL
383   );
384
385   if (newClassDlg->ShowModal() == wxID_OK)
386     {
387       std::string className = crea::wx2std(newClassDlg->GetValue());
388       //check class name
389       if(className.size() > 0)
390         {
391           if(!this->application->CreateClass(className))
392             wxMessageBox(crea::std2wx("Something has gone wrong with the creation of the class."),_T("New Class - Error!"),wxOK | wxICON_ERROR);
393
394           ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
395
396           wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
397           newEvent->SetId(0);
398           newEvent->SetClientData(this->application);
399           wxPostEvent(this->GetParent(), *newEvent);
400
401           wxMessageBox(crea::std2wx("The class has been created successfully."),_T("New Class - Success"),wxOK | wxICON_INFORMATION);
402         }
403       else
404         {
405           wxMessageBox(crea::std2wx("The new class name cannot be empty."),_T("New Class - Error!"),wxOK | wxICON_ERROR);
406         }
407     }
408 }
409
410 void wxCDMApplicationDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)
411 {
412   //get name
413   wxString folderName = wxGetTextFromUser(
414       wxT("Enter the name of the new folder:"),
415       wxT("Create Folder - creaDevManager")
416   );
417   //check name
418   std::vector<std::string> parts;
419   CDMUtilities::splitter::split(parts, crea::wx2std(folderName), " /\\\"", CDMUtilities::splitter::no_empties);
420   if(parts.size() > 0)
421     {
422       std::string* result;
423       modelCDMFolder* folderC = this->application->CreateFolder(crea::wx2std(folderName), result);
424       if(folderC == NULL)
425         {
426           wxMessageBox(crea::std2wx(*result),_T("Create Folder - Error!"),wxOK | wxICON_ERROR);
427           return;
428         }
429       ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
430       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
431       newEvent->SetClientData(folderC);
432       wxPostEvent(this->GetParent(), *newEvent);
433       wxMessageBox(crea::std2wx("The folder was successfully created"),_T("Create Folder - Success"),wxOK | wxICON_INFORMATION);
434     }
435   else
436     {
437       wxMessageBox(crea::std2wx("No name specified"),_T("Create Folder - Error!"),wxOK | wxICON_ERROR);
438     }
439 }
440
441 void wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
442 {
443   std::string* result;
444   if(!this->application->OpenCMakeListsFile(result))
445     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
446
447   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
448
449   if(this->application->GetCMakeLists() != NULL)
450     {
451       newEvent->SetClientData(this->application->GetCMakeLists());
452       newEvent->SetId(0);
453       wxPostEvent(this->GetParent(), *newEvent);
454     }
455
456   event.Skip();
457 }
458
459 void wxCDMApplicationDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
460 {
461   std::string* result;
462   if(!this->application->OpenInFileExplorer(result))
463     wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
464 }
465
466 void wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
467 {
468   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
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   event.Skip();
477 }
478
479 void wxCDMApplicationDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
480 {
481   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
482
483   if(this->application->GetCMakeLists() != NULL)
484     {
485       newEvent->SetClientData(this->application->GetCMakeLists());
486       newEvent->SetId(0);
487       wxPostEvent(this->GetParent(), *newEvent);
488     }
489   event.Skip();
490 }
491
492 void wxCDMApplicationDescriptionPanel::OnBtnOpenMain(wxCommandEvent& event)
493 {
494   if (this->application->GetMainFile() != NULL)
495     {
496       if (CDMUtilities::openTextEditor(this->application->GetMainFile()->GetPath()))
497       {
498         wxMessageBox(crea::std2wx("The main file couldn't be opened."),_T("Open Main File - Error!"),wxOK | wxICON_ERROR);
499       }
500
501       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
502
503       newEvent->SetClientData(this->application->GetMainFile());
504       newEvent->SetId(0);
505       wxPostEvent(this->GetParent(), *newEvent);
506
507       event.Skip();
508     }
509   else
510     {
511       wxMessageBox(crea::std2wx("There is no main file or it couldn't be detected."),_T("Open Main File - Error!"),wxOK | wxICON_ERROR);
512     }
513 }
514
515 void wxCDMApplicationDescriptionPanel::OnMainMouseEnter(wxMouseEvent& event)
516 {
517   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
518
519   if(this->application->GetMainFile() != NULL)
520     {
521       newEvent->SetClientData(this->application->GetMainFile());
522       newEvent->SetId(0);
523       wxPostEvent(this->GetParent(), *newEvent);
524     }
525   event.Skip();
526 }
527
528 void wxCDMApplicationDescriptionPanel::OnMainMouseExit(wxMouseEvent& event)
529 {
530   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
531
532   if(this->application->GetMainFile() != NULL)
533     {
534       newEvent->SetClientData(this->application->GetMainFile());
535       newEvent->SetId(0);
536       wxPostEvent(this->GetParent(), *newEvent);
537     }
538   event.Skip();
539 }