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