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