2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------
29 #include "wxCDMMainFrame.h"
35 #include "creaSystem.h"
36 #include "wx/treectrl.h"
37 #include "wx/treebase.h"
38 #include "wx/tooltip.h"
39 #include "wx/wxhtml.h"
40 #include "wx/statline.h"
41 #include "wx/config.h"
42 #include "CDMUtilities.h"
43 #include "images/CIcon64.xpm"
45 #include "creaDevManagerIds.h"
46 #include "wxCDMMainDescriptionPanel.h"
47 #include "wxCDMProjectDescriptionPanel.h"
48 #include "wxCDMAppliDescriptionPanel.h"
49 #include "wxCDMApplicationDescriptionPanel.h"
50 #include "wxCDMLibDescriptionPanel.h"
51 #include "wxCDMLibraryDescriptionPanel.h"
52 #include "wxCDMPackageDescriptionPanel.h"
53 #include "wxCDMBlackBoxDescriptionPanel.h"
54 #include "wxCDMBBSFileDescriptionPanel.h"
55 #include "wxCDMBBGFileDescriptionPanel.h"
56 #include "wxCDMCodeFileDescriptionPanel.h"
57 #include "wxCDMCMakeListsDescriptionPanel.h"
58 #include "wxCDMFolderDescriptionPanel.h"
59 #include "wxCDMFileDescriptionPanel.h"
60 #include "wxCDMPackageManagerPanel.h"
61 #include "wxCDMProjectMapDialog.h"
63 #include "wxCDMSettingsDialog.h"
65 #include "wxCDMProjectActionsPanel.h"
66 #include "wxCDMNewProjectDialog.h"
70 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
71 EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
72 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
73 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
74 EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
75 EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
76 EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
77 EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
78 EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
79 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
80 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
81 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
82 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
83 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
84 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
85 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
86 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
87 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
88 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
89 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
90 EVT_MENU(ID_MENU_SHOW_PROJECT_MAP, wxCDMMainFrame::OnMenuShowProjectMap)
91 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
92 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
93 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
95 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
96 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
98 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
100 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
101 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
102 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
105 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
108 wxCDMMainFrame::wxCDMMainFrame(
111 const wxString& caption,
117 this->menu_File = NULL;
118 this->menu_Edit = NULL;
119 this->menu_Tools = NULL;
120 this->menu_Help = NULL;
121 this->panel_Properties = NULL;
122 this->panel_ProjectActions = NULL;
123 this->tree_Projects = NULL;
124 Create(parent, id, caption, pos, size, style);
127 wxCDMMainFrame::~wxCDMMainFrame()
129 wxConfigBase* pConfig = wxConfigBase::Get();
130 pConfig->Write(wxT("HELP"), this->help);
135 bool wxCDMMainFrame::Create(
138 const wxString& caption,
144 wxFrame::Create(parent, id, caption, pos, size, style);
147 wxConfigBase* pConfig = wxConfigBase::Get();
148 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
150 this->model = new modelCDMMain();
154 this->SetIcon(wxIcon(CIcon64));
158 modelCDMMain* wxCDMMainFrame::GetModel() const
163 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
165 return this->panel_Properties;
168 bool wxCDMMainFrame::isHelp() const
173 void wxCDMMainFrame::RefreshProject()
176 std::cout << "refreshing project" << std::endl;
177 this->model->RefreshProject(result);
178 std::cout << "rebuilding project tree" << std::endl;
179 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
180 this->tree_Projects->Unselect();
181 this->actualTreeItem.Unset();
184 void wxCDMMainFrame::CreateMenus()
186 wxMenuBar* menuBar = new wxMenuBar;
188 //Recently opened projects
189 menu_Recent = new wxMenu();
190 wxConfigBase* pConfig = wxConfigBase::Get();
191 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
194 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
195 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
198 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
199 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
202 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
203 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
206 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
207 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
210 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
218 menu_File = new wxMenu();
219 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
220 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
221 menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
222 menu_File->AppendSeparator();
223 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
224 menu_File->AppendSeparator();
225 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
226 menu_File->AppendSeparator();
227 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
229 menuBar->Append(menu_File, wxT("&File"));
232 menu_Edit = new wxMenu();
233 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
234 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
236 menuBar->Append(menu_Edit, wxT("&Edit"));
239 menu_Tools = new wxMenu();
240 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("Open BBEditor (BBTK &Graphical Editor)"));
241 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("Open &CreaTools"));
242 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("Open Code &Editor"));
243 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("Open Command &Line"));
245 menuBar->Append(menu_Tools, wxT("&Tools"));
248 menu_Help = new wxMenu();
249 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
250 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
251 menu_Help->Append(ID_MENU_SHOW_PROJECT_MAP, wxT("&Show Project Map"));
252 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
253 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
254 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
255 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
257 menuBar->Append(menu_Help, wxT("&Help"));
262 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
263 statusBar->SetFieldsCount(1);
264 SetStatusBar(statusBar);
268 void wxCDMMainFrame::CreateControls()
271 auiManager.SetManagedWindow(this);
274 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
275 #if wxMAJOR_VERSION <= 2
276 tree_Projects = new wxCDMProjectsTreeCtrl(
281 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS );
282 this->actualTreeItem.Unset();
284 tree_Projects = new wxCDMProjectsTreeCtrl(
290 this->actualTreeItem.Unset();
294 panel_Properties = new wxCDMMainDescriptionPanel(
296 ID_WINDOW_PROPERTIES,
297 wxT("Description Panel"),
303 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
304 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
306 //auiManager.LoadPerspective(pers,true);
307 wxToolTip::Enable(true);
308 wxToolTip::SetDelay(0);
313 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
316 int tam = menu_Recent->GetMenuItemCount();
317 for (int i = 0; i < tam; ++i) {
318 menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
320 //populate recent menu
321 wxConfigBase* pConfig = wxConfigBase::Get();
322 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
325 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
326 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
329 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
330 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
333 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
334 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
337 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
338 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
341 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
350 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
354 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
356 userResponse = dialog->ShowModal();
358 if(userResponse == wxID_FORWARD)
361 if(this->model->GetProject() != NULL)
363 if(!this->model->CloseProject(result))
365 std::cout << "error closing project: " << *result << std::endl;
366 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
371 if(this->panel_Properties != NULL)
373 auiManager.DetachPane(this->panel_Properties);
374 this->panel_Properties->Hide();
376 if(this->panel_ProjectActions != NULL)
378 auiManager.DetachPane(this->panel_ProjectActions);
379 this->panel_ProjectActions->Hide();
385 if(!this->model->CreateProject(
386 crea::wx2std(dialog->GetProjectName()),
387 crea::wx2std(dialog->GetProjectLocation()),
389 crea::wx2std(dialog->GetPackageAuthor()),
390 crea::wx2std(dialog->GetPackageDescription())
393 std::cout << "error opening project: " << *result << std::endl;
394 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
399 //update recently open projects
400 wxConfigBase* pConfig = wxConfigBase::Get();
401 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
403 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
404 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
405 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
406 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
407 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
411 //show project actions panel
412 if(this->panel_ProjectActions != NULL)
414 auiManager.DetachPane(this->panel_Properties);
415 this->panel_ProjectActions->Destroy();
416 this->panel_ProjectActions = NULL;
419 panel_ProjectActions = new wxCDMProjectActionsPanel(
421 this->model->GetProject(),
422 ID_WINDOW_PROJ_ACTIONS,
423 wxT("Project Actions Panel"),
429 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
432 //populate tree control
433 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
434 tree_Projects->Unselect();
435 this->actualTreeItem.Unset();
436 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
437 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
440 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
444 //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
446 std::string path = "";
447 wxConfigBase* pConfig = wxConfigBase::Get();
448 if(event.GetId() == ID_MENU_OPEN_RECENT1)
449 path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
450 else if(event.GetId() == ID_MENU_OPEN_RECENT2)
451 path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
452 else if(event.GetId() == ID_MENU_OPEN_RECENT3)
453 path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
454 else if(event.GetId() == ID_MENU_OPEN_RECENT4)
455 path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
456 else if(event.GetId() == ID_MENU_OPEN_RECENT5)
457 path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
459 std::cout << "Selection to open: " << path << std::endl;
464 if(this->model->GetProject() != NULL)
466 std::cout << "Project not null, closing it" << std::endl;
467 if(!this->model->CloseProject(result))
469 std::cout << "error closing project: " << *result << std::endl;
470 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
475 if(this->panel_Properties != NULL)
477 auiManager.DetachPane(this->panel_Properties);
478 this->panel_Properties->Hide();
480 if(this->panel_ProjectActions != NULL)
482 auiManager.DetachPane(this->panel_ProjectActions);
483 this->panel_ProjectActions->Hide();
487 if (!this->model->OpenProject(path, result))
489 std::cout << "error opening project: " << *result << std::endl;
490 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
495 //update recently open projects
496 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
498 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
499 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
500 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
501 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
502 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
505 std::cout << "building ui" << std::endl;
507 //populate tree control
508 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
509 tree_Projects->Unselect();
510 this->actualTreeItem.Unset();
511 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
514 //change project's actions panel
515 if(this->panel_ProjectActions!= NULL)
517 auiManager.DetachPane(this->panel_ProjectActions);
518 this->panel_ProjectActions->Destroy();
519 this->panel_ProjectActions = NULL;
521 panel_ProjectActions = new wxCDMProjectActionsPanel(
523 this->model->GetProject(),
524 ID_WINDOW_PROJ_ACTIONS,
525 wxT("Project Actions Panel"),
530 panel_ProjectActions->SetMinSize(wxSize(500, 100));
533 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
538 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
542 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
543 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
544 long userResponse = FD->ShowModal();
545 if(userResponse == wxID_OK)
547 std::string path = crea::wx2std (FD->GetPath());
551 std::cout << "Selection to open: " << path << std::endl;
555 if(this->model->GetProject() != NULL)
557 std::cout << "Project not null, closing it" << std::endl;
558 if(!this->model->CloseProject(result))
560 std::cout << "error closing project: " << *result << std::endl;
561 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
566 if(this->panel_Properties != NULL)
568 auiManager.DetachPane(this->panel_Properties);
569 this->panel_Properties->Hide();
571 if(this->panel_ProjectActions != NULL)
573 auiManager.DetachPane(this->panel_ProjectActions);
574 this->panel_ProjectActions->Hide();
578 if (!this->model->OpenProject(path, result))
580 std::cout << "error opening project: " << *result << std::endl;
581 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
586 //update recently open projects
587 wxConfigBase* pConfig = wxConfigBase::Get();
588 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
590 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
591 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
592 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
593 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
594 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
597 std::cout << "building ui" << std::endl;
599 //populate tree control
600 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
601 tree_Projects->Unselect();
602 this->actualTreeItem.Unset();
603 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
606 //change project's actions panel
607 if(this->panel_ProjectActions!= NULL)
609 auiManager.DetachPane(this->panel_ProjectActions);
610 this->panel_ProjectActions->Destroy();
611 this->panel_ProjectActions = NULL;
613 panel_ProjectActions = new wxCDMProjectActionsPanel(
615 this->model->GetProject(),
616 ID_WINDOW_PROJ_ACTIONS,
617 wxT("Project Actions Panel"),
622 panel_ProjectActions->SetMinSize(wxSize(500, 100));
625 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
632 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
634 std::cout << "closing project" << std::endl;
636 if(!this->model->CloseProject(result))
638 std::cout << "error closing project: " << *result << std::endl;
639 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
642 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
643 this->actualTreeItem.Unset();
644 if(this->panel_Properties != NULL)
646 auiManager.DetachPane(this->panel_Properties);
647 this->panel_Properties->Hide();
649 if(this->panel_ProjectActions != NULL)
651 auiManager.DetachPane(this->panel_ProjectActions);
652 this->panel_ProjectActions->Hide();
655 this->panel_Properties = new wxCDMMainDescriptionPanel(
657 ID_WINDOW_PROPERTIES,
658 wxT("Description Panel"),
664 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
669 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
671 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
674 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
676 std::cout << "Closing CreaDevManager..." << std::endl;
678 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
680 std::cout << "error closing project: " << *result << std::endl;
683 if(this->panel_Properties != NULL)
685 auiManager.DetachPane(this->panel_Properties);
686 this->panel_Properties->Destroy();
687 this->panel_Properties = NULL;
690 if(this->tree_Projects != NULL)
692 auiManager.DetachPane(this->tree_Projects);
693 this->tree_Projects->Destroy();
694 this->tree_Projects = NULL;
697 if(this->panel_ProjectActions != NULL)
699 auiManager.DetachPane(this->panel_ProjectActions);
700 this->panel_ProjectActions->Destroy();
701 this->panel_ProjectActions = NULL;
708 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
711 if(!model->RefreshProject(result))
713 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
715 if(this->model->GetProject() != NULL)
717 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
718 this->auiManager.Update();
720 this->tree_Projects->Unselect();
721 this->actualTreeItem.Unset();
722 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
727 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
729 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
730 settingsDialog->SetHelpEnabled(this->help);
732 int res = settingsDialog->ShowModal();
735 this->help = settingsDialog->IsHelpEnabled();
736 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
740 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
742 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
744 if(CDMUtilities::openBBEditor())
746 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
749 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
751 if(CDMUtilities::openCreaToolsTools())
753 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
756 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
758 if(CDMUtilities::openTextEditor())
760 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);
763 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
765 if(CDMUtilities::openTerminal())
767 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);
772 void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event)
774 wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this);
780 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
782 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0);
784 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
786 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
788 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
790 wxBoxSizer *topsizer;
792 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
794 topsizer = new wxBoxSizer(wxVERTICAL);
796 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
797 html -> SetBorders(0);
799 std::string content = ""
801 "<body bgcolor=\"#3333CC\">"
802 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
804 " <td bgcolor=\"#3333CC\">"
806 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
812 " <td bgcolor=\"#FFFFFF\">"
813 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
815 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
817 " <td width=\"65%\">"
818 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
823 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
833 html -> SetPage(crea::std2wx(content));
834 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
835 html -> GetInternalRepresentation() -> GetHeight());
837 topsizer -> Add(html, 1, wxALL, 10);
840 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
841 #endif // wxUSE_STATLINE
843 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
846 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
848 dlg.SetSizer(topsizer);
849 topsizer -> Fit(&dlg);
853 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
855 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
858 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
861 //get selected element
862 wxTreeItemId elementId = event.GetItem();
863 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
864 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
865 if(elementId.IsOk() && this->actualTreeItem != elementId)
868 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
869 //get element from model
870 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
874 std::cout << "Tree Selection: " << element->GetName() << std::endl;
876 //std::stringstream ss;
877 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
878 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
879 this->actualTreeItem = elementId;
883 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
884 wxPanel* description;
885 if(elementProject != NULL)
887 //create element description
888 description = new wxCDMProjectDescriptionPanel(
891 ID_WINDOW_PROPERTIES,
892 wxT("Description Panel"),
902 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
903 if(elementAppli != NULL)
905 //create element description
906 description = new wxCDMAppliDescriptionPanel(
909 ID_WINDOW_PROPERTIES,
910 wxT("Description Panel"),
920 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
921 if(elementApplication != NULL)
923 //create element description
924 description = new wxCDMApplicationDescriptionPanel(
927 ID_WINDOW_PROPERTIES,
928 wxT("Description Panel"),
937 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
938 if(elementLib != NULL)
940 //create element description
941 description = new wxCDMLibDescriptionPanel(
944 ID_WINDOW_PROPERTIES,
945 wxT("Description Panel"),
954 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
955 if(elementLibrary != NULL)
957 //create element description
958 description = new wxCDMLibraryDescriptionPanel(
961 ID_WINDOW_PROPERTIES,
962 wxT("Description Panel"),
971 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
972 if(elementPackage != NULL)
974 //create element description
975 description = new wxCDMPackageDescriptionPanel(
978 ID_WINDOW_PROPERTIES,
979 wxT("Description Panel"),
988 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
989 if(elementBlackBox != NULL)
991 //create element description
992 description = new wxCDMBlackBoxDescriptionPanel(
995 ID_WINDOW_PROPERTIES,
996 wxT("Description Panel"),
1005 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
1006 if(elementCMakeLists != NULL)
1008 //create element description
1009 description = new wxCDMCMakeListsDescriptionPanel(
1012 ID_WINDOW_PROPERTIES,
1013 wxT("Description Panel"),
1022 modelCDMCodeFile* elementCodeFile = dynamic_cast<modelCDMCodeFile*>(element);
1023 if(elementCodeFile != NULL)
1025 //create element description
1026 description = new wxCDMCodeFileDescriptionPanel(
1029 ID_WINDOW_PROPERTIES,
1030 wxT("Description Panel"),
1039 modelCDMBBSFile* elementBBSFile = dynamic_cast<modelCDMBBSFile*>(element);
1040 if(elementBBSFile != NULL)
1042 //create element description
1043 description = new wxCDMBBSFileDescriptionPanel(
1046 ID_WINDOW_PROPERTIES,
1047 wxT("Description Panel"),
1056 modelCDMBBGFile* elementBBGFile = dynamic_cast<modelCDMBBGFile*>(element);
1057 if(elementBBGFile != NULL)
1059 //create element description
1060 description = new wxCDMBBGFileDescriptionPanel(
1063 ID_WINDOW_PROPERTIES,
1064 wxT("Description Panel"),
1073 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
1074 if(elementFolder != NULL)
1076 //create element description
1077 description = new wxCDMFolderDescriptionPanel(
1080 ID_WINDOW_PROPERTIES,
1081 wxT("Description Panel"),
1090 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1091 if(elementFile != NULL)
1093 //create element description
1094 description = new wxCDMFileDescriptionPanel(
1097 ID_WINDOW_PROPERTIES,
1098 wxT("Description Panel"),
1108 //create element description
1109 description = new wxCDMMainDescriptionPanel(
1111 ID_WINDOW_PROPERTIES,
1112 wxT("Description Panel"),
1132 if(this->panel_Properties!= NULL)
1134 this->panel_Properties->Hide();
1135 auiManager.DetachPane(this->panel_Properties);
1136 //this->panel_Properties->Destroy();
1137 //this->panel_Properties = NULL;
1140 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1141 this->panel_Properties = description;
1143 auiManager.Update();
1154 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1156 modelCDMIProjectTreeNode* myItem = NULL;
1157 wxPanel* description = NULL;
1158 switch(event.GetId())
1161 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1162 //select out old one to generate selection event
1163 this->tree_Projects->Unselect();
1164 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1165 this->tree_Projects->Expand(myItem->GetId().GetWxId());
1169 if(event.GetString() == wxT("manage_packages"))
1171 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1172 //this->tree_Projects->Unselect();
1173 this->actualTreeItem.Unset();
1174 description = new wxCDMPackageManagerPanel(
1176 this->model->GetProject(),
1177 ID_WINDOW_PROPERTIES,
1178 wxT("Description Panel"),
1184 else if(event.GetString() == wxT("manage_libraries"))
1186 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1187 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1190 else if(event.GetString() == wxT("manage_applications"))
1192 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1193 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1196 else if(event.GetString() == wxT("blackbox"))
1198 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1199 this->actualTreeItem.Unset();
1200 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1201 description = new wxCDMBlackBoxDescriptionPanel(
1204 ID_WINDOW_PROPERTIES,
1205 wxT("Description Panel"),
1215 if(this->panel_Properties!= NULL)
1217 this->panel_Properties->Hide();
1218 auiManager.DetachPane(this->panel_Properties);
1219 this->panel_Properties->Destroy();
1220 this->panel_Properties = NULL;
1223 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1224 this->panel_Properties = description;
1225 auiManager.Update();
1234 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1236 //std::cout << "element " << event.GetInt() << std::endl;
1237 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1238 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1239 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1240 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1241 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1242 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1243 auiManager.Update();
1246 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1248 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1249 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1250 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1251 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1252 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1253 auiManager.Update();
1256 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1258 this->help = !this->help;
1259 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1262 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1269 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);