]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp
5ac469193a929be3c6b55f486a63caffd56a7680
[crea.git] / lib / creaDevManagerLib / wxCDMPackageDescriptionPanel.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  * wxCDMPackageDescriptionPanel.cpp
30  *
31  *  Created on: Nov 27, 2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #include "wxCDMPackageDescriptionPanel.h"
36
37 #include "wxCDMMainFrame.h"
38
39 #include "creaDevManagerIds.h"
40 #include "images/PkIcon64.xpm"
41
42 #include "wxCDMNewBlackBoxDialog.h"
43 #include "wxCDMPackageConfigurationDialog.h"
44 #include <wx/textdlg.h>
45 #include "CDMUtilities.h"
46
47 #include <vector>
48 #include "modelCDMCMakeListsFile.h"
49 #include "wxCDMPackageHelpDialog.h"
50
51
52 BEGIN_EVENT_TABLE(wxCDMPackageDescriptionPanel, wxPanel)
53 EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMPackageDescriptionPanel::OnBtnReturn)
54 EVT_BUTTON(ID_BUTTON_SET_AUTHOR, wxCDMPackageDescriptionPanel::OnBtnSetAuthor)
55 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMPackageDescriptionPanel::OnBtnSetVersion)
56 EVT_BUTTON(ID_BUTTON_SET_DESCRIPTION, wxCDMPackageDescriptionPanel::OnBtnSetDescription)
57 EVT_HYPERLINK(ID_LINK_SELECT_BLACKBOX, wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect)
58 EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox)
59 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists)
60 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMPackageDescriptionPanel::OnBtnOpenFolder)
61 EVT_BUTTON(ID_BUTTON_CHOOSE, wxCDMPackageDescriptionPanel::OnBtnConfigurePackage)
62 END_EVENT_TABLE()
63
64 wxCDMPackageDescriptionPanel::wxCDMPackageDescriptionPanel(
65     wxWindow* parent,
66     modelCDMPackage* package,
67     wxWindowID id,
68     const wxString& caption,
69     const wxPoint& pos,
70     const wxSize& size,
71     long style
72 )
73 {
74   wxCDMPackageDescriptionPanel::Create(parent, package, id, caption, pos, size, style);
75 }
76
77 wxCDMPackageDescriptionPanel::~wxCDMPackageDescriptionPanel()
78 {
79 }
80
81 bool wxCDMPackageDescriptionPanel::Create(
82     wxWindow* parent,
83     modelCDMPackage* package,
84     wxWindowID id,
85     const wxString& caption,
86     const wxPoint& pos,
87     const wxSize& size,
88     long style
89 )
90 {
91   wxPanel::Create(parent, id, pos, size, style);
92   // this part makes the scrollbars show up
93   this->FitInside(); // ask the sizer about the needed size
94   this->SetScrollRate(5, 5);
95
96   this->package = package;
97   CreateControls();
98   return TRUE;
99 }
100
101 void wxCDMPackageDescriptionPanel::CreateControls()
102 {
103   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
104
105   //Links to return
106   wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
107   std::vector<modelCDMIProjectTreeNode*> parents = this->package->GetParents();
108   for (int i = 0; i < (int)(parents.size()); i++)
109     {
110       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);
111       returnLnk->SetWindowStyle(wxNO_BORDER);
112           returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
113       linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
114       linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
115     }
116
117   linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->package->GetName())), 0, wxALIGN_CENTER, 0);
118
119   sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
120
121   //Header
122   wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
123   {
124     //Image
125     headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PkIcon64)),0, wxALIGN_CENTER, 0);
126     wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
127     //Title
128     textSizer->Add(new wxStaticText(this, -1, _("Package")),0, wxALIGN_LEFT, 0);
129     //Package Name
130     textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->package->GetNamePackage())),0, wxALIGN_LEFT, 0);
131     headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
132   }
133   sizer->Add(headerSizer, 0, wxALIGN_CENTER);
134
135   //Package Properties
136   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
137   wxPanel* propertiesPanel = new wxPanel(this);
138   wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
139   wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
140
141   wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author"));
142   wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version"));
143   wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description"));
144
145   // author
146   wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL);
147   this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetAuthors()));
148   wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change"));
149   pAuthorbt->SetToolTip(wxT("Update the author/s of the package."));
150   pAuthorsz->Add(this->authortc, 1, wxALIGN_CENTER_VERTICAL);
151   pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10);
152
153   // version
154   wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
155   this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetVersion()));
156   wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
157   pVersionbt->SetToolTip(wxT("Update the version of the package."));
158   pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER_VERTICAL);
159   pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
160
161   // description
162   wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL);
163   this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetDescription()));
164   wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change"));
165   pDescriptionbt->SetToolTip(wxT("Update the description of the project."));
166   pDescriptionsz->Add(this->descriptiontc, 1, wxALIGN_CENTER_VERTICAL);
167   pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
168
169   propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
170   propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND);
171   propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
172   propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
173   propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
174   propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND);
175
176   propertiesGridSizer->AddGrowableCol(1,1);
177
178   propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND);
179   propertiesPanel->SetSizer(propertiesPanelSizer);
180   propertiesPanelSizer->Fit(propertiesPanel);
181   propertiesBox->Add(propertiesPanel, 0, wxEXPAND | wxALL, 5);
182
183   sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
184
185   //Black Boxes
186   wxStaticBoxSizer* BBBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Black Boxes"));
187   BBBox->GetStaticBox()->SetToolTip(wxT("Select any of the available black boxes to see its details or modify them."));
188   wxPanel* BBPanel = new wxPanel(this);
189   wxBoxSizer* BBPanelSizer = new wxBoxSizer(wxVERTICAL);
190
191
192   std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetSrc()->GetBlackBoxes();
193   for (int i = 0; i < (int)(blackBoxes.size()); i++)
194     {
195
196       if(blackBoxes[i] != NULL)
197         {
198
199                         wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
200           pBBlk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
201           std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories();
202           pBBlk->SetToolTip(crea::std2wx(tt));
203           pBBlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseEnter,NULL,this);
204           pBBlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseExit,NULL,this);
205           BBPanelSizer -> Add(pBBlk, 0, wxEXPAND | wxALL, 5);
206         }
207     }
208
209   BBPanel->SetSizer(BBPanelSizer);
210   BBPanelSizer->Fit(BBPanel);
211   BBBox->Add(BBPanel, 1, wxEXPAND | wxALL, 5);
212   sizer -> Add(BBBox, 0, wxEXPAND | wxALL, 10);
213
214   //Actions
215   wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
216   wxPanel* actionsPanel = new wxPanel(this);
217   wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
218   //actionsGrid Sizer
219   wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
220
221   wxButton* createBBbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_BLACKBOX, _T("A. Create Black Box"));
222   createBBbt->SetToolTip(wxT("Create a new black box for the active project inside this package."));
223   actionsGridSizer->Add(createBBbt, 1, wxALL | wxEXPAND, 5);
224   wxButton* editConfbt = new wxButton(actionsPanel, ID_BUTTON_CHOOSE, _T("B. Configure Package"));
225   editConfbt->SetToolTip(wxT("Select the libraries your package is going to use. This procedure changes the package's CMakeLists file."));
226   actionsGridSizer->Add(editConfbt, 1, wxALL | wxEXPAND, 5);
227   wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
228   editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the package's CMakeLists.txt file."));
229   editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseEnter,NULL,this);
230   editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseExit,NULL,this);
231   actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
232   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder"));
233   openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer."));
234   actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
235
236   actionsGridSizer->AddGrowableCol(0,1);
237   actionsGridSizer->AddGrowableCol(1,1);
238
239   actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
240   actionsPanel->SetSizer(actionsPanelSizer);
241   actionsPanelSizer->Fit(actionsPanel);
242   actionsBox->Add(actionsPanel, 1, wxEXPAND);
243   sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
244
245   //Assign sizer
246   SetSizer(sizer);
247   sizer->SetSizeHints(this);
248
249   if (((wxCDMMainFrame*)this->GetParent())->isHelp())
250     {
251       wxCDMPackageHelpDialog* helpDialog = new wxCDMPackageHelpDialog(this->GetParent(), this->package, wxID_ANY);
252       helpDialog->Show(true);
253     }
254 }
255
256 void wxCDMPackageDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
257 {
258   std::vector<modelCDMIProjectTreeNode*> parents = this->package->GetParents();
259   std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
260   //std::cout << parentURL << std::endl;
261   for (int i = 0; i < (int)(parents.size()); i++)
262     {
263       if (parents[i]->GetPath() == parentURL)
264         {
265           wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
266           newEvent->SetClientData(parents[i]);
267           newEvent->SetId(0);
268           wxPostEvent(this->GetParent(), *newEvent);
269         }
270     }
271 }
272
273 void wxCDMPackageDescriptionPanel::OnBtnSetAuthor(wxCommandEvent& event)
274 {
275   //get author from user
276   wxTextEntryDialog* authDlg = new wxTextEntryDialog(
277       this,
278       wxT("Enter the new authors name. Separate each author with a '/'."),
279       wxT("Change Package Author - creaDevManager"),
280       crea::std2wx(this->package->GetAuthors()),
281       wxTE_MULTILINE | wxOK | wxCANCEL
282   );
283
284   if (authDlg->ShowModal() == wxID_OK)
285     {
286       std::string authorsStr = crea::wx2std(authDlg->GetValue());
287       //check name
288       if(authorsStr.size() > 0)
289         {
290           std::string* result;
291           if(!this->package->SetAuthors(authorsStr, result))
292             wxMessageBox(crea::std2wx(*result),_T("Change Package Author - Error!"),wxOK | wxICON_ERROR);
293         }
294       this->authortc->SetLabel(crea::std2wx(this->package->GetAuthors()));
295       this->authortc->GetParent()->GetSizer()->RecalcSizes();
296     }
297
298 }
299
300 void wxCDMPackageDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
301 {
302   //get version
303   wxString versionWx = wxGetTextFromUser(
304       wxT("Enter the new version name"),
305       wxT("Change Package Version - creaDevManager"),
306       crea::std2wx(this->package->GetVersion())
307   );
308   //check name
309   std::vector<std::string> parts;
310   CDMUtilities::splitter::split(parts, crea::wx2std(versionWx), " .", CDMUtilities::splitter::no_empties);
311   if(parts.size() == 3)
312     {
313       std::string* result;
314       if(!this->package->SetVersion(crea::wx2std(versionWx), result))
315         wxMessageBox(crea::std2wx(*result),_T("Change Package Version - Error!"),wxOK | wxICON_ERROR);
316     }
317   else
318     {
319       wxMessageBox(crea::std2wx("The version format is incorrect, please follow the following format:\nX.Y.Z\nX: Major Version\nY: Minor Version\nZ: Build Version"),_T("Set Project Version - Error!"),wxOK | wxICON_ERROR);
320     }
321   this->versiontc->SetLabel(crea::std2wx(this->package->GetVersion()));
322 }
323
324 void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
325 {
326   //get description from user
327   wxTextEntryDialog* descDlg = new wxTextEntryDialog(
328       this,
329       wxT("Edit the package description."),
330       wxT("Change Package Description - creaDevManager"),
331       crea::std2wx(this->package->GetDescription()),
332       wxTE_MULTILINE | wxOK | wxCANCEL
333   );
334
335   if (descDlg->ShowModal() == wxID_OK)
336     {
337       std::string descriptionStr = crea::wx2std(descDlg->GetValue());
338       //check desc
339       if(descriptionStr.size() > 0)
340         {
341           std::string* result;
342           if(!this->package->SetDescription(descriptionStr, result))
343             wxMessageBox(crea::std2wx(*result),_T("Change Package Description - Error!"),wxOK | wxICON_ERROR);
344         }
345       this->descriptiontc->SetLabel(crea::std2wx(this->package->GetDescription()));
346       this->descriptiontc->GetParent()->GetSizer()->RecalcSizes();
347     }
348 }
349
350 void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event)
351 {
352   modelCDMBlackBox* bb;
353   std::vector<modelCDMBlackBox*> bbs = this->package->GetSrc()->GetBlackBoxes();
354   for (int i = 0; i < (int)(bbs.size()); i++)
355     {
356       if(bbs[i]->GetName() == crea::wx2std(event.GetURL()))
357         {
358           bb = bbs[i];
359           break;
360         }
361     }
362
363   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
364   newEvent->SetClientData(bb);
365   newEvent->SetId(1);
366   newEvent->SetString(wxT("blackbox"));
367   wxPostEvent(this->GetParent(), *newEvent);
368
369   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
370   newEvent1->SetClientData(bb->GetHeaderFile());
371   newEvent1->SetId(0);
372   wxPostEvent(this->GetParent(), *newEvent1);
373
374 }
375
376 void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
377 {
378
379   wxCDMNewBlackBoxDialog* dialog = new wxCDMNewBlackBoxDialog(this);
380   long userResponse;
381   userResponse = dialog->ShowModal();
382
383   if(userResponse == wxID_FORWARD)
384     {
385       std::string* result;
386       //create black box
387       modelCDMIProjectTreeNode* blackBox = this->package->CreateBlackBox(
388           result,
389           crea::wx2std(dialog->GetBlackBoxName()),
390           crea::wx2std(dialog->GetBlackBoxType()),
391           crea::wx2std(dialog->GetBlackBoxFormat()),
392           crea::wx2std(dialog->GetBlackBoxCategories()),
393           crea::wx2std(dialog->GetBlackBoxAuthor()),
394           crea::wx2std(dialog->GetBlackBoxAuthorEmail()),
395           crea::wx2std(dialog->GetBlackBoxDescription())
396       );
397       //check black box created
398       if(blackBox == NULL)
399         {
400           wxMessageBox(crea::std2wx(*result),_T("New Black Box - Error!"),wxOK | wxICON_ERROR);
401           return;
402         }
403       wxMessageBox(crea::std2wx("Black box successfully created."),_T("New Black Box - Success!"),wxOK | wxICON_INFORMATION);
404
405       //refreshing tree and description
406       //send event instead of calling parent to avoid crashing
407
408       ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
409
410       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
411       newEvent->SetId(1);
412       newEvent->SetClientData(blackBox);
413       newEvent->SetString(wxT("blackbox"));
414       newEvent->SetClientData(blackBox);
415       wxPostEvent(this->GetParent(), *newEvent);
416     }
417 }
418
419 void
420 wxCDMPackageDescriptionPanel::OnBtnConfigurePackage(wxCommandEvent& event)
421 {
422   wxCDMPackageConfigurationDialog* dialog = new wxCDMPackageConfigurationDialog(this,this->package);
423   long userResponse;
424   userResponse = dialog->ShowModal();
425 }
426
427 void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
428 {
429   std::string* result;
430   if(!this->package->OpenCMakeListsFile(result))
431     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
432
433   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
434
435   if(this->package->GetCMakeLists() != NULL)
436     {
437       newEvent->SetClientData(this->package->GetCMakeLists());
438       newEvent->SetId(0);
439       wxPostEvent(this->GetParent(), *newEvent);
440     }
441
442   event.Skip();
443 }
444
445 void wxCDMPackageDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
446 {
447   std::string* result;
448   if(!this->package->OpenInFileExplorer(result))
449     wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
450 }
451
452 void wxCDMPackageDescriptionPanel::OnMouseEnter(wxMouseEvent& event)
453 {
454   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
455   std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
456
457   modelCDMFile* bbHeader = NULL;
458   std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
459   for (int i = 0; i < (int)(boxes.size()); i++)
460     {
461       if(boxes[i]->GetName() == BBName)
462         {
463           bbHeader = boxes[i]->GetHeaderFile();
464           break;
465         }
466     }
467   newEvent->SetClientData(bbHeader);
468   newEvent->SetId(0);
469   wxPostEvent(this->GetParent(), *newEvent);
470   event.Skip();
471 }
472
473 void wxCDMPackageDescriptionPanel::OnMouseExit(wxMouseEvent& event)
474 {
475   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
476   std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
477   modelCDMFile* bbHeader = NULL;
478   std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
479   for (int i = 0; i < (int)(boxes.size()); i++)
480     {
481       if(boxes[i]->GetName() == BBName)
482         {
483           bbHeader = boxes[i]->GetHeaderFile();
484           break;
485         }
486     }
487   newEvent->SetClientData(bbHeader);
488   newEvent->SetId(0);
489   wxPostEvent(this->GetParent(), *newEvent);
490   event.Skip();
491 }
492
493 void wxCDMPackageDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
494 {
495   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
496
497   if(this->package->GetCMakeLists() != NULL)
498     {
499       newEvent->SetClientData(this->package->GetCMakeLists());
500       newEvent->SetId(0);
501       wxPostEvent(this->GetParent(), *newEvent);
502     }
503   event.Skip();
504 }
505
506 void wxCDMPackageDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
507 {
508   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
509
510   if(this->package->GetCMakeLists() != NULL)
511     {
512       newEvent->SetClientData(this->package->GetCMakeLists());
513       newEvent->SetId(0);
514       wxPostEvent(this->GetParent(), *newEvent);
515     }
516   event.Skip();
517 }
518
519