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