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 "CDMUtilities.h"
43 #include "creaDevManagerIds.h"
44 #include "wxCDMMainDescriptionPanel.h"
45 #include "wxCDMProjectDescriptionPanel.h"
46 #include "wxCDMAppliDescriptionPanel.h"
47 #include "wxCDMApplicationDescriptionPanel.h"
48 #include "wxCDMLibDescriptionPanel.h"
49 #include "wxCDMLibraryDescriptionPanel.h"
50 #include "wxCDMPackageDescriptionPanel.h"
51 #include "wxCDMBlackBoxDescriptionPanel.h"
52 #include "wxCDMCMakeListsDescriptionPanel.h"
53 #include "wxCDMFolderDescriptionPanel.h"
54 #include "wxCDMFileDescriptionPanel.h"
55 #include "wxCDMPackageManagerPanel.h"
57 #include "wxCDMProjectActionsPanel.h"
58 #include "wxCDMNewProjectDialog.h"
62 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
63 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
64 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
65 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
66 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
67 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
68 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
69 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
70 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
71 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
72 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
73 EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
74 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
75 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
76 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
77 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
79 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
80 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
82 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
84 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView)
85 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected)
86 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected)
89 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
92 wxCDMMainFrame::wxCDMMainFrame(
95 const wxString& caption,
101 this->menu_File = NULL;
102 this->menu_Edit = NULL;
103 this->menu_Tools = NULL;
104 this->menu_Help = NULL;
105 this->panel_Properties = NULL;
106 this->panel_ProjectActions = NULL;
107 this->tree_Projects = NULL;
108 Create(parent, id, caption, pos, size, style);
111 wxCDMMainFrame::~wxCDMMainFrame()
116 bool wxCDMMainFrame::Create(
119 const wxString& caption,
125 wxFrame::Create(parent, id, caption, pos, size, style);
126 this->model = new modelCDMMain();
133 modelCDMMain* wxCDMMainFrame::GetModel() const
138 wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
140 return this->panel_Properties;
143 bool wxCDMMainFrame::isHelp() const
148 void wxCDMMainFrame::RefreshProject()
151 std::cout << "refreshing project" << std::endl;
152 this->model->RefreshProject(result);
153 std::cout << "rebuilding project tree" << std::endl;
154 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
155 this->tree_Projects->Unselect();
156 this->actualTreeItem.Unset();
159 void wxCDMMainFrame::CreateMenus()
161 wxMenuBar* menuBar = new wxMenuBar;
164 menu_File = new wxMenu();
165 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
166 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
167 menu_File->AppendSeparator();
168 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
169 menu_File->AppendSeparator();
170 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
171 menu_File->AppendSeparator();
172 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
174 menuBar->Append(menu_File, wxT("&File"));
177 menu_Edit = new wxMenu();
178 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
180 menuBar->Append(menu_Edit, wxT("&Edit"));
183 menu_Tools = new wxMenu();
184 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
185 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
186 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
187 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
189 menuBar->Append(menu_Tools, wxT("&Tools"));
192 menu_Help = new wxMenu();
193 menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
194 menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
195 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
196 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
197 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
198 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
200 menuBar->Append(menu_Help, wxT("&Help"));
205 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
206 statusBar->SetFieldsCount(1);
207 SetStatusBar(statusBar);
211 void wxCDMMainFrame::CreateControls()
214 auiManager.SetManagedWindow(this);
217 tree_Projects = new wxCDMProjectsTreeCtrl(
222 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
224 this->actualTreeItem.Unset();
226 panel_Properties = new wxCDMMainDescriptionPanel(
228 ID_WINDOW_PROPERTIES,
229 wxT("Description Panel"),
235 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
236 auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
238 //auiManager.LoadPerspective(pers,true);
239 wxToolTip::Enable(true);
240 wxToolTip::SetDelay(0);
245 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
249 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
251 userResponse = dialog->ShowModal();
253 if(userResponse == wxID_FORWARD)
256 if(this->model->GetProject() != NULL)
258 if(!this->model->CloseProject(result))
260 std::cout << "error closing project: " << *result << std::endl;
261 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
265 if(this->panel_Properties != NULL)
267 auiManager.DetachPane(this->panel_Properties);
268 this->panel_Properties->Hide();
270 if(this->panel_ProjectActions != NULL)
272 auiManager.DetachPane(this->panel_ProjectActions);
273 this->panel_ProjectActions->Hide();
279 if(!this->model->CreateProject(
280 crea::wx2std(dialog->GetProjectName()),
281 crea::wx2std(dialog->GetProjectLocation()),
283 crea::wx2std(dialog->GetPackageAuthor()),
284 crea::wx2std(dialog->GetPackageDescription())
287 std::cout << "error opening project: " << *result << std::endl;
288 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
293 //show project actions panel
294 if(this->panel_ProjectActions != NULL)
296 auiManager.DetachPane(this->panel_Properties);
297 this->panel_ProjectActions->Destroy();
298 this->panel_ProjectActions = NULL;
301 panel_ProjectActions = new wxCDMProjectActionsPanel(
303 this->model->GetProject(),
304 ID_WINDOW_PROJ_ACTIONS,
305 wxT("Project Actions Panel"),
311 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
314 //populate tree control
315 tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
316 tree_Projects->Unselect();
317 this->actualTreeItem.Unset();
318 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
319 //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
322 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
326 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
327 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
328 long userResponse = FD->ShowModal();
329 if(userResponse == wxID_OK)
331 std::string path = crea::wx2std (FD->GetPath());
335 std::cout << "Selection to open: " << path << std::endl;
339 if(this->model->GetProject() != NULL)
341 std::cout << "Project not null, closing it" << std::endl;
342 if(!this->model->CloseProject(result))
344 std::cout << "error closing project: " << *result << std::endl;
345 wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
349 if(this->panel_Properties != NULL)
351 auiManager.DetachPane(this->panel_Properties);
352 this->panel_Properties->Hide();
354 if(this->panel_ProjectActions != NULL)
356 auiManager.DetachPane(this->panel_ProjectActions);
357 this->panel_ProjectActions->Hide();
361 if (!this->model->OpenProject(path, result))
363 std::cout << "error opening project: " << *result << std::endl;
364 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
369 std::cout << "building ui" << std::endl;
371 //populate tree control
372 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
373 tree_Projects->Unselect();
374 this->actualTreeItem.Unset();
375 tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
378 //change project's actions panel
379 if(this->panel_ProjectActions!= NULL)
381 auiManager.DetachPane(this->panel_ProjectActions);
382 this->panel_ProjectActions->Destroy();
383 this->panel_ProjectActions = NULL;
385 panel_ProjectActions = new wxCDMProjectActionsPanel(
387 this->model->GetProject(),
388 ID_WINDOW_PROJ_ACTIONS,
389 wxT("Project Actions Panel"),
394 panel_ProjectActions->SetMinSize(wxSize(500, 100));
397 auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
404 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
406 std::cout << "closing project" << std::endl;
408 if(!this->model->CloseProject(result))
410 std::cout << "error closing project: " << *result << std::endl;
411 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
414 tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
415 this->actualTreeItem.Unset();
416 if(this->panel_Properties != NULL)
418 auiManager.DetachPane(this->panel_Properties);
419 this->panel_Properties->Hide();
421 if(this->panel_ProjectActions != NULL)
423 auiManager.DetachPane(this->panel_ProjectActions);
424 this->panel_ProjectActions->Hide();
427 this->panel_Properties = new wxCDMMainDescriptionPanel(
429 ID_WINDOW_PROPERTIES,
430 wxT("Description Panel"),
436 auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
441 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
443 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
446 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
448 std::cout << "Closing CreaDevManager..." << std::endl;
450 if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
452 std::cout << "error closing project: " << *result << std::endl;
455 if(this->panel_Properties != NULL)
457 auiManager.DetachPane(this->panel_Properties);
458 this->panel_Properties->Destroy();
459 this->panel_Properties = NULL;
462 if(this->tree_Projects != NULL)
464 auiManager.DetachPane(this->tree_Projects);
465 this->tree_Projects->Destroy();
466 this->tree_Projects = NULL;
469 if(this->panel_ProjectActions != NULL)
471 auiManager.DetachPane(this->panel_ProjectActions);
472 this->panel_ProjectActions->Destroy();
473 this->panel_ProjectActions = NULL;
480 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
483 if(!model->RefreshProject(result))
485 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
487 if(this->model->GetProject() != NULL)
489 this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
490 this->auiManager.Update();
492 this->tree_Projects->Unselect();
493 this->actualTreeItem.Unset();
494 this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
499 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
501 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
503 if(CDMUtilities::openBBEditor())
505 wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
508 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
510 if(CDMUtilities::openCreaToolsTools())
512 wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR);
515 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
517 if(CDMUtilities::openTextEditor())
519 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);
522 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
524 if(CDMUtilities::openTerminal())
526 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);
531 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
533 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0);
535 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
537 wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0);
539 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
541 wxBoxSizer *topsizer;
543 wxDialog dlg(this, wxID_ANY, wxString(_("About")));
545 topsizer = new wxBoxSizer(wxVERTICAL);
547 html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
548 html -> SetBorders(0);
550 std::string content = ""
552 "<body bgcolor=\"#3333CC\">"
553 "<table cellspacing=3 cellpadding=4 width=\"100%\">"
555 " <td bgcolor=\"#3333CC\">"
557 " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
563 " <td bgcolor=\"#FFFFFF\">"
564 " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
566 " <table cellpadding=0 cellspacing=0 width=\"100%\">"
568 " <td width=\"65%\">"
569 " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
574 " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
584 html -> SetPage(crea::std2wx(content));
585 html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
586 html -> GetInternalRepresentation() -> GetHeight());
588 topsizer -> Add(html, 1, wxALL, 10);
591 topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
592 #endif // wxUSE_STATLINE
594 wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
597 topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
599 dlg.SetSizer(topsizer);
600 topsizer -> Fit(&dlg);
604 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
606 wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0);
609 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
612 //get selected element
613 wxTreeItemId elementId = event.GetItem();
614 //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl;
615 //elementId.IsOk() && this->tree_Projects->IsSelected(elementId)
616 if(elementId.IsOk() && this->actualTreeItem != elementId)
619 //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl;
620 //get element from model
621 modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
625 std::cout << "Tree Selection: " << element->GetName() << std::endl;
627 //std::stringstream ss;
628 //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem;
629 //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR);
630 this->actualTreeItem = elementId;
634 modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
635 wxPanel* description;
636 if(elementProject != NULL)
638 //create element description
639 description = new wxCDMProjectDescriptionPanel(
642 ID_WINDOW_PROPERTIES,
643 wxT("Description Panel"),
653 modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
654 if(elementAppli != NULL)
656 //create element description
657 description = new wxCDMAppliDescriptionPanel(
660 ID_WINDOW_PROPERTIES,
661 wxT("Description Panel"),
671 modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
672 if(elementApplication != NULL)
674 //create element description
675 description = new wxCDMApplicationDescriptionPanel(
678 ID_WINDOW_PROPERTIES,
679 wxT("Description Panel"),
688 modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
689 if(elementLib != NULL)
691 //create element description
692 description = new wxCDMLibDescriptionPanel(
695 ID_WINDOW_PROPERTIES,
696 wxT("Description Panel"),
705 modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
706 if(elementLibrary != NULL)
708 //create element description
709 description = new wxCDMLibraryDescriptionPanel(
712 ID_WINDOW_PROPERTIES,
713 wxT("Description Panel"),
722 modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
723 if(elementPackage != NULL)
725 //create element description
726 description = new wxCDMPackageDescriptionPanel(
729 ID_WINDOW_PROPERTIES,
730 wxT("Description Panel"),
739 modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
740 if(elementBlackBox != NULL)
742 //create element description
743 description = new wxCDMBlackBoxDescriptionPanel(
746 ID_WINDOW_PROPERTIES,
747 wxT("Description Panel"),
756 modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
757 if(elementCMakeLists != NULL)
759 //create element description
760 description = new wxCDMCMakeListsDescriptionPanel(
763 ID_WINDOW_PROPERTIES,
764 wxT("Description Panel"),
773 modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
774 if(elementFolder != NULL)
776 //create element description
777 description = new wxCDMFolderDescriptionPanel(
780 ID_WINDOW_PROPERTIES,
781 wxT("Description Panel"),
790 modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
791 if(elementFile != NULL)
793 //create element description
794 description = new wxCDMFileDescriptionPanel(
797 ID_WINDOW_PROPERTIES,
798 wxT("Description Panel"),
808 //create element description
809 description = new wxCDMMainDescriptionPanel(
811 ID_WINDOW_PROPERTIES,
812 wxT("Description Panel"),
829 if(this->panel_Properties!= NULL)
831 this->panel_Properties->Hide();
832 auiManager.DetachPane(this->panel_Properties);
833 //this->panel_Properties->Destroy();
834 //this->panel_Properties = NULL;
837 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
838 this->panel_Properties = description;
851 void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
853 modelCDMIProjectTreeNode* myItem = NULL;
854 wxPanel* description = NULL;
855 switch(event.GetId())
858 myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
859 //select out old one to generate selection event
860 this->tree_Projects->Unselect();
861 this->tree_Projects->SelectItem(myItem->GetId().GetWxId());
862 this->tree_Projects->Expand(myItem->GetId().GetWxId());
866 if(event.GetString() == wxT("manage_packages"))
868 //this->tree_Projects->Expand(this->model->GetProject()->GetId());
869 //this->tree_Projects->Unselect();
870 this->actualTreeItem.Unset();
871 description = new wxCDMPackageManagerPanel(
873 this->model->GetProject(),
874 ID_WINDOW_PROPERTIES,
875 wxT("Description Panel"),
881 else if(event.GetString() == wxT("manage_libraries"))
883 this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId());
884 this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId());
887 else if(event.GetString() == wxT("manage_applications"))
889 this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId());
890 this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId());
893 else if(event.GetString() == wxT("blackbox"))
895 modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
896 this->actualTreeItem.Unset();
897 description = new wxCDMBlackBoxDescriptionPanel(
900 ID_WINDOW_PROPERTIES,
901 wxT("Description Panel"),
910 if(this->panel_Properties!= NULL)
912 this->panel_Properties->Hide();
913 auiManager.DetachPane(this->panel_Properties);
914 this->panel_Properties->Destroy();
915 this->panel_Properties = NULL;
918 auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
919 this->panel_Properties = description;
928 void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event)
930 //std::cout << "element " << event.GetInt() << std::endl;
931 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
932 this->tree_Projects->EnsureVisible(item->GetId().GetWxId());
933 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true);
934 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255));
935 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255));
936 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
940 void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
942 modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData();
943 this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false);
944 this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0));
945 this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255));
946 this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
950 void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
952 this->help = !this->help;
953 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
956 void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
963 this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);