]> 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   //TODO: Show possible problems in CMakeLists files
520   event.Skip();
521 }
522 void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event)
523 {
524   std::cerr << "Event OnMenuMenuCut not implemented" << std::endl;
525   event.Skip();
526 }
527 void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event)
528 {
529   std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl;
530   event.Skip();
531 }
532 void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event)
533 {
534   std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl;
535   event.Skip();
536 }
537 void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event)
538 {
539   std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl;
540   event.Skip();
541 }
542 void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event)
543 {
544   std::cerr << "Event OnMenuSelectAll not implemented" << std::endl;
545   event.Skip();
546 }
547 void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event)
548 {
549   std::cerr << "Event OnMenuSelectNone not implemented" << std::endl;
550   event.Skip();
551 }
552
553 //Tools Menu
554 void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event)
555 {
556   std::cerr << "Event OnMenuEventLog not implemented" << std::endl;
557   event.Skip();
558 }
559 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
560 {
561   std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
562   event.Skip();
563 }
564 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
565 {
566   std::cerr << "Event OnMenuMiniTools not implemented" << std::endl;
567   event.Skip();
568 }
569 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
570 {
571   std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl;
572   event.Skip();
573 }
574 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
575 {
576   std::cerr << "Event OnMenuCommandLine not implemented" << std::endl;
577   event.Skip();
578 }
579
580 //Help Menu
581 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
582 {
583   std::cerr << "Event OnMenuHelp not implemented" << std::endl;
584   event.Skip();
585 }
586 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
587 {
588   std::cerr << "Event OnMenuReportBug not implemented" << std::endl;
589   event.Skip();
590 }
591 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
592 {
593   std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl;
594   event.Skip();
595 }
596 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
597 {
598   std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl;
599   event.Skip();
600 }
601
602 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
603 {
604   std::cout << "New Tree Selection" << std::endl;
605   //get selected element
606   wxTreeItemId elementId = event.GetItem();
607
608   //get element from model
609   modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
610   std::cout << "Tree Selection: " << element->GetName() << std::endl;
611
612   //TODO get element type
613   //project
614   modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
615   if(elementProject != NULL)
616     {
617
618       //create element description
619       wxCDMProjectDescriptionPanel* description = new wxCDMProjectDescriptionPanel(
620           this,
621           elementProject,
622           ID_WINDOW_PROPERTIES,
623           wxT("Description Panel"),
624           wxDefaultPosition,
625           wxSize(300, 400),
626           0
627       );
628       //delete old view
629       if(this->panel_Properties!= NULL)
630         {
631           this->panel_Properties->Hide();
632           this->panel_Properties->Destroy();
633           auiManager.DetachPane(this->panel_Properties);
634         }
635       //set new view
636       this->panel_Properties = description;
637       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
638       auiManager.Update();
639       event.Skip();
640       return;
641     }
642   //appli
643   modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
644   if(elementAppli != NULL)
645     {
646       //create element description
647       wxCDMAppliDescriptionPanel* description = new wxCDMAppliDescriptionPanel(
648           this,
649           elementAppli,
650           ID_WINDOW_PROPERTIES,
651           wxT("Description Panel"),
652           wxDefaultPosition,
653           wxSize(300, 400),
654           0
655       );
656       //delete old view
657       if(this->panel_Properties!= NULL)
658         {
659           this->panel_Properties->Hide();
660           this->panel_Properties->Destroy();
661           auiManager.DetachPane(this->panel_Properties);
662         }
663       //set new view
664       this->panel_Properties = description;
665       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
666       auiManager.Update();
667       event.Skip();
668       return;
669     }
670   //application
671   modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
672   if(elementApplication != NULL)
673     {
674       //create element description
675       wxCDMApplicationDescriptionPanel* description = new wxCDMApplicationDescriptionPanel(
676           this,
677           elementApplication,
678           ID_WINDOW_PROPERTIES,
679           wxT("Description Panel"),
680           wxDefaultPosition,
681           wxSize(300, 400),
682           0
683       );
684       //delete old view
685       if(this->panel_Properties!= NULL)
686         {
687           this->panel_Properties->Hide();
688           this->panel_Properties->Destroy();
689           auiManager.DetachPane(this->panel_Properties);
690
691         }
692       //set new view
693       this->panel_Properties = description;
694       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
695       auiManager.Update();
696       event.Skip();
697       return;
698     }
699   //lib
700   modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
701   if(elementLib != NULL)
702     {
703       //create element description
704       wxCDMLibDescriptionPanel* description = new wxCDMLibDescriptionPanel(
705           this,
706           elementLib,
707           ID_WINDOW_PROPERTIES,
708           wxT("Description Panel"),
709           wxDefaultPosition,
710           wxSize(300, 400),
711           0
712       );
713       //delete old view
714       if(this->panel_Properties!= NULL)
715         {
716           this->panel_Properties->Hide();
717           this->panel_Properties->Destroy();
718           auiManager.DetachPane(this->panel_Properties);
719
720         }
721       //set new view
722       this->panel_Properties = description;
723       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
724       auiManager.Update();
725       event.Skip();
726       return;
727     }
728   //library
729   modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
730   if(elementLibrary != NULL)
731     {
732       //create element description
733       wxCDMLibraryDescriptionPanel* description = new wxCDMLibraryDescriptionPanel(
734           this,
735           elementLibrary,
736           ID_WINDOW_PROPERTIES,
737           wxT("Description Panel"),
738           wxDefaultPosition,
739           wxSize(300, 400),
740           0
741       );
742       //delete old view
743       if(this->panel_Properties!= NULL)
744         {
745           auiManager.DetachPane(this->panel_Properties);
746           this->panel_Properties->Hide();
747           this->panel_Properties->Destroy();
748         }
749
750       //set new view
751       this->panel_Properties = description;
752       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
753       auiManager.Update();
754       event.Skip();
755       return;
756     }
757   //package
758   modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
759   if(elementPackage != NULL)
760     {
761       //create element description
762       wxCDMPackageDescriptionPanel* description = new wxCDMPackageDescriptionPanel(
763           this,
764           elementPackage,
765           ID_WINDOW_PROPERTIES,
766           wxT("Description Panel"),
767           wxDefaultPosition,
768           wxSize(300, 400),
769           0
770       );
771       //delete old view
772       if(this->panel_Properties!= NULL)
773         {
774           this->panel_Properties->Hide();
775           this->panel_Properties->Destroy();
776           auiManager.DetachPane(this->panel_Properties);
777
778         }
779       //set new view
780       this->panel_Properties = description;
781       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
782       auiManager.Update();
783       event.Skip();
784       return;
785     }
786   //black box
787   modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
788   if(elementBlackBox != NULL)
789     {
790       //create element description
791       wxCDMBlackBoxDescriptionPanel* description = new wxCDMBlackBoxDescriptionPanel(
792           this,
793           elementBlackBox,
794           ID_WINDOW_PROPERTIES,
795           wxT("Description Panel"),
796           wxDefaultPosition,
797           wxSize(300, 400),
798           0
799       );
800       //delete old view
801       if(this->panel_Properties!= NULL)
802         {
803           this->panel_Properties->Hide();
804           this->panel_Properties->Destroy();
805           auiManager.DetachPane(this->panel_Properties);
806
807         }
808       //set new view
809       this->panel_Properties = description;
810       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
811       auiManager.Update();
812       event.Skip();
813       return;
814     }
815   //CMakeLists
816   modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
817   if(elementCMakeLists != NULL)
818     {
819       //create element description
820       wxCDMCMakeListsDescriptionPanel* description = new wxCDMCMakeListsDescriptionPanel(
821           this,
822           elementCMakeLists,
823           ID_WINDOW_PROPERTIES,
824           wxT("Description Panel"),
825           wxDefaultPosition,
826           wxSize(300, 400),
827           0
828       );
829       //delete old view
830       if(this->panel_Properties!= NULL)
831         {
832           this->panel_Properties->Hide();
833           this->panel_Properties->Destroy();
834           auiManager.DetachPane(this->panel_Properties);
835
836         }
837       //set new view
838       this->panel_Properties = description;
839       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
840       auiManager.Update();
841       event.Skip();
842       return;
843     }
844   //folder
845   modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
846   if(elementFolder != NULL)
847     {
848       //create element description
849       wxCDMFolderDescriptionPanel* description = new wxCDMFolderDescriptionPanel(
850           this,
851           elementFolder,
852           ID_WINDOW_PROPERTIES,
853           wxT("Description Panel"),
854           wxDefaultPosition,
855           wxSize(300, 400),
856           0
857       );
858       //delete old view
859       if(this->panel_Properties!= NULL)
860         {
861           this->panel_Properties->Hide();
862           this->panel_Properties->Destroy();
863           auiManager.DetachPane(this->panel_Properties);
864
865         }
866       //set new view
867       this->panel_Properties = description;
868       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
869       auiManager.Update();
870       event.Skip();
871       return;
872     }
873   //TODO: file
874   modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
875   if(elementFile != NULL)
876     {
877       //create element description
878       wxCDMFileDescriptionPanel* description = new wxCDMFileDescriptionPanel(
879           this,
880           elementFile,
881           ID_WINDOW_PROPERTIES,
882           wxT("Description Panel"),
883           wxDefaultPosition,
884           wxSize(300, 400),
885           0
886       );
887       //delete old view
888       if(this->panel_Properties!= NULL)
889         {
890           this->panel_Properties->Hide();
891           this->panel_Properties->Destroy();
892           auiManager.DetachPane(this->panel_Properties);
893
894         }
895       //set new view
896       this->panel_Properties = description;
897       auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
898       auiManager.Update();
899       event.Skip();
900       return;
901     }
902
903   //main if not any
904   //create element description
905   wxCDMMainDescriptionPanel* description = new wxCDMMainDescriptionPanel(
906       this,
907       ID_WINDOW_PROPERTIES,
908       wxT("Description Panel"),
909       wxDefaultPosition,
910       wxSize(300, 400),
911       0
912   );
913   //delete old view
914   if(this->panel_Properties!= NULL)
915     {
916       this->panel_Properties->Hide();
917       this->panel_Properties->Destroy();
918       auiManager.DetachPane(this->panel_Properties);
919
920     }
921   //set new view
922   this->panel_Properties = description;
923   auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
924   auiManager.Update();
925   event.Skip();
926   return;
927
928 }
929
930 void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event)
931 {
932   std::cout << "inMainFrame " << event.GetInt() << std::endl;
933   this->tree_Projects->SelectItem(event.GetInt());
934   event.Skip();
935 }