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 "wxCDMCMakeListsDescriptionPanel.h"
55 #include "wxCDMFolderDescriptionPanel.h"
56 #include "wxCDMFileDescriptionPanel.h"
57 #include "wxCDMPackageManagerPanel.h"
59 #include "wxCDMSettingsDialog.h"
61 #include "wxCDMProjectActionsPanel.h"
62 #include "wxCDMNewProjectDialog.h"
66 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
67 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
68 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
69 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
70 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
71 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
72 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
73 EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
74 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
75 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
76 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
77 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
78 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
79 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
80 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
81 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
82 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
84 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
85 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
87 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
89 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
90 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
91 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
94 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
97 wxCDMMainFrame::wxCDMMainFrame(
100 const wxString& caption,
106 this->menu_File = NULL;
107 this->menu_Edit = NULL;
108 this->menu_Tools = NULL;
109 this->menu_Help = NULL;
110 this->panel_Properties = NULL;
111 this->panel_ProjectActions = NULL;
112 this->tree_Projects = NULL;
113 Create(parent, id, caption, pos, size, style);
116 wxCDMMainFrame::~wxCDMMainFrame()
118 wxConfigBase* pConfig = wxConfigBase::Get();
119 pConfig->Write(wxT("HELP"), this->help);
124 bool wxCDMMainFrame::Create(
127 const wxString& caption,
133 wxFrame::Create(parent, id, caption, pos, size, style);
136 wxConfigBase* pConfig = wxConfigBase::Get();
137 this->help = pConfig->Read(wxT("HELP"), this->help) != 0;
139 this->model = new modelCDMMain();
143 SetIcon(wxIcon(CIcon64));
147 modelCDMMain* wxCDMMainFrame::GetModel() const
152 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
154 return this->panel_Properties;
157 bool wxCDMMainFrame::isHelp() const
162 void wxCDMMainFrame::RefreshProject()
165 std::cout << "refreshing project" << std::endl;
166 this->model->RefreshProject(result);
167 std::cout << "rebuilding project tree" << std::endl;
168 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
169 this->tree_Projects->Unselect();
170 this->actualTreeItem.Unset();
173 void wxCDMMainFrame::CreateMenus()
175 wxMenuBar* menuBar = new wxMenuBar;
178 menu_File = new wxMenu();
179 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
180 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
181 menu_File->AppendSeparator();
182 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
183 menu_File->AppendSeparator();
184 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
185 menu_File->AppendSeparator();
186 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
188 menuBar->Append(menu_File, wxT("&File"));
191 menu_Edit = new wxMenu();
192 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
193 menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
195 menuBar->Append(menu_Edit, wxT("&Edit"));
198 menu_Tools = new wxMenu();
199 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
200 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
201 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
202 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
204 menuBar->Append(menu_Tools, wxT("&Tools"));
207 menu_Help = new wxMenu();
208 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
209 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
210 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
211 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
212 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
213 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
215 menuBar->Append(menu_Help, wxT("&Help"));
220 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
221 statusBar->SetFieldsCount(1);
222 SetStatusBar(statusBar);
226 void wxCDMMainFrame::CreateControls()
229 auiManager.SetManagedWindow(this);
232 tree_Projects = new wxCDMProjectsTreeCtrl(
237 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
239 this->actualTreeItem.Unset();
241 panel_Properties = new wxCDMMainDescriptionPanel(
243 ID_WINDOW_PROPERTIES,
244 wxT("Description Panel"),
250 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
251 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
253 //auiManager.LoadPerspective(pers,true);
254 wxToolTip::Enable(true);
255 wxToolTip::SetDelay(0);
260 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
264 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
266 userResponse = dialog->ShowModal();
268 if(userResponse == wxID_FORWARD)
271 if(this->model->GetProject() != NULL)
273 if(!this->model->CloseProject(result))
275 std::cout << "error closing project: " << *result << std::endl;
276 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
280 if(this->panel_Properties != NULL)
282 auiManager.DetachPane(this->panel_Properties);
283 this->panel_Properties->Hide();
285 if(this->panel_ProjectActions != NULL)
287 auiManager.DetachPane(this->panel_ProjectActions);
288 this->panel_ProjectActions->Hide();
294 if(!this->model->CreateProject(
295 crea::wx2std(dialog->GetProjectName()),
296 crea::wx2std(dialog->GetProjectLocation()),
298 crea::wx2std(dialog->GetPackageAuthor()),
299 crea::wx2std(dialog->GetPackageDescription())
302 std::cout << "error opening project: " << *result << std::endl;
303 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
308 //show project actions panel
309 if(this->panel_ProjectActions != NULL)
311 auiManager.DetachPane(this->panel_Properties);
312 this->panel_ProjectActions->Destroy();
313 this->panel_ProjectActions = NULL;
316 panel_ProjectActions = new wxCDMProjectActionsPanel(
318 this->model->GetProject(),
319 ID_WINDOW_PROJ_ACTIONS,
320 wxT("Project Actions Panel"),
326 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
329 //populate tree control
330 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
331 tree_Projects->Unselect();
332 this->actualTreeItem.Unset();
333 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
334 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
337 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
341 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
342 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
343 long userResponse = FD->ShowModal();
344 if(userResponse == wxID_OK)
346 std::string path = crea::wx2std (FD->GetPath());
350 std::cout << "Selection to open: " << path << std::endl;
354 if(this->model->GetProject() != NULL)
356 std::cout << "Project not null, closing it" << std::endl;
357 if(!this->model->CloseProject(result))
359 std::cout << "error closing project: " << *result << std::endl;
360 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
364 if(this->panel_Properties != NULL)
366 auiManager.DetachPane(this->panel_Properties);
367 this->panel_Properties->Hide();
369 if(this->panel_ProjectActions != NULL)
371 auiManager.DetachPane(this->panel_ProjectActions);
372 this->panel_ProjectActions->Hide();
376 if (!this->model->OpenProject(path, result))
378 std::cout << "error opening project: " << *result << std::endl;
379 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
384 std::cout << "building ui" << std::endl;
386 //populate tree control
387 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
388 tree_Projects->Unselect();
389 this->actualTreeItem.Unset();
390 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
393 //change project's actions panel
394 if(this->panel_ProjectActions!= NULL)
396 auiManager.DetachPane(this->panel_ProjectActions);
397 this->panel_ProjectActions->Destroy();
398 this->panel_ProjectActions = NULL;
400 panel_ProjectActions = new wxCDMProjectActionsPanel(
402 this->model->GetProject(),
403 ID_WINDOW_PROJ_ACTIONS,
404 wxT("Project Actions Panel"),
409 panel_ProjectActions->SetMinSize(wxSize(500, 100));
412 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
419 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
421 std::cout << "closing project" << std::endl;
423 if(!this->model->CloseProject(result))
425 std::cout << "error closing project: " << *result << std::endl;
426 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
429 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
430 this->actualTreeItem.Unset();
431 if(this->panel_Properties != NULL)
433 auiManager.DetachPane(this->panel_Properties);
434 this->panel_Properties->Hide();
436 if(this->panel_ProjectActions != NULL)
438 auiManager.DetachPane(this->panel_ProjectActions);
439 this->panel_ProjectActions->Hide();
442 this->panel_Properties = new wxCDMMainDescriptionPanel(
444 ID_WINDOW_PROPERTIES,
445 wxT("Description Panel"),
451 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
456 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
458 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
461 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
463 std::cout << "Closing CreaDevManager..." << std::endl;
465 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
467 std::cout << "error closing project: " << *result << std::endl;
470 if(this->panel_Properties != NULL)
472 auiManager.DetachPane(this->panel_Properties);
473 this->panel_Properties->Destroy();
474 this->panel_Properties = NULL;
477 if(this->tree_Projects != NULL)
479 auiManager.DetachPane(this->tree_Projects);
480 this->tree_Projects->Destroy();
481 this->tree_Projects = NULL;
484 if(this->panel_ProjectActions != NULL)
486 auiManager.DetachPane(this->panel_ProjectActions);
487 this->panel_ProjectActions->Destroy();
488 this->panel_ProjectActions = NULL;
495 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
498 if(!model->RefreshProject(result))
500 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
502 if(this->model->GetProject() != NULL)
504 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
505 this->auiManager.Update();
507 this->tree_Projects->Unselect();
508 this->actualTreeItem.Unset();
509 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
514 void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
516 wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
517 settingsDialog->SetHelpEnabled(this->help);
519 int res = settingsDialog->ShowModal();
522 this->help = settingsDialog->IsHelpEnabled();
523 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
527 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
529 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
531 if(CDMUtilities::openBBEditor())
533 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
536 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
538 if(CDMUtilities::openCreaToolsTools())
540 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
543 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
545 if(CDMUtilities::openTextEditor())
547 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);
550 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
552 if(CDMUtilities::openTerminal())
554 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);
559 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
561 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0);
563 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
565 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
567 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
569 wxBoxSizer *topsizer;
571 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
573 topsizer = new wxBoxSizer(wxVERTICAL);
575 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
576 html -> SetBorders(0);
578 std::string content = ""
580 "<body bgcolor=\"#3333CC\">"
581 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
583 " <td bgcolor=\"#3333CC\">"
585 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
591 " <td bgcolor=\"#FFFFFF\">"
592 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
594 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
596 " <td width=\"65%\">"
597 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
602 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
612 html -> SetPage(crea::std2wx(content));
613 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
614 html -> GetInternalRepresentation() -> GetHeight());
616 topsizer -> Add(html, 1, wxALL, 10);
619 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
620 #endif // wxUSE_STATLINE
622 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
625 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
627 dlg.SetSizer(topsizer);
628 topsizer -> Fit(&dlg);
632 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
634 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
637 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
640 //get selected element
641 wxTreeItemId elementId = event.GetItem();
642 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
643 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
644 if(elementId.IsOk() && this->actualTreeItem != elementId)
647 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
648 //get element from model
649 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
653 std::cout << "Tree Selection: " << element->GetName() << std::endl;
655 //std::stringstream ss;
656 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
657 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
658 this->actualTreeItem = elementId;
662 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
663 wxPanel* description;
664 if(elementProject != NULL)
666 //create element description
667 description = new wxCDMProjectDescriptionPanel(
670 ID_WINDOW_PROPERTIES,
671 wxT("Description Panel"),
681 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
682 if(elementAppli != NULL)
684 //create element description
685 description = new wxCDMAppliDescriptionPanel(
688 ID_WINDOW_PROPERTIES,
689 wxT("Description Panel"),
699 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
700 if(elementApplication != NULL)
702 //create element description
703 description = new wxCDMApplicationDescriptionPanel(
706 ID_WINDOW_PROPERTIES,
707 wxT("Description Panel"),
716 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
717 if(elementLib != NULL)
719 //create element description
720 description = new wxCDMLibDescriptionPanel(
723 ID_WINDOW_PROPERTIES,
724 wxT("Description Panel"),
733 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
734 if(elementLibrary != NULL)
736 //create element description
737 description = new wxCDMLibraryDescriptionPanel(
740 ID_WINDOW_PROPERTIES,
741 wxT("Description Panel"),
750 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
751 if(elementPackage != NULL)
753 //create element description
754 description = new wxCDMPackageDescriptionPanel(
757 ID_WINDOW_PROPERTIES,
758 wxT("Description Panel"),
767 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
768 if(elementBlackBox != NULL)
770 //create element description
771 description = new wxCDMBlackBoxDescriptionPanel(
774 ID_WINDOW_PROPERTIES,
775 wxT("Description Panel"),
784 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
785 if(elementCMakeLists != NULL)
787 //create element description
788 description = new wxCDMCMakeListsDescriptionPanel(
791 ID_WINDOW_PROPERTIES,
792 wxT("Description Panel"),
801 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
802 if(elementFolder != NULL)
804 //create element description
805 description = new wxCDMFolderDescriptionPanel(
808 ID_WINDOW_PROPERTIES,
809 wxT("Description Panel"),
818 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
819 if(elementFile != NULL)
821 //create element description
822 description = new wxCDMFileDescriptionPanel(
825 ID_WINDOW_PROPERTIES,
826 wxT("Description Panel"),
836 //create element description
837 description = new wxCDMMainDescriptionPanel(
839 ID_WINDOW_PROPERTIES,
840 wxT("Description Panel"),
857 if(this->panel_Properties!= NULL)
859 this->panel_Properties->Hide();
860 auiManager.DetachPane(this->panel_Properties);
861 //this->panel_Properties->Destroy();
862 //this->panel_Properties = NULL;
865 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
866 this->panel_Properties = description;
879 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
881 modelCDMIProjectTreeNode* myItem = NULL;
882 wxPanel* description = NULL;
883 switch(event.GetId())
886 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
887 //select out old one to generate selection event
888 this->tree_Projects->Unselect();
889 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
890 this->tree_Projects->Expand(myItem->GetId().GetWxId());
894 if(event.GetString() == wxT("manage_packages"))
896 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
897 //this->tree_Projects->Unselect();
898 this->actualTreeItem.Unset();
899 description = new wxCDMPackageManagerPanel(
901 this->model->GetProject(),
902 ID_WINDOW_PROPERTIES,
903 wxT("Description Panel"),
909 else if(event.GetString() == wxT("manage_libraries"))
911 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
912 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
915 else if(event.GetString() == wxT("manage_applications"))
917 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
918 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
921 else if(event.GetString() == wxT("blackbox"))
923 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
924 this->actualTreeItem.Unset();
925 this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId());
926 description = new wxCDMBlackBoxDescriptionPanel(
929 ID_WINDOW_PROPERTIES,
930 wxT("Description Panel"),
940 if(this->panel_Properties!= NULL)
942 this->panel_Properties->Hide();
943 auiManager.DetachPane(this->panel_Properties);
944 this->panel_Properties->Destroy();
945 this->panel_Properties = NULL;
948 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
949 this->panel_Properties = description;
959 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
961 //std::cout << "element " << event.GetInt() << std::endl;
962 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
963 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
964 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
965 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
966 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
967 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
971 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
973 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
974 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
975 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
976 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
977 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
981 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
983 this->help = !this->help;
984 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
987 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
994 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);