]> 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_CHANGING(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(200,400),
199       wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
200   );
201
202   panel_Properties = new wxCDMMainDescriptionPanel(
203       this,
204       ID_WINDOW_PROPERTIES,
205       wxT("Description Panel"),
206       wxDefaultPosition,
207       wxSize(400, 600),
208       0
209   );
210
211
212
213
214
215
216
217   auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("Properties")));
218   auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Projects Tree")));
219
220   wxString pers = auiManager.SavePerspective();
221
222   auiManager.Update();
223   auiManager.LoadPerspective(pers,true);
224 }
225
226 //Event Handlers
227 //File menu
228 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
229 {
230   std::string* result;
231
232   wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
233   long userResponse;
234   userResponse = dialog->ShowModal();
235
236   if(userResponse == wxID_FORWARD)
237     {
238       //create project
239       if(this->model->GetProject() != NULL)
240         {
241           if(!this->model->CloseProject(result))
242             {
243               std::cout << "error closing project: " << *result << std::endl;
244               wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
245               event.Skip();
246               return;
247             }
248         }
249
250       if(!this->model->CreateProject(
251           crea::wx2std(dialog->GetProjectName()),
252           crea::wx2std(dialog->GetProjectLocation()),
253           result,
254           crea::wx2std(dialog->GetPackageAuthor()),
255           crea::wx2std(dialog->GetPackageDescription())
256       ))
257         {
258           std::cout << "error opening project: " << *result << std::endl;
259           wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
260           event.Skip();
261           return;
262         }
263
264       //populate tree control
265       tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
266       tree_Projects->SelectItem(this->model->GetProject()->GetId());
267
268       //change description panel
269       if(this->panel_Properties != NULL)
270         {
271           auiManager.DetachPane(this->panel_Properties);
272           this->panel_Properties->Destroy();
273         }
274
275       this->panel_Properties = new wxCDMProjectDescriptionPanel(
276           this,
277           this->model->GetProject(),
278           ID_WINDOW_PROPERTIES,
279           wxT("Description Panel"),
280           wxDefaultPosition,
281           wxSize(600, 400),
282           0);
283       //show projectactions panel
284       if(this->panel_ProjectActions != NULL)
285         {
286           auiManager.DetachPane(this->panel_Properties);
287           this->panel_ProjectActions->Destroy();
288         }
289
290       panel_ProjectActions = new wxCDMProjectActionsPanel(
291           this,
292           ID_WINDOW_PROJ_ACTIONS,
293           wxT("Project Actions Panel"),
294           wxDefaultPosition,
295           wxSize(800,200),
296           0
297       );
298       panel_ProjectActions->SetMinSize(wxSize(500, 100));
299
300
301       auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400));
302       auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("Project Actions")).BestSize(800,70).CloseButton(false));
303
304       auiManager.Update();
305
306       wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
307     }
308
309   event.Skip();
310 }
311 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
312 {
313   std::string* result;
314
315   long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
316   wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
317   long userResponse = FD->ShowModal();
318   if(userResponse == wxID_OK)
319     {
320       std::string path = crea::wx2std (FD->GetPath());
321       FD -> Destroy();
322       FD = NULL;
323
324       std::cout << "Selection to open: " << path << std::endl;
325
326
327       //populate model
328       if(this->model->GetProject() != NULL)
329         {
330           std::cout << "Project not null, closing it" << std::endl;
331           if(!this->model->CloseProject(result))
332             {
333               std::cout << "error closing project: " << *result << std::endl;
334               wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
335               event.Skip();
336               return;
337             }
338         }
339
340       if (!this->model->OpenProject(path, result))
341         {
342           std::cout << "error opening project: " << *result << std::endl;
343           wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
344           event.Skip();
345           return;
346         };
347
348       std::cout << "building ui" << std::endl;
349
350
351       //populate tree control
352       tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
353       tree_Projects->SelectItem(this->model->GetProject()->GetId());
354
355       //change description panel
356       if(this->panel_Properties != NULL)
357         {
358           auiManager.DetachPane(this->panel_Properties);
359           this->panel_Properties->Destroy();
360         }
361
362       this->panel_Properties = new wxCDMProjectDescriptionPanel(
363           this,
364           this->model->GetProject(),
365           ID_WINDOW_PROPERTIES,
366           wxT("Description Panel"),
367           wxDefaultPosition,
368           wxSize(600, 400),
369           0
370       );
371
372       //change project's actions panel
373       if(this->panel_ProjectActions!= NULL)
374         {
375           auiManager.DetachPane(this->panel_ProjectActions);
376           this->panel_ProjectActions->Destroy();
377         }
378       panel_ProjectActions = new wxCDMProjectActionsPanel(
379           this,
380           ID_WINDOW_PROJ_ACTIONS,
381           wxT("Project Actions Panel"),
382           wxDefaultPosition,
383           wxSize(800,200),
384           0
385       );
386       panel_ProjectActions->SetMinSize(wxSize(500, 100));
387
388
389       auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400));
390       auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("Project Actions")).BestSize(800,70).CloseButton(false));
391
392       auiManager.Update();
393     }
394
395   event.Skip();
396 }
397 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
398 {
399   std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl;
400   event.Skip();
401 }
402 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
403 {
404   std::cout << "closing project" << std::endl;
405   std::string* result;
406   if(!this->model->CloseProject(result))
407     {
408       std::cout << "error closing project: " << *result << std::endl;
409       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
410     }
411
412   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
413
414   if(this->panel_Properties != NULL)
415     {
416       auiManager.DetachPane(this->panel_Properties);
417       this->panel_Properties->Destroy();
418     }
419   if(this->panel_ProjectActions != NULL)
420     {
421       auiManager.DetachPane(this->panel_ProjectActions);
422       this->panel_ProjectActions->Destroy();
423     }
424
425   this->panel_Properties = new wxCDMMainDescriptionPanel(
426       this,
427       ID_WINDOW_PROPERTIES,
428       wxT("Description Panel"),
429       wxDefaultPosition,
430       wxSize(600, 400),
431       0
432   );
433
434   auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400));
435
436   auiManager.Update();
437   event.Skip();
438 }
439 void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event)
440 {
441   std::cerr << "Event OnMenuCloseAllProjects closing only one project" << std::endl;
442   std::string* result;
443   if(!this->model->CloseProject(result))
444     {
445       std::cout << "error closing project: " << *result << std::endl;
446       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
447     }
448   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
449
450   if(this->panel_Properties != NULL)
451     {
452       auiManager.DetachPane(this->panel_Properties);
453       this->panel_Properties->Destroy();
454     }
455   if(this->panel_ProjectActions != NULL)
456     {
457       auiManager.DetachPane(this->panel_ProjectActions);
458       this->panel_ProjectActions->Destroy();
459     }
460
461   this->panel_Properties = new wxCDMMainDescriptionPanel(
462       this,
463       ID_WINDOW_PROPERTIES,
464       wxT("Description Panel"),
465       wxDefaultPosition,
466       wxSize(600, 400),
467       0
468   );
469
470   auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400));
471
472   auiManager.Update();
473   event.Skip();
474 }
475 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
476 {
477   std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
478   event.Skip();
479 }
480 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
481 {
482   std::cout << "Closing CreaDevManager..." << std::endl;
483   std::string* result;
484   if(!this->model->CloseProject(result))
485     {
486       std::cout << "error closing project: " << *result << std::endl;
487       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
488     }
489   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
490
491   if(this->panel_Properties != NULL)
492     {
493       auiManager.DetachPane(this->panel_Properties);
494       this->panel_Properties->Destroy();
495     }
496   if(this->panel_ProjectActions != NULL)
497     {
498       auiManager.DetachPane(this->panel_ProjectActions);
499       this->panel_ProjectActions->Destroy();
500     }
501
502   this->panel_Properties = new wxCDMMainDescriptionPanel(
503       this,
504       ID_WINDOW_PROPERTIES,
505       wxT("Description Panel"),
506       wxDefaultPosition,
507       wxSize(600, 400),
508       0
509   );
510   Close();
511   event.Skip();
512 }
513
514 //Edit Menu
515 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
516 {
517   std::string* result;
518   if(!model->RefreshProject(result))
519     {
520       wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
521     }
522   this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
523   this->auiManager.Update();
524   //TODO: Show possible problems in CMakeLists files
525   event.Skip();
526 }
527 void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event)
528 {
529   std::cerr << "Event OnMenuMenuCut not implemented" << std::endl;
530   event.Skip();
531 }
532 void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event)
533 {
534   std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl;
535   event.Skip();
536 }
537 void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event)
538 {
539   std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl;
540   event.Skip();
541 }
542 void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event)
543 {
544   std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl;
545   event.Skip();
546 }
547 void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event)
548 {
549   std::cerr << "Event OnMenuSelectAll not implemented" << std::endl;
550   event.Skip();
551 }
552 void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event)
553 {
554   std::cerr << "Event OnMenuSelectNone not implemented" << std::endl;
555   event.Skip();
556 }
557
558 //Tools Menu
559 void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event)
560 {
561   std::cerr << "Event OnMenuEventLog not implemented" << std::endl;
562   event.Skip();
563 }
564 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
565 {
566   std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
567   event.Skip();
568 }
569 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
570 {
571   std::cerr << "Event OnMenuMiniTools not implemented" << std::endl;
572   event.Skip();
573 }
574 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
575 {
576   std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl;
577   event.Skip();
578 }
579 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
580 {
581   std::cerr << "Event OnMenuCommandLine not implemented" << std::endl;
582   event.Skip();
583 }
584
585 //Help Menu
586 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
587 {
588   std::cerr << "Event OnMenuHelp not implemented" << std::endl;
589   event.Skip();
590 }
591 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
592 {
593   std::cerr << "Event OnMenuReportBug not implemented" << std::endl;
594   event.Skip();
595 }
596 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
597 {
598   std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl;
599   event.Skip();
600 }
601 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
602 {
603   std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl;
604   event.Skip();
605 }
606
607 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
608 {
609   std::cout << "New Tree Selection" << std::endl;
610   //get selected element
611   wxTreeItemId elementId = event.GetItem();
612
613   //get element from model
614   modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
615   std::cout << "Tree Selection: " << element->GetName() << std::endl;
616
617   //TODO get element type
618   //project
619   modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
620   wxPanel* description;
621   if(elementProject != NULL)
622     {
623       //create element description
624       description = new wxCDMProjectDescriptionPanel(
625           this,
626           elementProject,
627           ID_WINDOW_PROPERTIES,
628           wxT("Description Panel"),
629           wxDefaultPosition,
630           wxSize(600, 400),
631           0
632       );
633
634     }
635   else
636     {
637       //appli
638       modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
639       if(elementAppli != NULL)
640         {
641           //create element description
642           description = new wxCDMAppliDescriptionPanel(
643               this,
644               elementAppli,
645               ID_WINDOW_PROPERTIES,
646               wxT("Description Panel"),
647               wxDefaultPosition,
648               wxSize(600, 400),
649               0
650           );
651         }
652       else
653         {
654           //application
655           modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
656           if(elementApplication != NULL)
657             {
658               //create element description
659               description = new wxCDMApplicationDescriptionPanel(
660                   this,
661                   elementApplication,
662                   ID_WINDOW_PROPERTIES,
663                   wxT("Description Panel"),
664                   wxDefaultPosition,
665                   wxSize(600, 400),
666                   0
667               );
668             }
669           else
670             {
671               //lib
672               modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
673               if(elementLib != NULL)
674                 {
675                   //create element description
676                   description = new wxCDMLibDescriptionPanel(
677                       this,
678                       elementLib,
679                       ID_WINDOW_PROPERTIES,
680                       wxT("Description Panel"),
681                       wxDefaultPosition,
682                       wxSize(600, 400),
683                       0
684                   );
685                 }
686               else
687                 {
688                   //library
689                   modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
690                   if(elementLibrary != NULL)
691                     {
692                       //create element description
693                       description = new wxCDMLibraryDescriptionPanel(
694                           this,
695                           elementLibrary,
696                           ID_WINDOW_PROPERTIES,
697                           wxT("Description Panel"),
698                           wxDefaultPosition,
699                           wxSize(600, 400),
700                           0
701                       );
702                     }
703                   else
704                     {
705                       //package
706                       modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
707                       if(elementPackage != NULL)
708                         {
709                           //create element description
710                           description = new wxCDMPackageDescriptionPanel(
711                               this,
712                               elementPackage,
713                               ID_WINDOW_PROPERTIES,
714                               wxT("Description Panel"),
715                               wxDefaultPosition,
716                               wxSize(600, 400),
717                               0
718                           );
719                         }
720                       else
721                         {
722                           //black box
723                           modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
724                           if(elementBlackBox != NULL)
725                             {
726                               //create element description
727                               description = new wxCDMBlackBoxDescriptionPanel(
728                                   this,
729                                   elementBlackBox,
730                                   ID_WINDOW_PROPERTIES,
731                                   wxT("Description Panel"),
732                                   wxDefaultPosition,
733                                   wxSize(600, 400),
734                                   0
735                               );
736                             }
737                           else
738                             {
739                               //CMakeLists
740                               modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
741                               if(elementCMakeLists != NULL)
742                                 {
743                                   //create element description
744                                   description = new wxCDMCMakeListsDescriptionPanel(
745                                       this,
746                                       elementCMakeLists,
747                                       ID_WINDOW_PROPERTIES,
748                                       wxT("Description Panel"),
749                                       wxDefaultPosition,
750                                       wxSize(600, 400),
751                                       0
752                                   );
753                                 }
754                               else
755                                 {
756                                   //folder
757                                   modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
758                                   if(elementFolder != NULL)
759                                     {
760                                       //create element description
761                                       description = new wxCDMFolderDescriptionPanel(
762                                           this,
763                                           elementFolder,
764                                           ID_WINDOW_PROPERTIES,
765                                           wxT("Description Panel"),
766                                           wxDefaultPosition,
767                                           wxSize(600, 400),
768                                           0
769                                       );
770                                     }
771                                   else
772                                     {
773                                       //file
774                                       modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
775                                       if(elementFile != NULL)
776                                         {
777                                           //create element description
778                                           description = new wxCDMFileDescriptionPanel(
779                                               this,
780                                               elementFile,
781                                               ID_WINDOW_PROPERTIES,
782                                               wxT("Description Panel"),
783                                               wxDefaultPosition,
784                                               wxSize(600, 400),
785                                               0
786                                           );
787                                         }
788                                       else
789                                         {
790
791                                           //main if not any
792                                           //create element description
793                                           description = new wxCDMMainDescriptionPanel(
794                                               this,
795                                               ID_WINDOW_PROPERTIES,
796                                               wxT("Description Panel"),
797                                               wxDefaultPosition,
798                                               wxSize(600, 400),
799                                               0
800                                           );
801                                         }
802                                     }
803                                 }
804                             }
805                         }
806                     }
807                 }
808             }
809         }
810     }
811
812   if(this->panel_Properties!= NULL)
813     this->panel_Properties->Hide();
814
815   auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400));
816   auiManager.Update();
817
818   //delete old view
819   if(this->panel_Properties!= NULL)
820     {
821       this->panel_Properties->Destroy();
822       auiManager.DetachPane(this->panel_Properties);
823     }
824   //set new view
825
826   this->panel_Properties = description;
827   //auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400));
828   auiManager.Update();
829   event.Skip();
830   return;
831
832 }
833
834 void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event)
835 {
836   std::cout << "inMainFrame " << event.GetInt() << std::endl;
837   this->tree_Projects->SelectItem(event.GetInt());
838   event.Skip();
839 }