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;
86 // this part makes the scrollbars show up
87 this->FitInside(); // ask the sizer about the needed size
88 this->SetScrollRate(5, 5);
92 void wxCDMProjectDescriptionPanel::CreateControls()
94 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
97 wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
100 headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
101 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
103 textSizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_LEFT, 0);
105 textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_LEFT, 0);
106 headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
108 sizer->Add(headerSizer, 0, wxALIGN_CENTER);
113 //----------------------------------Project Properties-----------------------------------
114 //properties StaticBoxSizer
115 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
117 wxPanel* propertiesPanel = new wxPanel(this);
119 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
120 //propertiesGrid Sizer
121 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
122 //properties elements
124 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
125 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
126 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
127 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
130 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
131 this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
132 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
133 pVersionbt->SetToolTip(wxT("Update the version of the project."));
134 pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER, 1);
135 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
137 this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
139 wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
140 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
141 pSourceLocationtc->SetMaxSize(wxSize(200,-1));
142 wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
143 pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
144 pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
145 pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
147 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
148 this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
149 this->buildPathtc->SetMaxSize(wxSize(200,-1));
150 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
151 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
152 pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
153 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
155 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
156 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
157 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
158 propertiesGridSizer->Add(this->versionDatetc, 1, wxEXPAND);
159 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
160 propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
161 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
162 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
164 propertiesGridSizer->AddGrowableCol(1,1);
166 propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5);
168 //SetPanel sizer and box
169 propertiesPanel->SetSizer(propertiesPanelSizer);
170 propertiesPanelSizer->Fit(propertiesPanel);
171 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
172 sizer->Add(propertiesBox, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
174 //----------------------------------Project Actions--------------------------------------
175 //actions StaticBoxSizer
176 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
177 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."));
179 wxPanel* actionsPanel = new wxPanel(this);
181 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
184 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
187 // show only if there is a lib folder
188 if(this->project->GetLib() != NULL)
190 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("A. Library Manager"));
191 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."));
192 libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this);
193 libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this);
194 actionsGridSizer->Add(libMgrbt, 1, wxALL | wxEXPAND, 5);
197 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("B. Package Manager"));
198 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
199 actionsGridSizer->Add(packageMgrbt, 1, wxALL | wxEXPAND, 5);
202 // show only if there is a appli folder
203 if(this->project->GetAppli() != NULL)
205 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("C. Application Manager"));
206 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."));
207 appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this);
208 appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
209 actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
211 // edit CMakeLists file
212 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
213 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
214 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
215 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
216 actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
218 actionsGridSizer->AddGrowableCol(0,1);
219 actionsGridSizer->AddGrowableCol(1,1);
221 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
222 //SetPanel sizer and box
223 actionsPanel->SetSizer(actionsPanelSizer);
224 actionsPanelSizer->Fit(actionsPanel);
225 actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5);
226 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
230 this->SetSizer(sizer);
231 sizer->SetSizeHints(this);
233 if(((wxCDMMainFrame*)this->GetParent())->isHelp())
235 wxCDMProjectHelpDialog* helpDialog = new wxCDMProjectHelpDialog(this->GetParent(), this->project, wxID_ANY);
236 helpDialog->Show(true);
240 modelCDMProject* wxCDMProjectDescriptionPanel::GetProject() const
242 return this->project;
245 void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
247 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
249 newEvent->SetString(wxT("manage_packages"));
250 newEvent->SetClientData(this->project);
251 wxPostEvent(this->GetParent(), *newEvent);
255 void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
257 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
259 newEvent->SetString(wxT("manage_libraries"));
260 wxPostEvent(this->GetParent(), *newEvent);
262 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
264 if(this->project->GetLib() != NULL)
266 newEvent1->SetClientData(this->project->GetLib());
268 wxPostEvent(this->GetParent(), *newEvent1);
274 void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
276 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
278 newEvent->SetString(wxT("manage_applications"));
279 wxPostEvent(this->GetParent(), *newEvent);
281 wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
283 if(this->project->GetAppli() != NULL)
285 newEvent1->SetClientData(this->project->GetAppli());
287 wxPostEvent(this->GetParent(), *newEvent1);
293 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
296 if(!this->project->OpenCMakeListsFile(result))
297 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
299 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
301 if(this->project->GetCMakeLists() != NULL)
303 newEvent->SetClientData(this->project->GetCMakeLists());
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_LISTBOX_DOUBLECLICKED);
360 if(this->project->GetCMakeLists() != NULL)
362 newEvent->SetClientData(this->project->GetCMakeLists());
364 wxPostEvent(this->GetParent(), *newEvent);
369 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
371 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
373 if(this->project->GetCMakeLists() != NULL)
375 newEvent->SetClientData(this->project->GetCMakeLists());
377 wxPostEvent(this->GetParent(), *newEvent);
382 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
384 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
385 std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
386 if(this->project->GetAppli() != NULL)
388 newEvent->SetClientData(this->project->GetAppli());
390 wxPostEvent(this->GetParent(), *newEvent);
395 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
397 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
399 if(this->project->GetAppli() != NULL)
401 newEvent->SetClientData(this->project->GetAppli());
403 wxPostEvent(this->GetParent(), *newEvent);
408 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
410 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
412 if(this->project->GetLib() != NULL)
414 newEvent->SetClientData(this->project->GetLib());
416 wxPostEvent(this->GetParent(), *newEvent);
421 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
423 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
425 if(this->project->GetLib() != NULL)
427 newEvent->SetClientData(this->project->GetLib());
429 wxPostEvent(this->GetParent(), *newEvent);