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 "wxCDMCMakeListsDescriptionPanel.h"
55 #include "wxCDMFolderDescriptionPanel.h"
56 #include "wxCDMFileDescriptionPanel.h"
57 #include "wxCDMPackageManagerPanel.h"
58 #include "wxCDMProjectMapDialog.h"
60 #include "wxCDMSettingsDialog.h"
62 #include "wxCDMProjectActionsPanel.h"
63 #include "wxCDMNewProjectDialog.h"
67 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
68 EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
69 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
70 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
71 EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
72 EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
73 EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
74 EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
75 EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
76 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
77 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
78 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
79 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
80 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
81 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
82 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
83 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
84 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
85 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
86 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
87 EVT_MENU(ID_MENU_SHOW_PROJECT_MAP, wxCDMMainFrame::OnMenuShowProjectMap)
88 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
89 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
90 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
92 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
93 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
95 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
97 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
98 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
99 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
102 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
105 wxCDMMainFrame::wxCDMMainFrame(
108 const wxString& caption,
114 this->menu_File = NULL;
115 this->menu_Edit = NULL;
116 this->menu_Tools = NULL;
117 this->menu_Help = NULL;
118 this->panel_Properties = NULL;
119 this->panel_ProjectActions = NULL;
120 this->tree_Projects = NULL;
121 Create(parent, id, caption, pos, size, style);
124 wxCDMMainFrame::~wxCDMMainFrame()
126 wxConfigBase* pConfig = wxConfigBase::Get();
127 pConfig->Write(wxT("HELP"), this->help);
132 bool wxCDMMainFrame::Create(
135 const wxString& caption,
141 wxFrame::Create(parent, id, caption, pos, size, style);
144 wxConfigBase* pConfig = wxConfigBase::Get();
145 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
147 this->model = new modelCDMMain();
151 this->SetIcon(wxIcon(CIcon64));
155 modelCDMMain* wxCDMMainFrame::GetModel() const
160 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
162 return this->panel_Properties;
165 bool wxCDMMainFrame::isHelp() const
170 void wxCDMMainFrame::RefreshProject()
173 std::cout << "refreshing project" << std::endl;
174 this->model->RefreshProject(result);
175 std::cout << "rebuilding project tree" << std::endl;
176 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
177 this->tree_Projects->Unselect();
178 this->actualTreeItem.Unset();
181 void wxCDMMainFrame::CreateMenus()
183 wxMenuBar* menuBar = new wxMenuBar;
185 //Recently opened projects
186 menu_Recent = new wxMenu();
187 wxConfigBase* pConfig = wxConfigBase::Get();
188 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
191 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
192 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
195 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
196 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
199 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
200 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
203 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
204 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
207 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
215 menu_File = new wxMenu();
216 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
217 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
218 menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
219 menu_File->AppendSeparator();
220 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
221 menu_File->AppendSeparator();
222 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
223 menu_File->AppendSeparator();
224 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
226 menuBar->Append(menu_File, wxT("&File"));
229 menu_Edit = new wxMenu();
230 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
231 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
233 menuBar->Append(menu_Edit, wxT("&Edit"));
236 menu_Tools = new wxMenu();
237 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("Open BBEditor (BBTK &Graphical Editor)"));
238 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("Open &CreaTools"));
239 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("Open Code &Editor"));
240 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("Open Command &Line"));
242 menuBar->Append(menu_Tools, wxT("&Tools"));
245 menu_Help = new wxMenu();
246 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
247 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
248 menu_Help->Append(ID_MENU_SHOW_PROJECT_MAP, wxT("&Show Project Map"));
249 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
250 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
251 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
252 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
254 menuBar->Append(menu_Help, wxT("&Help"));
259 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
260 statusBar->SetFieldsCount(1);
261 SetStatusBar(statusBar);
265 void wxCDMMainFrame::CreateControls()
268 auiManager.SetManagedWindow(this);
271 tree_Projects = new wxCDMProjectsTreeCtrl(
276 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
278 this->actualTreeItem.Unset();
280 panel_Properties = new wxCDMMainDescriptionPanel(
282 ID_WINDOW_PROPERTIES,
283 wxT("Description Panel"),
289 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
290 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
292 //auiManager.LoadPerspective(pers,true);
293 wxToolTip::Enable(true);
294 wxToolTip::SetDelay(0);
299 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
302 int tam = menu_Recent->GetMenuItemCount();
303 for (int i = 0; i < tam; ++i) {
304 menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
306 //populate recent menu
307 wxConfigBase* pConfig = wxConfigBase::Get();
308 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
311 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
312 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
315 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
316 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
319 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
320 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
323 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
324 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
327 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
336 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
340 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
342 userResponse = dialog->ShowModal();
344 if(userResponse == wxID_FORWARD)
347 if(this->model->GetProject() != NULL)
349 if(!this->model->CloseProject(result))
351 std::cout << "error closing project: " << *result << std::endl;
352 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
357 if(this->panel_Properties != NULL)
359 auiManager.DetachPane(this->panel_Properties);
360 this->panel_Properties->Hide();
362 if(this->panel_ProjectActions != NULL)
364 auiManager.DetachPane(this->panel_ProjectActions);
365 this->panel_ProjectActions->Hide();
371 if(!this->model->CreateProject(
372 crea::wx2std(dialog->GetProjectName()),
373 crea::wx2std(dialog->GetProjectLocation()),
375 crea::wx2std(dialog->GetPackageAuthor()),
376 crea::wx2std(dialog->GetPackageDescription())
379 std::cout << "error opening project: " << *result << std::endl;
380 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
385 //update recently open projects
386 wxConfigBase* pConfig = wxConfigBase::Get();
387 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
389 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
390 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
391 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
392 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
393 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
397 //show project actions panel
398 if(this->panel_ProjectActions != NULL)
400 auiManager.DetachPane(this->panel_Properties);
401 this->panel_ProjectActions->Destroy();
402 this->panel_ProjectActions = NULL;
405 panel_ProjectActions = new wxCDMProjectActionsPanel(
407 this->model->GetProject(),
408 ID_WINDOW_PROJ_ACTIONS,
409 wxT("Project Actions Panel"),
415 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
418 //populate tree control
419 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
420 tree_Projects->Unselect();
421 this->actualTreeItem.Unset();
422 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
423 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
426 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
430 //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
432 std::string path = "";
433 wxConfigBase* pConfig = wxConfigBase::Get();
434 if(event.GetId() == ID_MENU_OPEN_RECENT1)
435 path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
436 else if(event.GetId() == ID_MENU_OPEN_RECENT2)
437 path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
438 else if(event.GetId() == ID_MENU_OPEN_RECENT3)
439 path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
440 else if(event.GetId() == ID_MENU_OPEN_RECENT4)
441 path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
442 else if(event.GetId() == ID_MENU_OPEN_RECENT5)
443 path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
445 std::cout << "Selection to open: " << path << std::endl;
450 if(this->model->GetProject() != NULL)
452 std::cout << "Project not null, closing it" << std::endl;
453 if(!this->model->CloseProject(result))
455 std::cout << "error closing project: " << *result << std::endl;
456 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
461 if(this->panel_Properties != NULL)
463 auiManager.DetachPane(this->panel_Properties);
464 this->panel_Properties->Hide();
466 if(this->panel_ProjectActions != NULL)
468 auiManager.DetachPane(this->panel_ProjectActions);
469 this->panel_ProjectActions->Hide();
473 if (!this->model->OpenProject(path, result))
475 std::cout << "error opening project: " << *result << std::endl;
476 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
481 //update recently open projects
482 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
484 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
485 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
486 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
487 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
488 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
491 std::cout << "building ui" << std::endl;
493 //populate tree control
494 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
495 tree_Projects->Unselect();
496 this->actualTreeItem.Unset();
497 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
500 //change project's actions panel
501 if(this->panel_ProjectActions!= NULL)
503 auiManager.DetachPane(this->panel_ProjectActions);
504 this->panel_ProjectActions->Destroy();
505 this->panel_ProjectActions = NULL;
507 panel_ProjectActions = new wxCDMProjectActionsPanel(
509 this->model->GetProject(),
510 ID_WINDOW_PROJ_ACTIONS,
511 wxT("Project Actions Panel"),
516 panel_ProjectActions->SetMinSize(wxSize(500, 100));
519 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
524 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
528 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
529 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
530 long userResponse = FD->ShowModal();
531 if(userResponse == wxID_OK)
533 std::string path = crea::wx2std (FD->GetPath());
537 std::cout << "Selection to open: " << path << std::endl;
541 if(this->model->GetProject() != NULL)
543 std::cout << "Project not null, closing it" << std::endl;
544 if(!this->model->CloseProject(result))
546 std::cout << "error closing project: " << *result << std::endl;
547 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
552 if(this->panel_Properties != NULL)
554 auiManager.DetachPane(this->panel_Properties);
555 this->panel_Properties->Hide();
557 if(this->panel_ProjectActions != NULL)
559 auiManager.DetachPane(this->panel_ProjectActions);
560 this->panel_ProjectActions->Hide();
564 if (!this->model->OpenProject(path, result))
566 std::cout << "error opening project: " << *result << std::endl;
567 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
572 //update recently open projects
573 wxConfigBase* pConfig = wxConfigBase::Get();
574 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
576 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
577 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
578 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
579 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
580 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
583 std::cout << "building ui" << std::endl;
585 //populate tree control
586 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
587 tree_Projects->Unselect();
588 this->actualTreeItem.Unset();
589 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
592 //change project's actions panel
593 if(this->panel_ProjectActions!= NULL)
595 auiManager.DetachPane(this->panel_ProjectActions);
596 this->panel_ProjectActions->Destroy();
597 this->panel_ProjectActions = NULL;
599 panel_ProjectActions = new wxCDMProjectActionsPanel(
601 this->model->GetProject(),
602 ID_WINDOW_PROJ_ACTIONS,
603 wxT("Project Actions Panel"),
608 panel_ProjectActions->SetMinSize(wxSize(500, 100));
611 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
618 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
620 std::cout << "closing project" << std::endl;
622 if(!this->model->CloseProject(result))
624 std::cout << "error closing project: " << *result << std::endl;
625 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
628 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
629 this->actualTreeItem.Unset();
630 if(this->panel_Properties != NULL)
632 auiManager.DetachPane(this->panel_Properties);
633 this->panel_Properties->Hide();
635 if(this->panel_ProjectActions != NULL)
637 auiManager.DetachPane(this->panel_ProjectActions);
638 this->panel_ProjectActions->Hide();
641 this->panel_Properties = new wxCDMMainDescriptionPanel(
643 ID_WINDOW_PROPERTIES,
644 wxT("Description Panel"),
650 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
655 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
657 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
660 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
662 std::cout << "Closing CreaDevManager..." << std::endl;
664 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
666 std::cout << "error closing project: " << *result << std::endl;
669 if(this->panel_Properties != NULL)
671 auiManager.DetachPane(this->panel_Properties);
672 this->panel_Properties->Destroy();
673 this->panel_Properties = NULL;
676 if(this->tree_Projects != NULL)
678 auiManager.DetachPane(this->tree_Projects);
679 this->tree_Projects->Destroy();
680 this->tree_Projects = NULL;
683 if(this->panel_ProjectActions != NULL)
685 auiManager.DetachPane(this->panel_ProjectActions);
686 this->panel_ProjectActions->Destroy();
687 this->panel_ProjectActions = NULL;
694 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
697 if(!model->RefreshProject(result))
699 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
701 if(this->model->GetProject() != NULL)
703 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
704 this->auiManager.Update();
706 this->tree_Projects->Unselect();
707 this->actualTreeItem.Unset();
708 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
713 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
715 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
716 settingsDialog->SetHelpEnabled(this->help);
718 int res = settingsDialog->ShowModal();
721 this->help = settingsDialog->IsHelpEnabled();
722 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
726 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
728 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
730 if(CDMUtilities::openBBEditor())
732 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
735 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
737 if(CDMUtilities::openCreaToolsTools())
739 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
742 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
744 if(CDMUtilities::openTextEditor())
746 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);
749 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
751 if(CDMUtilities::openTerminal())
753 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);
758 void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event)
760 wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this);
766 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
768 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0);
770 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
772 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
774 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
776 wxBoxSizer *topsizer;
778 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
780 topsizer = new wxBoxSizer(wxVERTICAL);
782 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
783 html -> SetBorders(0);
785 std::string content = ""
787 "<body bgcolor=\"#3333CC\">"
788 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
790 " <td bgcolor=\"#3333CC\">"
792 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
798 " <td bgcolor=\"#FFFFFF\">"
799 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
801 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
803 " <td width=\"65%\">"
804 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
809 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
819 html -> SetPage(crea::std2wx(content));
820 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
821 html -> GetInternalRepresentation() -> GetHeight());
823 topsizer -> Add(html, 1, wxALL, 10);
826 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
827 #endif // wxUSE_STATLINE
829 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
832 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
834 dlg.SetSizer(topsizer);
835 topsizer -> Fit(&dlg);
839 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
841 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
844 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
847 //get selected element
848 wxTreeItemId elementId = event.GetItem();
849 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
850 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
851 if(elementId.IsOk() && this->actualTreeItem != elementId)
854 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
855 //get element from model
856 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
860 std::cout << "Tree Selection: " << element->GetName() << std::endl;
862 //std::stringstream ss;
863 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
864 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
865 this->actualTreeItem = elementId;
869 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
870 wxPanel* description;
871 if(elementProject != NULL)
873 //create element description
874 description = new wxCDMProjectDescriptionPanel(
877 ID_WINDOW_PROPERTIES,
878 wxT("Description Panel"),
888 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
889 if(elementAppli != NULL)
891 //create element description
892 description = new wxCDMAppliDescriptionPanel(
895 ID_WINDOW_PROPERTIES,
896 wxT("Description Panel"),
906 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
907 if(elementApplication != NULL)
909 //create element description
910 description = new wxCDMApplicationDescriptionPanel(
913 ID_WINDOW_PROPERTIES,
914 wxT("Description Panel"),
923 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
924 if(elementLib != NULL)
926 //create element description
927 description = new wxCDMLibDescriptionPanel(
930 ID_WINDOW_PROPERTIES,
931 wxT("Description Panel"),
940 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
941 if(elementLibrary != NULL)
943 //create element description
944 description = new wxCDMLibraryDescriptionPanel(
947 ID_WINDOW_PROPERTIES,
948 wxT("Description Panel"),
957 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
958 if(elementPackage != NULL)
960 //create element description
961 description = new wxCDMPackageDescriptionPanel(
964 ID_WINDOW_PROPERTIES,
965 wxT("Description Panel"),
974 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
975 if(elementBlackBox != NULL)
977 //create element description
978 description = new wxCDMBlackBoxDescriptionPanel(
981 ID_WINDOW_PROPERTIES,
982 wxT("Description Panel"),
991 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
992 if(elementCMakeLists != NULL)
994 //create element description
995 description = new wxCDMCMakeListsDescriptionPanel(
998 ID_WINDOW_PROPERTIES,
999 wxT("Description Panel"),
1008 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
1009 if(elementFolder != NULL)
1011 //create element description
1012 description = new wxCDMFolderDescriptionPanel(
1015 ID_WINDOW_PROPERTIES,
1016 wxT("Description Panel"),
1025 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1026 if(elementFile != NULL)
1028 //create element description
1029 description = new wxCDMFileDescriptionPanel(
1032 ID_WINDOW_PROPERTIES,
1033 wxT("Description Panel"),
1043 //create element description
1044 description = new wxCDMMainDescriptionPanel(
1046 ID_WINDOW_PROPERTIES,
1047 wxT("Description Panel"),
1064 if(this->panel_Properties!= NULL)
1066 this->panel_Properties->Hide();
1067 auiManager.DetachPane(this->panel_Properties);
1068 //this->panel_Properties->Destroy();
1069 //this->panel_Properties = NULL;
1072 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1073 this->panel_Properties = description;
1075 auiManager.Update();
1086 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1088 modelCDMIProjectTreeNode* myItem = NULL;
1089 wxPanel* description = NULL;
1090 switch(event.GetId())
1093 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1094 //select out old one to generate selection event
1095 this->tree_Projects->Unselect();
1096 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1097 this->tree_Projects->Expand(myItem->GetId().GetWxId());
1101 if(event.GetString() == wxT("manage_packages"))
1103 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1104 //this->tree_Projects->Unselect();
1105 this->actualTreeItem.Unset();
1106 description = new wxCDMPackageManagerPanel(
1108 this->model->GetProject(),
1109 ID_WINDOW_PROPERTIES,
1110 wxT("Description Panel"),
1116 else if(event.GetString() == wxT("manage_libraries"))
1118 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1119 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1122 else if(event.GetString() == wxT("manage_applications"))
1124 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1125 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1128 else if(event.GetString() == wxT("blackbox"))
1130 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1131 this->actualTreeItem.Unset();
1132 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1133 description = new wxCDMBlackBoxDescriptionPanel(
1136 ID_WINDOW_PROPERTIES,
1137 wxT("Description Panel"),
1147 if(this->panel_Properties!= NULL)
1149 this->panel_Properties->Hide();
1150 auiManager.DetachPane(this->panel_Properties);
1151 this->panel_Properties->Destroy();
1152 this->panel_Properties = NULL;
1155 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1156 this->panel_Properties = description;
1157 auiManager.Update();
1166 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1168 //std::cout << "element " << event.GetInt() << std::endl;
1169 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1170 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1171 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1172 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1173 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1174 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1175 auiManager.Update();
1178 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1180 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1181 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1182 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1183 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1184 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1185 auiManager.Update();
1188 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1190 this->help = !this->help;
1191 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1194 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1201 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);