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()
117 wxConfigBase* pConfig = wxConfigBase::Get();
118 pConfig->Write(wxT("HELP"), this->help);
123 bool wxCDMMainFrame::Create(
126 const wxString& caption,
132 wxFrame::Create(parent, id, caption, pos, size, style);
135 wxConfigBase* pConfig = wxConfigBase::Get();
136 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
138 this->model = new modelCDMMain();
145 modelCDMMain* wxCDMMainFrame::GetModel() const
150 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
152 return this->panel_Properties;
155 bool wxCDMMainFrame::isHelp() const
160 void wxCDMMainFrame::RefreshProject()
163 std::cout << "refreshing project" << std::endl;
164 this->model->RefreshProject(result);
165 std::cout << "rebuilding project tree" << std::endl;
166 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
167 this->tree_Projects->Unselect();
168 this->actualTreeItem.Unset();
171 void wxCDMMainFrame::CreateMenus()
173 wxMenuBar* menuBar = new wxMenuBar;
176 menu_File = new wxMenu();
177 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
178 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
179 menu_File->AppendSeparator();
180 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
181 menu_File->AppendSeparator();
182 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
183 menu_File->AppendSeparator();
184 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
186 menuBar->Append(menu_File, wxT("&File"));
189 menu_Edit = new wxMenu();
190 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
191 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
193 menuBar->Append(menu_Edit, wxT("&Edit"));
196 menu_Tools = new wxMenu();
197 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
198 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
199 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
200 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
202 menuBar->Append(menu_Tools, wxT("&Tools"));
205 menu_Help = new wxMenu();
206 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
207 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
208 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
209 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
210 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
211 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
213 menuBar->Append(menu_Help, wxT("&Help"));
218 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
219 statusBar->SetFieldsCount(1);
220 SetStatusBar(statusBar);
224 void wxCDMMainFrame::CreateControls()
227 auiManager.SetManagedWindow(this);
230 tree_Projects = new wxCDMProjectsTreeCtrl(
235 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
237 this->actualTreeItem.Unset();
239 panel_Properties = new wxCDMMainDescriptionPanel(
241 ID_WINDOW_PROPERTIES,
242 wxT("Description Panel"),
248 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
249 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
251 //auiManager.LoadPerspective(pers,true);
252 wxToolTip::Enable(true);
253 wxToolTip::SetDelay(0);
258 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
262 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
264 userResponse = dialog->ShowModal();
266 if(userResponse == wxID_FORWARD)
269 if(this->model->GetProject() != NULL)
271 if(!this->model->CloseProject(result))
273 std::cout << "error closing project: " << *result << std::endl;
274 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
278 if(this->panel_Properties != NULL)
280 auiManager.DetachPane(this->panel_Properties);
281 this->panel_Properties->Hide();
283 if(this->panel_ProjectActions != NULL)
285 auiManager.DetachPane(this->panel_ProjectActions);
286 this->panel_ProjectActions->Hide();
292 if(!this->model->CreateProject(
293 crea::wx2std(dialog->GetProjectName()),
294 crea::wx2std(dialog->GetProjectLocation()),
296 crea::wx2std(dialog->GetPackageAuthor()),
297 crea::wx2std(dialog->GetPackageDescription())
300 std::cout << "error opening project: " << *result << std::endl;
301 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
306 //show project actions panel
307 if(this->panel_ProjectActions != NULL)
309 auiManager.DetachPane(this->panel_Properties);
310 this->panel_ProjectActions->Destroy();
311 this->panel_ProjectActions = NULL;
314 panel_ProjectActions = new wxCDMProjectActionsPanel(
316 this->model->GetProject(),
317 ID_WINDOW_PROJ_ACTIONS,
318 wxT("Project Actions Panel"),
324 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
327 //populate tree control
328 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
329 tree_Projects->Unselect();
330 this->actualTreeItem.Unset();
331 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
332 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
335 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
339 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
340 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
341 long userResponse = FD->ShowModal();
342 if(userResponse == wxID_OK)
344 std::string path = crea::wx2std (FD->GetPath());
348 std::cout << "Selection to open: " << path << std::endl;
352 if(this->model->GetProject() != NULL)
354 std::cout << "Project not null, closing it" << std::endl;
355 if(!this->model->CloseProject(result))
357 std::cout << "error closing project: " << *result << std::endl;
358 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
362 if(this->panel_Properties != NULL)
364 auiManager.DetachPane(this->panel_Properties);
365 this->panel_Properties->Hide();
367 if(this->panel_ProjectActions != NULL)
369 auiManager.DetachPane(this->panel_ProjectActions);
370 this->panel_ProjectActions->Hide();
374 if (!this->model->OpenProject(path, result))
376 std::cout << "error opening project: " << *result << std::endl;
377 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
382 std::cout << "building ui" << std::endl;
384 //populate tree control
385 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
386 tree_Projects->Unselect();
387 this->actualTreeItem.Unset();
388 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
391 //change project's actions panel
392 if(this->panel_ProjectActions!= NULL)
394 auiManager.DetachPane(this->panel_ProjectActions);
395 this->panel_ProjectActions->Destroy();
396 this->panel_ProjectActions = NULL;
398 panel_ProjectActions = new wxCDMProjectActionsPanel(
400 this->model->GetProject(),
401 ID_WINDOW_PROJ_ACTIONS,
402 wxT("Project Actions Panel"),
407 panel_ProjectActions->SetMinSize(wxSize(500, 100));
410 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
417 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
419 std::cout << "closing project" << std::endl;
421 if(!this->model->CloseProject(result))
423 std::cout << "error closing project: " << *result << std::endl;
424 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
427 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
428 this->actualTreeItem.Unset();
429 if(this->panel_Properties != NULL)
431 auiManager.DetachPane(this->panel_Properties);
432 this->panel_Properties->Hide();
434 if(this->panel_ProjectActions != NULL)
436 auiManager.DetachPane(this->panel_ProjectActions);
437 this->panel_ProjectActions->Hide();
440 this->panel_Properties = new wxCDMMainDescriptionPanel(
442 ID_WINDOW_PROPERTIES,
443 wxT("Description Panel"),
449 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
454 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
456 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
459 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
461 std::cout << "Closing CreaDevManager..." << std::endl;
463 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
465 std::cout << "error closing project: " << *result << std::endl;
468 if(this->panel_Properties != NULL)
470 auiManager.DetachPane(this->panel_Properties);
471 this->panel_Properties->Destroy();
472 this->panel_Properties = NULL;
475 if(this->tree_Projects != NULL)
477 auiManager.DetachPane(this->tree_Projects);
478 this->tree_Projects->Destroy();
479 this->tree_Projects = NULL;
482 if(this->panel_ProjectActions != NULL)
484 auiManager.DetachPane(this->panel_ProjectActions);
485 this->panel_ProjectActions->Destroy();
486 this->panel_ProjectActions = NULL;
493 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
496 if(!model->RefreshProject(result))
498 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
500 if(this->model->GetProject() != NULL)
502 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
503 this->auiManager.Update();
505 this->tree_Projects->Unselect();
506 this->actualTreeItem.Unset();
507 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
512 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
514 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
515 settingsDialog->SetHelpEnabled(this->help);
517 int res = settingsDialog->ShowModal();
520 this->help = settingsDialog->IsHelpEnabled();
521 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
525 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
527 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
529 if(CDMUtilities::openBBEditor())
531 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
534 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
536 if(CDMUtilities::openCreaToolsTools())
538 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
541 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
543 if(CDMUtilities::openTextEditor())
545 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);
548 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
550 if(CDMUtilities::openTerminal())
552 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);
557 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
559 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0);
561 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
563 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
565 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
567 wxBoxSizer *topsizer;
569 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
571 topsizer = new wxBoxSizer(wxVERTICAL);
573 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
574 html -> SetBorders(0);
576 std::string content = ""
578 "<body bgcolor=\"#3333CC\">"
579 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
581 " <td bgcolor=\"#3333CC\">"
583 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
589 " <td bgcolor=\"#FFFFFF\">"
590 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
592 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
594 " <td width=\"65%\">"
595 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
600 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
610 html -> SetPage(crea::std2wx(content));
611 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
612 html -> GetInternalRepresentation() -> GetHeight());
614 topsizer -> Add(html, 1, wxALL, 10);
617 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
618 #endif // wxUSE_STATLINE
620 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
623 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
625 dlg.SetSizer(topsizer);
626 topsizer -> Fit(&dlg);
630 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
632 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
635 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
638 //get selected element
639 wxTreeItemId elementId = event.GetItem();
640 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
641 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
642 if(elementId.IsOk() && this->actualTreeItem != elementId)
645 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
646 //get element from model
647 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
651 std::cout << "Tree Selection: " << element->GetName() << std::endl;
653 //std::stringstream ss;
654 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
655 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
656 this->actualTreeItem = elementId;
660 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
661 wxPanel* description;
662 if(elementProject != NULL)
664 //create element description
665 description = new wxCDMProjectDescriptionPanel(
668 ID_WINDOW_PROPERTIES,
669 wxT("Description Panel"),
679 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
680 if(elementAppli != NULL)
682 //create element description
683 description = new wxCDMAppliDescriptionPanel(
686 ID_WINDOW_PROPERTIES,
687 wxT("Description Panel"),
697 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
698 if(elementApplication != NULL)
700 //create element description
701 description = new wxCDMApplicationDescriptionPanel(
704 ID_WINDOW_PROPERTIES,
705 wxT("Description Panel"),
714 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
715 if(elementLib != NULL)
717 //create element description
718 description = new wxCDMLibDescriptionPanel(
721 ID_WINDOW_PROPERTIES,
722 wxT("Description Panel"),
731 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
732 if(elementLibrary != NULL)
734 //create element description
735 description = new wxCDMLibraryDescriptionPanel(
738 ID_WINDOW_PROPERTIES,
739 wxT("Description Panel"),
748 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
749 if(elementPackage != NULL)
751 //create element description
752 description = new wxCDMPackageDescriptionPanel(
755 ID_WINDOW_PROPERTIES,
756 wxT("Description Panel"),
765 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
766 if(elementBlackBox != NULL)
768 //create element description
769 description = new wxCDMBlackBoxDescriptionPanel(
772 ID_WINDOW_PROPERTIES,
773 wxT("Description Panel"),
782 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
783 if(elementCMakeLists != NULL)
785 //create element description
786 description = new wxCDMCMakeListsDescriptionPanel(
789 ID_WINDOW_PROPERTIES,
790 wxT("Description Panel"),
799 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
800 if(elementFolder != NULL)
802 //create element description
803 description = new wxCDMFolderDescriptionPanel(
806 ID_WINDOW_PROPERTIES,
807 wxT("Description Panel"),
816 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
817 if(elementFile != NULL)
819 //create element description
820 description = new wxCDMFileDescriptionPanel(
823 ID_WINDOW_PROPERTIES,
824 wxT("Description Panel"),
834 //create element description
835 description = new wxCDMMainDescriptionPanel(
837 ID_WINDOW_PROPERTIES,
838 wxT("Description Panel"),
855 if(this->panel_Properties!= NULL)
857 this->panel_Properties->Hide();
858 auiManager.DetachPane(this->panel_Properties);
859 //this->panel_Properties->Destroy();
860 //this->panel_Properties = NULL;
863 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
864 this->panel_Properties = description;
877 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
879 modelCDMIProjectTreeNode* myItem = NULL;
880 wxPanel* description = NULL;
881 switch(event.GetId())
884 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
885 //select out old one to generate selection event
886 this->tree_Projects->Unselect();
887 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
888 this->tree_Projects->Expand(myItem->GetId().GetWxId());
892 if(event.GetString() == wxT("manage_packages"))
894 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
895 //this->tree_Projects->Unselect();
896 this->actualTreeItem.Unset();
897 description = new wxCDMPackageManagerPanel(
899 this->model->GetProject(),
900 ID_WINDOW_PROPERTIES,
901 wxT("Description Panel"),
907 else if(event.GetString() == wxT("manage_libraries"))
909 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
910 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
913 else if(event.GetString() == wxT("manage_applications"))
915 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
916 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
919 else if(event.GetString() == wxT("blackbox"))
921 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
922 this->actualTreeItem.Unset();
923 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
924 description = new wxCDMBlackBoxDescriptionPanel(
927 ID_WINDOW_PROPERTIES,
928 wxT("Description Panel"),
938 if(this->panel_Properties!= NULL)
940 this->panel_Properties->Hide();
941 auiManager.DetachPane(this->panel_Properties);
942 this->panel_Properties->Destroy();
943 this->panel_Properties = NULL;
946 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
947 this->panel_Properties = description;
957 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
959 //std::cout << "element " << event.GetInt() << std::endl;
960 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
961 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
962 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
963 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
964 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
965 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
969 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
971 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
972 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
973 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
974 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
975 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
979 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
981 this->help = !this->help;
982 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
985 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
992 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);