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