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