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"
39 #include "wxCDMProjectConfigurationDialog.h"
41 #include "wxCDMProjectHelpDialog.h"
43 #include "creaDevManagerIds.h"
44 #include "images/PrIcon64.xpm"
45 #include "CDMUtilities.h"
47 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
48 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
49 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageLibraries)
50 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
51 EVT_BUTTON(ID_BUTTON_CHOOSE, wxCDMProjectDescriptionPanel::OnBtnConfigProject)
52 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
53 EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
54 EVT_BUTTON(ID_BUTTON_OPEN_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnOpenBuild)
55 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
56 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
59 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
61 modelCDMProject* project,
63 const wxString& caption,
69 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
72 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
76 bool wxCDMProjectDescriptionPanel::Create(
78 modelCDMProject* project,
80 const wxString& caption,
86 wxPanel::Create(parent, id, pos, size, style);
87 this->project = project;
89 // this part makes the scrollbars show up
90 this->FitInside(); // ask the sizer about the needed size
91 this->SetScrollRate(5, 5);
95 void wxCDMProjectDescriptionPanel::CreateControls()
97 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
100 wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
103 headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
104 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
106 textSizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_LEFT, 0);
108 textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_LEFT, 0);
109 headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
111 sizer->Add(headerSizer, 0, wxALIGN_CENTER);
116 //----------------------------------Project Properties-----------------------------------
117 //properties StaticBoxSizer
118 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
120 wxPanel* propertiesPanel = new wxPanel(this);
122 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
123 //propertiesGrid Sizer
124 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
125 //properties elements
127 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
128 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
129 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
130 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
133 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
134 this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
135 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
136 pVersionbt->SetToolTip(wxT("Update the version of the project."));
137 pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER, 1);
138 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
140 this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
142 wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
143 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
144 pSourceLocationtc->SetMaxSize(wxSize(200,-1));
145 wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
146 pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
147 pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
148 pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
150 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
151 this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
152 this->buildPathtc->SetMaxSize(wxSize(200,-1));
154 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose..."));
155 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
157 wxButton* pBuildOpenbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_BUILD_PATH, wxT("Open"));
158 pBuildOpenbt->SetToolTip(wxT("Open the binaries folder in the file explorer."));
160 pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
161 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
162 pBuildLocationsz->Add(pBuildOpenbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
164 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
165 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
166 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
167 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
168 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
169 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
170 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
171 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
173 propertiesGridSizer->AddGrowableCol(1,1);
175 propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5);
177 //SetPanel sizer and box
178 propertiesPanel->SetSizer(propertiesPanelSizer);
179 propertiesPanelSizer->Fit(propertiesPanel);
180 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
181 sizer->Add(propertiesBox, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
183 //----------------------------------Project Actions--------------------------------------
184 //actions StaticBoxSizer
185 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
186 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."));
188 wxPanel* actionsPanel = new wxPanel(this);
190 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
193 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(3, 2, 9, 15);
196 // show only if there is a lib folder
197 if(this->project->GetLib() != NULL)
199 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("A. Library Manager"));
200 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."));
201 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
202 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
203 actionsGridSizer->Add(libMgrbt, 1, wxALL | wxEXPAND, 5);
206 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("B. Package Manager"));
207 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
208 actionsGridSizer->Add(packageMgrbt, 1, wxALL | wxEXPAND, 5);
211 // show only if there is a appli folder
212 if(this->project->GetAppli() != NULL)
214 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("C. Application Manager"));
215 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."));
216 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
217 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
218 actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
220 // edit 3rd Party libraries
221 wxButton* configPrjbt = new wxButton(actionsPanel, ID_BUTTON_CHOOSE, _T("D. 3rd Party Libraries Manager"));
222 configPrjbt->SetToolTip(wxT("Select which third party libraries will be used in this project."));
223 actionsGridSizer->Add(configPrjbt, 1, wxALL | wxEXPAND, 5);
225 // edit CMakeLists file
226 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
227 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
228 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
229 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
230 actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
232 actionsGridSizer->AddGrowableCol(0,1);
233 actionsGridSizer->AddGrowableCol(1,1);
235 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
236 //SetPanel sizer and box
237 actionsPanel->SetSizer(actionsPanelSizer);
238 actionsPanelSizer->Fit(actionsPanel);
239 actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
240 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
244 this->SetSizer(sizer);
245 sizer->SetSizeHints(this);
247 if(((wxCDMMainFrame*)this->GetParent())->isHelp())
249 wxCDMProjectHelpDialog* helpDialog = new wxCDMProjectHelpDialog(this->GetParent(), this->project, wxID_ANY);
250 helpDialog->Show(true);
254 modelCDMProject* wxCDMProjectDescriptionPanel::GetProject() const
256 return this->project;
259 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
261 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
263 newEvent->SetString(wxT("manage_packages"));
264 newEvent->SetClientData(this->project);
265 wxPostEvent(this->GetParent(), *newEvent);
269 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
271 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
273 newEvent->SetString(wxT("manage_libraries"));
274 wxPostEvent(this->GetParent(), *newEvent);
276 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
278 if(this->project->GetLib() != NULL)
280 newEvent1->SetClientData(this->project->GetLib());
282 wxPostEvent(this->GetParent(), *newEvent1);
288 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
290 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
292 newEvent->SetString(wxT("manage_applications"));
293 wxPostEvent(this->GetParent(), *newEvent);
295 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
297 if(this->project->GetAppli() != NULL)
299 newEvent1->SetClientData(this->project->GetAppli());
301 wxPostEvent(this->GetParent(), *newEvent1);
307 void wxCDMProjectDescriptionPanel::OnBtnConfigProject(wxCommandEvent& event)
309 wxCDMProjectConfigurationDialog* dialog = new wxCDMProjectConfigurationDialog(this,this->project);
311 userResponse = dialog->ShowModal();
314 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
317 if(!this->project->OpenCMakeListsFile(result))
318 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
320 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
322 if(this->project->GetCMakeLists() != NULL)
324 newEvent->SetClientData(this->project->GetCMakeLists());
326 wxPostEvent(this->GetParent(), *newEvent);
330 void wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
332 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
333 if(dialog->ShowModal())
336 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
337 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
339 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
342 void wxCDMProjectDescriptionPanel::OnBtnOpenBuild(wxCommandEvent& event)
344 if(CDMUtilities::openFileExplorer(this->project->GetBuildPath()))
345 wxMessageBox(crea::std2wx("The folder doesn't exist or hasn't yet been created."),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
348 void wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
351 if(!this->project->OpenInFileExplorer(result))
352 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
355 void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
358 wxString libraryName = wxGetTextFromUser(
359 wxT("Enter the new version name"),
360 wxT("Change Project Version - creaDevManager"),
361 crea::std2wx(this->project->GetVersion())
364 std::vector<std::string> parts;
365 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
366 if(parts.size() == 3)
369 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
370 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
374 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);
376 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
377 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
381 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
383 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
385 if(this->project->GetCMakeLists() != NULL)
387 newEvent->SetClientData(this->project->GetCMakeLists());
389 wxPostEvent(this->GetParent(), *newEvent);
394 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
396 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
398 if(this->project->GetCMakeLists() != NULL)
400 newEvent->SetClientData(this->project->GetCMakeLists());
402 wxPostEvent(this->GetParent(), *newEvent);
407 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
409 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
410 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
411 if(this->project->GetAppli() != NULL)
413 newEvent->SetClientData(this->project->GetAppli());
415 wxPostEvent(this->GetParent(), *newEvent);
420 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
422 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
424 if(this->project->GetAppli() != NULL)
426 newEvent->SetClientData(this->project->GetAppli());
428 wxPostEvent(this->GetParent(), *newEvent);
433 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
435 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
437 if(this->project->GetLib() != NULL)
439 newEvent->SetClientData(this->project->GetLib());
441 wxPostEvent(this->GetParent(), *newEvent);
446 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
448 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
450 if(this->project->GetLib() != NULL)
452 newEvent->SetClientData(this->project->GetLib());
454 wxPostEvent(this->GetParent(), *newEvent);