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