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_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage)
45 EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox)
46 EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMProjectDescriptionPanel::OnBtnCreateLibrary)
47 EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMProjectDescriptionPanel::OnBtnCreateApplication)
48 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
49 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMProjectDescriptionPanel::OnCreationComplete)
52 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
54 modelCDMProject* project,
56 const wxString& caption,
62 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
65 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
69 bool wxCDMProjectDescriptionPanel::Create(
71 modelCDMProject* project,
73 const wxString& caption,
79 wxPanel::Create(parent, id, pos, size, style);
80 this->project = project;
85 void wxCDMProjectDescriptionPanel::CreateControls()
87 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
90 sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
93 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
96 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
99 wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
100 wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL);
102 wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
104 wxStaticText *pVersion = new wxStaticText(this, -1, wxT("Version"));
105 wxStaticText *pVersionDate = new wxStaticText(this, -1, wxT("Version Date"));
106 wxStaticText *pSourceLocation = new wxStaticText(this, -1, wxT("Source Location"));
107 wxStaticText *pBuildLocation = new wxStaticText(this, -1, wxT("Build Location"));
109 wxTextCtrl *pVersiontc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersion()));
110 wxTextCtrl *pVersionDatetc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersionDate()));
111 wxTextCtrl *pSourceLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetPath()));
112 wxTextCtrl *pBuildLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetBuildPath()));
114 flexGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
115 flexGridSizer->Add(pVersiontc, 1, wxEXPAND);
116 flexGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
117 flexGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
118 flexGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
119 flexGridSizer->Add(pSourceLocationtc, 1, wxEXPAND);
120 flexGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
121 flexGridSizer->Add(pBuildLocationtc, 1, wxEXPAND);
123 propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND);
124 sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
127 wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
128 wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL);
129 sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
131 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_PACKAGE, _T("Create Package")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
132 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_BLACKBOX, _T("Create Black Box")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
133 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
134 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_APPLICATION, _T("Create Application")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
136 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
139 actionsBoxInnerSizer->SetSizeHints(this);
142 sizer->SetSizeHints(this);
145 void wxCDMProjectDescriptionPanel::OnBtnCreatePackage(wxCommandEvent& event)
149 wxCDMNewPackageDialog* dialog = new wxCDMNewPackageDialog(this);
151 userResponse = dialog->ShowModal();
153 if(userResponse == wxID_FORWARD)
155 modelCDMIProjectTreeNode* package = this->project->CreatePackage(
156 crea::wx2std(dialog->GetPackageName()),
158 crea::wx2std(dialog->GetPackageAuthor()),
159 crea::wx2std(dialog->GetPackageAuthorEmail()),
160 crea::wx2std(dialog->GetPackageDescription())
164 std::cout << "error creating package: " << *result << std::endl;
165 wxMessageBox(crea::std2wx(*result),_T("New Package - Error!"),wxOK | wxICON_ERROR);
169 wxMessageBox(crea::std2wx("Package successfully created."),_T("New Package - Success!"),wxOK | wxICON_INFORMATION);
171 //refreshing tree and description
172 //send event instead of calling parent to avoid crashing
174 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
176 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
177 newEvent->SetInt(package->GetId());
178 wxPostEvent(this->GetParent(), *newEvent);
185 void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
187 //TODO: implement method
188 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
192 void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
195 wxString libraryName = wxGetTextFromUser(
196 _T("Enter the new library name"),
197 _T("New Library - creaDevManager"),
201 if(libraryName.Len() > 0)
205 modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
206 //check library created
209 wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
213 wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION);
215 //refreshing tree and description
216 //send event instead of calling parent to avoid crashing
218 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
220 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
221 newEvent->SetInt(library->GetId());
222 wxPostEvent(this->GetParent(), *newEvent);
227 void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
230 wxString applicationName = wxGetTextFromUser(
231 _T("Enter the new application name"),
232 _T("New Application - creaDevManager"),
236 if(applicationName.Len() > 0)
240 modelCDMIProjectTreeNode* application = this->project->CreateApplication(crea::wx2std(applicationName),result);
241 //check library created
242 if(application == NULL)
244 wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR);
248 wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - Success!"),wxOK | wxICON_INFORMATION);
250 //refreshing tree and description
251 //send event instead of calling parent to avoid crashing
253 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
255 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
256 newEvent->SetInt(application->GetId());
257 wxPostEvent(this->GetParent(), *newEvent);
262 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
264 //TODO: implement method
265 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
269 void wxCDMProjectDescriptionPanel::OnCreationComplete(wxCommandEvent& event)
271 std::cout << "catched" << std::endl;