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