]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMMainFrame.cpp
Feature #1711
[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
33 #include <creaWx.h>
34 #include "wx/treectrl.h"
35 #include "CDMUtilities.h"
36
37 #include "creaDevManagerIds.h"
38 #include "wxCDMMainDescriptionPanel.h"
39 #include "wxCDMProjectDescriptionPanel.h"
40 #include "wxCDMAppliDescriptionPanel.h"
41 #include "wxCDMApplicationDescriptionPanel.h"
42 #include "wxCDMLibDescriptionPanel.h"
43 #include "wxCDMLibraryDescriptionPanel.h"
44 #include "wxCDMPackageDescriptionPanel.h"
45 #include "wxCDMBlackBoxDescriptionPanel.h"
46
47 #include "wxCDMProjectActionsPanel.h"
48 #include "wxCDMNewProjectDialog.h"
49
50
51 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
52 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
53 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
54 EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent)
55 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
56 EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects)
57 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
58 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
59 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
60 EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut)
61 EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy)
62 EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste)
63 EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete)
64 EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll)
65 EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone)
66 EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog)
67 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
68 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
69 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
70 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
71 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
72 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
73 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
74 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
75 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
76 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
77 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
78 END_EVENT_TABLE()
79
80 wxCDMMainFrame::wxCDMMainFrame(
81     wxWindow* parent,
82     wxWindowID id,
83     const wxString& caption,
84     const wxPoint& pos,
85     const wxSize& size,
86     long style
87 )
88 {
89   Create(parent, id, caption, pos, size, style);
90 }
91
92 wxCDMMainFrame::~wxCDMMainFrame()
93 {
94   auiManager.UnInit();
95 }
96
97 bool wxCDMMainFrame::Create(
98     wxWindow* parent,
99     wxWindowID id,
100     const wxString& caption,
101     const wxPoint& pos,
102     const wxSize& size,
103     long style
104 )
105 {
106   wxFrame::Create(parent, id, caption, pos, size, style);
107   this->model = new modelCDMMain();
108   CreateMenus();
109   CreateControls();
110   return TRUE;
111 }
112
113 void wxCDMMainFrame::CreateMenus()
114 {
115   wxMenuBar* menuBar = new wxMenuBar;
116
117   //FileMenu
118   menu_File = new wxMenu();
119   menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
120   menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
121   menu_File->Append(ID_MENU_OPEN_RECENT, wxT("Open &Recent"));
122   menu_File->AppendSeparator();
123   menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
124   menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxT("C&lose All Projects"));
125   menu_File->AppendSeparator();
126   menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
127   menu_File->AppendSeparator();
128   menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
129
130   menuBar->Append(menu_File, wxT("&File"));
131
132   //EditMenu
133   menu_Edit = new wxMenu();
134   menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
135   menu_Edit->AppendSeparator();
136   menu_Edit->Append(ID_MENU_CUT, wxT("Cu&t"));
137   menu_Edit->Append(ID_MENU_COPY, wxT("&Copy"));
138   menu_Edit->Append(ID_MENU_PASTE, wxT("&Paste"));
139   menu_Edit->AppendSeparator();
140   menu_Edit->Append(ID_MENU_DELETE, wxT("&Delete"));
141   menu_Edit->Append(ID_MENU_SELECT_ALL, wxT("Select &All"));
142   menu_Edit->Append(ID_MENU_SELECT_NONE, wxT("Ca&ncel Selection"));
143
144   menuBar->Append(menu_Edit, wxT("&Edit"));
145
146   //ToolsMenu
147   menu_Tools = new wxMenu();
148   menu_Tools->Append(ID_MENU_EVENT_LOG, wxT("Event &Log"));
149   menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
150   menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
151   menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
152   menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
153
154   menuBar->Append(menu_Tools, wxT("&Tools"));
155
156   //HelpMenu
157   menu_Help = new wxMenu();
158   menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
159   menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
160   menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
161   menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
162
163   menuBar->Append(menu_Help, wxT("&Help"));
164
165   //Set Bar
166   SetMenuBar(menuBar);
167
168   wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
169   statusBar->SetFieldsCount(1);
170   SetStatusBar(statusBar);
171
172 }
173
174 void wxCDMMainFrame::CreateControls()
175 {
176
177   auiManager.SetManagedWindow(this);
178
179
180   tree_Projects = new wxCDMProjectsTreeCtrl(
181       this,
182       ID_TREE_PROJECTS,
183       wxDefaultPosition,
184       wxSize(300,400),
185       wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
186   );
187   tree_Projects->SetMinSize(wxSize(200,200));
188
189   panel_Properties = new wxCDMMainDescriptionPanel(
190       this,
191       ID_WINDOW_PROPERTIES,
192       wxT("Description Panel"),
193       wxDefaultPosition,
194       wxSize(300, 400),
195       0
196   );
197
198
199
200
201
202   auiManager.AddPane(tree_Projects, wxLEFT, wxT("Projects Tree"));
203   auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
204
205   auiManager.Update();
206   auiManager.GetPane(tree_Projects).CloseButton(false).MaximizeButton(true);
207 }
208
209 //Event Handlers
210 //File menu
211 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
212 {
213   std::string* result;
214
215   wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
216   long userResponse;
217   userResponse = dialog->ShowModal();
218
219   if(userResponse == wxID_FORWARD)
220     {
221       //create project
222       if(this->model->GetProject() != NULL)
223         {
224           if(!this->model->CloseProject(result))
225             {
226               std::cout << "error closing project: " << *result << std::endl;
227               wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
228               event.Skip();
229               return;
230             }
231         }
232
233       if(!this->model->CreateProject(
234           crea::wx2std(dialog->GetProjectName()),
235           crea::wx2std(dialog->GetProjectLocation()),
236           result,
237           crea::wx2std(dialog->GetPackageAuthor()),
238           crea::wx2std(dialog->GetPackageDescription())
239       ))
240         {
241           std::cout << "error opening project: " << *result << std::endl;
242           wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
243           event.Skip();
244           return;
245         }
246
247       //populate tree control
248       tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
249       tree_Projects->SelectItem(this->model->GetProject()->GetId());
250
251       //change description panel
252       if(this->panel_Properties != NULL)
253         {
254           auiManager.DetachPane(this->panel_Properties);
255           this->panel_Properties->Destroy();
256         }
257
258       this->panel_Properties = new wxCDMProjectDescriptionPanel(
259           this,
260           this->model->GetProject(),
261           ID_WINDOW_PROPERTIES,
262           wxT("Description Panel"),
263           wxDefaultPosition,
264           wxSize(300, 400),
265           0);
266       //show projectactions panel
267       if(this->panel_ProjectActions != NULL)
268         {
269           auiManager.DetachPane(this->panel_Properties);
270           this->panel_ProjectActions->Destroy();
271         }
272
273       panel_ProjectActions = new wxCDMProjectActionsPanel(
274           this,
275           ID_WINDOW_PROJ_ACTIONS,
276           wxT("Project Actions Panel"),
277           wxDefaultPosition,
278           wxSize(600,200),
279           0
280       );
281       panel_ProjectActions->SetMinSize(wxSize(500, 100));
282
283
284       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
285       auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxT("Project Actions"));
286
287       auiManager.Update();
288
289       wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
290     }
291
292   event.Skip();
293 }
294 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
295 {
296   std::string* result;
297
298   long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
299   wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
300   long userResponse = FD->ShowModal();
301   if(userResponse == wxID_OK)
302     {
303       std::string path = crea::wx2std (FD->GetPath());
304       FD -> Destroy();
305       FD = NULL;
306
307       std::cout << "Selection to open: " << path << std::endl;
308
309
310       //populate model
311       if(this->model->GetProject() != NULL)
312         {
313           std::cout << "Project not null, closing it" << std::endl;
314           if(!this->model->CloseProject(result))
315             {
316               std::cout << "error closing project: " << *result << std::endl;
317               wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
318               event.Skip();
319               return;
320             }
321         }
322
323       if (!this->model->OpenProject(path, result))
324         {
325           std::cout << "error opening project: " << *result << std::endl;
326           wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
327           event.Skip();
328           return;
329         };
330
331       std::cout << "building ui" << std::endl;
332
333
334       //populate tree control
335       tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
336       tree_Projects->SelectItem(this->model->GetProject()->GetId());
337
338       //change description panel
339       if(this->panel_Properties != NULL)
340         {
341           auiManager.DetachPane(this->panel_Properties);
342           this->panel_Properties->Destroy();
343         }
344
345       this->panel_Properties = new wxCDMProjectDescriptionPanel(
346           this,
347           this->model->GetProject(),
348           ID_WINDOW_PROPERTIES,
349           wxT("Description Panel"),
350           wxDefaultPosition,
351           wxSize(300, 400),
352           0
353       );
354
355       //change project's actions panel
356       if(this->panel_ProjectActions!= NULL)
357         {
358           auiManager.DetachPane(this->panel_ProjectActions);
359           this->panel_ProjectActions->Destroy();
360         }
361       panel_ProjectActions = new wxCDMProjectActionsPanel(
362           this,
363           ID_WINDOW_PROJ_ACTIONS,
364           wxT("Project Actions Panel"),
365           wxDefaultPosition,
366           wxSize(600,200),
367           0
368       );
369       panel_ProjectActions->SetMinSize(wxSize(500, 100));
370
371
372       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
373       auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxT("Project Actions"));
374
375       auiManager.Update();
376     }
377
378   event.Skip();
379 }
380 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
381 {
382   std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl;
383   event.Skip();
384 }
385 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
386 {
387   std::string* result;
388   if(!this->model->CloseProject(result))
389     {
390       std::cout << "error closing project: " << *result << std::endl;
391       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
392     }
393   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
394
395   if(this->panel_Properties != NULL)
396     {
397       auiManager.DetachPane(this->panel_Properties);
398       this->panel_Properties->Destroy();
399     }
400   if(this->panel_ProjectActions != NULL)
401     {
402       auiManager.DetachPane(this->panel_ProjectActions);
403       this->panel_ProjectActions->Destroy();
404     }
405
406   this->panel_Properties = new wxCDMMainDescriptionPanel(
407       this,
408       ID_WINDOW_PROPERTIES,
409       wxT("Description Panel"),
410       wxDefaultPosition,
411       wxSize(300, 400),
412       0
413   );
414
415   auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
416
417   auiManager.Update();
418   event.Skip();
419 }
420 void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event)
421 {
422   std::cerr << "Event OnMenuCloseAllProjects closing only one project" << std::endl;
423   std::string* result;
424   if(!this->model->CloseProject(result))
425     {
426       std::cout << "error closing project: " << *result << std::endl;
427       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
428     }
429   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
430
431   if(this->panel_Properties != NULL)
432     {
433       auiManager.DetachPane(this->panel_Properties);
434       this->panel_Properties->Destroy();
435     }
436   if(this->panel_ProjectActions != NULL)
437     {
438       auiManager.DetachPane(this->panel_ProjectActions);
439       this->panel_ProjectActions->Destroy();
440     }
441
442   this->panel_Properties = new wxCDMMainDescriptionPanel(
443       this,
444       ID_WINDOW_PROPERTIES,
445       wxT("Description Panel"),
446       wxDefaultPosition,
447       wxSize(300, 400),
448       0
449   );
450
451   auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
452
453   auiManager.Update();
454   event.Skip();
455 }
456 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
457 {
458   std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
459   event.Skip();
460 }
461 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
462 {
463   std::cout << "Closing CreaDevManager..." << std::endl;
464   std::string* result;
465   if(!this->model->CloseProject(result))
466     {
467       std::cout << "error closing project: " << *result << std::endl;
468       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
469     }
470   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
471
472   if(this->panel_Properties != NULL)
473     {
474       auiManager.DetachPane(this->panel_Properties);
475       this->panel_Properties->Destroy();
476     }
477   if(this->panel_ProjectActions != NULL)
478     {
479       auiManager.DetachPane(this->panel_ProjectActions);
480       this->panel_ProjectActions->Destroy();
481     }
482
483   this->panel_Properties = new wxCDMMainDescriptionPanel(
484       this,
485       ID_WINDOW_PROPERTIES,
486       wxT("Description Panel"),
487       wxDefaultPosition,
488       wxSize(300, 400),
489       0
490   );
491   Close();
492   event.Skip();
493 }
494
495 //Edit Menu
496 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
497 {
498   std::string* result;
499   if(!model->RefreshProject(result))
500     {
501       wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
502     }
503   //TODO: Show possible problems in CMakeLists files
504   event.Skip();
505 }
506 void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event)
507 {
508   std::cerr << "Event OnMenuMenuCut not implemented" << std::endl;
509   event.Skip();
510 }
511 void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event)
512 {
513   std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl;
514   event.Skip();
515 }
516 void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event)
517 {
518   std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl;
519   event.Skip();
520 }
521 void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event)
522 {
523   std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl;
524   event.Skip();
525 }
526 void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event)
527 {
528   std::cerr << "Event OnMenuSelectAll not implemented" << std::endl;
529   event.Skip();
530 }
531 void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event)
532 {
533   std::cerr << "Event OnMenuSelectNone not implemented" << std::endl;
534   event.Skip();
535 }
536
537 //Tools Menu
538 void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event)
539 {
540   std::cerr << "Event OnMenuEventLog not implemented" << std::endl;
541   event.Skip();
542 }
543 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
544 {
545   std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
546   event.Skip();
547 }
548 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
549 {
550   std::cerr << "Event OnMenuMiniTools not implemented" << std::endl;
551   event.Skip();
552 }
553 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
554 {
555   std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl;
556   event.Skip();
557 }
558 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
559 {
560   std::cerr << "Event OnMenuCommandLine not implemented" << std::endl;
561   event.Skip();
562 }
563
564 //Help Menu
565 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
566 {
567   std::cerr << "Event OnMenuHelp not implemented" << std::endl;
568   event.Skip();
569 }
570 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
571 {
572   std::cerr << "Event OnMenuReportBug not implemented" << std::endl;
573   event.Skip();
574 }
575 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
576 {
577   std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl;
578   event.Skip();
579 }
580 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
581 {
582   std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl;
583   event.Skip();
584 }
585
586 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
587 {
588   std::cout << "New Tree Selection" << std::endl;
589   //get selected element
590   wxTreeItemId elementId = event.GetItem();
591
592   //get element from model
593   modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
594   std::cout << "Tree Selection: " << element->GetName() << std::endl;
595
596   //TODO get element type
597   //project
598   modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
599   if(elementProject != NULL)
600     {
601
602       //create element description
603       wxCDMProjectDescriptionPanel* description = new wxCDMProjectDescriptionPanel(
604           this,
605           elementProject,
606           ID_WINDOW_PROPERTIES,
607           wxT("Description Panel"),
608           wxDefaultPosition,
609           wxSize(300, 400),
610           0
611       );
612       //delete old view
613       if(this->panel_Properties!= NULL)
614         {
615           this->panel_Properties->Hide();
616           this->panel_Properties->Destroy();
617           auiManager.DetachPane(this->panel_Properties);
618         }
619       //set new view
620       this->panel_Properties = description;
621       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
622       auiManager.Update();
623       event.Skip();
624       return;
625     }
626   //appli
627   modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
628   if(elementAppli != NULL)
629     {
630       //create element description
631       wxCDMAppliDescriptionPanel* description = new wxCDMAppliDescriptionPanel(
632           this,
633           elementAppli,
634           ID_WINDOW_PROPERTIES,
635           wxT("Description Panel"),
636           wxDefaultPosition,
637           wxSize(300, 400),
638           0
639       );
640       //delete old view
641       if(this->panel_Properties!= NULL)
642         {
643           this->panel_Properties->Hide();
644           this->panel_Properties->Destroy();
645           auiManager.DetachPane(this->panel_Properties);
646         }
647       //set new view
648       this->panel_Properties = description;
649       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
650       auiManager.Update();
651       event.Skip();
652       return;
653     }
654   //application
655   modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
656   if(elementApplication != NULL)
657     {
658       //create element description
659       wxCDMApplicationDescriptionPanel* description = new wxCDMApplicationDescriptionPanel(
660           this,
661           elementApplication,
662           ID_WINDOW_PROPERTIES,
663           wxT("Description Panel"),
664           wxDefaultPosition,
665           wxSize(300, 400),
666           0
667       );
668       //delete old view
669       if(this->panel_Properties!= NULL)
670         {
671           this->panel_Properties->Hide();
672           this->panel_Properties->Destroy();
673           auiManager.DetachPane(this->panel_Properties);
674
675         }
676       //set new view
677       this->panel_Properties = description;
678       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
679       auiManager.Update();
680       event.Skip();
681       return;
682     }
683   //lib
684   modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
685   if(elementLib != NULL)
686     {
687       //create element description
688       wxCDMLibDescriptionPanel* description = new wxCDMLibDescriptionPanel(
689           this,
690           elementLib,
691           ID_WINDOW_PROPERTIES,
692           wxT("Description Panel"),
693           wxDefaultPosition,
694           wxSize(300, 400),
695           0
696       );
697       //delete old view
698       if(this->panel_Properties!= NULL)
699         {
700           this->panel_Properties->Hide();
701           this->panel_Properties->Destroy();
702           auiManager.DetachPane(this->panel_Properties);
703
704         }
705       //set new view
706       this->panel_Properties = description;
707       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
708       auiManager.Update();
709       event.Skip();
710       return;
711     }
712   //library
713   modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
714   if(elementLibrary != NULL)
715     {
716       //create element description
717       wxCDMLibraryDescriptionPanel* description = new wxCDMLibraryDescriptionPanel(
718           this,
719           elementLibrary,
720           ID_WINDOW_PROPERTIES,
721           wxT("Description Panel"),
722           wxDefaultPosition,
723           wxSize(300, 400),
724           0
725       );
726       //delete old view
727       if(this->panel_Properties!= NULL)
728         {
729           this->panel_Properties->Hide();
730           this->panel_Properties->Destroy();
731           auiManager.DetachPane(this->panel_Properties);
732
733         }
734       //set new view
735       this->panel_Properties = description;
736       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
737       auiManager.Update();
738       event.Skip();
739       return;
740     }
741   //package
742   modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
743   if(elementPackage != NULL)
744     {
745       //create element description
746       wxCDMPackageDescriptionPanel* description = new wxCDMPackageDescriptionPanel(
747           this,
748           elementPackage,
749           ID_WINDOW_PROPERTIES,
750           wxT("Description Panel"),
751           wxDefaultPosition,
752           wxSize(300, 400),
753           0
754       );
755       //delete old view
756       if(this->panel_Properties!= NULL)
757         {
758           this->panel_Properties->Hide();
759           this->panel_Properties->Destroy();
760           auiManager.DetachPane(this->panel_Properties);
761
762         }
763       //set new view
764       this->panel_Properties = description;
765       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
766       auiManager.Update();
767       event.Skip();
768       return;
769     }
770   //black box
771   modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
772   if(elementBlackBox != NULL)
773     {
774       //create element description
775       wxCDMBlackBoxDescriptionPanel* description = new wxCDMBlackBoxDescriptionPanel(
776           this,
777           elementBlackBox,
778           ID_WINDOW_PROPERTIES,
779           wxT("Description Panel"),
780           wxDefaultPosition,
781           wxSize(300, 400),
782           0
783       );
784       //delete old view
785       if(this->panel_Properties!= NULL)
786         {
787           this->panel_Properties->Hide();
788           this->panel_Properties->Destroy();
789           auiManager.DetachPane(this->panel_Properties);
790
791         }
792       //set new view
793       this->panel_Properties = description;
794       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
795       auiManager.Update();
796       event.Skip();
797       return;
798     }
799   //TODO: CMakeLists
800   //TODO: folder
801   //TODO: file
802   //TODO: main
803   //create element description
804   wxCDMMainDescriptionPanel* description = new wxCDMMainDescriptionPanel(
805       this,
806       ID_WINDOW_PROPERTIES,
807       wxT("Description Panel"),
808       wxDefaultPosition,
809       wxSize(300, 400),
810       0
811   );
812   //delete old view
813   if(this->panel_Properties!= NULL)
814     {
815       this->panel_Properties->Hide();
816       this->panel_Properties->Destroy();
817       auiManager.DetachPane(this->panel_Properties);
818
819     }
820   //set new view
821   this->panel_Properties = description;
822   auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
823   auiManager.Update();
824   event.Skip();
825   return;
826
827 }