]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMMainFrame.cpp
#3125 crea Feature New Normal - branch changeWx28to30 compilation with wxWidgets3
[crea.git] / lib / creaDevManagerLib / wxCDMMainFrame.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 #include "wxCDMMainFrame.h"
30
31 #include <iostream>
32 #include <sstream>
33
34 #include <creaWx.h>
35 #include "creaSystem.h"
36 #include "wx/treectrl.h"
37 #include "wx/treebase.h"
38 #include "wx/tooltip.h"
39 #include "wx/wxhtml.h"
40 #include "wx/statline.h"
41 #include "wx/config.h"
42 #include "CDMUtilities.h"
43 #include "images/CIcon64.xpm"
44
45 #include "creaDevManagerIds.h"
46 #include "wxCDMMainDescriptionPanel.h"
47 #include "wxCDMProjectDescriptionPanel.h"
48 #include "wxCDMAppliDescriptionPanel.h"
49 #include "wxCDMApplicationDescriptionPanel.h"
50 #include "wxCDMLibDescriptionPanel.h"
51 #include "wxCDMLibraryDescriptionPanel.h"
52 #include "wxCDMPackageDescriptionPanel.h"
53 #include "wxCDMBlackBoxDescriptionPanel.h"
54 #include "wxCDMBBSFileDescriptionPanel.h"
55 #include "wxCDMBBGFileDescriptionPanel.h"
56 #include "wxCDMCodeFileDescriptionPanel.h"
57 #include "wxCDMCMakeListsDescriptionPanel.h"
58 #include "wxCDMFolderDescriptionPanel.h"
59 #include "wxCDMFileDescriptionPanel.h"
60 #include "wxCDMPackageManagerPanel.h"
61 #include "wxCDMProjectMapDialog.h"
62
63 #include "wxCDMSettingsDialog.h"
64
65 #include "wxCDMProjectActionsPanel.h"
66 #include "wxCDMNewProjectDialog.h"
67
68
69
70 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
71 EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
72 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
73 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
74 EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
75 EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
76 EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
77 EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
78 EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
79 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
80 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
81 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
82 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
83 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
84 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
85 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
86 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
87 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
88 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
89 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
90 EVT_MENU(ID_MENU_SHOW_PROJECT_MAP, wxCDMMainFrame::OnMenuShowProjectMap)
91 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
92 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
93 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
94
95 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
96 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
97
98 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
99
100 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
101 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
102 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
103
104
105 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
106 END_EVENT_TABLE()
107
108 wxCDMMainFrame::wxCDMMainFrame(
109     wxWindow* parent,
110     wxWindowID id,
111     const wxString& caption,
112     const wxPoint& pos,
113     const wxSize& size,
114     long style
115 )
116 {
117   this->menu_File = NULL;
118   this->menu_Edit = NULL;
119   this->menu_Tools = NULL;
120   this->menu_Help = NULL;
121   this->panel_Properties = NULL;
122   this->panel_ProjectActions = NULL;
123   this->tree_Projects = NULL;
124   Create(parent, id, caption, pos, size, style);
125 }
126
127 wxCDMMainFrame::~wxCDMMainFrame()
128 {
129   wxConfigBase* pConfig = wxConfigBase::Get();
130   pConfig->Write(wxT("HELP"), this->help);
131
132   auiManager.UnInit();
133 }
134
135 bool wxCDMMainFrame::Create(
136     wxWindow* parent,
137     wxWindowID id,
138     const wxString& caption,
139     const wxPoint& pos,
140     const wxSize& size,
141     long style
142 )
143 {
144   wxFrame::Create(parent, id, caption, pos, size, style);
145   this->help = true;
146
147   wxConfigBase* pConfig = wxConfigBase::Get();
148   this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
149
150   this->model = new modelCDMMain();
151
152   CreateMenus();
153   CreateControls();
154   this->SetIcon(wxIcon(CIcon64));
155   return TRUE;
156 }
157
158 modelCDMMain* wxCDMMainFrame::GetModel() const
159 {
160   return this->model;
161 }
162
163 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
164 {
165   return this->panel_Properties;
166 }
167
168 bool wxCDMMainFrame::isHelp() const
169 {
170   return this->help;
171 }
172
173 void wxCDMMainFrame::RefreshProject()
174 {
175   std::string* result;
176   std::cout << "refreshing project" << std::endl;
177   this->model->RefreshProject(result);
178   std::cout << "rebuilding project tree" << std::endl;
179   this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
180   this->tree_Projects->Unselect();
181   this->actualTreeItem.Unset();
182 }
183
184 void wxCDMMainFrame::CreateMenus()
185 {
186   wxMenuBar* menuBar = new wxMenuBar;
187
188   //Recently opened projects
189   menu_Recent = new wxMenu();
190   wxConfigBase* pConfig = wxConfigBase::Get();
191   std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
192   if(rp != "")
193     {
194       menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
195       rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
196       if(rp != "")
197         {
198           menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
199           rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
200           if(rp != "")
201             {
202               menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
203               rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
204               if(rp != "")
205                 {
206                   menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
207                   rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
208                   if(rp != "")
209                     {
210                       menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
211                     }
212                 }
213             }
214         }
215     }
216
217   //FileMenu
218   menu_File = new wxMenu();
219   menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
220   menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
221   menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
222   menu_File->AppendSeparator();
223   menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
224   menu_File->AppendSeparator();
225   menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
226   menu_File->AppendSeparator();
227   menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
228
229   menuBar->Append(menu_File, wxT("&File"));
230
231   //EditMenu
232   menu_Edit = new wxMenu();
233   menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
234   menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
235
236   menuBar->Append(menu_Edit, wxT("&Edit"));
237
238   //ToolsMenu
239   menu_Tools = new wxMenu();
240   menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("Open BBEditor (BBTK &Graphical Editor)"));
241   menu_Tools->Append(ID_MENU_MINITOOLS, wxT("Open &CreaTools"));
242   menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("Open Code &Editor"));
243   menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("Open Command &Line"));
244
245   menuBar->Append(menu_Tools, wxT("&Tools"));
246
247   //HelpMenu
248   menu_Help = new wxMenu();
249   menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
250   menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
251   menu_Help->Append(ID_MENU_SHOW_PROJECT_MAP, wxT("&Show Project Map"));
252   menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
253   menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
254   menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
255   menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
256
257   menuBar->Append(menu_Help, wxT("&Help"));
258
259   //Set Bar
260   SetMenuBar(menuBar);
261
262   wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
263   statusBar->SetFieldsCount(1);
264   SetStatusBar(statusBar);
265
266 }
267
268 void wxCDMMainFrame::CreateControls()
269 {
270
271   auiManager.SetManagedWindow(this);
272
273
274 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
275 #if wxMAJOR_VERSION <= 2
276   tree_Projects = new wxCDMProjectsTreeCtrl(
277       this,
278       ID_TREE_PROJECTS,
279       wxDefaultPosition,
280       wxSize(200,400),
281       wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS );
282   this->actualTreeItem.Unset();
283 #else
284   tree_Projects = new wxCDMProjectsTreeCtrl(
285       this,
286       ID_TREE_PROJECTS,
287       wxDefaultPosition,
288       wxSize(200,400),
289       wxTR_HAS_BUTTONS  );
290   this->actualTreeItem.Unset();
291 #endif
292
293
294   panel_Properties = new wxCDMMainDescriptionPanel(
295       this,
296       ID_WINDOW_PROPERTIES,
297       wxT("Description Panel"),
298       wxDefaultPosition,
299       wxSize(400, 600),
300       0
301   );
302
303   auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
304   auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
305   auiManager.Update();
306   //auiManager.LoadPerspective(pers,true);
307   wxToolTip::Enable(true);
308   wxToolTip::SetDelay(0);
309 }
310
311 //Event Handlers
312
313 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
314 {
315   //clean recent menu
316   int tam = menu_Recent->GetMenuItemCount();
317   for (int i = 0; i < tam; ++i) {
318     menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
319   }
320   //populate recent menu
321   wxConfigBase* pConfig = wxConfigBase::Get();
322   std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
323   if(rp != "")
324     {
325       menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
326       rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
327       if(rp != "")
328         {
329           menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
330           rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
331           if(rp != "")
332             {
333               menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
334               rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
335               if(rp != "")
336                 {
337                   menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
338                   rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
339                   if(rp != "")
340                     {
341                       menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
342                     }
343                 }
344             }
345         }
346     }
347 }
348
349 //File menu
350 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
351 {
352   std::string* result;
353
354   wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
355   long userResponse;
356   userResponse = dialog->ShowModal();
357
358   if(userResponse == wxID_FORWARD)
359     {
360       //close open project
361       if(this->model->GetProject() != NULL)
362         {
363           if(!this->model->CloseProject(result))
364             {
365               std::cout << "error closing project: " << *result << std::endl;
366               wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
367               event.Skip();
368               return;
369             }
370
371           if(this->panel_Properties != NULL)
372             {
373               auiManager.DetachPane(this->panel_Properties);
374               this->panel_Properties->Hide();
375             }
376           if(this->panel_ProjectActions != NULL)
377             {
378               auiManager.DetachPane(this->panel_ProjectActions);
379               this->panel_ProjectActions->Hide();    
380             }
381
382         }
383
384       //create project
385       if(!this->model->CreateProject(
386           crea::wx2std(dialog->GetProjectName()),
387           crea::wx2std(dialog->GetProjectLocation()),
388           result,
389           crea::wx2std(dialog->GetPackageAuthor()),
390           crea::wx2std(dialog->GetPackageDescription())
391       ))
392         {
393           std::cout << "error opening project: " << *result << std::endl;
394           wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
395           event.Skip();
396           return;
397         }
398       
399       //update recently open projects
400       wxConfigBase* pConfig = wxConfigBase::Get();
401       if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
402         {
403           pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
404           pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
405           pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
406           pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
407           pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
408         }
409
410
411       //show project actions panel
412       if(this->panel_ProjectActions != NULL)
413         {
414           auiManager.DetachPane(this->panel_Properties);
415           this->panel_ProjectActions->Destroy();
416           this->panel_ProjectActions = NULL;
417         }
418           
419       panel_ProjectActions = new wxCDMProjectActionsPanel(
420           this,
421           this->model->GetProject(),
422           ID_WINDOW_PROJ_ACTIONS,
423           wxT("Project Actions Panel"),
424           wxDefaultPosition,
425           wxSize(800,200),
426           0
427       );
428       
429       auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
430       auiManager.Update();
431
432       //populate tree control
433           tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
434       tree_Projects->Unselect();
435           this->actualTreeItem.Unset();
436           tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
437           //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
438     }
439 }
440 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
441 {
442   std::string* result;
443
444   //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
445
446   std::string path = "";
447   wxConfigBase* pConfig = wxConfigBase::Get();
448   if(event.GetId() == ID_MENU_OPEN_RECENT1)
449     path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
450   else if(event.GetId() == ID_MENU_OPEN_RECENT2)
451     path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
452   else if(event.GetId() == ID_MENU_OPEN_RECENT3)
453     path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
454   else if(event.GetId() == ID_MENU_OPEN_RECENT4)
455     path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
456   else if(event.GetId() == ID_MENU_OPEN_RECENT5)
457     path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
458
459   std::cout << "Selection to open: " << path << std::endl;
460   std::cout.flush();
461
462
463   //populate model
464   if(this->model->GetProject() != NULL)
465     {
466       std::cout << "Project not null, closing it" << std::endl;
467       if(!this->model->CloseProject(result))
468         {
469           std::cout << "error closing project: " << *result << std::endl;
470           wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
471           event.Skip();
472           return;
473         }
474
475       if(this->panel_Properties != NULL)
476         {
477           auiManager.DetachPane(this->panel_Properties);
478           this->panel_Properties->Hide();
479         }
480       if(this->panel_ProjectActions != NULL)
481         {
482           auiManager.DetachPane(this->panel_ProjectActions);
483           this->panel_ProjectActions->Hide();
484         }
485     }
486
487   if (!this->model->OpenProject(path, result))
488     {
489       std::cout << "error opening project: " << *result << std::endl;
490       wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
491       event.Skip();
492       return;
493     };
494
495   //update recently open projects
496   if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
497     {
498       pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
499       pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
500       pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
501       pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
502       pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
503     }
504
505   std::cout << "building ui" << std::endl;
506
507   //populate tree control
508   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
509   tree_Projects->Unselect();
510   this->actualTreeItem.Unset();
511       tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
512
513
514   //change project's actions panel
515   if(this->panel_ProjectActions!= NULL)
516     {
517       auiManager.DetachPane(this->panel_ProjectActions);
518       this->panel_ProjectActions->Destroy();
519       this->panel_ProjectActions = NULL;
520     }
521   panel_ProjectActions = new wxCDMProjectActionsPanel(
522       this,
523       this->model->GetProject(),
524       ID_WINDOW_PROJ_ACTIONS,
525       wxT("Project Actions Panel"),
526       wxDefaultPosition,
527       wxSize(800,200),
528       0
529   );
530   panel_ProjectActions->SetMinSize(wxSize(500, 100));
531
532
533   auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
534
535   auiManager.Update();
536
537 }
538 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
539 {
540   std::string* result;
541
542   long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
543   wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
544   long userResponse = FD->ShowModal();
545   if(userResponse == wxID_OK)
546     {
547       std::string path = crea::wx2std (FD->GetPath());
548       FD -> Destroy();
549       FD = NULL;
550
551       std::cout << "Selection to open: " << path << std::endl;
552
553
554       //populate model
555       if(this->model->GetProject() != NULL)
556         {
557           std::cout << "Project not null, closing it" << std::endl;
558           if(!this->model->CloseProject(result))
559             {
560               std::cout << "error closing project: " << *result << std::endl;
561               wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
562               event.Skip();
563               return;
564             }
565
566           if(this->panel_Properties != NULL)
567             {
568               auiManager.DetachPane(this->panel_Properties);
569               this->panel_Properties->Hide();
570             }
571           if(this->panel_ProjectActions != NULL)
572             {
573               auiManager.DetachPane(this->panel_ProjectActions);
574               this->panel_ProjectActions->Hide();    
575             }
576         }
577
578       if (!this->model->OpenProject(path, result))
579         {
580           std::cout << "error opening project: " << *result << std::endl;
581           wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
582           event.Skip();
583           return;
584         };
585
586       //update recently open projects
587       wxConfigBase* pConfig = wxConfigBase::Get();
588       if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
589         {
590           pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
591           pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
592           pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
593           pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
594           pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
595         }
596
597       std::cout << "building ui" << std::endl;
598
599       //populate tree control
600       tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
601       tree_Projects->Unselect();
602       this->actualTreeItem.Unset();
603           tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
604
605
606       //change project's actions panel
607       if(this->panel_ProjectActions!= NULL)
608         {
609           auiManager.DetachPane(this->panel_ProjectActions);
610           this->panel_ProjectActions->Destroy();
611           this->panel_ProjectActions = NULL;
612         }
613       panel_ProjectActions = new wxCDMProjectActionsPanel(
614           this,
615           this->model->GetProject(),
616           ID_WINDOW_PROJ_ACTIONS,
617           wxT("Project Actions Panel"),
618           wxDefaultPosition,
619           wxSize(800,200),
620           0
621       );
622       panel_ProjectActions->SetMinSize(wxSize(500, 100));
623
624
625       auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
626
627       auiManager.Update();
628
629     }
630 }
631
632 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
633 {
634   std::cout << "closing project" << std::endl;
635   std::string* result;
636   if(!this->model->CloseProject(result))
637     {
638       std::cout << "error closing project: " << *result << std::endl;
639       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
640     }
641
642   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
643   this->actualTreeItem.Unset();
644   if(this->panel_Properties != NULL)
645     {
646       auiManager.DetachPane(this->panel_Properties);
647           this->panel_Properties->Hide();
648     }
649   if(this->panel_ProjectActions != NULL)
650     {
651       auiManager.DetachPane(this->panel_ProjectActions);
652       this->panel_ProjectActions->Hide();    
653     }
654
655   this->panel_Properties = new wxCDMMainDescriptionPanel(
656       this,
657       ID_WINDOW_PROPERTIES,
658       wxT("Description Panel"),
659       wxDefaultPosition,
660       wxSize(600, 400),
661       0
662   );
663
664   auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
665
666   auiManager.Update();
667 }
668
669 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
670 {
671   std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
672   event.Skip();
673 }
674 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
675 {
676   std::cout << "Closing CreaDevManager..." << std::endl;
677   std::string* result;
678   if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
679     {
680       std::cout << "error closing project: " << *result << std::endl;
681     }
682
683   if(this->panel_Properties != NULL)
684     {
685       auiManager.DetachPane(this->panel_Properties);
686       this->panel_Properties->Destroy();
687       this->panel_Properties = NULL;
688     }
689   
690   if(this->tree_Projects != NULL)
691     {
692       auiManager.DetachPane(this->tree_Projects);
693       this->tree_Projects->Destroy();
694       this->tree_Projects = NULL;
695     }
696
697   if(this->panel_ProjectActions != NULL)
698     {
699       auiManager.DetachPane(this->panel_ProjectActions);
700       this->panel_ProjectActions->Destroy();
701       this->panel_ProjectActions = NULL;
702     }
703   
704   Close();
705 }
706
707 //Edit Menu
708 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
709 {
710   std::string* result;
711   if(!model->RefreshProject(result))
712     {
713       wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
714     }
715   if(this->model->GetProject() != NULL)
716     {
717       this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
718       this->auiManager.Update();
719
720       this->tree_Projects->Unselect();
721           this->actualTreeItem.Unset();
722       this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
723     }
724   event.Skip();
725 }
726
727 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
728 {
729   wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
730   settingsDialog->SetHelpEnabled(this->help);
731
732   int res = settingsDialog->ShowModal();
733   if(res == wxID_OK)
734     {
735       this->help = settingsDialog->IsHelpEnabled();
736       this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
737     }
738 }
739
740 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
741 {
742   std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
743   event.Skip();
744   if(CDMUtilities::openBBEditor())
745     {
746       wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
747     }
748 }
749 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
750 {
751   if(CDMUtilities::openCreaToolsTools())
752     {
753       wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
754     }
755 }
756 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
757 {
758   if(CDMUtilities::openTextEditor())
759     {
760       wxMessageBox( wxT("Can't open the Text Editor. Please check the default text editor command in the Crea Development Manager settings (Edit -> Settings)."), wxT("Refresh Project - Error"), wxICON_ERROR);
761     }
762 }
763 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
764 {
765   if(CDMUtilities::openTerminal())
766     {
767       wxMessageBox( wxT("Can't open Terminal. Please check the default terminal command in the Crea Development Manager settings (Edit -> Settings)."), wxT("Refresh Project - Error"), wxICON_ERROR);
768     }
769 }
770
771 //Help Menu
772 void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event)
773 {
774   wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this);
775
776   dialog->Show(true);
777 }
778
779 //Help Menu
780 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
781 {
782   wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0);
783 }
784 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
785 {
786   wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
787 }
788 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
789 {
790   wxBoxSizer *topsizer;
791   wxHtmlWindow *html;
792   wxDialog dlg(this, wxID_ANY, wxString(_("About")));
793
794   topsizer = new wxBoxSizer(wxVERTICAL);
795
796   html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
797   html -> SetBorders(0);
798
799   std::string content = ""
800       "<html>"
801       "<body bgcolor=\"#3333CC\">"
802       "<table cellspacing=3 cellpadding=4 width=\"100%\">"
803       "  <tr>"
804       "    <td bgcolor=\"#3333CC\">"
805       "    <center>"
806       "    <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
807       "    </font>"
808       "    </center>"
809       "    </td>"
810       "  </tr>"
811       "  <tr>"
812       "    <td bgcolor=\"#FFFFFF\">"
813       "    <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
814       "    <font size=-1>"
815       "      <table cellpadding=0 cellspacing=0 width=\"100%\">"
816       "        <tr>"
817       "          <td width=\"65%\">"
818       "            <p>Created by Daniel Gonz&aacute;lez - daniel.gonzalez@creatis.insa-lyon.fr</p>"
819       "          </td>"
820       "        </tr>"
821       "      </table>"
822       "      <font size=1>"
823       "        <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
824       "      </font>"
825       "    </font>"
826       "    </td>"
827       "  </tr>"
828       "</table>"
829       "</body>"
830       "</html>"
831       ;
832
833   html -> SetPage(crea::std2wx(content));
834   html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
835       html -> GetInternalRepresentation() -> GetHeight());
836
837   topsizer -> Add(html, 1, wxALL, 10);
838
839 #if wxUSE_STATLINE
840   topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
841 #endif // wxUSE_STATLINE
842
843   wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
844   bu1 -> SetDefault();
845
846   topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
847
848   dlg.SetSizer(topsizer);
849   topsizer -> Fit(&dlg);
850
851   dlg.ShowModal();
852 }
853 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
854 {
855   wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
856 }
857
858 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
859 {
860
861   //get selected element
862   wxTreeItemId elementId = event.GetItem();
863   //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
864   //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
865   if(elementId.IsOk() && this->actualTreeItem != elementId)
866     {
867       
868       //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
869       //get element from model
870       modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
871
872           if (element == NULL)
873                   return;
874       std::cout << "Tree Selection: " << element->GetName() << std::endl;
875
876           //std::stringstream ss;
877           //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
878           //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);   
879       this->actualTreeItem = elementId;
880
881           //get element type
882       //project
883       modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
884       wxPanel* description;
885       if(elementProject != NULL)
886         {
887           //create element description
888           description = new wxCDMProjectDescriptionPanel(
889               this,
890               elementProject,
891               ID_WINDOW_PROPERTIES,
892               wxT("Description Panel"),
893               wxDefaultPosition,
894               wxSize(600, 400),
895               0
896           );
897
898         }
899       else
900         {
901           //appli
902           modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
903           if(elementAppli != NULL)
904             {
905               //create element description
906               description = new wxCDMAppliDescriptionPanel(
907                   this,
908                   elementAppli,
909                   ID_WINDOW_PROPERTIES,
910                   wxT("Description Panel"),
911                   wxDefaultPosition,
912                   wxSize(600, 400),
913                   0
914               );
915
916             }
917           else
918             {
919               //application
920               modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
921                           if(elementApplication != NULL)
922                 {
923                   //create element description
924                   description = new wxCDMApplicationDescriptionPanel(
925                       this,
926                       elementApplication,
927                       ID_WINDOW_PROPERTIES,
928                       wxT("Description Panel"),
929                       wxDefaultPosition,
930                       wxSize(600, 400),
931                       0
932                   );
933                 }
934               else
935                 {
936                   //lib
937                   modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
938                   if(elementLib != NULL)
939                     {
940                       //create element description
941                       description = new wxCDMLibDescriptionPanel(
942                           this,
943                           elementLib,
944                           ID_WINDOW_PROPERTIES,
945                           wxT("Description Panel"),
946                           wxDefaultPosition,
947                           wxSize(600, 400),
948                           0
949                       );
950                     }
951                   else
952                     {
953                       //library
954                       modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
955                       if(elementLibrary != NULL)
956                         {
957                           //create element description
958                           description = new wxCDMLibraryDescriptionPanel(
959                               this,
960                               elementLibrary,
961                               ID_WINDOW_PROPERTIES,
962                               wxT("Description Panel"),
963                               wxDefaultPosition,
964                               wxSize(600, 400),
965                               0
966                           );
967                         }
968                       else
969                         {
970                           //package
971                           modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
972                           if(elementPackage != NULL)
973                             {
974                               //create element description
975                               description = new wxCDMPackageDescriptionPanel(
976                                   this,
977                                   elementPackage,
978                                   ID_WINDOW_PROPERTIES,
979                                   wxT("Description Panel"),
980                                   wxDefaultPosition,
981                                   wxSize(600, 400),
982                                   0
983                               );
984                             }
985                           else
986                             {
987                               //black box
988                               modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
989                               if(elementBlackBox != NULL)
990                                 {
991                                   //create element description
992                                   description = new wxCDMBlackBoxDescriptionPanel(
993                                       this,
994                                       elementBlackBox,
995                                       ID_WINDOW_PROPERTIES,
996                                       wxT("Description Panel"),
997                                       wxDefaultPosition,
998                                       wxSize(600, 400),
999                                       0
1000                                   );
1001                                 }
1002                               else
1003                                 {
1004                                   //CMakeLists
1005                                   modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
1006                                   if(elementCMakeLists != NULL)
1007                                     {
1008                                       //create element description
1009                                       description = new wxCDMCMakeListsDescriptionPanel(
1010                                           this,
1011                                           elementCMakeLists,
1012                                           ID_WINDOW_PROPERTIES,
1013                                           wxT("Description Panel"),
1014                                           wxDefaultPosition,
1015                                           wxSize(600, 400),
1016                                           0
1017                                       );
1018                                     }
1019                                   else
1020                                     {
1021                                       //CodeFile
1022                                       modelCDMCodeFile* elementCodeFile = dynamic_cast<modelCDMCodeFile*>(element);
1023                                       if(elementCodeFile != NULL)
1024                                         {
1025                                           //create element description
1026                                           description = new wxCDMCodeFileDescriptionPanel(
1027                                               this,
1028                                               elementCodeFile,
1029                                               ID_WINDOW_PROPERTIES,
1030                                               wxT("Description Panel"),
1031                                               wxDefaultPosition,
1032                                               wxSize(600, 400),
1033                                               0
1034                                           );
1035                                         }
1036                                       else
1037                                         {
1038                                           //BBSFile
1039                                           modelCDMBBSFile* elementBBSFile = dynamic_cast<modelCDMBBSFile*>(element);
1040                                           if(elementBBSFile != NULL)
1041                                             {
1042                                               //create element description
1043                                               description = new wxCDMBBSFileDescriptionPanel(
1044                                                   this,
1045                                                   elementBBSFile,
1046                                                   ID_WINDOW_PROPERTIES,
1047                                                   wxT("Description Panel"),
1048                                                   wxDefaultPosition,
1049                                                   wxSize(600, 400),
1050                                                   0
1051                                               );
1052                                             }
1053                                           else
1054                                             {
1055                                               //BBSFile
1056                                               modelCDMBBGFile* elementBBGFile = dynamic_cast<modelCDMBBGFile*>(element);
1057                                               if(elementBBGFile != NULL)
1058                                                 {
1059                                                   //create element description
1060                                                   description = new wxCDMBBGFileDescriptionPanel(
1061                                                       this,
1062                                                       elementBBGFile,
1063                                                       ID_WINDOW_PROPERTIES,
1064                                                       wxT("Description Panel"),
1065                                                       wxDefaultPosition,
1066                                                       wxSize(600, 400),
1067                                                       0
1068                                                   );
1069                                                 }
1070                                               else
1071                                                 {
1072                                                   //folder
1073                                                   modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
1074                                                   if(elementFolder != NULL)
1075                                                     {
1076                                                       //create element description
1077                                                       description = new wxCDMFolderDescriptionPanel(
1078                                                           this,
1079                                                           elementFolder,
1080                                                           ID_WINDOW_PROPERTIES,
1081                                                           wxT("Description Panel"),
1082                                                           wxDefaultPosition,
1083                                                           wxSize(600, 400),
1084                                                           0
1085                                                       );
1086                                                     }
1087                                                   else
1088                                                     {
1089                                                       //file
1090                                                       modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1091                                                       if(elementFile != NULL)
1092                                                         {
1093                                                           //create element description
1094                                                           description = new wxCDMFileDescriptionPanel(
1095                                                               this,
1096                                                               elementFile,
1097                                                               ID_WINDOW_PROPERTIES,
1098                                                               wxT("Description Panel"),
1099                                                               wxDefaultPosition,
1100                                                               wxSize(600, 400),
1101                                                               0
1102                                                           );
1103                                                         }
1104                                                       else
1105                                                         {
1106
1107                                                           //main if not any
1108                                                           //create element description
1109                                                           description = new wxCDMMainDescriptionPanel(
1110                                                               this,
1111                                                               ID_WINDOW_PROPERTIES,
1112                                                               wxT("Description Panel"),
1113                                                               wxDefaultPosition,
1114                                                               wxSize(600, 400),
1115                                                               0
1116                                                           );
1117                                                         }
1118                                                     }
1119                                                 }
1120                                             }
1121                                         }
1122                                     }
1123                                 }
1124                             }
1125                         }
1126                     }
1127                 }
1128             }
1129         }
1130
1131       //delete old view
1132       if(this->panel_Properties!= NULL)
1133         {
1134           this->panel_Properties->Hide();
1135           auiManager.DetachPane(this->panel_Properties);
1136           //this->panel_Properties->Destroy();
1137           //this->panel_Properties = NULL;
1138         }
1139       //set new view
1140       auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1141       this->panel_Properties = description;
1142
1143       auiManager.Update();
1144     }
1145   else
1146     {
1147       event.Skip();
1148         }
1149
1150   return;
1151
1152 }
1153
1154 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1155 {
1156   modelCDMIProjectTreeNode* myItem = NULL;
1157   wxPanel* description = NULL;
1158   switch(event.GetId())
1159   {
1160   case 0:
1161     myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1162     //select out old one to generate selection event
1163     this->tree_Projects->Unselect();
1164     this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1165     this->tree_Projects->Expand(myItem->GetId().GetWxId());
1166     break;
1167   case 1:
1168     
1169     if(event.GetString() == wxT("manage_packages"))
1170       {
1171         //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1172         //this->tree_Projects->Unselect();
1173         this->actualTreeItem.Unset();
1174         description = new wxCDMPackageManagerPanel(
1175             this,
1176             this->model->GetProject(),
1177             ID_WINDOW_PROPERTIES,
1178             wxT("Description Panel"),
1179             wxDefaultPosition,
1180             wxSize(600, 400),
1181             0
1182         );
1183       }
1184     else if(event.GetString() == wxT("manage_libraries"))
1185       {
1186         this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1187         this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1188         break;
1189       }
1190     else if(event.GetString() == wxT("manage_applications"))
1191       {
1192         this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1193         this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1194         break;
1195       }
1196     else if(event.GetString() == wxT("blackbox"))
1197       {
1198         modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1199         this->actualTreeItem.Unset();
1200         this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1201         description = new wxCDMBlackBoxDescriptionPanel(
1202             this,
1203             bb,
1204             ID_WINDOW_PROPERTIES,
1205             wxT("Description Panel"),
1206             wxDefaultPosition,
1207             wxSize(600, 400),
1208             0
1209         );
1210
1211                 
1212       }
1213
1214     //delete old view
1215     if(this->panel_Properties!= NULL)
1216       {
1217         this->panel_Properties->Hide();
1218         auiManager.DetachPane(this->panel_Properties);
1219         this->panel_Properties->Destroy();
1220         this->panel_Properties = NULL;
1221       }
1222     //set new view
1223     auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1224     this->panel_Properties = description;
1225     auiManager.Update();
1226     break;
1227   default:
1228     event.Skip();
1229     break;
1230   }
1231   
1232 }
1233
1234 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1235 {
1236   //std::cout << "element " << event.GetInt() << std::endl;
1237   modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1238   this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1239   this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1240   this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1241   this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1242   this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1243   auiManager.Update();
1244 }
1245
1246 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1247 {
1248   modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1249   this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1250   this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1251   this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1252   this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1253   auiManager.Update();
1254 }
1255
1256 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1257 {
1258   this->help = !this->help;
1259   this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1260 }
1261
1262 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1263 {
1264   if (event.GetInt())
1265     this->help = false;
1266   else
1267     this->help = true;
1268
1269   this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1270 }