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 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
181 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
182 actionsPanelSizer->Add(libMgrbt, 0, wxALL, 5);
185 // show only if there is a appli folder
186 if(this->project->GetAppli() != NULL)
188 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager"));
189 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."));
190 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
191 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
192 actionsPanelSizer->Add(appliMgrbt, 0, wxALL, 5);
194 // edit CMakeLists file
195 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
196 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
197 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
198 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
199 actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
201 //SetPanel sizer and box
202 actionsPanel->SetSizer(actionsPanelSizer);
203 actionsPanelSizer->Fit(actionsPanel);
204 actionsBox->Add(actionsPanel, 0, wxALL, 5);
205 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
209 this->SetSizer(sizer);
210 sizer->SetSizeHints(this);
213 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
215 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
217 newEvent->SetString(wxT("manage_packages"));
218 newEvent->SetInt(this->project->GetId());
219 wxPostEvent(this->GetParent(), *newEvent);
223 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
225 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
227 newEvent->SetString(wxT("manage_libraries"));
228 wxPostEvent(this->GetParent(), *newEvent);
230 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
232 if(this->project->GetLib() != NULL)
234 int CMId = this->project->GetLib()->GetId();
235 newEvent1->SetInt(CMId);
237 wxPostEvent(this->GetParent(), *newEvent1);
243 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
245 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
247 newEvent->SetString(wxT("manage_applications"));
248 wxPostEvent(this->GetParent(), *newEvent);
250 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
252 if(this->project->GetAppli() != NULL)
254 int CMId = this->project->GetAppli()->GetId();
255 newEvent1->SetInt(CMId);
257 wxPostEvent(this->GetParent(), *newEvent1);
263 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
266 if(!this->project->OpenCMakeListsFile(result))
267 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
269 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
271 if(this->project->GetCMakeLists() != NULL)
273 int CMId = this->project->GetCMakeLists()->GetId();
274 newEvent->SetInt(CMId);
276 wxPostEvent(this->GetParent(), *newEvent);
281 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
283 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
284 if(dialog->ShowModal())
287 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
288 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
290 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
294 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
297 if(!this->project->OpenInFileExplorer(result))
298 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
301 void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
303 //TODO: implement method
304 std::cerr << "Event OnBtnSetVersion not implemented" << std::endl;
308 wxString libraryName = wxGetTextFromUser(
309 wxT("Enter the new version name"),
310 wxT("New Library - creaDevManager"),
311 crea::std2wx(this->project->GetVersion())
314 std::vector<std::string> parts;
315 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
316 if(parts.size() == 3)
319 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
320 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
324 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);
326 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
327 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
331 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
333 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
335 if(this->project->GetCMakeLists() != NULL)
337 int CMId = this->project->GetCMakeLists()->GetId();
338 newEvent->SetInt(CMId);
340 wxPostEvent(this->GetParent(), *newEvent);
345 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
347 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
349 if(this->project->GetCMakeLists() != NULL)
351 int CMId = this->project->GetCMakeLists()->GetId();
352 newEvent->SetInt(CMId);
354 wxPostEvent(this->GetParent(), *newEvent);
359 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
361 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
362 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
363 if(this->project->GetAppli() != NULL)
365 int AppId = this->project->GetAppli()->GetId();
366 newEvent->SetInt(AppId);
368 wxPostEvent(this->GetParent(), *newEvent);
373 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
375 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
377 if(this->project->GetAppli() != NULL)
379 int AppId = this->project->GetAppli()->GetId();
380 newEvent->SetInt(AppId);
382 wxPostEvent(this->GetParent(), *newEvent);
387 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
389 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
391 if(this->project->GetLib() != NULL)
393 int LbId = this->project->GetLib()->GetId();
394 newEvent->SetInt(LbId);
396 wxPostEvent(this->GetParent(), *newEvent);
401 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
403 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
405 if(this->project->GetLib() != NULL)
407 int LbId = this->project->GetLib()->GetId();
408 newEvent->SetInt(LbId);
410 wxPostEvent(this->GetParent(), *newEvent);