]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
ecd4e894b9ed75029418effb088dc6d31e176515
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Sant�)
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
9 #
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.
16 #
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
21 #  liability.
22 #
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 # ------------------------------------------------------------------------
26  */
27
28 /*
29  * wxCDMProjectDescriptionPanel.cpp
30  *
31  *  Created on: Nov 27, 2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #include "wxCDMProjectDescriptionPanel.h"
36
37 #include "wxCDMMainFrame.h"
38 #include "wxCDMNewPackageDialog.h"
39
40 #include "creaDevManagerIds.h"
41 #include "images/PrIcon64.xpm"
42
43 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
44 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
45 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageLibraries)
46 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
47 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
48 EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
49 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
50 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
51 END_EVENT_TABLE()
52
53 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
54     wxWindow* parent,
55     modelCDMProject* project,
56     wxWindowID id,
57     const wxString& caption,
58     const wxPoint& pos,
59     const wxSize& size,
60     long style
61 )
62 {
63   wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
64 }
65
66 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
67 {
68 }
69
70 bool wxCDMProjectDescriptionPanel::Create(
71     wxWindow* parent,
72     modelCDMProject* project,
73     wxWindowID id,
74     const wxString& caption,
75     const wxPoint& pos,
76     const wxSize& size,
77     long style
78 )
79 {
80   wxPanel::Create(parent, id, pos, size, style);
81   this->project = project;
82   CreateControls();
83   return TRUE;
84 }
85
86 void wxCDMProjectDescriptionPanel::CreateControls()
87 {
88   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
89
90   //Welcome
91   sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
92
93   //Image
94   sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
95
96   //Project Name
97   sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
98
99   //----------------------------------Project Properties-----------------------------------
100   //properties StaticBoxSizer
101   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
102   //properties Panel
103   wxPanel* propertiesPanel = new wxPanel(this);
104   //properties Sizer
105   wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
106   //propertiesGrid Sizer
107   wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
108   //properties elements
109   //labels
110   wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
111   wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
112   wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
113   wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
114   //values
115   // version
116   wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
117   wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
118   wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
119   pVersionbt->SetToolTip(wxT("Update the version of the project."));
120   pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
121   pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
122   // versionDate
123   wxStaticText* pVersionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
124   // sourceLocation
125   wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
126   wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
127   pSourceLocationtc->SetMaxSize(wxSize(350,-1));
128   wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
129   pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
130   pSourceLocationsz->Add(pSourceLocationtc, 0, wxALIGN_CENTER, 0);
131   pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
132   // buildLocation
133   wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
134   wxStaticText* pBuildLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
135   pBuildLocationtc->SetMaxSize(wxSize(350,-1));
136   wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
137   pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
138   pBuildLocationsz->Add(pBuildLocationtc, 0, wxALIGN_CENTER, 0);
139   pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
140
141   propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
142   propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
143   propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
144   propertiesGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
145   propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
146   propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
147   propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
148   propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
149
150   propertiesGridSizer->AddGrowableCol(1,1);
151
152   propertiesPanelSizer-> Add(propertiesGridSizer, 0, wxALL | wxEXPAND, 5);
153
154   //SetPanel sizer and box
155   propertiesPanel->SetSizer(propertiesPanelSizer);
156   propertiesPanelSizer->Fit(propertiesPanel);
157   propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
158   sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
159
160   //----------------------------------Project Actions--------------------------------------
161   //actions StaticBoxSizer
162   wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
163   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."));
164   //actions Panel
165   wxPanel* actionsPanel = new wxPanel(this);
166   //actions Sizer
167   wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
168   //buttons
169   // package manager
170   wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager"));
171   packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
172   actionsPanelSizer->Add(packageMgrbt, 0, wxALL, 5);
173   // lib manager
174   // show only if there is a lib folder
175   if(this->project->GetLib() != NULL)
176     {
177       wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("Library Manager"));
178       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."));
179       actionsPanelSizer->Add(libMgrbt, 0, wxALL, 5);
180     }
181   // appli manager
182   // show only if there is a appli folder
183   if(this->project->GetAppli() != NULL)
184     {
185       wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager"));
186       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."));
187       actionsPanelSizer->Add(appliMgrbt, 0, wxALL, 5);
188     }
189   // edit CMakeLists file
190   wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
191   editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
192   actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
193
194   //SetPanel sizer and box
195   actionsPanel->SetSizer(actionsPanelSizer);
196   actionsPanelSizer->Fit(actionsPanel);
197   actionsBox->Add(actionsPanel, 0, wxALL, 5);
198   sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
199
200
201   //Assign sizer
202   this->SetSizer(sizer);
203   sizer->SetSizeHints(this);
204 }
205
206 void
207 wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
208 {
209   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
210   newEvent->SetId(1);
211   newEvent->SetString(wxT("manage_packages"));
212   newEvent->SetInt(this->project->GetId());
213   wxPostEvent(this->GetParent(), *newEvent);
214   event.Skip();
215 }
216
217 void
218 wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
219 {
220   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
221   newEvent->SetId(1);
222   newEvent->SetString(wxT("manage_libraries"));
223   wxPostEvent(this->GetParent(), *newEvent);
224   event.Skip();
225 }
226
227 void
228 wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
229 {
230   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
231   newEvent->SetId(1);
232   newEvent->SetString(wxT("manage_applications"));
233   wxPostEvent(this->GetParent(), *newEvent);
234   event.Skip();
235 }
236
237 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
238 {
239   //TODO: implement method
240   std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
241   event.Skip();
242 }
243
244 void
245 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
246 {
247   //TODO: implement method
248   std::cerr << "Event OnBtnSetBuildPath not implemented" << std::endl;
249   event.Skip();
250 }
251
252 void
253 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
254 {
255   //TODO: implement method
256   std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
257   event.Skip();
258 }
259
260 void
261 wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
262 {
263   //TODO: implement method
264   std::cerr << "Event OnBtnSetVersion not implemented" << std::endl;
265   event.Skip();
266 }