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 * wxCDMProjectDescriptionPanel.cpp
31 * Created on: Nov 27, 2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "wxCDMProjectDescriptionPanel.h"
37 #include "wxCDMMainFrame.h"
38 #include "wxCDMNewPackageDialog.h"
40 #include "creaDevManagerIds.h"
41 #include "images/PrIcon64.xpm"
43 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
44 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
45 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageLibraries)
46 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
47 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
51 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
53 modelCDMProject* project,
55 const wxString& caption,
61 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
64 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
68 bool wxCDMProjectDescriptionPanel::Create(
70 modelCDMProject* project,
72 const wxString& caption,
78 wxPanel::Create(parent, id, pos, size, style);
79 this->project = project;
84 void wxCDMProjectDescriptionPanel::CreateControls()
86 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
89 sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
92 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
95 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
98 wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
99 wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL);
101 wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
103 wxStaticText* pVersion = new wxStaticText(this, -1, wxT("Version"));
104 wxStaticText* pVersionDate = new wxStaticText(this, -1, wxT("Version Date"));
105 wxStaticText* pSourceLocation = new wxStaticText(this, -1, wxT("Source Location"));
106 wxStaticText* pBuildLocation = new wxStaticText(this, -1, wxT("Build Location"));
108 wxStaticText* pVersiontc = new wxStaticText(this, -1, crea::std2wx(this->project->GetVersion()));
109 wxStaticText* pVersionDatetc = new wxStaticText(this, -1, crea::std2wx(this->project->GetVersionDate()));
110 wxStaticText* pSourceLocationtc = new wxStaticText(this, -1, crea::std2wx(this->project->GetPath()));
111 wxStaticText* pBuildLocationtc = new wxStaticText(this, -1, crea::std2wx(this->project->GetBuildPath()));
113 wxButton* pVersionbt = new wxButton(this, ID_BUTTON_SET_VERSION, wxT("Set"));
114 wxButton* pBuildLocationbt = new wxButton(this, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
116 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
117 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
119 pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
120 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
121 pBuildLocationsz->Add(pBuildLocationtc, 0, wxALIGN_CENTER, 0);
122 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
124 flexGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
125 flexGridSizer->Add(pVersionsz, 1, wxEXPAND);
126 flexGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
127 flexGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
128 flexGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
129 flexGridSizer->Add(pSourceLocationtc, 1, wxEXPAND);
130 flexGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
131 flexGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
133 flexGridSizer->AddGrowableCol(1,1);
135 propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxALL | wxEXPAND, 5);
136 sizer -> Add(propertiesBoxInnerSizer, 0, wxEXPAND | wxALL, 10);
139 wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
140 wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxHORIZONTAL);
141 sizer -> Add(actionsBoxInnerSizer, 0, wxEXPAND | wxALL, 10);
143 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager")), 0, wxALL, 5);
144 //TODO: show only if there is a lib folder
145 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_GOTO_LIB_MANAGER, _T("Library Manager")), 0, wxALL, 5);
146 //TODO: show only if there is a appli folder
147 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager")), 0, wxALL, 5);
149 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxALL, 5);
152 actionsBoxInnerSizer->SetSizeHints(this);
155 sizer->SetSizeHints(this);
159 void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
162 wxString libraryName = wxGetTextFromUser(
163 _T("Enter the new library name"),
164 _T("New Library - creaDevManager"),
168 if(libraryName.Len() > 0)
172 modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
173 //check library created
176 wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
180 wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION);
182 //refreshing tree and description
183 //send event instead of calling parent to avoid crashing
185 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
187 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
188 newEvent->SetInt(library->GetId());
189 wxPostEvent(this->GetParent(), *newEvent);
194 void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
197 wxString applicationName = wxGetTextFromUser(
198 _T("Enter the new application name"),
199 _T("New Application - creaDevManager"),
203 if(applicationName.Len() > 0)
207 modelCDMIProjectTreeNode* application = this->project->CreateApplication(crea::wx2std(applicationName),result);
208 //check library created
209 if(application == NULL)
211 wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR);
215 wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - Success!"),wxOK | wxICON_INFORMATION);
217 //refreshing tree and description
218 //send event instead of calling parent to avoid crashing
220 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
222 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
223 newEvent->SetInt(application->GetId());
224 wxPostEvent(this->GetParent(), *newEvent);
229 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
231 //TODO: implement method
232 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
237 wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
239 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
241 newEvent->SetString(wxT("manage_packages"));
242 newEvent->SetInt(this->project->GetId());
243 wxPostEvent(this->GetParent(), *newEvent);
248 wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
250 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
252 newEvent->SetString(wxT("manage_libraries"));
253 //TODO: implement GetLib in project
254 //newEvent->SetInt(this->project->GetLib()->GetId());
255 wxPostEvent(this->GetParent(), *newEvent);
260 wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
262 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
264 newEvent->SetString(wxT("manage_applications"));
265 //TODO: implement GetAppli in project
266 //newEvent->SetInt(this->project->GetAppli->GetId());
267 wxPostEvent(this->GetParent(), *newEvent);