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 "wxCDMCodeFileDescriptionPanel.h"
55 #include "wxCDMCMakeListsDescriptionPanel.h"
56 #include "wxCDMFolderDescriptionPanel.h"
57 #include "wxCDMFileDescriptionPanel.h"
58 #include "wxCDMPackageManagerPanel.h"
59 #include "wxCDMProjectMapDialog.h"
61 #include "wxCDMSettingsDialog.h"
63 #include "wxCDMProjectActionsPanel.h"
64 #include "wxCDMNewProjectDialog.h"
68 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
69 EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
70 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
71 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
72 EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
73 EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
74 EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
75 EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
76 EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
77 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
78 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
79 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
80 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
81 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
82 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
83 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
84 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
85 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
86 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
87 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
88 EVT_MENU(ID_MENU_SHOW_PROJECT_MAP, wxCDMMainFrame::OnMenuShowProjectMap)
89 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
90 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
91 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
93 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
94 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
96 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
98 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
99 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
100 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
103 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
106 wxCDMMainFrame::wxCDMMainFrame(
109 const wxString& caption,
115 this->menu_File = NULL;
116 this->menu_Edit = NULL;
117 this->menu_Tools = NULL;
118 this->menu_Help = NULL;
119 this->panel_Properties = NULL;
120 this->panel_ProjectActions = NULL;
121 this->tree_Projects = NULL;
122 Create(parent, id, caption, pos, size, style);
125 wxCDMMainFrame::~wxCDMMainFrame()
127 wxConfigBase* pConfig = wxConfigBase::Get();
128 pConfig->Write(wxT("HELP"), this->help);
133 bool wxCDMMainFrame::Create(
136 const wxString& caption,
142 wxFrame::Create(parent, id, caption, pos, size, style);
145 wxConfigBase* pConfig = wxConfigBase::Get();
146 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
148 this->model = new modelCDMMain();
152 this->SetIcon(wxIcon(CIcon64));
156 modelCDMMain* wxCDMMainFrame::GetModel() const
161 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
163 return this->panel_Properties;
166 bool wxCDMMainFrame::isHelp() const
171 void wxCDMMainFrame::RefreshProject()
174 std::cout << "refreshing project" << std::endl;
175 this->model->RefreshProject(result);
176 std::cout << "rebuilding project tree" << std::endl;
177 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
178 this->tree_Projects->Unselect();
179 this->actualTreeItem.Unset();
182 void wxCDMMainFrame::CreateMenus()
184 wxMenuBar* menuBar = new wxMenuBar;
186 //Recently opened projects
187 menu_Recent = new wxMenu();
188 wxConfigBase* pConfig = wxConfigBase::Get();
189 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
192 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
193 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
196 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
197 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
200 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
201 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
204 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
205 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
208 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
216 menu_File = new wxMenu();
217 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
218 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
219 menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
220 menu_File->AppendSeparator();
221 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
222 menu_File->AppendSeparator();
223 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
224 menu_File->AppendSeparator();
225 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
227 menuBar->Append(menu_File, wxT("&File"));
230 menu_Edit = new wxMenu();
231 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
232 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
234 menuBar->Append(menu_Edit, wxT("&Edit"));
237 menu_Tools = new wxMenu();
238 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("Open BBEditor (BBTK &Graphical Editor)"));
239 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("Open &CreaTools"));
240 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("Open Code &Editor"));
241 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("Open Command &Line"));
243 menuBar->Append(menu_Tools, wxT("&Tools"));
246 menu_Help = new wxMenu();
247 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
248 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
249 menu_Help->Append(ID_MENU_SHOW_PROJECT_MAP, wxT("&Show Project Map"));
250 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
251 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
252 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
253 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
255 menuBar->Append(menu_Help, wxT("&Help"));
260 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
261 statusBar->SetFieldsCount(1);
262 SetStatusBar(statusBar);
266 void wxCDMMainFrame::CreateControls()
269 auiManager.SetManagedWindow(this);
272 tree_Projects = new wxCDMProjectsTreeCtrl(
277 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
279 this->actualTreeItem.Unset();
281 panel_Properties = new wxCDMMainDescriptionPanel(
283 ID_WINDOW_PROPERTIES,
284 wxT("Description Panel"),
290 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
291 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
293 //auiManager.LoadPerspective(pers,true);
294 wxToolTip::Enable(true);
295 wxToolTip::SetDelay(0);
300 void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
303 int tam = menu_Recent->GetMenuItemCount();
304 for (int i = 0; i < tam; ++i) {
305 menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
307 //populate recent menu
308 wxConfigBase* pConfig = wxConfigBase::Get();
309 std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
312 menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
313 rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
316 menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
317 rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
320 menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
321 rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
324 menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
325 rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
328 menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
337 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
341 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
343 userResponse = dialog->ShowModal();
345 if(userResponse == wxID_FORWARD)
348 if(this->model->GetProject() != NULL)
350 if(!this->model->CloseProject(result))
352 std::cout << "error closing project: " << *result << std::endl;
353 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
358 if(this->panel_Properties != NULL)
360 auiManager.DetachPane(this->panel_Properties);
361 this->panel_Properties->Hide();
363 if(this->panel_ProjectActions != NULL)
365 auiManager.DetachPane(this->panel_ProjectActions);
366 this->panel_ProjectActions->Hide();
372 if(!this->model->CreateProject(
373 crea::wx2std(dialog->GetProjectName()),
374 crea::wx2std(dialog->GetProjectLocation()),
376 crea::wx2std(dialog->GetPackageAuthor()),
377 crea::wx2std(dialog->GetPackageDescription())
380 std::cout << "error opening project: " << *result << std::endl;
381 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
386 //update recently open projects
387 wxConfigBase* pConfig = wxConfigBase::Get();
388 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
390 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
391 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
392 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
393 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
394 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
398 //show project actions panel
399 if(this->panel_ProjectActions != NULL)
401 auiManager.DetachPane(this->panel_Properties);
402 this->panel_ProjectActions->Destroy();
403 this->panel_ProjectActions = NULL;
406 panel_ProjectActions = new wxCDMProjectActionsPanel(
408 this->model->GetProject(),
409 ID_WINDOW_PROJ_ACTIONS,
410 wxT("Project Actions Panel"),
416 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
419 //populate tree control
420 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
421 tree_Projects->Unselect();
422 this->actualTreeItem.Unset();
423 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
424 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
427 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
431 //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
433 std::string path = "";
434 wxConfigBase* pConfig = wxConfigBase::Get();
435 if(event.GetId() == ID_MENU_OPEN_RECENT1)
436 path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
437 else if(event.GetId() == ID_MENU_OPEN_RECENT2)
438 path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
439 else if(event.GetId() == ID_MENU_OPEN_RECENT3)
440 path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
441 else if(event.GetId() == ID_MENU_OPEN_RECENT4)
442 path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
443 else if(event.GetId() == ID_MENU_OPEN_RECENT5)
444 path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
446 std::cout << "Selection to open: " << path << std::endl;
451 if(this->model->GetProject() != NULL)
453 std::cout << "Project not null, closing it" << std::endl;
454 if(!this->model->CloseProject(result))
456 std::cout << "error closing project: " << *result << std::endl;
457 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
462 if(this->panel_Properties != NULL)
464 auiManager.DetachPane(this->panel_Properties);
465 this->panel_Properties->Hide();
467 if(this->panel_ProjectActions != NULL)
469 auiManager.DetachPane(this->panel_ProjectActions);
470 this->panel_ProjectActions->Hide();
474 if (!this->model->OpenProject(path, result))
476 std::cout << "error opening project: " << *result << std::endl;
477 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
482 //update recently open projects
483 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
485 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
486 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
487 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
488 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
489 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
492 std::cout << "building ui" << std::endl;
494 //populate tree control
495 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
496 tree_Projects->Unselect();
497 this->actualTreeItem.Unset();
498 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
501 //change project's actions panel
502 if(this->panel_ProjectActions!= NULL)
504 auiManager.DetachPane(this->panel_ProjectActions);
505 this->panel_ProjectActions->Destroy();
506 this->panel_ProjectActions = NULL;
508 panel_ProjectActions = new wxCDMProjectActionsPanel(
510 this->model->GetProject(),
511 ID_WINDOW_PROJ_ACTIONS,
512 wxT("Project Actions Panel"),
517 panel_ProjectActions->SetMinSize(wxSize(500, 100));
520 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
525 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
529 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
530 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
531 long userResponse = FD->ShowModal();
532 if(userResponse == wxID_OK)
534 std::string path = crea::wx2std (FD->GetPath());
538 std::cout << "Selection to open: " << path << std::endl;
542 if(this->model->GetProject() != NULL)
544 std::cout << "Project not null, closing it" << std::endl;
545 if(!this->model->CloseProject(result))
547 std::cout << "error closing project: " << *result << std::endl;
548 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
553 if(this->panel_Properties != NULL)
555 auiManager.DetachPane(this->panel_Properties);
556 this->panel_Properties->Hide();
558 if(this->panel_ProjectActions != NULL)
560 auiManager.DetachPane(this->panel_ProjectActions);
561 this->panel_ProjectActions->Hide();
565 if (!this->model->OpenProject(path, result))
567 std::cout << "error opening project: " << *result << std::endl;
568 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
573 //update recently open projects
574 wxConfigBase* pConfig = wxConfigBase::Get();
575 if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
577 pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
578 pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
579 pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
580 pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
581 pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
584 std::cout << "building ui" << std::endl;
586 //populate tree control
587 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
588 tree_Projects->Unselect();
589 this->actualTreeItem.Unset();
590 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
593 //change project's actions panel
594 if(this->panel_ProjectActions!= NULL)
596 auiManager.DetachPane(this->panel_ProjectActions);
597 this->panel_ProjectActions->Destroy();
598 this->panel_ProjectActions = NULL;
600 panel_ProjectActions = new wxCDMProjectActionsPanel(
602 this->model->GetProject(),
603 ID_WINDOW_PROJ_ACTIONS,
604 wxT("Project Actions Panel"),
609 panel_ProjectActions->SetMinSize(wxSize(500, 100));
612 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
619 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
621 std::cout << "closing project" << std::endl;
623 if(!this->model->CloseProject(result))
625 std::cout << "error closing project: " << *result << std::endl;
626 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
629 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
630 this->actualTreeItem.Unset();
631 if(this->panel_Properties != NULL)
633 auiManager.DetachPane(this->panel_Properties);
634 this->panel_Properties->Hide();
636 if(this->panel_ProjectActions != NULL)
638 auiManager.DetachPane(this->panel_ProjectActions);
639 this->panel_ProjectActions->Hide();
642 this->panel_Properties = new wxCDMMainDescriptionPanel(
644 ID_WINDOW_PROPERTIES,
645 wxT("Description Panel"),
651 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
656 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
658 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
661 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
663 std::cout << "Closing CreaDevManager..." << std::endl;
665 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
667 std::cout << "error closing project: " << *result << std::endl;
670 if(this->panel_Properties != NULL)
672 auiManager.DetachPane(this->panel_Properties);
673 this->panel_Properties->Destroy();
674 this->panel_Properties = NULL;
677 if(this->tree_Projects != NULL)
679 auiManager.DetachPane(this->tree_Projects);
680 this->tree_Projects->Destroy();
681 this->tree_Projects = NULL;
684 if(this->panel_ProjectActions != NULL)
686 auiManager.DetachPane(this->panel_ProjectActions);
687 this->panel_ProjectActions->Destroy();
688 this->panel_ProjectActions = NULL;
695 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
698 if(!model->RefreshProject(result))
700 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
702 if(this->model->GetProject() != NULL)
704 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
705 this->auiManager.Update();
707 this->tree_Projects->Unselect();
708 this->actualTreeItem.Unset();
709 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
714 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
716 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
717 settingsDialog->SetHelpEnabled(this->help);
719 int res = settingsDialog->ShowModal();
722 this->help = settingsDialog->IsHelpEnabled();
723 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
727 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
729 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
731 if(CDMUtilities::openBBEditor())
733 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
736 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
738 if(CDMUtilities::openCreaToolsTools())
740 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
743 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
745 if(CDMUtilities::openTextEditor())
747 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);
750 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
752 if(CDMUtilities::openTerminal())
754 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);
759 void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event)
761 wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this);
767 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
769 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0);
771 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
773 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
775 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
777 wxBoxSizer *topsizer;
779 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
781 topsizer = new wxBoxSizer(wxVERTICAL);
783 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
784 html -> SetBorders(0);
786 std::string content = ""
788 "<body bgcolor=\"#3333CC\">"
789 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
791 " <td bgcolor=\"#3333CC\">"
793 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
799 " <td bgcolor=\"#FFFFFF\">"
800 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
802 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
804 " <td width=\"65%\">"
805 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
810 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
820 html -> SetPage(crea::std2wx(content));
821 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
822 html -> GetInternalRepresentation() -> GetHeight());
824 topsizer -> Add(html, 1, wxALL, 10);
827 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
828 #endif // wxUSE_STATLINE
830 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
833 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
835 dlg.SetSizer(topsizer);
836 topsizer -> Fit(&dlg);
840 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
842 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
845 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
848 //get selected element
849 wxTreeItemId elementId = event.GetItem();
850 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
851 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
852 if(elementId.IsOk() && this->actualTreeItem != elementId)
855 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
856 //get element from model
857 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
861 std::cout << "Tree Selection: " << element->GetName() << std::endl;
863 //std::stringstream ss;
864 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
865 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
866 this->actualTreeItem = elementId;
870 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
871 wxPanel* description;
872 if(elementProject != NULL)
874 //create element description
875 description = new wxCDMProjectDescriptionPanel(
878 ID_WINDOW_PROPERTIES,
879 wxT("Description Panel"),
889 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
890 if(elementAppli != NULL)
892 //create element description
893 description = new wxCDMAppliDescriptionPanel(
896 ID_WINDOW_PROPERTIES,
897 wxT("Description Panel"),
907 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
908 if(elementApplication != NULL)
910 //create element description
911 description = new wxCDMApplicationDescriptionPanel(
914 ID_WINDOW_PROPERTIES,
915 wxT("Description Panel"),
924 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
925 if(elementLib != NULL)
927 //create element description
928 description = new wxCDMLibDescriptionPanel(
931 ID_WINDOW_PROPERTIES,
932 wxT("Description Panel"),
941 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
942 if(elementLibrary != NULL)
944 //create element description
945 description = new wxCDMLibraryDescriptionPanel(
948 ID_WINDOW_PROPERTIES,
949 wxT("Description Panel"),
958 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
959 if(elementPackage != NULL)
961 //create element description
962 description = new wxCDMPackageDescriptionPanel(
965 ID_WINDOW_PROPERTIES,
966 wxT("Description Panel"),
975 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
976 if(elementBlackBox != NULL)
978 //create element description
979 description = new wxCDMBlackBoxDescriptionPanel(
982 ID_WINDOW_PROPERTIES,
983 wxT("Description Panel"),
992 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
993 if(elementCMakeLists != NULL)
995 //create element description
996 description = new wxCDMCMakeListsDescriptionPanel(
999 ID_WINDOW_PROPERTIES,
1000 wxT("Description Panel"),
1009 modelCDMCodeFile* elementCodeFile = dynamic_cast<modelCDMCodeFile*>(element);
1010 if(elementCodeFile != NULL)
1012 //create element description
1013 description = new wxCDMCodeFileDescriptionPanel(
1016 ID_WINDOW_PROPERTIES,
1017 wxT("Description Panel"),
1026 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
1027 if(elementFolder != NULL)
1029 //create element description
1030 description = new wxCDMFolderDescriptionPanel(
1033 ID_WINDOW_PROPERTIES,
1034 wxT("Description Panel"),
1043 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
1044 if(elementFile != NULL)
1046 //create element description
1047 description = new wxCDMFileDescriptionPanel(
1050 ID_WINDOW_PROPERTIES,
1051 wxT("Description Panel"),
1061 //create element description
1062 description = new wxCDMMainDescriptionPanel(
1064 ID_WINDOW_PROPERTIES,
1065 wxT("Description Panel"),
1083 if(this->panel_Properties!= NULL)
1085 this->panel_Properties->Hide();
1086 auiManager.DetachPane(this->panel_Properties);
1087 //this->panel_Properties->Destroy();
1088 //this->panel_Properties = NULL;
1091 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1092 this->panel_Properties = description;
1094 auiManager.Update();
1105 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
1107 modelCDMIProjectTreeNode* myItem = NULL;
1108 wxPanel* description = NULL;
1109 switch(event.GetId())
1112 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
1113 //select out old one to generate selection event
1114 this->tree_Projects->Unselect();
1115 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
1116 this->tree_Projects->Expand(myItem->GetId().GetWxId());
1120 if(event.GetString() == wxT("manage_packages"))
1122 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
1123 //this->tree_Projects->Unselect();
1124 this->actualTreeItem.Unset();
1125 description = new wxCDMPackageManagerPanel(
1127 this->model->GetProject(),
1128 ID_WINDOW_PROPERTIES,
1129 wxT("Description Panel"),
1135 else if(event.GetString() == wxT("manage_libraries"))
1137 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
1138 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
1141 else if(event.GetString() == wxT("manage_applications"))
1143 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1144 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
1147 else if(event.GetString() == wxT("blackbox"))
1149 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
1150 this->actualTreeItem.Unset();
1151 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
1152 description = new wxCDMBlackBoxDescriptionPanel(
1155 ID_WINDOW_PROPERTIES,
1156 wxT("Description Panel"),
1166 if(this->panel_Properties!= NULL)
1168 this->panel_Properties->Hide();
1169 auiManager.DetachPane(this->panel_Properties);
1170 this->panel_Properties->Destroy();
1171 this->panel_Properties = NULL;
1174 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
1175 this->panel_Properties = description;
1176 auiManager.Update();
1185 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
1187 //std::cout << "element " << event.GetInt() << std::endl;
1188 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1189 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
1190 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
1191 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
1192 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
1193 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1194 auiManager.Update();
1197 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
1199 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
1200 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
1201 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
1202 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
1203 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
1204 auiManager.Update();
1207 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
1209 this->help = !this->help;
1210 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
1213 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
1220 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);