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 part makes the scrollbars show up
85 this->FitInside(); // ask the sizer about the needed size
86 this->SetScrollRate(5, 5);
88 this->project = project;
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));
151 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
152 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
153 pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
154 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
156 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
157 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
158 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
159 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
160 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
161 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
162 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
163 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
165 propertiesGridSizer->AddGrowableCol(1,1);
167 propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5);
169 //SetPanel sizer and box
170 propertiesPanel->SetSizer(propertiesPanelSizer);
171 propertiesPanelSizer->Fit(propertiesPanel);
172 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
173 sizer->Add(propertiesBox, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
175 //----------------------------------Project Actions--------------------------------------
176 //actions StaticBoxSizer
177 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
178 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."));
180 wxPanel* actionsPanel = new wxPanel(this);
182 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
185 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
188 // show only if there is a lib folder
189 if(this->project->GetLib() != NULL)
191 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("A. Library Manager"));
192 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."));
193 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
194 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
195 actionsGridSizer->Add(libMgrbt, 1, wxALL | wxEXPAND, 5);
198 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("B. Package Manager"));
199 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
200 actionsGridSizer->Add(packageMgrbt, 1, wxALL | wxEXPAND, 5);
203 // show only if there is a appli folder
204 if(this->project->GetAppli() != NULL)
206 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("C. Application Manager"));
207 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."));
208 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
209 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
210 actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
212 // edit CMakeLists file
213 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
214 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
215 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
216 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
217 actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
219 actionsGridSizer->AddGrowableCol(0,1);
220 actionsGridSizer->AddGrowableCol(1,1);
222 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
223 //SetPanel sizer and box
224 actionsPanel->SetSizer(actionsPanelSizer);
225 actionsPanelSizer->Fit(actionsPanel);
226 actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
227 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
231 this->SetSizer(sizer);
232 sizer->SetSizeHints(this);
234 if(((wxCDMMainFrame*)this->GetParent())->isHelp())
236 wxCDMProjectHelpDialog* helpDialog = new wxCDMProjectHelpDialog(this->GetParent(), this->project, wxID_ANY);
237 helpDialog->Show(true);
241 modelCDMProject* wxCDMProjectDescriptionPanel::GetProject() const
243 return this->project;
246 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
248 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
250 newEvent->SetString(wxT("manage_packages"));
251 newEvent->SetClientData(this->project);
252 wxPostEvent(this->GetParent(), *newEvent);
256 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
258 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
260 newEvent->SetString(wxT("manage_libraries"));
261 wxPostEvent(this->GetParent(), *newEvent);
263 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
265 if(this->project->GetLib() != NULL)
267 newEvent1->SetClientData(this->project->GetLib());
269 wxPostEvent(this->GetParent(), *newEvent1);
275 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
277 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
279 newEvent->SetString(wxT("manage_applications"));
280 wxPostEvent(this->GetParent(), *newEvent);
282 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
284 if(this->project->GetAppli() != NULL)
286 newEvent1->SetClientData(this->project->GetAppli());
288 wxPostEvent(this->GetParent(), *newEvent1);
294 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
297 if(!this->project->OpenCMakeListsFile(result))
298 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
300 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
302 if(this->project->GetCMakeLists() != NULL)
304 newEvent->SetClientData(this->project->GetCMakeLists());
306 wxPostEvent(this->GetParent(), *newEvent);
311 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
313 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
314 if(dialog->ShowModal())
317 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
318 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
320 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
324 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
327 if(!this->project->OpenInFileExplorer(result))
328 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
331 void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
334 wxString libraryName = wxGetTextFromUser(
335 wxT("Enter the new version name"),
336 wxT("Change Project Version - creaDevManager"),
337 crea::std2wx(this->project->GetVersion())
340 std::vector<std::string> parts;
341 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
342 if(parts.size() == 3)
345 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
346 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
350 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);
352 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
353 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
357 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
359 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
361 if(this->project->GetCMakeLists() != NULL)
363 newEvent->SetClientData(this->project->GetCMakeLists());
365 wxPostEvent(this->GetParent(), *newEvent);
370 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
372 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
374 if(this->project->GetCMakeLists() != NULL)
376 newEvent->SetClientData(this->project->GetCMakeLists());
378 wxPostEvent(this->GetParent(), *newEvent);
383 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
385 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
386 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
387 if(this->project->GetAppli() != NULL)
389 newEvent->SetClientData(this->project->GetAppli());
391 wxPostEvent(this->GetParent(), *newEvent);
396 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
398 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
400 if(this->project->GetAppli() != NULL)
402 newEvent->SetClientData(this->project->GetAppli());
404 wxPostEvent(this->GetParent(), *newEvent);
409 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
411 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
413 if(this->project->GetLib() != NULL)
415 newEvent->SetClientData(this->project->GetLib());
417 wxPostEvent(this->GetParent(), *newEvent);
422 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
424 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
426 if(this->project->GetLib() != NULL)
428 newEvent->SetClientData(this->project->GetLib());
430 wxPostEvent(this->GetParent(), *newEvent);