From 9db3dcfa7151c22fb19fe0202ec03b4e8ac3f4b4 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Thu, 13 Dec 2012 13:04:00 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation - Fixing up tooltips and flow control with packages and blackboxes - Fixed bug in Package manager and Black Box Description views for tooltips. Still presented in CMakeFileLists, File and Folder Description views. --- lib/creaDevManagerLib/creaDevManagerIds.h | 1 + lib/creaDevManagerLib/modelCDMBlackBox.cpp | 13 +- lib/creaDevManagerLib/modelCDMBlackBox.h | 3 + lib/creaDevManagerLib/modelCDMPackage.cpp | 5 + lib/creaDevManagerLib/modelCDMPackage.h | 1 + .../wxCDMBlackBoxDescriptionPanel.cpp | 135 ++++++++++---- .../wxCDMBlackBoxDescriptionPanel.h | 2 + .../wxCDMLibDescriptionPanel.cpp | 7 +- .../wxCDMPackageDescriptionPanel.cpp | 176 ++++++++++++++---- .../wxCDMPackageDescriptionPanel.h | 4 + .../wxCDMPackageManagerPanel.cpp | 99 ++++++---- .../wxCDMPackageManagerPanel.h | 5 +- 12 files changed, 329 insertions(+), 122 deletions(-) diff --git a/lib/creaDevManagerLib/creaDevManagerIds.h b/lib/creaDevManagerLib/creaDevManagerIds.h index a9d5979..0e4b788 100644 --- a/lib/creaDevManagerLib/creaDevManagerIds.h +++ b/lib/creaDevManagerLib/creaDevManagerIds.h @@ -103,5 +103,6 @@ #define ID_LINK_SELECT_PACKAGE 10326 #define ID_LINK_SELECT_LIBRARY 10327 #define ID_LINK_SELECT_APPLICATION 10328 +#define ID_LINK_SELECT_BLACKBOX 10329 #endif /* CREADEVMANAGERIDS_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMBlackBox.cpp b/lib/creaDevManagerLib/modelCDMBlackBox.cpp index d326e00..5ea4a26 100644 --- a/lib/creaDevManagerLib/modelCDMBlackBox.cpp +++ b/lib/creaDevManagerLib/modelCDMBlackBox.cpp @@ -43,7 +43,7 @@ modelCDMBlackBox::modelCDMBlackBox() modelCDMBlackBox::modelCDMBlackBox(const std::string& hName, const std::string& path, const int& level) { - this->name = hName.substr(2, hName.size()-4); + this->name = this->nameBlackBox = hName.substr(2, hName.size()-4); this->path = path; this->level = level; this->type = wxDIR_DIRS; @@ -78,6 +78,11 @@ const std::string& modelCDMBlackBox::GetDescription() const return this->description; } +const std::string& modelCDMBlackBox::GetVersion() const +{ + return this->version; +} + bool modelCDMBlackBox::SetAuthors(const std::string& authors, std::string*& result) { //TODO: implement method @@ -111,6 +116,12 @@ bool modelCDMBlackBox::SetDescription( return true; } +bool modelCDMBlackBox::SetVersion(const std::string& version, std::string*& result) +{ + //TODO: implement method + return true; +} + bool modelCDMBlackBox::OpenCxx(std::string*& result) { //TODO: implement method diff --git a/lib/creaDevManagerLib/modelCDMBlackBox.h b/lib/creaDevManagerLib/modelCDMBlackBox.h index 127a4d5..f3d986a 100644 --- a/lib/creaDevManagerLib/modelCDMBlackBox.h +++ b/lib/creaDevManagerLib/modelCDMBlackBox.h @@ -50,11 +50,13 @@ public: const std::string& GetAuthors() const; const std::string& GetAuthorsEmail() const; const std::string& GetCategories() const; + const std::string& GetVersion() const; const std::string& GetDescription() const; bool SetAuthors(const std::string& authors, std::string*& result); bool SetAuthorsEmail(const std::string& email, std::string*& result); bool SetCategories(const std::string& version, std::string*& result); + bool SetVersion(const std::string& version, std::string*& result); bool SetDescription(const std::string& description, std::string*& result); @@ -68,6 +70,7 @@ private: std::string authorsEmail; std::string categories; std::string description; + std::string version; }; #endif /* MODELCDMBLACKBOX_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMPackage.cpp b/lib/creaDevManagerLib/modelCDMPackage.cpp index c589a8e..d2d6e12 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.cpp +++ b/lib/creaDevManagerLib/modelCDMPackage.cpp @@ -147,6 +147,11 @@ const std::string& modelCDMPackage::GetDescription() const return this->description; } +const std::vector& modelCDMPackage::GetBlackBoxes() const +{ + return this->blackBoxes; +} + bool modelCDMPackage::SetAuthors(const std::string& authors, std::string*& result) { //TODO: implement method diff --git a/lib/creaDevManagerLib/modelCDMPackage.h b/lib/creaDevManagerLib/modelCDMPackage.h index e18031a..66d86c7 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.h +++ b/lib/creaDevManagerLib/modelCDMPackage.h @@ -53,6 +53,7 @@ public: const std::string& GetAuthorsEmail() const; const std::string& GetVersion() const; const std::string& GetDescription() const; + const std::vector& GetBlackBoxes() const; bool SetAuthors(const std::string& authors, std::string*& result); bool SetAuthorsEmail(const std::string& email, std::string*& result); diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp index f04d5af..1303e95 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp @@ -34,12 +34,16 @@ #include "wxCDMBlackBoxDescriptionPanel.h" +#include "wxCDMMainFrame.h" + #include "creaDevManagerIds.h" #include "images/BBIcon64.xpm" BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel) +EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn) EVT_MENU(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx) EVT_MENU(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx) +EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder) END_EVENT_TABLE() wxCDMBlackBoxDescriptionPanel::wxCDMBlackBoxDescriptionPanel( @@ -79,6 +83,11 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() { wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + //Link to return + wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project")); + returnbt->SetToolTip(wxT("Return to the active project description.")); + sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5); + //Welcome sizer->Add(new wxStaticText(this, -1, _("Black Box")),0, wxALIGN_CENTER, 0); @@ -89,49 +98,100 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->blackBox->GetNameBlackBox())),0, wxALIGN_CENTER, 0); //BlackBox Properties - wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties")); - wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL); - - wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15); - - wxStaticText *pAuthor = new wxStaticText(this, -1, wxT("Author")); - wxStaticText *pAuthorEmail = new wxStaticText(this, -1, wxT("Author E-mail")); - wxStaticText *pCategories = new wxStaticText(this, -1, wxT("Categories")); - wxStaticText *pDescription = new wxStaticText(this, -1, wxT("Description")); - - wxTextCtrl *pAuthortc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetAuthors())); - wxTextCtrl *pAuthorEmailtc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetAuthorsEmail())); - wxTextCtrl *pCategoriestc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetCategories())); - wxTextCtrl *pDescriptiontc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetDescription())); - - flexGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pAuthortc, 1, wxEXPAND); - flexGridSizer->Add(pAuthorEmail, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pAuthorEmailtc, 1, wxEXPAND); - flexGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pCategoriestc, 1, wxEXPAND); - flexGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pDescriptiontc, 1, wxEXPAND); - - propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND); - sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20); + wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties")); + wxPanel* propertiesPanel = new wxPanel(this); + wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); + wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15); + + wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author")); + wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version")); + wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description")); + wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories")); + + // author + wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors())); + wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + pAuthorbt->SetToolTip(wxT("Update the author/s of the package.")); + pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0); + pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + // version + wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetVersion())); + wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); + pVersionbt->SetToolTip(wxT("Update the version of the package.")); + pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + // description + wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription())); + wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + pDescriptionbt->SetToolTip(wxT("Update the description of the project.")); + pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + // categories + wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pCategoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories())); + wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + pCategoriesbt->SetToolTip(wxT("Update the categories of the project.")); + pCategoriessz->Add(pCategoriestc, 0, wxALIGN_CENTER_VERTICAL, 0); + pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND); + propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND); + propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND); + propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pCategoriessz, 1, wxEXPAND); + + propertiesGridSizer->AddGrowableCol(1,1); + + propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND); + propertiesPanel->SetSizer(propertiesPanelSizer); + propertiesPanelSizer->Fit(propertiesPanel); + propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + + sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10); //Actions - wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions")); - wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL); - sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20); - - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_OPEN_CXX, _T("Open Cxx")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20); - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_OPEN_HXX, _T("Open Hxx")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20); + wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions")); + wxPanel* actionsPanel = new wxPanel(this); + wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); + + wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Cxx")); + openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor.")); + actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5); + wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Hxx")); + openHxxbt->SetToolTip(wxT("Open the .hxx file in the default text editor.")); + actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5); + wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder")); + openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer.")); + actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5); + + actionsPanel->SetSizer(actionsPanelSizer); + actionsPanelSizer->Fit(actionsPanel); + actionsBox->Add(actionsPanel, 0, wxEXPAND); + sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10); //Assign sizer - actionsBoxInnerSizer->SetSizeHints(this); - SetSizer(sizer); sizer->SetSizeHints(this); } +void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); +} + void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event) { //TODO: implement method @@ -145,3 +205,10 @@ void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event) std::cerr << "Event OnBtnOpenHxx not implemented" << std::endl; event.Skip(); } + +void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +{ + //TODO: implement method + std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; + event.Skip(); +} diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h index e14e621..eb32dc1 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h @@ -73,8 +73,10 @@ private: //handlers protected: + void OnBtnReturn(wxCommandEvent& event); void OnBtnOpenCxx(wxCommandEvent& event); void OnBtnOpenHxx(wxCommandEvent& event); + void OnBtnOpenFolder(wxCommandEvent& event); }; diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index e7b1379..07f9cc1 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -97,7 +97,7 @@ void wxCDMLibDescriptionPanel::CreateControls() //Libraries wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Libraries")); - propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available libraries to see its details or the modify them.")); + propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available libraries to see its details or modify them.")); wxPanel* propertiesPanel = new wxPanel(this); wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); @@ -126,7 +126,7 @@ void wxCDMLibDescriptionPanel::CreateControls() createLibrarybt->SetToolTip(wxT("Create a new library for this project.")); actionsPanelSizer->Add(createLibrarybt, 0, wxALL, 5); wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); - editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the CMakeLists.txt file.")); + editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the Lib's CMakeLists.txt file.")); actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder")); openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer.")); @@ -210,8 +210,7 @@ void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event) wxPostEvent(this->GetParent(), *newEvent); } -void -wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +void wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { //TODO: implement method std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp index a958d35..5a4f56a 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp @@ -34,12 +34,17 @@ #include "wxCDMPackageDescriptionPanel.h" +#include "wxCDMMainFrame.h" + #include "creaDevManagerIds.h" #include "images/PkIcon64.xpm" BEGIN_EVENT_TABLE(wxCDMPackageDescriptionPanel, wxPanel) -EVT_MENU(ID_BUTTON_CREATE_BLACKBOX, wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox) -EVT_MENU(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_PREV, wxCDMPackageDescriptionPanel::OnBtnReturn) +EVT_HYPERLINK(ID_LINK_SELECT_BLACKBOX, wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect) +EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox) +EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMPackageDescriptionPanel::OnBtnOpenFolder) END_EVENT_TABLE() wxCDMPackageDescriptionPanel::wxCDMPackageDescriptionPanel( @@ -79,59 +84,142 @@ void wxCDMPackageDescriptionPanel::CreateControls() { wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); - //Welcome + //Link to return + wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project")); + returnbt->SetToolTip(wxT("Return to the active project description.")); + sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5); + + //Title sizer->Add(new wxStaticText(this, -1, _("Package")),0, wxALIGN_CENTER, 0); //Image sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PkIcon64)),0, wxALIGN_CENTER, 0); - //Project Name + //Package Name sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->package->GetNamePackage())),0, wxALIGN_CENTER, 0); - //Project Properties - wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties")); - wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL); - - wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15); - - wxStaticText *pAuthor = new wxStaticText(this, -1, wxT("Author")); - wxStaticText *pAuthorEmail = new wxStaticText(this, -1, wxT("Author E-mail")); - wxStaticText *pVersion = new wxStaticText(this, -1, wxT("Version")); - wxStaticText *pDescription = new wxStaticText(this, -1, wxT("Description")); - - wxTextCtrl *pAuthortc = new wxTextCtrl(this, -1, crea::std2wx(this->package->GetAuthors())); - wxTextCtrl *pAuthorEmailtc = new wxTextCtrl(this, -1, crea::std2wx(this->package->GetAuthorsEmail())); - wxTextCtrl *pVersiontc = new wxTextCtrl(this, -1, crea::std2wx(this->package->GetVersion())); - wxTextCtrl *pDescriptiontc = new wxTextCtrl(this, -1, crea::std2wx(this->package->GetDescription())); - - flexGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pAuthortc, 1, wxEXPAND); - flexGridSizer->Add(pAuthorEmail, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pAuthorEmailtc, 1, wxEXPAND); - flexGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pVersiontc, 1, wxEXPAND); - flexGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - flexGridSizer->Add(pDescriptiontc, 1, wxEXPAND); - - propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND); - sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20); + //Package Properties + wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties")); + wxPanel* propertiesPanel = new wxPanel(this); + wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); + wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15); + + wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author")); + wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version")); + wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description")); + + // author + wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetAuthors())); + wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + pAuthorbt->SetToolTip(wxT("Update the author/s of the package.")); + pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0); + pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + // version + wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetVersion())); + wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); + pVersionbt->SetToolTip(wxT("Update the version of the package.")); + pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + // description + wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL); + wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetDescription())); + wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + pDescriptionbt->SetToolTip(wxT("Update the description of the project.")); + pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10); + + propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND); + propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND); + propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND); + + propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND); + propertiesPanel->SetSizer(propertiesPanelSizer); + propertiesPanelSizer->Fit(propertiesPanel); + propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + + sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10); + + //Black Boxes + wxStaticBoxSizer* BBBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Black Boxes")); + BBBox->GetStaticBox()->SetToolTip(wxT("Select any of the available black boxes to see its details or modify them.")); + wxPanel* BBPanel = new wxPanel(this); + wxBoxSizer* BBPanelSizer = new wxBoxSizer(wxVERTICAL); + + std::vector blackBoxes = this->package->GetBlackBoxes(); + for (int i = 0; i < blackBoxes.size(); i++) + { + wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str())); + std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories(); + pBBlk->SetToolTip(crea::std2wx(tt)); + BBPanelSizer -> Add(pBBlk, 0, wxALIGN_LEFT | wxALL, 5); + } + + BBPanel->SetSizer(BBPanelSizer); + BBPanelSizer->Fit(BBPanel); + BBBox->Add(BBPanel, 0, wxALL, 5); + + sizer -> Add(BBBox, 0, wxEXPAND | wxALL, 10); //Actions - wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions")); - wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL); - sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20); - - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_BLACKBOX, _T("Create Black Box")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20); - - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20); + wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions")); + wxPanel* actionsPanel = new wxPanel(this); + wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); + + wxButton* createBBbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_BLACKBOX, _T("Create Black Box")); + createBBbt->SetToolTip(wxT("Create a new black box for the active project inside this package.")); + actionsPanelSizer->Add(createBBbt, 0, wxALL, 5); + wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); + editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the package's CMakeLists.txt file.")); + actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); + wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder")); + openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer.")); + actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5); + + actionsPanel->SetSizer(actionsPanelSizer); + actionsPanelSizer->Fit(actionsPanel); + actionsBox->Add(actionsPanel, 0, wxEXPAND); + sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10); //Assign sizer - actionsBoxInnerSizer->SetSizeHints(this); - SetSizer(sizer); sizer->SetSizeHints(this); } +void wxCDMPackageDescriptionPanel::OnBtnReturn(wxCommandEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); +} + +void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event) +{ + int bbId = 0; + std::vector bbs = this->package->GetBlackBoxes(); + for (int i = 0; i < bbs.size(); i++) + { + if(bbs[i]->GetName() == crea::wx2std(event.GetURL())) + { + bbId = bbs[i]->GetId(); + break; + } + } + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(bbId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + +} + void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event) { //TODO: implement method @@ -145,3 +233,11 @@ void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; event.Skip(); } + +void wxCDMPackageDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +{ + //TODO: implement method + std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; + event.Skip(); +} + diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h index b6d7b1b..a6688a2 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h @@ -37,6 +37,7 @@ #include #include +#include #include "modelCDMPackage.h" @@ -73,8 +74,11 @@ private: //handlers protected: + void OnBtnReturn(wxCommandEvent& event); + void OnLnkBlackBoxSelect(wxHyperlinkEvent& event); void OnBtnCreateBlackBox(wxCommandEvent& event); void OnBtnEditCMakeLists(wxCommandEvent& event); + void OnBtnOpenFolder(wxCommandEvent& event); }; diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp index a82f2e3..dbd6e73 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp @@ -85,7 +85,9 @@ void wxCDMPackageManagerPanel::CreateControls() wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); //Link to return - sizer->Add(new wxButton(this, ID_BUTTON_PREV, wxT("Return to project")), 0, wxALIGN_CENTER | wxALL, 5); + wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project")); + returnbt->SetToolTip(wxT("Return to the active project description.")); + sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5); //Title sizer->Add(new wxStaticText(this, -1, _("Package Management")),0, wxALIGN_CENTER, 0); @@ -94,33 +96,76 @@ void wxCDMPackageManagerPanel::CreateControls() sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PkIcon64)),0, wxALIGN_CENTER, 0); //Packages - wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Available Packages")); - wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL); + wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Packages")); + propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available packages to see its details or modify them. Remember that black boxes are created inside packages, any of these packages is available.")); + wxPanel* propertiesPanel = new wxPanel(this); + wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); std::vector packages = this->project->GetPackages(); for (int i = 0; i < packages.size(); i++) { - wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(this,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str())); - propertiesBoxInnerSizer -> Add(pPackagelk, 0, wxALIGN_LEFT | wxALL, 5); + wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str())); + std::string tt = "Author: " + packages[i]->GetAuthors() + "\nDescription: " + packages[i]->GetDescription(); + pPackagelk->SetToolTip(crea::std2wx(tt)); + propertiesPanelSizer -> Add(pPackagelk, 0, wxALIGN_LEFT | wxALL, 5); } - sizer -> Add(propertiesBoxInnerSizer, 0, wxEXPAND | wxALL, 10); + propertiesPanel->SetSizer(propertiesPanelSizer); + propertiesPanelSizer->Fit(propertiesPanel); + propertiesBox->Add(propertiesPanel, 0, wxALL, 5); - //Actions - wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions")); - wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxHORIZONTAL); - sizer -> Add(actionsBoxInnerSizer, 0, wxEXPAND | wxALL, 10); + sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_PACKAGE, _T("Create Package")), 0, wxALL, 5); - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxALL, 5); + //Actions + wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions")); + wxPanel* actionsPanel = new wxPanel(this); + wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); + + wxButton* createPkgbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_PACKAGE, _T("Create Package")); + createPkgbt->SetToolTip(wxT("Create a new package for this project.")); + actionsPanelSizer->Add(createPkgbt, 0, wxALL, 5); + wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); + editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project.")); + actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); + + actionsPanel->SetSizer(actionsPanelSizer); + actionsPanelSizer->Fit(actionsPanel); + actionsBox->Add(actionsPanel, 0, wxEXPAND); + sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10); //Assign sizer - actionsBoxInnerSizer->SetSizeHints(this); - SetSizer(sizer); sizer->SetSizeHints(this); } +void wxCDMPackageManagerPanel::OnBtnReturn(wxCommandEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(project->GetId()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); +} + +void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event) +{ + int packageId = 0; + std::vector packages = this->project->GetPackages(); + for (int i = 0; i < packages.size(); i++) + { + if(packages[i]->GetName() == crea::wx2std(event.GetURL())) + { + packageId = packages[i]->GetId(); + break; + } + } + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetInt(packageId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + +} + void wxCDMPackageManagerPanel::OnBtnCreatePackage(wxCommandEvent& event) { std::string* result; @@ -169,30 +214,4 @@ void wxCDMPackageManagerPanel::OnBtnEditCMakeLists(wxCommandEvent& event) event.Skip(); } -void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event) -{ - int packageId = 0; - std::vector packages = this->project->GetPackages(); - for (int i = 0; i < packages.size(); i++) - { - if(packages[i]->GetName() == crea::wx2std(event.GetURL())) - { - packageId = packages[i]->GetId(); - break; - } - } - - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); - newEvent->SetInt(packageId); - newEvent->SetId(0); - wxPostEvent(this->GetParent(), *newEvent); - -} -void wxCDMPackageManagerPanel::OnBtnReturn(wxCommandEvent& event) -{ - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); - newEvent->SetInt(project->GetId()); - newEvent->SetId(0); - wxPostEvent(this->GetParent(), *newEvent); -} diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h index a8634cb..aeb3eda 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h @@ -75,12 +75,11 @@ private: //handlers protected: + void OnBtnReturn(wxCommandEvent& event); + void OnLnkPackageSelect(wxHyperlinkEvent& event); void OnBtnCreatePackage(wxCommandEvent& event); void OnBtnEditCMakeLists(wxCommandEvent& event); - void OnLnkPackageSelect(wxHyperlinkEvent& event); - - void OnBtnReturn(wxCommandEvent& event); }; #endif /* WXCDMPACKAGEMANAGERPANEL_H_ */ -- 2.46.2