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 sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
97 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
100 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
102 //----------------------------------Project Properties-----------------------------------
103 //properties StaticBoxSizer
104 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
106 wxPanel* propertiesPanel = new wxPanel(this);
108 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
109 //propertiesGrid Sizer
110 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
111 //properties elements
113 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
114 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
115 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
116 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
119 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
120 this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
121 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
122 pVersionbt->SetToolTip(wxT("Update the version of the project."));
123 pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER, 1);
124 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
126 this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
128 wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
129 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
130 //pSourceLocationtc->SetMaxSize(wxSize(350,-1));
131 wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
132 pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
133 pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
134 pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
136 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
137 this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
138 //this->buildPathtc->SetMaxSize(wxSize(350,-1));
139 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
140 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
141 pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
142 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
144 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
145 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
146 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
147 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
148 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
149 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
150 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
151 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
153 propertiesGridSizer->AddGrowableCol(1,1);
155 propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5);
157 //SetPanel sizer and box
158 propertiesPanel->SetSizer(propertiesPanelSizer);
159 propertiesPanelSizer->Fit(propertiesPanel);
160 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
161 sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
163 //----------------------------------Project Actions--------------------------------------
164 //actions StaticBoxSizer
165 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
166 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."));
168 wxPanel* actionsPanel = new wxPanel(this);
170 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
173 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager"));
174 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
175 actionsPanelSizer->Add(packageMgrbt, 1, wxALL, 5);
177 // show only if there is a lib folder
178 if(this->project->GetLib() != NULL)
180 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("Library Manager"));
181 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."));
182 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
183 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
184 actionsPanelSizer->Add(libMgrbt, 1, wxALL, 5);
187 // show only if there is a appli folder
188 if(this->project->GetAppli() != NULL)
190 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager"));
191 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."));
192 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
193 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
194 actionsPanelSizer->Add(appliMgrbt, 1, wxALL, 5);
196 // edit CMakeLists file
197 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
198 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
199 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
200 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
201 actionsPanelSizer->Add(editCMakebt, 1, wxALL, 5);
203 //SetPanel sizer and box
204 actionsPanel->SetSizer(actionsPanelSizer);
205 actionsPanelSizer->Fit(actionsPanel);
206 actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
207 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
211 this->SetSizer(sizer);
212 sizer->SetSizeHints(this);
214 if(((wxCDMMainFrame*)this->GetParent())->isHelp())
216 wxCDMProjectHelpDialog* helpDialog = new wxCDMProjectHelpDialog(this->GetParent(), this, wxID_ANY);
217 helpDialog->Show(true);
221 modelCDMProject* wxCDMProjectDescriptionPanel::GetProject() const
223 return this->project;
226 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
228 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
230 newEvent->SetString(wxT("manage_packages"));
231 newEvent->SetInt(this->project->GetId());
232 wxPostEvent(this->GetParent(), *newEvent);
236 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
238 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
240 newEvent->SetString(wxT("manage_libraries"));
241 wxPostEvent(this->GetParent(), *newEvent);
243 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
245 if(this->project->GetLib() != NULL)
247 int CMId = this->project->GetLib()->GetId();
248 newEvent1->SetInt(CMId);
250 wxPostEvent(this->GetParent(), *newEvent1);
256 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
258 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
260 newEvent->SetString(wxT("manage_applications"));
261 wxPostEvent(this->GetParent(), *newEvent);
263 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
265 if(this->project->GetAppli() != NULL)
267 int CMId = this->project->GetAppli()->GetId();
268 newEvent1->SetInt(CMId);
270 wxPostEvent(this->GetParent(), *newEvent1);
276 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
279 if(!this->project->OpenCMakeListsFile(result))
280 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
282 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
284 if(this->project->GetCMakeLists() != NULL)
286 int CMId = this->project->GetCMakeLists()->GetId();
287 newEvent->SetInt(CMId);
289 wxPostEvent(this->GetParent(), *newEvent);
294 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
296 wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
297 if(dialog->ShowModal())
300 if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
301 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
303 this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
307 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
310 if(!this->project->OpenInFileExplorer(result))
311 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
314 void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
317 wxString libraryName = wxGetTextFromUser(
318 wxT("Enter the new version name"),
319 wxT("Change Project Version - creaDevManager"),
320 crea::std2wx(this->project->GetVersion())
323 std::vector<std::string> parts;
324 CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
325 if(parts.size() == 3)
328 if(!this->project->SetVersion(crea::wx2std(libraryName), result))
329 wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
333 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);
335 this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
336 this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
340 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
342 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
344 if(this->project->GetCMakeLists() != NULL)
346 int CMId = this->project->GetCMakeLists()->GetId();
347 newEvent->SetInt(CMId);
349 wxPostEvent(this->GetParent(), *newEvent);
354 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
356 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
358 if(this->project->GetCMakeLists() != NULL)
360 int CMId = this->project->GetCMakeLists()->GetId();
361 newEvent->SetInt(CMId);
363 wxPostEvent(this->GetParent(), *newEvent);
368 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
370 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
371 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
372 if(this->project->GetAppli() != NULL)
374 int AppId = this->project->GetAppli()->GetId();
375 newEvent->SetInt(AppId);
377 wxPostEvent(this->GetParent(), *newEvent);
382 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
384 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
386 if(this->project->GetAppli() != NULL)
388 int AppId = this->project->GetAppli()->GetId();
389 newEvent->SetInt(AppId);
391 wxPostEvent(this->GetParent(), *newEvent);
396 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
398 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
400 if(this->project->GetLib() != NULL)
402 int LbId = this->project->GetLib()->GetId();
403 newEvent->SetInt(LbId);
405 wxPostEvent(this->GetParent(), *newEvent);
410 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
412 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
414 if(this->project->GetLib() != NULL)
416 int LbId = this->project->GetLib()->GetId();
417 newEvent->SetInt(LbId);
419 wxPostEvent(this->GetParent(), *newEvent);