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