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 tree_Projects = new wxCDMProjectsTreeCtrl(
279 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
281 this->actualTreeItem.Unset();
283 panel_Properties = new wxCDMMainDescriptionPanel(
285 ID_WINDOW_PROPERTIES,
286 wxT("Description Panel"),
292 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
293 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
295 //auiManager.LoadPerspective(pers,true);
296 wxToolTip::Enable(true);
297 wxToolTip::SetDelay(0);
302 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
305 int tam = menu_Recent->GetMenuItemCount();
306 for (int i = 0; i < tam; ++i) {
307 menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
309 //populate recent menu
310 wxConfigBase* pConfig = wxConfigBase::Get();
311 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
314 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
315 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
318 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
319 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
322 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
323 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
326 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
327 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
330 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
339 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
343 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
345 userResponse = dialog->ShowModal();
347 if(userResponse == wxID_FORWARD)
350 if(this->model->GetProject() != NULL)
352 if(!this->model->CloseProject(result))
354 std::cout << "error closing project: " << *result << std::endl;
355 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
360 if(this->panel_Properties != NULL)
362 auiManager.DetachPane(this->panel_Properties);
363 this->panel_Properties->Hide();
365 if(this->panel_ProjectActions != NULL)
367 auiManager.DetachPane(this->panel_ProjectActions);
368 this->panel_ProjectActions->Hide();
374 if(!this->model->CreateProject(
375 crea::wx2std(dialog->GetProjectName()),
376 crea::wx2std(dialog->GetProjectLocation()),
378 crea::wx2std(dialog->GetPackageAuthor()),
379 crea::wx2std(dialog->GetPackageDescription())
382 std::cout << "error opening project: " << *result << std::endl;
383 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
388 //update recently open projects
389 wxConfigBase* pConfig = wxConfigBase::Get();
390 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
392 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
393 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
394 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
395 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
396 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
400 //show project actions panel
401 if(this->panel_ProjectActions != NULL)
403 auiManager.DetachPane(this->panel_Properties);
404 this->panel_ProjectActions->Destroy();
405 this->panel_ProjectActions = NULL;
408 panel_ProjectActions = new wxCDMProjectActionsPanel(
410 this->model->GetProject(),
411 ID_WINDOW_PROJ_ACTIONS,
412 wxT("Project Actions Panel"),
418 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
421 //populate tree control
422 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
423 tree_Projects->Unselect();
424 this->actualTreeItem.Unset();
425 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
426 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
429 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
433 //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
435 std::string path = "";
436 wxConfigBase* pConfig = wxConfigBase::Get();
437 if(event.GetId() == ID_MENU_OPEN_RECENT1)
438 path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
439 else if(event.GetId() == ID_MENU_OPEN_RECENT2)
440 path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
441 else if(event.GetId() == ID_MENU_OPEN_RECENT3)
442 path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
443 else if(event.GetId() == ID_MENU_OPEN_RECENT4)
444 path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
445 else if(event.GetId() == ID_MENU_OPEN_RECENT5)
446 path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
448 std::cout << "Selection to open: " << path << std::endl;
453 if(this->model->GetProject() != NULL)
455 std::cout << "Project not null, closing it" << std::endl;
456 if(!this->model->CloseProject(result))
458 std::cout << "error closing project: " << *result << std::endl;
459 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
464 if(this->panel_Properties != NULL)
466 auiManager.DetachPane(this->panel_Properties);
467 this->panel_Properties->Hide();
469 if(this->panel_ProjectActions != NULL)
471 auiManager.DetachPane(this->panel_ProjectActions);
472 this->panel_ProjectActions->Hide();
476 if (!this->model->OpenProject(path, result))
478 std::cout << "error opening project: " << *result << std::endl;
479 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
484 //update recently open projects
485 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
487 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
488 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
489 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
490 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
491 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
494 std::cout << "building ui" << std::endl;
496 //populate tree control
497 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
498 tree_Projects->Unselect();
499 this->actualTreeItem.Unset();
500 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
503 //change project's actions panel
504 if(this->panel_ProjectActions!= NULL)
506 auiManager.DetachPane(this->panel_ProjectActions);
507 this->panel_ProjectActions->Destroy();
508 this->panel_ProjectActions = NULL;
510 panel_ProjectActions = new wxCDMProjectActionsPanel(
512 this->model->GetProject(),
513 ID_WINDOW_PROJ_ACTIONS,
514 wxT("Project Actions Panel"),
519 panel_ProjectActions->SetMinSize(wxSize(500, 100));
522 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
527 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
531 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
532 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
533 long userResponse = FD->ShowModal();
534 if(userResponse == wxID_OK)
536 std::string path = crea::wx2std (FD->GetPath());
540 std::cout << "Selection to open: " << path << std::endl;
544 if(this->model->GetProject() != NULL)
546 std::cout << "Project not null, closing it" << std::endl;
547 if(!this->model->CloseProject(result))
549 std::cout << "error closing project: " << *result << std::endl;
550 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
555 if(this->panel_Properties != NULL)
557 auiManager.DetachPane(this->panel_Properties);
558 this->panel_Properties->Hide();
560 if(this->panel_ProjectActions != NULL)
562 auiManager.DetachPane(this->panel_ProjectActions);
563 this->panel_ProjectActions->Hide();
567 if (!this->model->OpenProject(path, result))
569 std::cout << "error opening project: " << *result << std::endl;
570 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
575 //update recently open projects
576 wxConfigBase* pConfig = wxConfigBase::Get();
577 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
579 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
580 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
581 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
582 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
583 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
586 std::cout << "building ui" << std::endl;
588 //populate tree control
589 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
590 tree_Projects->Unselect();
591 this->actualTreeItem.Unset();
592 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
595 //change project's actions panel
596 if(this->panel_ProjectActions!= NULL)
598 auiManager.DetachPane(this->panel_ProjectActions);
599 this->panel_ProjectActions->Destroy();
600 this->panel_ProjectActions = NULL;
602 panel_ProjectActions = new wxCDMProjectActionsPanel(
604 this->model->GetProject(),
605 ID_WINDOW_PROJ_ACTIONS,
606 wxT("Project Actions Panel"),
611 panel_ProjectActions->SetMinSize(wxSize(500, 100));
614 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
621 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
623 std::cout << "closing project" << std::endl;
625 if(!this->model->CloseProject(result))
627 std::cout << "error closing project: " << *result << std::endl;
628 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
631 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
632 this->actualTreeItem.Unset();
633 if(this->panel_Properties != NULL)
635 auiManager.DetachPane(this->panel_Properties);
636 this->panel_Properties->Hide();
638 if(this->panel_ProjectActions != NULL)
640 auiManager.DetachPane(this->panel_ProjectActions);
641 this->panel_ProjectActions->Hide();
644 this->panel_Properties = new wxCDMMainDescriptionPanel(
646 ID_WINDOW_PROPERTIES,
647 wxT("Description Panel"),
653 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
658 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
660 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
663 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
665 std::cout << "Closing CreaDevManager..." << std::endl;
667 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
669 std::cout << "error closing project: " << *result << std::endl;
672 if(this->panel_Properties != NULL)
674 auiManager.DetachPane(this->panel_Properties);
675 this->panel_Properties->Destroy();
676 this->panel_Properties = NULL;
679 if(this->tree_Projects != NULL)
681 auiManager.DetachPane(this->tree_Projects);
682 this->tree_Projects->Destroy();
683 this->tree_Projects = NULL;
686 if(this->panel_ProjectActions != NULL)
688 auiManager.DetachPane(this->panel_ProjectActions);
689 this->panel_ProjectActions->Destroy();
690 this->panel_ProjectActions = NULL;
697 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
700 if(!model->RefreshProject(result))
702 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
704 if(this->model->GetProject() != NULL)
706 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
707 this->auiManager.Update();
709 this->tree_Projects->Unselect();
710 this->actualTreeItem.Unset();
711 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
716 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
718 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
719 settingsDialog->SetHelpEnabled(this->help);
721 int res = settingsDialog->ShowModal();
724 this->help = settingsDialog->IsHelpEnabled();
725 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
729 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
731 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
733 if(CDMUtilities::openBBEditor())
735 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
738 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
740 if(CDMUtilities::openCreaToolsTools())
742 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
745 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
747 if(CDMUtilities::openTextEditor())
749 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);
752 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
754 if(CDMUtilities::openTerminal())
756 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);
761 void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event)
763 wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this);
769 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
771 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0);
773 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
775 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
777 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
779 wxBoxSizer *topsizer;
781 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
783 topsizer = new wxBoxSizer(wxVERTICAL);
785 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
786 html -> SetBorders(0);
788 std::string content = ""
790 "<body bgcolor=\"#3333CC\">"
791 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
793 " <td bgcolor=\"#3333CC\">"
795 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
801 " <td bgcolor=\"#FFFFFF\">"
802 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
804 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
806 " <td width=\"65%\">"
807 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
812 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
822 html -> SetPage(crea::std2wx(content));
823 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
824 html -> GetInternalRepresentation() -> GetHeight());
826 topsizer -> Add(html, 1, wxALL, 10);
829 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
830 #endif // wxUSE_STATLINE
832 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
835 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
837 dlg.SetSizer(topsizer);
838 topsizer -> Fit(&dlg);
842 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
844 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
847 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
850 //get selected element
851 wxTreeItemId elementId = event.GetItem();
852 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
853 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
854 if(elementId.IsOk() && this->actualTreeItem != elementId)
857 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
858 //get element from model
859 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
863 std::cout << "Tree Selection: " << element->GetName() << std::endl;
865 //std::stringstream ss;
866 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
867 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
868 this->actualTreeItem = elementId;
872 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
873 wxPanel* description;
874 if(elementProject != NULL)
876 //create element description
877 description = new wxCDMProjectDescriptionPanel(
880 ID_WINDOW_PROPERTIES,
881 wxT("Description Panel"),
891 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
892 if(elementAppli != NULL)
894 //create element description
895 description = new wxCDMAppliDescriptionPanel(
898 ID_WINDOW_PROPERTIES,
899 wxT("Description Panel"),
909 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
910 if(elementApplication != NULL)
912 //create element description
913 description = new wxCDMApplicationDescriptionPanel(
916 ID_WINDOW_PROPERTIES,
917 wxT("Description Panel"),
926 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
927 if(elementLib != NULL)
929 //create element description
930 description = new wxCDMLibDescriptionPanel(
933 ID_WINDOW_PROPERTIES,
934 wxT("Description Panel"),
943 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
944 if(elementLibrary != NULL)
946 //create element description
947 description = new wxCDMLibraryDescriptionPanel(
950 ID_WINDOW_PROPERTIES,
951 wxT("Description Panel"),
960 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
961 if(elementPackage != NULL)
963 //create element description
964 description = new wxCDMPackageDescriptionPanel(
967 ID_WINDOW_PROPERTIES,
968 wxT("Description Panel"),
977 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
978 if(elementBlackBox != NULL)
980 //create element description
981 description = new wxCDMBlackBoxDescriptionPanel(
984 ID_WINDOW_PROPERTIES,
985 wxT("Description Panel"),
994 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
995 if(elementCMakeLists != NULL)
997 //create element description
998 description = new wxCDMCMakeListsDescriptionPanel(
1001 ID_WINDOW_PROPERTIES,
1002 wxT("Description Panel"),
1011 modelCDMCodeFile* elementCodeFile = dynamic_cast<modelCDMCodeFile*>(element);
1012 if(elementCodeFile != NULL)
1014 //create element description
1015 description = new wxCDMCodeFileDescriptionPanel(
1018 ID_WINDOW_PROPERTIES,
1019 wxT("Description Panel"),
1028 modelCDMBBSFile* elementBBSFile = dynamic_cast<modelCDMBBSFile*>(element);
1029 if(elementBBSFile != NULL)
1031 //create element description
1032 description = new wxCDMBBSFileDescriptionPanel(
1035 ID_WINDOW_PROPERTIES,
1036 wxT("Description Panel"),
1045 modelCDMBBGFile* elementBBGFile = dynamic_cast<modelCDMBBGFile*>(element);
1046 if(elementBBGFile != NULL)
1048 //create element description
1049 description = new wxCDMBBGFileDescriptionPanel(
1052 ID_WINDOW_PROPERTIES,
1053 wxT("Description Panel"),
1062 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
1063 if(elementFolder != NULL)
1065 //create element description
1066 description = new wxCDMFolderDescriptionPanel(
1069 ID_WINDOW_PROPERTIES,
1070 wxT("Description Panel"),
1079 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1080 if(elementFile != NULL)
1082 //create element description
1083 description = new wxCDMFileDescriptionPanel(
1086 ID_WINDOW_PROPERTIES,
1087 wxT("Description Panel"),
1097 //create element description
1098 description = new wxCDMMainDescriptionPanel(
1100 ID_WINDOW_PROPERTIES,
1101 wxT("Description Panel"),
1121 if(this->panel_Properties!= NULL)
1123 this->panel_Properties->Hide();
1124 auiManager.DetachPane(this->panel_Properties);
1125 //this->panel_Properties->Destroy();
1126 //this->panel_Properties = NULL;
1129 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1130 this->panel_Properties = description;
1132 auiManager.Update();
1143 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1145 modelCDMIProjectTreeNode* myItem = NULL;
1146 wxPanel* description = NULL;
1147 switch(event.GetId())
1150 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1151 //select out old one to generate selection event
1152 this->tree_Projects->Unselect();
1153 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1154 this->tree_Projects->Expand(myItem->GetId().GetWxId());
1158 if(event.GetString() == wxT("manage_packages"))
1160 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1161 //this->tree_Projects->Unselect();
1162 this->actualTreeItem.Unset();
1163 description = new wxCDMPackageManagerPanel(
1165 this->model->GetProject(),
1166 ID_WINDOW_PROPERTIES,
1167 wxT("Description Panel"),
1173 else if(event.GetString() == wxT("manage_libraries"))
1175 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1176 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1179 else if(event.GetString() == wxT("manage_applications"))
1181 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1182 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1185 else if(event.GetString() == wxT("blackbox"))
1187 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1188 this->actualTreeItem.Unset();
1189 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1190 description = new wxCDMBlackBoxDescriptionPanel(
1193 ID_WINDOW_PROPERTIES,
1194 wxT("Description Panel"),
1204 if(this->panel_Properties!= NULL)
1206 this->panel_Properties->Hide();
1207 auiManager.DetachPane(this->panel_Properties);
1208 this->panel_Properties->Destroy();
1209 this->panel_Properties = NULL;
1212 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1213 this->panel_Properties = description;
1214 auiManager.Update();
1223 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1225 //std::cout << "element " << event.GetInt() << std::endl;
1226 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1227 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1228 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1229 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1230 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1231 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1232 auiManager.Update();
1235 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1237 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1238 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1239 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1240 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1241 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1242 auiManager.Update();
1245 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1247 this->help = !this->help;
1248 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1251 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1258 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);