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_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnOpenBuild)
53 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
54 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
57 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
59 modelCDMProject* project,
61 const wxString& caption,
67 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
70 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
74 bool wxCDMProjectDescriptionPanel::Create(
76 modelCDMProject* project,
78 const wxString& caption,
84 wxPanel::Create(parent, id, pos, size, style);
85 this->project = project;
87 // this part makes the scrollbars show up
88 this->FitInside(); // ask the sizer about the needed size
89 this->SetScrollRate(5, 5);
93 void wxCDMProjectDescriptionPanel::CreateControls()
95 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
98 wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
101 headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
102 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
104 textSizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_LEFT, 0);
106 textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_LEFT, 0);
107 headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
109 sizer->Add(headerSizer, 0, wxALIGN_CENTER);
114 //----------------------------------Project Properties-----------------------------------
115 //properties StaticBoxSizer
116 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
118 wxPanel* propertiesPanel = new wxPanel(this);
120 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
121 //propertiesGrid Sizer
122 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
123 //properties elements
125 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
126 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
127 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
128 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
131 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
132 this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
133 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
134 pVersionbt->SetToolTip(wxT("Update the version of the project."));
135 pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER, 1);
136 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
138 this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
140 wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
141 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
142 pSourceLocationtc->SetMaxSize(wxSize(200,-1));
143 wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
144 pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
145 pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
146 pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
148 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
149 this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
150 this->buildPathtc->SetMaxSize(wxSize(200,-1));
152 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose..."));
153 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
155 wxButton* pBuildOpenbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_BUILD_PATH, wxT("Open"));
156 pBuildOpenbt->SetToolTip(wxT("Open the binaries folder in the file explorer."));
158 pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
159 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
160 pBuildLocationsz->Add(pBuildOpenbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
162 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
163 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
164 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
165 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
166 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
167 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
168 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
169 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
171 propertiesGridSizer->AddGrowableCol(1,1);
173 propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5);
175 //SetPanel sizer and box
176 propertiesPanel->SetSizer(propertiesPanelSizer);
177 propertiesPanelSizer->Fit(propertiesPanel);
178 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
179 sizer->Add(propertiesBox, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
181 //----------------------------------Project Actions--------------------------------------
182 //actions StaticBoxSizer
183 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
184 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."));
186 wxPanel* actionsPanel = new wxPanel(this);
188 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
191 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
194 // show only if there is a lib folder
195 if(this->project->GetLib() != NULL)
197 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("A. Library Manager"));
198 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."));
199 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
200 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
201 actionsGridSizer->Add(libMgrbt, 1, wxALL | wxEXPAND, 5);
204 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("B. Package Manager"));
205 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
206 actionsGridSizer->Add(packageMgrbt, 1, wxALL | wxEXPAND, 5);
209 // show only if there is a appli folder
210 if(this->project->GetAppli() != NULL)
212 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("C. Application Manager"));
213 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."));
214 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
215 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
216 actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
218 // edit CMakeLists file
219 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
220 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
221 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
222 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
223 actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
225 actionsGridSizer->AddGrowableCol(0,1);
226 actionsGridSizer->AddGrowableCol(1,1);
228 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
229 //SetPanel sizer and box
230 actionsPanel->SetSizer(actionsPanelSizer);
231 actionsPanelSizer->Fit(actionsPanel);
232 actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
233 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
237 this->SetSizer(sizer);
238 sizer->SetSizeHints(this);
240 if(((wxCDMMainFrame*)this->GetParent())->isHelp())
242 wxCDMProjectHelpDialog* helpDialog = new wxCDMProjectHelpDialog(this->GetParent(), this->project, wxID_ANY);
243 helpDialog->Show(true);
247 modelCDMProject* wxCDMProjectDescriptionPanel::GetProject() const
249 return this->project;
252 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
254 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
256 newEvent->SetString(wxT("manage_packages"));
257 newEvent->SetClientData(this->project);
258 wxPostEvent(this->GetParent(), *newEvent);
262 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
264 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
266 newEvent->SetString(wxT("manage_libraries"));
267 wxPostEvent(this->GetParent(), *newEvent);
269 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
271 if(this->project->GetLib() != NULL)
273 newEvent1->SetClientData(this->project->GetLib());
275 wxPostEvent(this->GetParent(), *newEvent1);
281 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
283 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
285 newEvent->SetString(wxT("manage_applications"));
286 wxPostEvent(this->GetParent(), *newEvent);
288 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
290 if(this->project->GetAppli() != NULL)
292 newEvent1->SetClientData(this->project->GetAppli());
294 wxPostEvent(this->GetParent(), *newEvent1);
300 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
303 if(!this->project->OpenCMakeListsFile(result))
304 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
306 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
308 if(this->project->GetCMakeLists() != NULL)
310 newEvent->SetClientData(this->project->GetCMakeLists());
312 wxPostEvent(this->GetParent(), *newEvent);
316 void wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
318 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
319 if(dialog->ShowModal())
322 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
323 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
325 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
328 void wxCDMProjectDescriptionPanel::OnBtnOpenBuild(wxCommandEvent& event)
330 if(CDMUtilities::openFileExplorer(this->project->GetBuildPath()))
331 wxMessageBox(crea::std2wx("The folder doesn't exist or hasn't yet been created."),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
334 void wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
337 if(!this->project->OpenInFileExplorer(result))
338 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
341 void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
344 wxString libraryName = wxGetTextFromUser(
345 wxT("Enter the new version name"),
346 wxT("Change Project Version - creaDevManager"),
347 crea::std2wx(this->project->GetVersion())
350 std::vector<std::string> parts;
351 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
352 if(parts.size() == 3)
355 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
356 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
360 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);
362 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
363 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
367 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
369 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
371 if(this->project->GetCMakeLists() != NULL)
373 newEvent->SetClientData(this->project->GetCMakeLists());
375 wxPostEvent(this->GetParent(), *newEvent);
380 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
382 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
384 if(this->project->GetCMakeLists() != NULL)
386 newEvent->SetClientData(this->project->GetCMakeLists());
388 wxPostEvent(this->GetParent(), *newEvent);
393 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
395 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
396 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
397 if(this->project->GetAppli() != NULL)
399 newEvent->SetClientData(this->project->GetAppli());
401 wxPostEvent(this->GetParent(), *newEvent);
406 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
408 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
410 if(this->project->GetAppli() != NULL)
412 newEvent->SetClientData(this->project->GetAppli());
414 wxPostEvent(this->GetParent(), *newEvent);
419 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
421 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
423 if(this->project->GetLib() != NULL)
425 newEvent->SetClientData(this->project->GetLib());
427 wxPostEvent(this->GetParent(), *newEvent);
432 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
434 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
436 if(this->project->GetLib() != NULL)
438 newEvent->SetClientData(this->project->GetLib());
440 wxPostEvent(this->GetParent(), *newEvent);