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 "creaDevManagerIds.h"
41 #include "images/PrIcon64.xpm"
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)
51 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
53 modelCDMProject* project,
55 const wxString& caption,
61 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
64 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
68 bool wxCDMProjectDescriptionPanel::Create(
70 modelCDMProject* project,
72 const wxString& caption,
78 wxPanel::Create(parent, id, pos, size, style);
79 this->project = project;
84 void wxCDMProjectDescriptionPanel::CreateControls()
86 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
89 sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
92 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
95 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
97 //----------------------------------Project Properties-----------------------------------
98 //properties StaticBoxSizer
99 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
101 wxPanel* propertiesPanel = new wxPanel(this);
103 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
104 //propertiesGrid Sizer
105 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
106 //properties elements
108 wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
109 wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
110 wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
111 wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
114 wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
115 wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
116 wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
117 pVersionbt->SetToolTip(wxT("Update the version of the project."));
118 pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
119 pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
121 wxStaticText* pVersionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
123 wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
124 pSourceLocationtc->SetMaxSize(wxSize(350,-1));
126 wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
127 wxStaticText* pBuildLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
128 pBuildLocationtc->SetMaxSize(wxSize(350,-1));
129 wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
130 pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
131 pBuildLocationsz->Add(pBuildLocationtc, 0, wxALIGN_CENTER, 0);
132 pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
134 propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
135 propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
136 propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
137 propertiesGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
138 propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
139 propertiesGridSizer->Add(pSourceLocationtc, 1, wxEXPAND);
140 propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
141 propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
143 propertiesGridSizer->AddGrowableCol(1,1);
145 propertiesPanelSizer-> Add(propertiesGridSizer, 0, wxALL | wxEXPAND, 5);
147 //SetPanel sizer and box
148 propertiesPanel->SetSizer(propertiesPanelSizer);
149 propertiesPanelSizer->Fit(propertiesPanel);
150 propertiesBox->Add(propertiesPanel, 1, wxEXPAND);
151 sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
153 //----------------------------------Project Actions--------------------------------------
154 //actions StaticBoxSizer
155 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
157 wxPanel* actionsPanel = new wxPanel(this);
159 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
162 wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager"));
163 packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
164 actionsPanelSizer->Add(packageMgrbt, 0, wxALL, 5);
166 // show only if there is a lib folder
167 if(this->project->GetLib() != NULL)
169 wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("Library Manager"));
170 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."));
171 actionsPanelSizer->Add(libMgrbt, 0, wxALL, 5);
174 // show only if there is a appli folder
175 if(this->project->GetAppli() != NULL)
177 wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager"));
178 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."));
179 actionsPanelSizer->Add(appliMgrbt, 0, wxALL, 5);
181 // edit CMakeLists file
182 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
183 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
184 actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
186 //SetPanel sizer and box
187 actionsPanel->SetSizer(actionsPanelSizer);
188 actionsPanelSizer->Fit(actionsPanel);
189 actionsBox->Add(actionsPanel, 1, wxEXPAND);
190 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
194 this->SetSizer(sizer);
195 sizer->SetSizeHints(this);
199 void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
202 wxString libraryName = wxGetTextFromUser(
203 _T("Enter the new library name"),
204 _T("New Library - creaDevManager"),
208 if(libraryName.Len() > 0)
212 modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
213 //check library created
216 wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
220 wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION);
222 //refreshing tree and description
223 //send event instead of calling parent to avoid crashing
225 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
227 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
228 newEvent->SetInt(library->GetId());
229 wxPostEvent(this->GetParent(), *newEvent);
234 void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
237 wxString applicationName = wxGetTextFromUser(
238 _T("Enter the new application name"),
239 _T("New Application - creaDevManager"),
243 if(applicationName.Len() > 0)
247 modelCDMIProjectTreeNode* application = this->project->CreateApplication(crea::wx2std(applicationName),result);
248 //check library created
249 if(application == NULL)
251 wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR);
255 wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - Success!"),wxOK | wxICON_INFORMATION);
257 //refreshing tree and description
258 //send event instead of calling parent to avoid crashing
260 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
262 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
263 newEvent->SetInt(application->GetId());
264 wxPostEvent(this->GetParent(), *newEvent);
269 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
271 //TODO: implement method
272 std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
277 wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
279 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
281 newEvent->SetString(wxT("manage_packages"));
282 newEvent->SetInt(this->project->GetId());
283 wxPostEvent(this->GetParent(), *newEvent);
288 wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
290 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
292 newEvent->SetString(wxT("manage_libraries"));
293 wxPostEvent(this->GetParent(), *newEvent);
298 wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
300 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
302 newEvent->SetString(wxT("manage_applications"));
303 wxPostEvent(this->GetParent(), *newEvent);