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"
42 #include "CDMUtilities.h"
44 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
45 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
46 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageLibraries)
47 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
48 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
49 EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
50 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
51 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
54 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
56 modelCDMProject* project,
58 const wxString& caption,
64 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
67 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
71 bool wxCDMProjectDescriptionPanel::Create(
73 modelCDMProject* project,
75 const wxString& caption,
81 wxPanel::Create(parent, id, pos, size, style);
82 this->project = project;
87 void wxCDMProjectDescriptionPanel::CreateControls()
89 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
92 sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
95 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
98 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
100 //----------------------------------Project Properties-----------------------------------
101 //properties StaticBoxSizer
102 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
104 wxPanel* propertiesPanel = new wxPanel(this);
106 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
107 //propertiesGrid Sizer
108 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
109 //properties elements
111 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
112 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
113 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
114 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
117 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
118 this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
119 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
120 pVersionbt->SetToolTip(wxT("Update the version of the project."));
121 pVersionsz->Add(this->versiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
122 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
124 this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
126 wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
127 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
128 pSourceLocationtc->SetMaxSize(wxSize(350,-1));
129 wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
130 pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
131 pSourceLocationsz->Add(pSourceLocationtc, 0, wxALIGN_CENTER, 0);
132 pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
134 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
135 this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
136 this->buildPathtc->SetMaxSize(wxSize(350,-1));
137 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
138 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
139 pBuildLocationsz->Add(this->buildPathtc, 0, wxALIGN_CENTER, 0);
140 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
142 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
143 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
144 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
145 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
146 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
147 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
148 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
149 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
151 propertiesGridSizer->AddGrowableCol(1,1);
153 propertiesPanelSizer-> Add(propertiesGridSizer, 0, wxALL | wxEXPAND, 5);
155 //SetPanel sizer and box
156 propertiesPanel->SetSizer(propertiesPanelSizer);
157 propertiesPanelSizer->Fit(propertiesPanel);
158 propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
159 sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
161 //----------------------------------Project Actions--------------------------------------
162 //actions StaticBoxSizer
163 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
164 actionsBox->GetStaticBox()->SetToolTip(wxT("Go to any of the content managers of the project or edit the project's CMakeLists.txt file by selecting any of the available actions."));
166 wxPanel* actionsPanel = new wxPanel(this);
168 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
171 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager"));
172 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
173 actionsPanelSizer->Add(packageMgrbt, 0, wxALL, 5);
175 // show only if there is a lib folder
176 if(this->project->GetLib() != NULL)
178 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("Library Manager"));
179 libMgrbt->SetToolTip(wxT("Find the current available libraries into this project. You can also create new Libraries in this section as well as edit the lib folder's CMakeLists.txt file."));
180 actionsPanelSizer->Add(libMgrbt, 0, wxALL, 5);
183 // show only if there is a appli folder
184 if(this->project->GetAppli() != NULL)
186 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager"));
187 appliMgrbt->SetToolTip(wxT("Find the current available applications into this project. You can also create new Applications in this section as well as edit the appli folder's CMakeLists.txt file."));
188 actionsPanelSizer->Add(appliMgrbt, 0, wxALL, 5);
190 // edit CMakeLists file
191 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
192 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
193 actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
195 //SetPanel sizer and box
196 actionsPanel->SetSizer(actionsPanelSizer);
197 actionsPanelSizer->Fit(actionsPanel);
198 actionsBox->Add(actionsPanel, 0, wxALL, 5);
199 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
203 this->SetSizer(sizer);
204 sizer->SetSizeHints(this);
207 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
209 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
211 newEvent->SetString(wxT("manage_packages"));
212 newEvent->SetInt(this->project->GetId());
213 wxPostEvent(this->GetParent(), *newEvent);
217 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
219 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
221 newEvent->SetString(wxT("manage_libraries"));
222 wxPostEvent(this->GetParent(), *newEvent);
226 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
228 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
230 newEvent->SetString(wxT("manage_applications"));
231 wxPostEvent(this->GetParent(), *newEvent);
235 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
238 if(!this->project->OpenCMakeListsFile(result))
239 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
243 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
245 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
246 if(dialog->ShowModal())
249 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
250 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
252 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
256 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
259 if(!this->project->OpenInFileExplorer(result))
260 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
264 wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
266 //TODO: implement method
267 std::cerr << "Event OnBtnSetVersion not implemented" << std::endl;
271 wxString libraryName = wxGetTextFromUser(
272 wxT("Enter the new version name"),
273 wxT("New Library - creaDevManager"),
274 crea::std2wx(this->project->GetVersion())
277 std::vector<std::string> parts;
278 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
279 if(parts.size() == 3)
282 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
283 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
287 wxMessageBox(crea::std2wx("The version format is incorrect, please follow the following format:\nX.Y.Z\nX: Major Version\nY: Minor Version\nZ: Build Version"),_T("Set Project Version - Error!"),wxOK | wxICON_ERROR);
289 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
290 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));