X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMMainFrame.cpp;h=ad37e22c023a6bc3f12de9fd1ab7163100d14836;hb=f4451b0dfa9bfa593ada3e9462570b6ca250f0d7;hp=630c1f85c8712072b2f40888aa29396d028e3804;hpb=17824854619941a12697fea8524f4218f9a14ef9;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 630c1f8..ad37e22 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -2,8 +2,10 @@ # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) +# pour la Sant�) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, @@ -20,58 +22,88 @@ # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. -# ------------------------------------------------------------------------ */ +# ------------------------------------------------------------------------ + */ #include "wxCDMMainFrame.h" +#include + +#include +#include "creaSystem.h" +#include "wx/treectrl.h" +#include "wx/treebase.h" +#include "wx/tooltip.h" +#include "wx/wxhtml.h" +#include "wx/statline.h" +#include "CDMUtilities.h" + #include "creaDevManagerIds.h" #include "wxCDMMainDescriptionPanel.h" +#include "wxCDMProjectDescriptionPanel.h" +#include "wxCDMAppliDescriptionPanel.h" +#include "wxCDMApplicationDescriptionPanel.h" +#include "wxCDMLibDescriptionPanel.h" +#include "wxCDMLibraryDescriptionPanel.h" +#include "wxCDMPackageDescriptionPanel.h" +#include "wxCDMBlackBoxDescriptionPanel.h" +#include "wxCDMCMakeListsDescriptionPanel.h" +#include "wxCDMFolderDescriptionPanel.h" +#include "wxCDMFileDescriptionPanel.h" +#include "wxCDMPackageManagerPanel.h" + #include "wxCDMProjectActionsPanel.h" #include "wxCDMNewProjectDialog.h" -#include - - BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame) - EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject) - EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject) - EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent) - EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject) - EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects) - EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy) - EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit) - EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject) - EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut) - EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy) - EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste) - EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete) - EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll) - EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone) - EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog) - EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor) - EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools) - EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor) - EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine) - EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp) - EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug) - EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager) - EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis) - EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject) - EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject) +EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject) +EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject) +EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject) +EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy) +EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit) +EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject) +EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor) +EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools) +EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor) +EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine) +EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp) +EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp) +EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug) +EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager) +EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis) + +EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject) +EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject) + +EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged) + +EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView) +EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected) +EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected) + + +EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp) END_EVENT_TABLE() wxCDMMainFrame::wxCDMMainFrame( - wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style + wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { + this->menu_File = NULL; + this->menu_Edit = NULL; + this->menu_Tools = NULL; + this->menu_Help = NULL; + this->panel_Properties = NULL; + this->panel_ProjectActions = NULL; + this->tree_Projects = NULL; Create(parent, id, caption, pos, size, style); } @@ -81,72 +113,88 @@ wxCDMMainFrame::~wxCDMMainFrame() } bool wxCDMMainFrame::Create( - wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style + wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { wxFrame::Create(parent, id, caption, pos, size, style); this->model = new modelCDMMain(); + this->help = true; CreateMenus(); CreateControls(); return TRUE; } +modelCDMMain* wxCDMMainFrame::GetModel() const +{ + return this->model; +} + +wxPanel* wxCDMMainFrame::GetPropertiesPanel() const +{ + return this->panel_Properties; +} + +bool wxCDMMainFrame::isHelp() const +{ + return this->help; +} + +void wxCDMMainFrame::RefreshProject() +{ + std::string* result; + std::cout << "refreshing project" << std::endl; + this->model->RefreshProject(result); + std::cout << "rebuilding project tree" << std::endl; + this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); +} + void wxCDMMainFrame::CreateMenus() { wxMenuBar* menuBar = new wxMenuBar; //FileMenu menu_File = new wxMenu(); - menu_File->Append(ID_MENU_NEW_PROJECT, wxString("&New Project...")); - menu_File->Append(ID_MENU_OPEN_PROJECT, wxString("&Open Project...")); - menu_File->Append(ID_MENU_OPEN_RECENT, wxString("Open &Recent")); + menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project...")); + menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project...")); menu_File->AppendSeparator(); - menu_File->Append(ID_MENU_CLOSE_PROJECT, wxString("&Close Project")); - menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxString("C&lose All Projects")); + menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project")); menu_File->AppendSeparator(); - menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxString("&Export Project Hierarchy...")); + menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy...")); menu_File->AppendSeparator(); - menu_File->Append(ID_MENU_EXIT, wxString("E&xit")); + menu_File->Append(ID_MENU_EXIT, wxT("E&xit")); - menuBar->Append(menu_File, wxString("&File")); + menuBar->Append(menu_File, wxT("&File")); //EditMenu menu_Edit = new wxMenu(); - menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxString("&Refresh Project")); - menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_CUT, wxString("Cu&t")); - menu_Edit->Append(ID_MENU_COPY, wxString("&Copy")); - menu_Edit->Append(ID_MENU_PASTE, wxString("&Paste")); - menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_DELETE, wxString("&Delete")); - menu_Edit->Append(ID_MENU_SELECT_ALL, wxString("Select &All")); - menu_Edit->Append(ID_MENU_SELECT_NONE, wxString("Ca&ncel Selection")); - - menuBar->Append(menu_Edit, wxString("&Edit")); + menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project")); + + menuBar->Append(menu_Edit, wxT("&Edit")); //ToolsMenu menu_Tools = new wxMenu(); - menu_Tools->Append(ID_MENU_EVENT_LOG, wxString("Event &Log")); - menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxString("BBTK &Graphical Editor")); - menu_Tools->Append(ID_MENU_MINITOOLS, wxString("&MiniTools")); - menu_Tools->Append(ID_MENU_CODE_EDITOR, wxString("&Code Editor")); - menu_Tools->Append(ID_MENU_COMMAND_LINE, wxString("&Command Line")); + menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor")); + menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools")); + menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor")); + menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line")); - menuBar->Append(menu_Tools, wxString("&Tools")); + menuBar->Append(menu_Tools, wxT("&Tools")); //HelpMenu menu_Help = new wxMenu(); - menu_Help->Append(ID_MENU_HELP, wxString("&Help")); - menu_Help->Append(ID_MENU_REPORT_BUG, wxString("Report &Bug")); - menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxString("&About CreaDevManager")); - menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxString("A&bout CREATIS")); + menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs")); + menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help); + menu_Help->Append(ID_MENU_HELP, wxT("&Help")); + menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug")); + menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager")); + menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS")); - menuBar->Append(menu_Help, wxString("&Help")); + menuBar->Append(menu_Help, wxT("&Help")); //Set Bar SetMenuBar(menuBar); @@ -164,106 +212,219 @@ void wxCDMMainFrame::CreateControls() tree_Projects = new wxCDMProjectsTreeCtrl( - this, - ID_TREE_PROJECTS, - wxDefaultPosition, - wxSize(300,400), - wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS + this, + ID_TREE_PROJECTS, + wxDefaultPosition, + wxSize(200,400), + wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS ); - tree_Projects->SetMinSize(wxSize(200,200)); panel_Properties = new wxCDMMainDescriptionPanel( - this, - ID_WINDOW_PROPERTIES, - wxString("Description Panel"), - wxDefaultPosition, - wxSize(300, 400), - 0 - ); - - - - panel_ProjectActions = new wxCDMProjectActionsPanel( - this, - ID_WINDOW_PROJ_ACTIONS, - wxString("Project Actions Panel"), - wxDefaultPosition, - wxSize(600,200), - 0 + this, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(400, 600), + 0 ); - panel_ProjectActions->SetMinSize(wxSize(500, 100)); - - auiManager.AddPane(tree_Projects, wxLEFT, wxString("Projects Tree")); - auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxString("Project Actions")); - auiManager.AddPane(panel_Properties, wxCENTER, wxString("Properties")); + auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false)); + auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false)); auiManager.Update(); - auiManager.GetPane(tree_Projects).CloseButton(false).MaximizeButton(true); - auiManager.GetPane(panel_Properties).CloseButton(false); + //auiManager.LoadPerspective(pers,true); + wxToolTip::Enable(true); + wxToolTip::SetDelay(0); } //Event Handlers //File menu void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) { + std::string* result; + wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this); long userResponse; userResponse = dialog->ShowModal(); if(userResponse == wxID_FORWARD) - { - //TODO createProject - std::cerr << "should create Project here" << std::endl; - //tree_Projects->BuildTree(this->model->GetActiveProjects()); - } + { + //create project + if(this->model->GetProject() != NULL) + { + if(!this->model->CloseProject(result)) + { + std::cout << "error closing project: " << *result << std::endl; + wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; + } + } + + + if(!this->model->CreateProject( + crea::wx2std(dialog->GetProjectName()), + crea::wx2std(dialog->GetProjectLocation()), + result, + crea::wx2std(dialog->GetPackageAuthor()), + crea::wx2std(dialog->GetPackageDescription()) + )) + { + std::cout << "error opening project: " << *result << std::endl; + wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; + } + + //populate tree control + tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject()); + tree_Projects->Unselect(); + tree_Projects->SelectItem(this->model->GetProject()->GetId()); + + + //show project actions panel + if(this->panel_ProjectActions != NULL) + { + auiManager.DetachPane(this->panel_Properties); + this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; + } + + panel_ProjectActions = new wxCDMProjectActionsPanel( + this, + this->model->GetProject(), + ID_WINDOW_PROJ_ACTIONS, + wxT("Project Actions Panel"), + wxDefaultPosition, + wxSize(800,200), + 0 + ); + panel_ProjectActions->SetMinSize(wxSize(500, 100)); + + + auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false)); + + auiManager.Update(); + + //wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION); + + } event.Skip(); } void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) { - /* + std::string* result; + long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; - wxDirDialog* FD = new wxDirDialog(this, wxString("Select the project directory"), wxString(""), style); - long userResponse; - userResponse = FD->ShowModal(); + wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style); + long userResponse = FD->ShowModal(); if(userResponse == wxID_OK) - { - switch(this->controller->OpenProject(crea::wx2std (FD->GetPath()))) { - case 1: - wxMessageBox( wxT("No project selected."), wxT("Open Project - Error"), wxICON_ERROR); - event.Skip(); - break; - case 2: - wxMessageBox( wxString("Sources not found."), wxString("Open Project - Error"), wxICON_ERROR); - event.Skip(); - break; - case 0: - break; - }; - - ((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects()); + std::string path = crea::wx2std (FD->GetPath()); + FD -> Destroy(); + FD = NULL; + + std::cout << "Selection to open: " << path << std::endl; + + + //populate model + if(this->model->GetProject() != NULL) + { + std::cout << "Project not null, closing it" << std::endl; + if(!this->model->CloseProject(result)) + { + std::cout << "error closing project: " << *result << std::endl; + wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; + } + } + + if (!this->model->OpenProject(path, result)) + { + std::cout << "error opening project: " << *result << std::endl; + wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR); + event.Skip(); + return; + }; + + std::cout << "building ui" << std::endl; + + //populate tree control + tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + tree_Projects->Unselect(); + tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + + + + //change project's actions panel + if(this->panel_ProjectActions!= NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; + } + panel_ProjectActions = new wxCDMProjectActionsPanel( + this, + this->model->GetProject(), + ID_WINDOW_PROJ_ACTIONS, + wxT("Project Actions Panel"), + wxDefaultPosition, + wxSize(800,200), + 0 + ); + panel_ProjectActions->SetMinSize(wxSize(500, 100)); + + + auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false)); + + auiManager.Update(); + + } - auiManager.Update(); - } - */ - event.Skip(); -} -void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl; event.Skip(); } + void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) { - std::cerr << "Event OnMenuCloseProject not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuCloseAllProjects not implemented" << std::endl; + std::cout << "closing project" << std::endl; + std::string* result; + if(!this->model->CloseProject(result)) + { + std::cout << "error closing project: " << *result << std::endl; + wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR); + } + + tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + + if(this->panel_Properties != NULL) + { + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Destroy(); + this->panel_Properties = NULL; + } + if(this->panel_ProjectActions != NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; + } + + this->panel_Properties = new wxCDMMainDescriptionPanel( + this, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + + auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); + + auiManager.Update(); event.Skip(); } + void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event) { std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl; @@ -272,92 +433,501 @@ void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event) void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) { std::cout << "Closing CreaDevManager..." << std::endl; + std::string* result; + if(this->model->GetProject() != NULL && !this->model->CloseProject(result)) + { + std::cout << "error closing project: " << *result << std::endl; + } + + if(this->panel_Properties != NULL) + { + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Destroy(); + this->panel_Properties = NULL; + } + + if(this->tree_Projects != NULL) + { + auiManager.DetachPane(this->tree_Projects); + this->tree_Projects->Destroy(); + this->tree_Projects = NULL; + } + + if(this->panel_ProjectActions != NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; + } + Close(); - event.Skip(); } //Edit Menu void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event) { - std::cerr << "Event OnMenuRefreshProject not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuCut not implemented" << std::endl; + std::string* result; + if(!model->RefreshProject(result)) + { + wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR); + } + if(this->model->GetProject() != NULL) + { + this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + this->auiManager.Update(); + + this->tree_Projects->Unselect(); + this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + } event.Skip(); } -void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event) + +void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event) { - std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl; + std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl; event.Skip(); + if(CDMUtilities::openBBEditor()) + { + wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } -void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event) { - std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openCreaToolsTools()) + { + wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } -void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event) { - std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openTextEditor()) + { + 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); + } } -void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event) { - std::cerr << "Event OnMenuSelectAll not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openTerminal()) + { + 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); + } } -void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event) + +//Help Menu +void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event) { - std::cerr << "Event OnMenuSelectNone not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0); } - -//Tools Menu -void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event) { - std::cerr << "Event OnMenuEventLog not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0); } -void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event) { - std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl; - event.Skip(); + wxBoxSizer *topsizer; + wxHtmlWindow *html; + wxDialog dlg(this, wxID_ANY, wxString(_("About"))); + + topsizer = new wxBoxSizer(wxVERTICAL); + + html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER); + html -> SetBorders(0); + + std::string content = "" + "" + "" + "" + " " + " " + " " + " " + " " + " " + "
" + "
" + " CREA Development Manager" + " " + "
" + "
" + "

Creatis 2012 - Lyon, France

" + " " + " " + " " + " " + " " + "
" + "

Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr

" + "
" + " " + "

This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.

" + "
" + "
" + "
" + "" + "" + ; + + html -> SetPage(crea::std2wx(content)); + html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(), + html -> GetInternalRepresentation() -> GetHeight()); + + topsizer -> Add(html, 1, wxALL, 10); + +#if wxUSE_STATLINE + topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10); +#endif // wxUSE_STATLINE + + wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK")); + bu1 -> SetDefault(); + + topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15); + + dlg.SetSizer(topsizer); + topsizer -> Fit(&dlg); + + dlg.ShowModal(); } -void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event) { - std::cerr << "Event OnMenuMiniTools not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0); } -void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event) + +void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) { - std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl; - event.Skip(); + + //get selected element + wxTreeItemId elementId = event.GetItem(); + if(this->tree_Projects->IsSelected(elementId)) + { + std::cout << "Tree Selection id: " << elementId << std::endl; + //get element from model + modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId]; + if (element == NULL) + return; + std::cout << "Tree Selection: " << element->GetName() << std::endl; + + //TODO get element type + //project + modelCDMProject* elementProject = dynamic_cast(element); + wxPanel* description; + if(elementProject != NULL) + { + //create element description + description = new wxCDMProjectDescriptionPanel( + this, + elementProject, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + + } + else + { + //appli + modelCDMAppli* elementAppli = dynamic_cast(element); + if(elementAppli != NULL) + { + //create element description + description = new wxCDMAppliDescriptionPanel( + this, + elementAppli, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + + } + else + { + //application + modelCDMApplication* elementApplication = dynamic_cast(element); + if(elementApplication != NULL) + { + //create element description + description = new wxCDMApplicationDescriptionPanel( + this, + elementApplication, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //lib + modelCDMLib* elementLib = dynamic_cast(element); + if(elementLib != NULL) + { + //create element description + description = new wxCDMLibDescriptionPanel( + this, + elementLib, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //library + modelCDMLibrary* elementLibrary = dynamic_cast(element); + if(elementLibrary != NULL) + { + //create element description + description = new wxCDMLibraryDescriptionPanel( + this, + elementLibrary, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //package + modelCDMPackage* elementPackage = dynamic_cast(element); + if(elementPackage != NULL) + { + //create element description + description = new wxCDMPackageDescriptionPanel( + this, + elementPackage, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //black box + modelCDMBlackBox* elementBlackBox = dynamic_cast(element); + if(elementBlackBox != NULL) + { + //create element description + description = new wxCDMBlackBoxDescriptionPanel( + this, + elementBlackBox, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //CMakeLists + modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast(element); + if(elementCMakeLists != NULL) + { + //create element description + description = new wxCDMCMakeListsDescriptionPanel( + this, + elementCMakeLists, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //folder + modelCDMFolder* elementFolder = dynamic_cast(element); + if(elementFolder != NULL) + { + //create element description + description = new wxCDMFolderDescriptionPanel( + this, + elementFolder, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //file + modelCDMFile* elementFile = dynamic_cast(element); + if(elementFile != NULL) + { + //create element description + description = new wxCDMFileDescriptionPanel( + this, + elementFile, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + + //main if not any + //create element description + description = new wxCDMMainDescriptionPanel( + this, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + } + } + } + } + } + } + } + } + } + + //delete old view + if(this->panel_Properties!= NULL) + { + this->panel_Properties->Hide(); + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Destroy(); + this->panel_Properties = NULL; + } + //set new view + auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); + this->panel_Properties = description; + + auiManager.Update(); + event.Skip(); + } + + return; + } -void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event) + +void wxCDMMainFrame::OnChangeView(wxCommandEvent& event) { - std::cerr << "Event OnMenuCommandLine not implemented" << std::endl; + modelCDMIProjectTreeNode* myItem = NULL; + switch(event.GetId()) + { + case 0: + myItem = ((modelCDMIProjectTreeNode*)event.GetClientData()); + //select out old one to generate selection event + this->tree_Projects->Unselect(); + this->tree_Projects->SelectItem(myItem->GetId(), true); + this->tree_Projects->Expand(myItem->GetId()); + break; + case 1: + wxPanel* description = NULL; + if(event.GetString() == wxT("manage_packages")) + { + //this->tree_Projects->Expand(this->model->GetProject()->GetId()); + //this->tree_Projects->Unselect(); + description = new wxCDMPackageManagerPanel( + this, + this->model->GetProject(), + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else if(event.GetString() == wxT("manage_libraries")) + { + this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId(), true); + this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId()); + break; + } + else if(event.GetString() == wxT("manage_applications")) + { + this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId(), true); + this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId()); + break; + } + else if(event.GetString() == wxT("blackbox")) + { + modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData(); + description = new wxCDMBlackBoxDescriptionPanel( + this, + bb, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + + //delete old view + if(this->panel_Properties!= NULL) + { + this->panel_Properties->Hide(); + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Destroy(); + this->panel_Properties = NULL; + } + //set new view + auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); + this->panel_Properties = description; + auiManager.Update(); + + break; + } event.Skip(); } -//Help Menu -void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event) +void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event) { - std::cerr << "Event OnMenuHelp not implemented" << std::endl; - event.Skip(); + //std::cout << "element " << event.GetInt() << std::endl; + modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData(); + this->tree_Projects->EnsureVisible(item->GetId()); + this->tree_Projects->SetItemBold(item->GetId(), true); + this->tree_Projects->SetItemTextColour(item->GetId(), wxColour(0,0,255)); + this->tree_Projects->SetItemBackgroundColour(item->GetId(), wxColour(230,230,255)); + this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); + auiManager.Update(); } -void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event) + +void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event) { - std::cerr << "Event OnMenuReportBug not implemented" << std::endl; - event.Skip(); + modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData(); + this->tree_Projects->SetItemBold(item->GetId(), false); + this->tree_Projects->SetItemTextColour(item->GetId(), wxColour(0,0,0)); + this->tree_Projects->SetItemBackgroundColour(item->GetId(), wxColour(255,255,255)); + this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); + auiManager.Update(); } -void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event) + +void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event) { - std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl; - event.Skip(); + this->help = !this->help; + this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help); } -void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event) + +void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event) { - std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl; - event.Skip(); + if (event.GetInt()) + this->help = false; + else + this->help = true; + + this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help); }