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(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
67 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
68 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
69 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
70 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
71 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
72 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
73 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
74 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
75 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
76 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
77 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
78 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
79 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
80 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
81 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
83 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
84 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
86 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
88 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
89 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
90 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
93 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
96 wxCDMMainFrame::wxCDMMainFrame(
99 const wxString& caption,
105 this->menu_File = NULL;
106 this->menu_Edit = NULL;
107 this->menu_Tools = NULL;
108 this->menu_Help = NULL;
109 this->panel_Properties = NULL;
110 this->panel_ProjectActions = NULL;
111 this->tree_Projects = NULL;
112 Create(parent, id, caption, pos, size, style);
115 wxCDMMainFrame::~wxCDMMainFrame()
120 bool wxCDMMainFrame::Create(
123 const wxString& caption,
129 wxFrame::Create(parent, id, caption, pos, size, style);
132 wxConfigBase* pConfig = wxConfigBase::Get();
133 this->help = pConfig->Read(wxT("HELP"), this->help);
135 this->model = new modelCDMMain();
142 modelCDMMain* wxCDMMainFrame::GetModel() const
147 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
149 return this->panel_Properties;
152 bool wxCDMMainFrame::isHelp() const
157 void wxCDMMainFrame::RefreshProject()
160 std::cout << "refreshing project" << std::endl;
161 this->model->RefreshProject(result);
162 std::cout << "rebuilding project tree" << std::endl;
163 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
164 this->tree_Projects->Unselect();
165 this->actualTreeItem.Unset();
168 void wxCDMMainFrame::CreateMenus()
170 wxMenuBar* menuBar = new wxMenuBar;
173 menu_File = new wxMenu();
174 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
175 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
176 menu_File->AppendSeparator();
177 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
178 menu_File->AppendSeparator();
179 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
180 menu_File->AppendSeparator();
181 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
183 menuBar->Append(menu_File, wxT("&File"));
186 menu_Edit = new wxMenu();
187 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
188 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
190 menuBar->Append(menu_Edit, wxT("&Edit"));
193 menu_Tools = new wxMenu();
194 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
195 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
196 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
197 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
199 menuBar->Append(menu_Tools, wxT("&Tools"));
202 menu_Help = new wxMenu();
203 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
204 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
205 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
206 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
207 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
208 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
210 menuBar->Append(menu_Help, wxT("&Help"));
215 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
216 statusBar->SetFieldsCount(1);
217 SetStatusBar(statusBar);
221 void wxCDMMainFrame::CreateControls()
224 auiManager.SetManagedWindow(this);
227 tree_Projects = new wxCDMProjectsTreeCtrl(
232 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
234 this->actualTreeItem.Unset();
236 panel_Properties = new wxCDMMainDescriptionPanel(
238 ID_WINDOW_PROPERTIES,
239 wxT("Description Panel"),
245 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
246 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
248 //auiManager.LoadPerspective(pers,true);
249 wxToolTip::Enable(true);
250 wxToolTip::SetDelay(0);
255 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
259 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
261 userResponse = dialog->ShowModal();
263 if(userResponse == wxID_FORWARD)
266 if(this->model->GetProject() != NULL)
268 if(!this->model->CloseProject(result))
270 std::cout << "error closing project: " << *result << std::endl;
271 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
275 if(this->panel_Properties != NULL)
277 auiManager.DetachPane(this->panel_Properties);
278 this->panel_Properties->Hide();
280 if(this->panel_ProjectActions != NULL)
282 auiManager.DetachPane(this->panel_ProjectActions);
283 this->panel_ProjectActions->Hide();
289 if(!this->model->CreateProject(
290 crea::wx2std(dialog->GetProjectName()),
291 crea::wx2std(dialog->GetProjectLocation()),
293 crea::wx2std(dialog->GetPackageAuthor()),
294 crea::wx2std(dialog->GetPackageDescription())
297 std::cout << "error opening project: " << *result << std::endl;
298 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
303 //show project actions panel
304 if(this->panel_ProjectActions != NULL)
306 auiManager.DetachPane(this->panel_Properties);
307 this->panel_ProjectActions->Destroy();
308 this->panel_ProjectActions = NULL;
311 panel_ProjectActions = new wxCDMProjectActionsPanel(
313 this->model->GetProject(),
314 ID_WINDOW_PROJ_ACTIONS,
315 wxT("Project Actions Panel"),
321 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
324 //populate tree control
325 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
326 tree_Projects->Unselect();
327 this->actualTreeItem.Unset();
328 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
329 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
332 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
336 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
337 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
338 long userResponse = FD->ShowModal();
339 if(userResponse == wxID_OK)
341 std::string path = crea::wx2std (FD->GetPath());
345 std::cout << "Selection to open: " << path << std::endl;
349 if(this->model->GetProject() != NULL)
351 std::cout << "Project not null, closing it" << std::endl;
352 if(!this->model->CloseProject(result))
354 std::cout << "error closing project: " << *result << std::endl;
355 wxMessageBox(crea::std2wx(result->c_str()),_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();
371 if (!this->model->OpenProject(path, result))
373 std::cout << "error opening project: " << *result << std::endl;
374 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
379 std::cout << "building ui" << std::endl;
381 //populate tree control
382 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
383 tree_Projects->Unselect();
384 this->actualTreeItem.Unset();
385 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
388 //change project's actions panel
389 if(this->panel_ProjectActions!= NULL)
391 auiManager.DetachPane(this->panel_ProjectActions);
392 this->panel_ProjectActions->Destroy();
393 this->panel_ProjectActions = NULL;
395 panel_ProjectActions = new wxCDMProjectActionsPanel(
397 this->model->GetProject(),
398 ID_WINDOW_PROJ_ACTIONS,
399 wxT("Project Actions Panel"),
404 panel_ProjectActions->SetMinSize(wxSize(500, 100));
407 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
414 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
416 std::cout << "closing project" << std::endl;
418 if(!this->model->CloseProject(result))
420 std::cout << "error closing project: " << *result << std::endl;
421 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
424 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
425 this->actualTreeItem.Unset();
426 if(this->panel_Properties != NULL)
428 auiManager.DetachPane(this->panel_Properties);
429 this->panel_Properties->Hide();
431 if(this->panel_ProjectActions != NULL)
433 auiManager.DetachPane(this->panel_ProjectActions);
434 this->panel_ProjectActions->Hide();
437 this->panel_Properties = new wxCDMMainDescriptionPanel(
439 ID_WINDOW_PROPERTIES,
440 wxT("Description Panel"),
446 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
451 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
453 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
456 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
458 std::cout << "Closing CreaDevManager..." << std::endl;
460 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
462 std::cout << "error closing project: " << *result << std::endl;
465 if(this->panel_Properties != NULL)
467 auiManager.DetachPane(this->panel_Properties);
468 this->panel_Properties->Destroy();
469 this->panel_Properties = NULL;
472 if(this->tree_Projects != NULL)
474 auiManager.DetachPane(this->tree_Projects);
475 this->tree_Projects->Destroy();
476 this->tree_Projects = NULL;
479 if(this->panel_ProjectActions != NULL)
481 auiManager.DetachPane(this->panel_ProjectActions);
482 this->panel_ProjectActions->Destroy();
483 this->panel_ProjectActions = NULL;
490 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
493 if(!model->RefreshProject(result))
495 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
497 if(this->model->GetProject() != NULL)
499 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
500 this->auiManager.Update();
502 this->tree_Projects->Unselect();
503 this->actualTreeItem.Unset();
504 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
509 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
511 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
512 settingsDialog->SetHelpEnabled(this->help);
514 int res = settingsDialog->ShowModal();
517 this->help = settingsDialog->IsHelpEnabled();
518 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
522 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
524 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
526 if(CDMUtilities::openBBEditor())
528 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
531 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
533 if(CDMUtilities::openCreaToolsTools())
535 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
538 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
540 if(CDMUtilities::openTextEditor())
542 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);
545 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
547 if(CDMUtilities::openTerminal())
549 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);
554 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
556 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0);
558 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
560 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
562 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
564 wxBoxSizer *topsizer;
566 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
568 topsizer = new wxBoxSizer(wxVERTICAL);
570 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
571 html -> SetBorders(0);
573 std::string content = ""
575 "<body bgcolor=\"#3333CC\">"
576 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
578 " <td bgcolor=\"#3333CC\">"
580 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
586 " <td bgcolor=\"#FFFFFF\">"
587 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
589 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
591 " <td width=\"65%\">"
592 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
597 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
607 html -> SetPage(crea::std2wx(content));
608 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
609 html -> GetInternalRepresentation() -> GetHeight());
611 topsizer -> Add(html, 1, wxALL, 10);
614 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
615 #endif // wxUSE_STATLINE
617 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
620 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
622 dlg.SetSizer(topsizer);
623 topsizer -> Fit(&dlg);
627 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
629 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
632 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
635 //get selected element
636 wxTreeItemId elementId = event.GetItem();
637 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
638 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
639 if(elementId.IsOk() && this->actualTreeItem != elementId)
642 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
643 //get element from model
644 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
648 std::cout << "Tree Selection: " << element->GetName() << std::endl;
650 //std::stringstream ss;
651 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
652 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
653 this->actualTreeItem = elementId;
657 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
658 wxPanel* description;
659 if(elementProject != NULL)
661 //create element description
662 description = new wxCDMProjectDescriptionPanel(
665 ID_WINDOW_PROPERTIES,
666 wxT("Description Panel"),
676 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
677 if(elementAppli != NULL)
679 //create element description
680 description = new wxCDMAppliDescriptionPanel(
683 ID_WINDOW_PROPERTIES,
684 wxT("Description Panel"),
694 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
695 if(elementApplication != NULL)
697 //create element description
698 description = new wxCDMApplicationDescriptionPanel(
701 ID_WINDOW_PROPERTIES,
702 wxT("Description Panel"),
711 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
712 if(elementLib != NULL)
714 //create element description
715 description = new wxCDMLibDescriptionPanel(
718 ID_WINDOW_PROPERTIES,
719 wxT("Description Panel"),
728 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
729 if(elementLibrary != NULL)
731 //create element description
732 description = new wxCDMLibraryDescriptionPanel(
735 ID_WINDOW_PROPERTIES,
736 wxT("Description Panel"),
745 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
746 if(elementPackage != NULL)
748 //create element description
749 description = new wxCDMPackageDescriptionPanel(
752 ID_WINDOW_PROPERTIES,
753 wxT("Description Panel"),
762 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
763 if(elementBlackBox != NULL)
765 //create element description
766 description = new wxCDMBlackBoxDescriptionPanel(
769 ID_WINDOW_PROPERTIES,
770 wxT("Description Panel"),
779 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
780 if(elementCMakeLists != NULL)
782 //create element description
783 description = new wxCDMCMakeListsDescriptionPanel(
786 ID_WINDOW_PROPERTIES,
787 wxT("Description Panel"),
796 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
797 if(elementFolder != NULL)
799 //create element description
800 description = new wxCDMFolderDescriptionPanel(
803 ID_WINDOW_PROPERTIES,
804 wxT("Description Panel"),
813 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
814 if(elementFile != NULL)
816 //create element description
817 description = new wxCDMFileDescriptionPanel(
820 ID_WINDOW_PROPERTIES,
821 wxT("Description Panel"),
831 //create element description
832 description = new wxCDMMainDescriptionPanel(
834 ID_WINDOW_PROPERTIES,
835 wxT("Description Panel"),
852 if(this->panel_Properties!= NULL)
854 this->panel_Properties->Hide();
855 auiManager.DetachPane(this->panel_Properties);
856 //this->panel_Properties->Destroy();
857 //this->panel_Properties = NULL;
860 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
861 this->panel_Properties = description;
874 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
876 modelCDMIProjectTreeNode* myItem = NULL;
877 wxPanel* description = NULL;
878 switch(event.GetId())
881 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
882 //select out old one to generate selection event
883 this->tree_Projects->Unselect();
884 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
885 this->tree_Projects->Expand(myItem->GetId().GetWxId());
889 if(event.GetString() == wxT("manage_packages"))
891 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
892 //this->tree_Projects->Unselect();
893 this->actualTreeItem.Unset();
894 description = new wxCDMPackageManagerPanel(
896 this->model->GetProject(),
897 ID_WINDOW_PROPERTIES,
898 wxT("Description Panel"),
904 else if(event.GetString() == wxT("manage_libraries"))
906 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
907 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
910 else if(event.GetString() == wxT("manage_applications"))
912 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
913 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
916 else if(event.GetString() == wxT("blackbox"))
918 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
919 this->actualTreeItem.Unset();
920 description = new wxCDMBlackBoxDescriptionPanel(
923 ID_WINDOW_PROPERTIES,
924 wxT("Description Panel"),
933 if(this->panel_Properties!= NULL)
935 this->panel_Properties->Hide();
936 auiManager.DetachPane(this->panel_Properties);
937 this->panel_Properties->Destroy();
938 this->panel_Properties = NULL;
941 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
942 this->panel_Properties = description;
952 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
954 //std::cout << "element " << event.GetInt() << std::endl;
955 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
956 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
957 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
958 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
959 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
960 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
964 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
966 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
967 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
968 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
969 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
970 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
974 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
976 this->help = !this->help;
977 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
980 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
987 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);