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