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"
44 #include "creaDevManagerIds.h"
45 #include "wxCDMMainDescriptionPanel.h"
46 #include "wxCDMProjectDescriptionPanel.h"
47 #include "wxCDMAppliDescriptionPanel.h"
48 #include "wxCDMApplicationDescriptionPanel.h"
49 #include "wxCDMLibDescriptionPanel.h"
50 #include "wxCDMLibraryDescriptionPanel.h"
51 #include "wxCDMPackageDescriptionPanel.h"
52 #include "wxCDMBlackBoxDescriptionPanel.h"
53 #include "wxCDMCMakeListsDescriptionPanel.h"
54 #include "wxCDMFolderDescriptionPanel.h"
55 #include "wxCDMFileDescriptionPanel.h"
56 #include "wxCDMPackageManagerPanel.h"
58 #include "wxCDMSettingsDialog.h"
60 #include "wxCDMProjectActionsPanel.h"
61 #include "wxCDMNewProjectDialog.h"
65 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
66 EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
67 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
68 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
69 EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
70 EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
71 EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
72 EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
73 EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
74 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
75 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
76 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
77 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
78 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
79 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
80 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
81 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
82 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
83 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
84 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
85 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
86 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
87 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
89 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
90 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
92 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
94 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
95 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
96 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
99 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
102 wxCDMMainFrame::wxCDMMainFrame(
105 const wxString& caption,
111 this->menu_File = NULL;
112 this->menu_Edit = NULL;
113 this->menu_Tools = NULL;
114 this->menu_Help = NULL;
115 this->panel_Properties = NULL;
116 this->panel_ProjectActions = NULL;
117 this->tree_Projects = NULL;
118 Create(parent, id, caption, pos, size, style);
121 wxCDMMainFrame::~wxCDMMainFrame()
123 wxConfigBase* pConfig = wxConfigBase::Get();
124 pConfig->Write(wxT("HELP"), this->help);
129 bool wxCDMMainFrame::Create(
132 const wxString& caption,
138 wxFrame::Create(parent, id, caption, pos, size, style);
141 wxConfigBase* pConfig = wxConfigBase::Get();
142 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
144 this->model = new modelCDMMain();
151 modelCDMMain* wxCDMMainFrame::GetModel() const
156 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
158 return this->panel_Properties;
161 bool wxCDMMainFrame::isHelp() const
166 void wxCDMMainFrame::RefreshProject()
169 std::cout << "refreshing project" << std::endl;
170 this->model->RefreshProject(result);
171 std::cout << "rebuilding project tree" << std::endl;
172 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
173 this->tree_Projects->Unselect();
174 this->actualTreeItem.Unset();
177 void wxCDMMainFrame::CreateMenus()
179 wxMenuBar* menuBar = new wxMenuBar;
181 //Recently opened projects
182 menu_Recent = new wxMenu();
183 wxConfigBase* pConfig = wxConfigBase::Get();
184 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
187 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
188 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
191 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
192 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
195 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
196 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
199 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
200 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
203 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
211 menu_File = new wxMenu();
212 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
213 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
214 menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
215 menu_File->AppendSeparator();
216 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
217 menu_File->AppendSeparator();
218 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
219 menu_File->AppendSeparator();
220 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
222 menuBar->Append(menu_File, wxT("&File"));
225 menu_Edit = new wxMenu();
226 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
227 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
229 menuBar->Append(menu_Edit, wxT("&Edit"));
232 menu_Tools = new wxMenu();
233 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
234 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
235 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
236 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
238 menuBar->Append(menu_Tools, wxT("&Tools"));
241 menu_Help = new wxMenu();
242 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
243 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
244 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
245 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
246 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
247 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
249 menuBar->Append(menu_Help, wxT("&Help"));
254 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
255 statusBar->SetFieldsCount(1);
256 SetStatusBar(statusBar);
260 void wxCDMMainFrame::CreateControls()
263 auiManager.SetManagedWindow(this);
266 tree_Projects = new wxCDMProjectsTreeCtrl(
271 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
273 this->actualTreeItem.Unset();
275 panel_Properties = new wxCDMMainDescriptionPanel(
277 ID_WINDOW_PROPERTIES,
278 wxT("Description Panel"),
284 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
285 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
287 //auiManager.LoadPerspective(pers,true);
288 wxToolTip::Enable(true);
289 wxToolTip::SetDelay(0);
294 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
297 int tam = menu_Recent->GetMenuItemCount();
298 for (int i = 0; i < tam; ++i) {
299 menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
301 //populate recent menu
302 wxConfigBase* pConfig = wxConfigBase::Get();
303 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
306 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
307 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
310 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
311 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
314 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
315 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
318 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
319 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
322 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
331 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
335 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
337 userResponse = dialog->ShowModal();
339 if(userResponse == wxID_FORWARD)
342 if(this->model->GetProject() != NULL)
344 if(!this->model->CloseProject(result))
346 std::cout << "error closing project: " << *result << std::endl;
347 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
352 if(this->panel_Properties != NULL)
354 auiManager.DetachPane(this->panel_Properties);
355 this->panel_Properties->Hide();
357 if(this->panel_ProjectActions != NULL)
359 auiManager.DetachPane(this->panel_ProjectActions);
360 this->panel_ProjectActions->Hide();
366 if(!this->model->CreateProject(
367 crea::wx2std(dialog->GetProjectName()),
368 crea::wx2std(dialog->GetProjectLocation()),
370 crea::wx2std(dialog->GetPackageAuthor()),
371 crea::wx2std(dialog->GetPackageDescription())
374 std::cout << "error opening project: " << *result << std::endl;
375 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
380 //update recently open projects
381 wxConfigBase* pConfig = wxConfigBase::Get();
382 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
384 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
385 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
386 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
387 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
388 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
392 //show project actions panel
393 if(this->panel_ProjectActions != NULL)
395 auiManager.DetachPane(this->panel_Properties);
396 this->panel_ProjectActions->Destroy();
397 this->panel_ProjectActions = NULL;
400 panel_ProjectActions = new wxCDMProjectActionsPanel(
402 this->model->GetProject(),
403 ID_WINDOW_PROJ_ACTIONS,
404 wxT("Project Actions Panel"),
410 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
413 //populate tree control
414 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
415 tree_Projects->Unselect();
416 this->actualTreeItem.Unset();
417 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
418 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
421 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
425 //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
427 std::string path = "";
428 wxConfigBase* pConfig = wxConfigBase::Get();
429 if(event.GetId() == ID_MENU_OPEN_RECENT1)
430 path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
431 else if(event.GetId() == ID_MENU_OPEN_RECENT2)
432 path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
433 else if(event.GetId() == ID_MENU_OPEN_RECENT3)
434 path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
435 else if(event.GetId() == ID_MENU_OPEN_RECENT4)
436 path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
437 else if(event.GetId() == ID_MENU_OPEN_RECENT5)
438 path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
440 std::cout << "Selection to open: " << path << std::endl;
445 if(this->model->GetProject() != NULL)
447 std::cout << "Project not null, closing it" << std::endl;
448 if(!this->model->CloseProject(result))
450 std::cout << "error closing project: " << *result << std::endl;
451 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
456 if(this->panel_Properties != NULL)
458 auiManager.DetachPane(this->panel_Properties);
459 this->panel_Properties->Hide();
461 if(this->panel_ProjectActions != NULL)
463 auiManager.DetachPane(this->panel_ProjectActions);
464 this->panel_ProjectActions->Hide();
468 if (!this->model->OpenProject(path, result))
470 std::cout << "error opening project: " << *result << std::endl;
471 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
476 //update recently open projects
477 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
479 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
480 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
481 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
482 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
483 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
486 std::cout << "building ui" << std::endl;
488 //populate tree control
489 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
490 tree_Projects->Unselect();
491 this->actualTreeItem.Unset();
492 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
495 //change project's actions panel
496 if(this->panel_ProjectActions!= NULL)
498 auiManager.DetachPane(this->panel_ProjectActions);
499 this->panel_ProjectActions->Destroy();
500 this->panel_ProjectActions = NULL;
502 panel_ProjectActions = new wxCDMProjectActionsPanel(
504 this->model->GetProject(),
505 ID_WINDOW_PROJ_ACTIONS,
506 wxT("Project Actions Panel"),
511 panel_ProjectActions->SetMinSize(wxSize(500, 100));
514 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
519 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
523 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
524 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
525 long userResponse = FD->ShowModal();
526 if(userResponse == wxID_OK)
528 std::string path = crea::wx2std (FD->GetPath());
532 std::cout << "Selection to open: " << path << std::endl;
536 if(this->model->GetProject() != NULL)
538 std::cout << "Project not null, closing it" << std::endl;
539 if(!this->model->CloseProject(result))
541 std::cout << "error closing project: " << *result << std::endl;
542 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
547 if(this->panel_Properties != NULL)
549 auiManager.DetachPane(this->panel_Properties);
550 this->panel_Properties->Hide();
552 if(this->panel_ProjectActions != NULL)
554 auiManager.DetachPane(this->panel_ProjectActions);
555 this->panel_ProjectActions->Hide();
559 if (!this->model->OpenProject(path, result))
561 std::cout << "error opening project: " << *result << std::endl;
562 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
567 //update recently open projects
568 wxConfigBase* pConfig = wxConfigBase::Get();
569 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
571 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
572 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
573 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
574 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
575 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
578 std::cout << "building ui" << std::endl;
580 //populate tree control
581 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
582 tree_Projects->Unselect();
583 this->actualTreeItem.Unset();
584 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
587 //change project's actions panel
588 if(this->panel_ProjectActions!= NULL)
590 auiManager.DetachPane(this->panel_ProjectActions);
591 this->panel_ProjectActions->Destroy();
592 this->panel_ProjectActions = NULL;
594 panel_ProjectActions = new wxCDMProjectActionsPanel(
596 this->model->GetProject(),
597 ID_WINDOW_PROJ_ACTIONS,
598 wxT("Project Actions Panel"),
603 panel_ProjectActions->SetMinSize(wxSize(500, 100));
606 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
613 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
615 std::cout << "closing project" << std::endl;
617 if(!this->model->CloseProject(result))
619 std::cout << "error closing project: " << *result << std::endl;
620 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
623 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
624 this->actualTreeItem.Unset();
625 if(this->panel_Properties != NULL)
627 auiManager.DetachPane(this->panel_Properties);
628 this->panel_Properties->Hide();
630 if(this->panel_ProjectActions != NULL)
632 auiManager.DetachPane(this->panel_ProjectActions);
633 this->panel_ProjectActions->Hide();
636 this->panel_Properties = new wxCDMMainDescriptionPanel(
638 ID_WINDOW_PROPERTIES,
639 wxT("Description Panel"),
645 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
650 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
652 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
655 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
657 std::cout << "Closing CreaDevManager..." << std::endl;
659 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
661 std::cout << "error closing project: " << *result << std::endl;
664 if(this->panel_Properties != NULL)
666 auiManager.DetachPane(this->panel_Properties);
667 this->panel_Properties->Destroy();
668 this->panel_Properties = NULL;
671 if(this->tree_Projects != NULL)
673 auiManager.DetachPane(this->tree_Projects);
674 this->tree_Projects->Destroy();
675 this->tree_Projects = NULL;
678 if(this->panel_ProjectActions != NULL)
680 auiManager.DetachPane(this->panel_ProjectActions);
681 this->panel_ProjectActions->Destroy();
682 this->panel_ProjectActions = NULL;
689 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
692 if(!model->RefreshProject(result))
694 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
696 if(this->model->GetProject() != NULL)
698 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
699 this->auiManager.Update();
701 this->tree_Projects->Unselect();
702 this->actualTreeItem.Unset();
703 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
708 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
710 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
711 settingsDialog->SetHelpEnabled(this->help);
713 int res = settingsDialog->ShowModal();
716 this->help = settingsDialog->IsHelpEnabled();
717 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
721 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
723 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
725 if(CDMUtilities::openBBEditor())
727 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
730 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
732 if(CDMUtilities::openCreaToolsTools())
734 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
737 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
739 if(CDMUtilities::openTextEditor())
741 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);
744 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
746 if(CDMUtilities::openTerminal())
748 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);
753 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
755 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0);
757 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
759 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
761 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
763 wxBoxSizer *topsizer;
765 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
767 topsizer = new wxBoxSizer(wxVERTICAL);
769 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
770 html -> SetBorders(0);
772 std::string content = ""
774 "<body bgcolor=\"#3333CC\">"
775 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
777 " <td bgcolor=\"#3333CC\">"
779 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
785 " <td bgcolor=\"#FFFFFF\">"
786 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
788 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
790 " <td width=\"65%\">"
791 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
796 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
806 html -> SetPage(crea::std2wx(content));
807 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
808 html -> GetInternalRepresentation() -> GetHeight());
810 topsizer -> Add(html, 1, wxALL, 10);
813 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
814 #endif // wxUSE_STATLINE
816 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
819 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
821 dlg.SetSizer(topsizer);
822 topsizer -> Fit(&dlg);
826 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
828 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
831 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
834 //get selected element
835 wxTreeItemId elementId = event.GetItem();
836 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
837 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
838 if(elementId.IsOk() && this->actualTreeItem != elementId)
841 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
842 //get element from model
843 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
847 std::cout << "Tree Selection: " << element->GetName() << std::endl;
849 //std::stringstream ss;
850 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
851 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
852 this->actualTreeItem = elementId;
856 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
857 wxPanel* description;
858 if(elementProject != NULL)
860 //create element description
861 description = new wxCDMProjectDescriptionPanel(
864 ID_WINDOW_PROPERTIES,
865 wxT("Description Panel"),
875 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
876 if(elementAppli != NULL)
878 //create element description
879 description = new wxCDMAppliDescriptionPanel(
882 ID_WINDOW_PROPERTIES,
883 wxT("Description Panel"),
893 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
894 if(elementApplication != NULL)
896 //create element description
897 description = new wxCDMApplicationDescriptionPanel(
900 ID_WINDOW_PROPERTIES,
901 wxT("Description Panel"),
910 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
911 if(elementLib != NULL)
913 //create element description
914 description = new wxCDMLibDescriptionPanel(
917 ID_WINDOW_PROPERTIES,
918 wxT("Description Panel"),
927 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
928 if(elementLibrary != NULL)
930 //create element description
931 description = new wxCDMLibraryDescriptionPanel(
934 ID_WINDOW_PROPERTIES,
935 wxT("Description Panel"),
944 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
945 if(elementPackage != NULL)
947 //create element description
948 description = new wxCDMPackageDescriptionPanel(
951 ID_WINDOW_PROPERTIES,
952 wxT("Description Panel"),
961 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
962 if(elementBlackBox != NULL)
964 //create element description
965 description = new wxCDMBlackBoxDescriptionPanel(
968 ID_WINDOW_PROPERTIES,
969 wxT("Description Panel"),
978 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
979 if(elementCMakeLists != NULL)
981 //create element description
982 description = new wxCDMCMakeListsDescriptionPanel(
985 ID_WINDOW_PROPERTIES,
986 wxT("Description Panel"),
995 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
996 if(elementFolder != NULL)
998 //create element description
999 description = new wxCDMFolderDescriptionPanel(
1002 ID_WINDOW_PROPERTIES,
1003 wxT("Description Panel"),
1012 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1013 if(elementFile != NULL)
1015 //create element description
1016 description = new wxCDMFileDescriptionPanel(
1019 ID_WINDOW_PROPERTIES,
1020 wxT("Description Panel"),
1030 //create element description
1031 description = new wxCDMMainDescriptionPanel(
1033 ID_WINDOW_PROPERTIES,
1034 wxT("Description Panel"),
1051 if(this->panel_Properties!= NULL)
1053 this->panel_Properties->Hide();
1054 auiManager.DetachPane(this->panel_Properties);
1055 //this->panel_Properties->Destroy();
1056 //this->panel_Properties = NULL;
1059 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1060 this->panel_Properties = description;
1062 auiManager.Update();
1073 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1075 modelCDMIProjectTreeNode* myItem = NULL;
1076 wxPanel* description = NULL;
1077 switch(event.GetId())
1080 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1081 //select out old one to generate selection event
1082 this->tree_Projects->Unselect();
1083 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1084 this->tree_Projects->Expand(myItem->GetId().GetWxId());
1088 if(event.GetString() == wxT("manage_packages"))
1090 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1091 //this->tree_Projects->Unselect();
1092 this->actualTreeItem.Unset();
1093 description = new wxCDMPackageManagerPanel(
1095 this->model->GetProject(),
1096 ID_WINDOW_PROPERTIES,
1097 wxT("Description Panel"),
1103 else if(event.GetString() == wxT("manage_libraries"))
1105 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1106 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1109 else if(event.GetString() == wxT("manage_applications"))
1111 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1112 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1115 else if(event.GetString() == wxT("blackbox"))
1117 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1118 this->actualTreeItem.Unset();
1119 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1120 description = new wxCDMBlackBoxDescriptionPanel(
1123 ID_WINDOW_PROPERTIES,
1124 wxT("Description Panel"),
1134 if(this->panel_Properties!= NULL)
1136 this->panel_Properties->Hide();
1137 auiManager.DetachPane(this->panel_Properties);
1138 this->panel_Properties->Destroy();
1139 this->panel_Properties = NULL;
1142 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1143 this->panel_Properties = description;
1144 auiManager.Update();
1153 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1155 //std::cout << "element " << event.GetInt() << std::endl;
1156 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1157 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1158 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1159 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1160 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1161 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1162 auiManager.Update();
1165 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1167 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1168 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1169 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1170 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1171 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1172 auiManager.Update();
1175 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1177 this->help = !this->help;
1178 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1181 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1188 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);