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 "wxCDMCodeFileDescriptionPanel.h"
56 #include "wxCDMCMakeListsDescriptionPanel.h"
57 #include "wxCDMFolderDescriptionPanel.h"
58 #include "wxCDMFileDescriptionPanel.h"
59 #include "wxCDMPackageManagerPanel.h"
60 #include "wxCDMProjectMapDialog.h"
62 #include "wxCDMSettingsDialog.h"
64 #include "wxCDMProjectActionsPanel.h"
65 #include "wxCDMNewProjectDialog.h"
69 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
70 EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
71 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
72 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
73 EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
74 EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
75 EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
76 EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
77 EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
78 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
79 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
80 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
81 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
82 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
83 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
84 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
85 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
86 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
87 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
88 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
89 EVT_MENU(ID_MENU_SHOW_PROJECT_MAP, wxCDMMainFrame::OnMenuShowProjectMap)
90 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
91 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
92 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
94 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
95 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
97 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
99 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
100 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
101 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
104 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
107 wxCDMMainFrame::wxCDMMainFrame(
110 const wxString& caption,
116 this->menu_File = NULL;
117 this->menu_Edit = NULL;
118 this->menu_Tools = NULL;
119 this->menu_Help = NULL;
120 this->panel_Properties = NULL;
121 this->panel_ProjectActions = NULL;
122 this->tree_Projects = NULL;
123 Create(parent, id, caption, pos, size, style);
126 wxCDMMainFrame::~wxCDMMainFrame()
128 wxConfigBase* pConfig = wxConfigBase::Get();
129 pConfig->Write(wxT("HELP"), this->help);
134 bool wxCDMMainFrame::Create(
137 const wxString& caption,
143 wxFrame::Create(parent, id, caption, pos, size, style);
146 wxConfigBase* pConfig = wxConfigBase::Get();
147 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
149 this->model = new modelCDMMain();
153 this->SetIcon(wxIcon(CIcon64));
157 modelCDMMain* wxCDMMainFrame::GetModel() const
162 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
164 return this->panel_Properties;
167 bool wxCDMMainFrame::isHelp() const
172 void wxCDMMainFrame::RefreshProject()
175 std::cout << "refreshing project" << std::endl;
176 this->model->RefreshProject(result);
177 std::cout << "rebuilding project tree" << std::endl;
178 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
179 this->tree_Projects->Unselect();
180 this->actualTreeItem.Unset();
183 void wxCDMMainFrame::CreateMenus()
185 wxMenuBar* menuBar = new wxMenuBar;
187 //Recently opened projects
188 menu_Recent = new wxMenu();
189 wxConfigBase* pConfig = wxConfigBase::Get();
190 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
193 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
194 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
197 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
198 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
201 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
202 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
205 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
206 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
209 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
217 menu_File = new wxMenu();
218 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
219 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
220 menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
221 menu_File->AppendSeparator();
222 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
223 menu_File->AppendSeparator();
224 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
225 menu_File->AppendSeparator();
226 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
228 menuBar->Append(menu_File, wxT("&File"));
231 menu_Edit = new wxMenu();
232 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
233 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
235 menuBar->Append(menu_Edit, wxT("&Edit"));
238 menu_Tools = new wxMenu();
239 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("Open BBEditor (BBTK &Graphical Editor)"));
240 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("Open &CreaTools"));
241 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("Open Code &Editor"));
242 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("Open Command &Line"));
244 menuBar->Append(menu_Tools, wxT("&Tools"));
247 menu_Help = new wxMenu();
248 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
249 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
250 menu_Help->Append(ID_MENU_SHOW_PROJECT_MAP, wxT("&Show Project Map"));
251 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
252 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
253 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
254 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
256 menuBar->Append(menu_Help, wxT("&Help"));
261 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
262 statusBar->SetFieldsCount(1);
263 SetStatusBar(statusBar);
267 void wxCDMMainFrame::CreateControls()
270 auiManager.SetManagedWindow(this);
273 tree_Projects = new wxCDMProjectsTreeCtrl(
278 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
280 this->actualTreeItem.Unset();
282 panel_Properties = new wxCDMMainDescriptionPanel(
284 ID_WINDOW_PROPERTIES,
285 wxT("Description Panel"),
291 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
292 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
294 //auiManager.LoadPerspective(pers,true);
295 wxToolTip::Enable(true);
296 wxToolTip::SetDelay(0);
301 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
304 int tam = menu_Recent->GetMenuItemCount();
305 for (int i = 0; i < tam; ++i) {
306 menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
308 //populate recent menu
309 wxConfigBase* pConfig = wxConfigBase::Get();
310 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
313 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
314 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
317 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
318 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
321 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
322 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
325 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
326 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
329 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
338 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
342 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
344 userResponse = dialog->ShowModal();
346 if(userResponse == wxID_FORWARD)
349 if(this->model->GetProject() != NULL)
351 if(!this->model->CloseProject(result))
353 std::cout << "error closing project: " << *result << std::endl;
354 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
359 if(this->panel_Properties != NULL)
361 auiManager.DetachPane(this->panel_Properties);
362 this->panel_Properties->Hide();
364 if(this->panel_ProjectActions != NULL)
366 auiManager.DetachPane(this->panel_ProjectActions);
367 this->panel_ProjectActions->Hide();
373 if(!this->model->CreateProject(
374 crea::wx2std(dialog->GetProjectName()),
375 crea::wx2std(dialog->GetProjectLocation()),
377 crea::wx2std(dialog->GetPackageAuthor()),
378 crea::wx2std(dialog->GetPackageDescription())
381 std::cout << "error opening project: " << *result << std::endl;
382 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
387 //update recently open projects
388 wxConfigBase* pConfig = wxConfigBase::Get();
389 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
391 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
392 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
393 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
394 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
395 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
399 //show project actions panel
400 if(this->panel_ProjectActions != NULL)
402 auiManager.DetachPane(this->panel_Properties);
403 this->panel_ProjectActions->Destroy();
404 this->panel_ProjectActions = NULL;
407 panel_ProjectActions = new wxCDMProjectActionsPanel(
409 this->model->GetProject(),
410 ID_WINDOW_PROJ_ACTIONS,
411 wxT("Project Actions Panel"),
417 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
420 //populate tree control
421 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
422 tree_Projects->Unselect();
423 this->actualTreeItem.Unset();
424 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
425 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
428 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
432 //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
434 std::string path = "";
435 wxConfigBase* pConfig = wxConfigBase::Get();
436 if(event.GetId() == ID_MENU_OPEN_RECENT1)
437 path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
438 else if(event.GetId() == ID_MENU_OPEN_RECENT2)
439 path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
440 else if(event.GetId() == ID_MENU_OPEN_RECENT3)
441 path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
442 else if(event.GetId() == ID_MENU_OPEN_RECENT4)
443 path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
444 else if(event.GetId() == ID_MENU_OPEN_RECENT5)
445 path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
447 std::cout << "Selection to open: " << path << std::endl;
452 if(this->model->GetProject() != NULL)
454 std::cout << "Project not null, closing it" << std::endl;
455 if(!this->model->CloseProject(result))
457 std::cout << "error closing project: " << *result << std::endl;
458 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
463 if(this->panel_Properties != NULL)
465 auiManager.DetachPane(this->panel_Properties);
466 this->panel_Properties->Hide();
468 if(this->panel_ProjectActions != NULL)
470 auiManager.DetachPane(this->panel_ProjectActions);
471 this->panel_ProjectActions->Hide();
475 if (!this->model->OpenProject(path, result))
477 std::cout << "error opening project: " << *result << std::endl;
478 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
483 //update recently open projects
484 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
486 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
487 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
488 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
489 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
490 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
493 std::cout << "building ui" << std::endl;
495 //populate tree control
496 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
497 tree_Projects->Unselect();
498 this->actualTreeItem.Unset();
499 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
502 //change project's actions panel
503 if(this->panel_ProjectActions!= NULL)
505 auiManager.DetachPane(this->panel_ProjectActions);
506 this->panel_ProjectActions->Destroy();
507 this->panel_ProjectActions = NULL;
509 panel_ProjectActions = new wxCDMProjectActionsPanel(
511 this->model->GetProject(),
512 ID_WINDOW_PROJ_ACTIONS,
513 wxT("Project Actions Panel"),
518 panel_ProjectActions->SetMinSize(wxSize(500, 100));
521 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
526 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
530 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
531 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
532 long userResponse = FD->ShowModal();
533 if(userResponse == wxID_OK)
535 std::string path = crea::wx2std (FD->GetPath());
539 std::cout << "Selection to open: " << path << std::endl;
543 if(this->model->GetProject() != NULL)
545 std::cout << "Project not null, closing it" << std::endl;
546 if(!this->model->CloseProject(result))
548 std::cout << "error closing project: " << *result << std::endl;
549 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
554 if(this->panel_Properties != NULL)
556 auiManager.DetachPane(this->panel_Properties);
557 this->panel_Properties->Hide();
559 if(this->panel_ProjectActions != NULL)
561 auiManager.DetachPane(this->panel_ProjectActions);
562 this->panel_ProjectActions->Hide();
566 if (!this->model->OpenProject(path, result))
568 std::cout << "error opening project: " << *result << std::endl;
569 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
574 //update recently open projects
575 wxConfigBase* pConfig = wxConfigBase::Get();
576 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
578 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
579 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
580 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
581 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
582 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
585 std::cout << "building ui" << std::endl;
587 //populate tree control
588 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
589 tree_Projects->Unselect();
590 this->actualTreeItem.Unset();
591 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
594 //change project's actions panel
595 if(this->panel_ProjectActions!= NULL)
597 auiManager.DetachPane(this->panel_ProjectActions);
598 this->panel_ProjectActions->Destroy();
599 this->panel_ProjectActions = NULL;
601 panel_ProjectActions = new wxCDMProjectActionsPanel(
603 this->model->GetProject(),
604 ID_WINDOW_PROJ_ACTIONS,
605 wxT("Project Actions Panel"),
610 panel_ProjectActions->SetMinSize(wxSize(500, 100));
613 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
620 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
622 std::cout << "closing project" << std::endl;
624 if(!this->model->CloseProject(result))
626 std::cout << "error closing project: " << *result << std::endl;
627 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
630 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
631 this->actualTreeItem.Unset();
632 if(this->panel_Properties != NULL)
634 auiManager.DetachPane(this->panel_Properties);
635 this->panel_Properties->Hide();
637 if(this->panel_ProjectActions != NULL)
639 auiManager.DetachPane(this->panel_ProjectActions);
640 this->panel_ProjectActions->Hide();
643 this->panel_Properties = new wxCDMMainDescriptionPanel(
645 ID_WINDOW_PROPERTIES,
646 wxT("Description Panel"),
652 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
657 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
659 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
662 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
664 std::cout << "Closing CreaDevManager..." << std::endl;
666 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
668 std::cout << "error closing project: " << *result << std::endl;
671 if(this->panel_Properties != NULL)
673 auiManager.DetachPane(this->panel_Properties);
674 this->panel_Properties->Destroy();
675 this->panel_Properties = NULL;
678 if(this->tree_Projects != NULL)
680 auiManager.DetachPane(this->tree_Projects);
681 this->tree_Projects->Destroy();
682 this->tree_Projects = NULL;
685 if(this->panel_ProjectActions != NULL)
687 auiManager.DetachPane(this->panel_ProjectActions);
688 this->panel_ProjectActions->Destroy();
689 this->panel_ProjectActions = NULL;
696 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
699 if(!model->RefreshProject(result))
701 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
703 if(this->model->GetProject() != NULL)
705 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
706 this->auiManager.Update();
708 this->tree_Projects->Unselect();
709 this->actualTreeItem.Unset();
710 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
715 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
717 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
718 settingsDialog->SetHelpEnabled(this->help);
720 int res = settingsDialog->ShowModal();
723 this->help = settingsDialog->IsHelpEnabled();
724 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
728 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
730 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
732 if(CDMUtilities::openBBEditor())
734 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
737 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
739 if(CDMUtilities::openCreaToolsTools())
741 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
744 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
746 if(CDMUtilities::openTextEditor())
748 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);
751 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
753 if(CDMUtilities::openTerminal())
755 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);
760 void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event)
762 wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this);
768 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
770 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0);
772 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
774 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
776 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
778 wxBoxSizer *topsizer;
780 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
782 topsizer = new wxBoxSizer(wxVERTICAL);
784 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
785 html -> SetBorders(0);
787 std::string content = ""
789 "<body bgcolor=\"#3333CC\">"
790 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
792 " <td bgcolor=\"#3333CC\">"
794 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
800 " <td bgcolor=\"#FFFFFF\">"
801 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
803 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
805 " <td width=\"65%\">"
806 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
811 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
821 html -> SetPage(crea::std2wx(content));
822 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
823 html -> GetInternalRepresentation() -> GetHeight());
825 topsizer -> Add(html, 1, wxALL, 10);
828 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
829 #endif // wxUSE_STATLINE
831 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
834 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
836 dlg.SetSizer(topsizer);
837 topsizer -> Fit(&dlg);
841 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
843 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
846 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
849 //get selected element
850 wxTreeItemId elementId = event.GetItem();
851 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
852 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
853 if(elementId.IsOk() && this->actualTreeItem != elementId)
856 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
857 //get element from model
858 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
862 std::cout << "Tree Selection: " << element->GetName() << std::endl;
864 //std::stringstream ss;
865 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
866 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
867 this->actualTreeItem = elementId;
871 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
872 wxPanel* description;
873 if(elementProject != NULL)
875 //create element description
876 description = new wxCDMProjectDescriptionPanel(
879 ID_WINDOW_PROPERTIES,
880 wxT("Description Panel"),
890 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
891 if(elementAppli != NULL)
893 //create element description
894 description = new wxCDMAppliDescriptionPanel(
897 ID_WINDOW_PROPERTIES,
898 wxT("Description Panel"),
908 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
909 if(elementApplication != NULL)
911 //create element description
912 description = new wxCDMApplicationDescriptionPanel(
915 ID_WINDOW_PROPERTIES,
916 wxT("Description Panel"),
925 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
926 if(elementLib != NULL)
928 //create element description
929 description = new wxCDMLibDescriptionPanel(
932 ID_WINDOW_PROPERTIES,
933 wxT("Description Panel"),
942 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
943 if(elementLibrary != NULL)
945 //create element description
946 description = new wxCDMLibraryDescriptionPanel(
949 ID_WINDOW_PROPERTIES,
950 wxT("Description Panel"),
959 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
960 if(elementPackage != NULL)
962 //create element description
963 description = new wxCDMPackageDescriptionPanel(
966 ID_WINDOW_PROPERTIES,
967 wxT("Description Panel"),
976 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
977 if(elementBlackBox != NULL)
979 //create element description
980 description = new wxCDMBlackBoxDescriptionPanel(
983 ID_WINDOW_PROPERTIES,
984 wxT("Description Panel"),
993 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
994 if(elementCMakeLists != NULL)
996 //create element description
997 description = new wxCDMCMakeListsDescriptionPanel(
1000 ID_WINDOW_PROPERTIES,
1001 wxT("Description Panel"),
1010 modelCDMCodeFile* elementCodeFile = dynamic_cast<modelCDMCodeFile*>(element);
1011 if(elementCodeFile != NULL)
1013 //create element description
1014 description = new wxCDMCodeFileDescriptionPanel(
1017 ID_WINDOW_PROPERTIES,
1018 wxT("Description Panel"),
1027 modelCDMBBSFile* elementBBSFile = dynamic_cast<modelCDMBBSFile*>(element);
1028 if(elementBBSFile != NULL)
1030 //create element description
1031 description = new wxCDMBBSFileDescriptionPanel(
1034 ID_WINDOW_PROPERTIES,
1035 wxT("Description Panel"),
1044 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
1045 if(elementFolder != NULL)
1047 //create element description
1048 description = new wxCDMFolderDescriptionPanel(
1051 ID_WINDOW_PROPERTIES,
1052 wxT("Description Panel"),
1061 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1062 if(elementFile != NULL)
1064 //create element description
1065 description = new wxCDMFileDescriptionPanel(
1068 ID_WINDOW_PROPERTIES,
1069 wxT("Description Panel"),
1079 //create element description
1080 description = new wxCDMMainDescriptionPanel(
1082 ID_WINDOW_PROPERTIES,
1083 wxT("Description Panel"),
1102 if(this->panel_Properties!= NULL)
1104 this->panel_Properties->Hide();
1105 auiManager.DetachPane(this->panel_Properties);
1106 //this->panel_Properties->Destroy();
1107 //this->panel_Properties = NULL;
1110 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1111 this->panel_Properties = description;
1113 auiManager.Update();
1124 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1126 modelCDMIProjectTreeNode* myItem = NULL;
1127 wxPanel* description = NULL;
1128 switch(event.GetId())
1131 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1132 //select out old one to generate selection event
1133 this->tree_Projects->Unselect();
1134 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1135 this->tree_Projects->Expand(myItem->GetId().GetWxId());
1139 if(event.GetString() == wxT("manage_packages"))
1141 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1142 //this->tree_Projects->Unselect();
1143 this->actualTreeItem.Unset();
1144 description = new wxCDMPackageManagerPanel(
1146 this->model->GetProject(),
1147 ID_WINDOW_PROPERTIES,
1148 wxT("Description Panel"),
1154 else if(event.GetString() == wxT("manage_libraries"))
1156 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1157 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1160 else if(event.GetString() == wxT("manage_applications"))
1162 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1163 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1166 else if(event.GetString() == wxT("blackbox"))
1168 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1169 this->actualTreeItem.Unset();
1170 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1171 description = new wxCDMBlackBoxDescriptionPanel(
1174 ID_WINDOW_PROPERTIES,
1175 wxT("Description Panel"),
1185 if(this->panel_Properties!= NULL)
1187 this->panel_Properties->Hide();
1188 auiManager.DetachPane(this->panel_Properties);
1189 this->panel_Properties->Destroy();
1190 this->panel_Properties = NULL;
1193 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1194 this->panel_Properties = description;
1195 auiManager.Update();
1204 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1206 //std::cout << "element " << event.GetInt() << std::endl;
1207 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1208 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1209 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1210 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1211 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1212 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1213 auiManager.Update();
1216 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1218 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1219 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1220 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1221 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1222 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1223 auiManager.Update();
1226 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1228 this->help = !this->help;
1229 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1232 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1239 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);