From a368f55c1759058cb8ad47da779394670f1f1fb2 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Tue, 27 Nov 2012 10:53:38 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation Project description panel created --- lib/creaDevManagerLib/modelCDMMain.cpp | 37 ++++++++-- lib/creaDevManagerLib/wxCDMMainFrame.cpp | 29 +++++++- lib/creaDevManagerLib/wxCDMMainFrame.h | 4 ++ .../wxCDMProjectDescriptionPanel.cpp | 66 +++++++++++++++++ .../wxCDMProjectDescriptionPanel.h | 70 +++++++++++++++++++ 5 files changed, 199 insertions(+), 7 deletions(-) create mode 100644 lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp create mode 100644 lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h diff --git a/lib/creaDevManagerLib/modelCDMMain.cpp b/lib/creaDevManagerLib/modelCDMMain.cpp index 25331dc..b3c381f 100644 --- a/lib/creaDevManagerLib/modelCDMMain.cpp +++ b/lib/creaDevManagerLib/modelCDMMain.cpp @@ -133,6 +133,11 @@ bool modelCDMMain::CreateProject( //std::cout << "executing " << add << std::endl; system(add.c_str()); + if(this->project != NULL) + { + if (!CloseProject(result)) + return false; + } this->project = new modelCDMProject(nomDirectory); @@ -216,6 +221,12 @@ bool modelCDMMain::OpenProject( //if is source folder if(isSource) { + if(this->project != NULL) + { + if (!CloseProject(result)) + return false; + } + std::cout << "Project sources at: " << pathSource << std::endl; if(isBinary) { @@ -240,14 +251,32 @@ bool modelCDMMain::RefreshProject( std::string*& result ) { - //TODO: recreate the project using the project's path - return true; + //recreate the project using the project's path + if (this->project != NULL) + { + return this->project->Refresh(result); + } + else + { + result = new std::string("There is no open project."); + return false; + } } bool modelCDMMain::CloseProject( std::string*& result ) { - //TODO: delete the project tree and leave it as NULL - return true; + //delete the project tree and leave it as NULL + if (this->project != NULL) + { + delete this->project; + this->project = NULL; + return true; + } + else + { + result = new std::string("There is no open project."); + return false; + } } diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index ad645b9..775cfc7 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -31,6 +31,7 @@ #include #include +#include "wx/treectrl.h" #include "CDMUtilities.h" #include "creaDevManagerIds.h" @@ -65,6 +66,7 @@ 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) END_EVENT_TABLE() wxCDMMainFrame::wxCDMMainFrame( @@ -224,13 +226,18 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) result, crea::wx2std(dialog->GetPackageAuthor()), crea::wx2std(dialog->GetPackageDescription()) - )) + )) { wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; } //populate tree control tree_Projects->BuildTree(this->model->GetProject()); + tree_Projects->SelectItem(this->model->GetProject()->GetId()); + //TODO: change description panel + //TODO: change project's actions panel auiManager.Update(); wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION); @@ -261,6 +268,7 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) //populate tree control tree_Projects->BuildTree(this->model->GetProject()); + tree_Projects->SelectItem(this->model->GetProject()->GetId()); auiManager.Update(); } @@ -273,7 +281,11 @@ void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event) } void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) { - std::cerr << "Event OnMenuCloseProject not implemented" << std::endl; + std::string* result; + if(!this->model->CloseProject(result)) + { + wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR); + } event.Skip(); } void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event) @@ -296,7 +308,12 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) //Edit Menu void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event) { - std::cerr << "Event OnMenuRefreshProject not implemented" << std::endl; + std::string* result; + if(!model->RefreshProject(result)) + { + wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR); + } + //TODO: Show possible problems in CMakeLists files event.Skip(); } void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event) @@ -378,3 +395,9 @@ void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event) std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl; event.Skip(); } + +void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) +{ + std::cerr << "Event OnTreeSelectionChange not implemented" << std::endl; + event.Skip(); +} diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.h b/lib/creaDevManagerLib/wxCDMMainFrame.h index e2505eb..ff957d5 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.h +++ b/lib/creaDevManagerLib/wxCDMMainFrame.h @@ -31,6 +31,7 @@ #include #include +#include #include "wxCDMProjectsTreeCtrl.h" #include "modelCDMMain.h" @@ -112,6 +113,9 @@ protected: void OnMenuReportBug(wxCommandEvent& event); void OnMenuAboutCreaDevManager(wxCommandEvent& event); void OnMenuAboutCreatis(wxCommandEvent& event); + + //Tree + void OnTreeSelectionChanged(wxTreeEvent& event); }; #endif diff --git a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp new file mode 100644 index 0000000..0fadfeb --- /dev/null +++ b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp @@ -0,0 +1,66 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# 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, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# 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. +# ------------------------------------------------------------------------ +*/ + +/* + * wxCDMProjectDescriptionPanel.cpp + * + * Created on: Nov 27, 2012 + * Author: Daniel Felipe Gonzalez Obando + */ + +#include "wxCDMProjectDescriptionPanel.h" + +wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel( + wxWindow* parent, + wxWindowID id, + const wxString& + caption, + const wxPoint& pos, + const wxSize& size, + long style +) +{ +} + +wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel() +{ +} + +bool wxCDMProjectDescriptionPanel::Create( + wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style +) +{ +} + +void wxCDMProjectDescriptionPanel::CreateControls() +{ +} diff --git a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h new file mode 100644 index 0000000..e91dca0 --- /dev/null +++ b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h @@ -0,0 +1,70 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# 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, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# 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. +# ------------------------------------------------------------------------ + */ + +/* + * wxCDMProjectDescriptionPanel.h + * + * Created on: Nov 27, 2012 + * Author: Daniel Felipe Gonzalez Obando + */ + +#ifndef WXCDMPROJECTDESCRIPTIONPANEL_H_ +#define WXCDMPROJECTDESCRIPTIONPANEL_H_ + +#include +#include + +class wxCDMProjectDescriptionPanel : public wxPanel +{ +public: + wxCDMProjectDescriptionPanel( + wxWindow* parent, + wxWindowID id = -1, + const wxString& caption = _("Description Frame"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE + ); + + ~wxCDMProjectDescriptionPanel(); + + bool Create( + wxWindow* parent, + wxWindowID id = -1, + const wxString& caption = _("Description Frame"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE + ); + + void CreateControls(); + + //handlers +protected: +}; + +#endif /* WXCDMPROJECTDESCRIPTIONPANEL_H_ */ -- 2.45.1