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 "wxCDMProjectHelpDialog.h"
42 #include "creaDevManagerIds.h"
43 #include "images/PrIcon64.xpm"
44 #include "CDMUtilities.h"
46 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
47 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
48 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageLibraries)
49 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
50 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
51 EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
52 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
53 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
56 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
58 modelCDMProject* project,
60 const wxString& caption,
66 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
69 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
73 bool wxCDMProjectDescriptionPanel::Create(
75 modelCDMProject* project,
77 const wxString& caption,
83 wxPanel::Create(parent, id, pos, size, style);
84 this->project = project;
89 void wxCDMProjectDescriptionPanel::CreateControls()
91 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
94 wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
97 headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
98 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
100 textSizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_LEFT, 0);
102 textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_LEFT, 0);
103 headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
105 sizer->Add(headerSizer, 0, wxALIGN_CENTER);
110 //----------------------------------Project Properties-----------------------------------
111 //properties StaticBoxSizer
112 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
114 wxPanel* propertiesPanel = new wxPanel(this);
116 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
117 //propertiesGrid Sizer
118 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
119 //properties elements
121 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
122 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
123 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
124 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
127 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
128 this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
129 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
130 pVersionbt->SetToolTip(wxT("Update the version of the project."));
131 pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER, 1);
132 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
134 this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
136 wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
137 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
138 //pSourceLocationtc->SetMaxSize(wxSize(350,-1));
139 wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
140 pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
141 pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
142 pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
144 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
145 this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
146 //this->buildPathtc->SetMaxSize(wxSize(350,-1));
147 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
148 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
149 pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
150 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
152 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
153 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
154 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
155 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
156 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
157 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
158 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
159 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
161 propertiesGridSizer->AddGrowableCol(1,1);
163 propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5);
165 //SetPanel sizer and box
166 propertiesPanel->SetSizer(propertiesPanelSizer);
167 propertiesPanelSizer->Fit(propertiesPanel);
168 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
169 sizer->Add(propertiesBox, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
171 //----------------------------------Project Actions--------------------------------------
172 //actions StaticBoxSizer
173 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
174 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."));
176 wxPanel* actionsPanel = new wxPanel(this);
178 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
181 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
184 // show only if there is a lib folder
185 if(this->project->GetLib() != NULL)
187 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("A. Library Manager"));
188 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."));
189 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
190 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
191 actionsGridSizer->Add(libMgrbt, 1, wxALL | wxEXPAND, 5);
194 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("B. Package Manager"));
195 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
196 actionsGridSizer->Add(packageMgrbt, 1, wxALL | wxEXPAND, 5);
199 // show only if there is a appli folder
200 if(this->project->GetAppli() != NULL)
202 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("C. Application Manager"));
203 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."));
204 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
205 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
206 actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
208 // edit CMakeLists file
209 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("D. Edit CMakeLists File"));
210 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
211 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
212 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
213 actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
215 actionsGridSizer->AddGrowableCol(0,1);
216 actionsGridSizer->AddGrowableCol(1,1);
218 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
219 //SetPanel sizer and box
220 actionsPanel->SetSizer(actionsPanelSizer);
221 actionsPanelSizer->Fit(actionsPanel);
222 actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
223 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
227 this->SetSizer(sizer);
228 sizer->SetSizeHints(this);
230 if(((wxCDMMainFrame*)this->GetParent())->isHelp())
232 wxCDMProjectHelpDialog* helpDialog = new wxCDMProjectHelpDialog(this->GetParent(), this->project, wxID_ANY);
233 helpDialog->Show(true);
237 modelCDMProject* wxCDMProjectDescriptionPanel::GetProject() const
239 return this->project;
242 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
244 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
246 newEvent->SetString(wxT("manage_packages"));
247 newEvent->SetInt(this->project->GetId());
248 wxPostEvent(this->GetParent(), *newEvent);
252 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
254 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
256 newEvent->SetString(wxT("manage_libraries"));
257 wxPostEvent(this->GetParent(), *newEvent);
259 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
261 if(this->project->GetLib() != NULL)
263 int CMId = this->project->GetLib()->GetId();
264 newEvent1->SetInt(CMId);
266 wxPostEvent(this->GetParent(), *newEvent1);
272 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
274 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
276 newEvent->SetString(wxT("manage_applications"));
277 wxPostEvent(this->GetParent(), *newEvent);
279 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
281 if(this->project->GetAppli() != NULL)
283 int CMId = this->project->GetAppli()->GetId();
284 newEvent1->SetInt(CMId);
286 wxPostEvent(this->GetParent(), *newEvent1);
292 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
295 if(!this->project->OpenCMakeListsFile(result))
296 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
298 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
300 if(this->project->GetCMakeLists() != NULL)
302 int CMId = this->project->GetCMakeLists()->GetId();
303 newEvent->SetInt(CMId);
305 wxPostEvent(this->GetParent(), *newEvent);
310 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
312 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
313 if(dialog->ShowModal())
316 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
317 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
319 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
323 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
326 if(!this->project->OpenInFileExplorer(result))
327 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
330 void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
333 wxString libraryName = wxGetTextFromUser(
334 wxT("Enter the new version name"),
335 wxT("Change Project Version - creaDevManager"),
336 crea::std2wx(this->project->GetVersion())
339 std::vector<std::string> parts;
340 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
341 if(parts.size() == 3)
344 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
345 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
349 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);
351 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
352 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
356 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
358 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
360 if(this->project->GetCMakeLists() != NULL)
362 int CMId = this->project->GetCMakeLists()->GetId();
363 newEvent->SetInt(CMId);
365 wxPostEvent(this->GetParent(), *newEvent);
370 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
372 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
374 if(this->project->GetCMakeLists() != NULL)
376 int CMId = this->project->GetCMakeLists()->GetId();
377 newEvent->SetInt(CMId);
379 wxPostEvent(this->GetParent(), *newEvent);
384 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
386 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
387 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
388 if(this->project->GetAppli() != NULL)
390 int AppId = this->project->GetAppli()->GetId();
391 newEvent->SetInt(AppId);
393 wxPostEvent(this->GetParent(), *newEvent);
398 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
400 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
402 if(this->project->GetAppli() != NULL)
404 int AppId = this->project->GetAppli()->GetId();
405 newEvent->SetInt(AppId);
407 wxPostEvent(this->GetParent(), *newEvent);
412 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
414 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
416 if(this->project->GetLib() != NULL)
418 int LbId = this->project->GetLib()->GetId();
419 newEvent->SetInt(LbId);
421 wxPostEvent(this->GetParent(), *newEvent);
426 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
428 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
430 if(this->project->GetLib() != NULL)
432 int LbId = this->project->GetLib()->GetId();
433 newEvent->SetInt(LbId);
435 wxPostEvent(this->GetParent(), *newEvent);