From df27aee30377cefdc3e33b4001b5afca1798b309 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Fri, 14 Dec 2012 17:17:30 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation - Setting up links highlighting in Lib and Appli Descriptions. - Open Folder in Appli implemented - Open CMakeLists file in Appli implemented - Fixed responsibility of open folder to folder class --- lib/creaDevManagerLib/modelCDMAppli.cpp | 6 -- lib/creaDevManagerLib/modelCDMAppli.h | 1 - lib/creaDevManagerLib/modelCDMFolder.cpp | 14 +++- .../modelCDMIProjectTreeNode.cpp | 64 +++++++++---------- lib/creaDevManagerLib/modelCDMLib.cpp | 11 ---- lib/creaDevManagerLib/modelCDMLib.h | 1 - .../wxCDMAppliDescriptionPanel.cpp | 51 +++++++++++++-- .../wxCDMAppliDescriptionPanel.h | 2 + .../wxCDMLibDescriptionPanel.cpp | 40 ++++++++++++ .../wxCDMLibDescriptionPanel.h | 2 + 10 files changed, 133 insertions(+), 59 deletions(-) diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index 79c17ea..ce3388e 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -138,12 +138,6 @@ modelCDMApplication* modelCDMAppli::CreateApplication( return application; } -bool modelCDMAppli::OpenCMakeListsFile(std::string*& result) -{ - //TODO: implement method - return true; -} - const bool modelCDMAppli::Refresh(std::string*& result) { //TODO: implement method diff --git a/lib/creaDevManagerLib/modelCDMAppli.h b/lib/creaDevManagerLib/modelCDMAppli.h index f239426..c37924d 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.h +++ b/lib/creaDevManagerLib/modelCDMAppli.h @@ -55,7 +55,6 @@ public: std::string*& result, const std::string& path = "/" ); - bool OpenCMakeListsFile(std::string*& result); virtual const bool Refresh(std::string*& result); private: diff --git a/lib/creaDevManagerLib/modelCDMFolder.cpp b/lib/creaDevManagerLib/modelCDMFolder.cpp index 73312b6..8122ebb 100644 --- a/lib/creaDevManagerLib/modelCDMFolder.cpp +++ b/lib/creaDevManagerLib/modelCDMFolder.cpp @@ -126,8 +126,18 @@ bool modelCDMFolder::CreateFolder(const std::string& name, std::string*& result, bool modelCDMFolder::OpenCMakeListsFile(std::string*& result) { - //TODO: implement method - return true; + if (this->CMakeLists == NULL) + { + result = new std::string("There's no CMakeLists file to open."); + return false; + } + if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath())) + return true; + else + { + result = new std::string("Couldn't open CMakeLists file."); + return false; + } } const bool modelCDMFolder::Refresh(std::string*& result) diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp index 8676627..fb02b71 100644 --- a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp @@ -23,7 +23,7 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ -*/ + */ /* * modelCDMIProjectTreeNode.cpp @@ -49,37 +49,37 @@ bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x unsigned char yType = y->GetType(); while ((i < xName.length()) && (i < yName.length())) - { - if (tolower (xName[i]) < tolower (yName[i])) - { - noWinner = false; - returnValue = true; - break; - } - else if (tolower (xName[i]) > tolower (yName[i])) { - noWinner = false; - returnValue = false; - break; + if (tolower (xName[i]) < tolower (yName[i])) + { + noWinner = false; + returnValue = true; + break; + } + else if (tolower (xName[i]) > tolower (yName[i])) + { + noWinner = false; + returnValue = false; + break; + } + i++; } - i++; - } if(noWinner) - { - if (xName.length() < yName.length()) - returnValue = true; - else - returnValue = false; - } + { + if (xName.length() < yName.length()) + returnValue = true; + else + returnValue = false; + } if(xType != yType) - { - if(xType == wxDIR_DIRS) - returnValue = true; - else - returnValue = false; - } + { + if(xType == wxDIR_DIRS) + returnValue = true; + else + returnValue = false; + } return returnValue; } @@ -145,10 +145,10 @@ const int& modelCDMIProjectTreeNode::GetLength() const bool modelCDMIProjectTreeNode::OpenInFileExplorer(std::string*& result) const { if (!CDMUtilities::openFileExplorer(this->GetPath())) - return true; - else - { - result = new std::string("Couldn't open file."); - return false; - } + return true; + else + { + result = new std::string("Couldn't open file."); + return false; + } } diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index 2403351..11b5f37 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -159,17 +159,6 @@ modelCDMLibrary* modelCDMLib::CreateLibrary( return library; } -bool modelCDMLib::OpenCMakeListsFile(std::string*& result) -{ - if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath())) - return true; - else - { - result = new std::string("Couldn't open CMakeLists file."); - return false; - } -} - const bool modelCDMLib::Refresh(std::string*& result) { this->type = wxDIR_DIRS; diff --git a/lib/creaDevManagerLib/modelCDMLib.h b/lib/creaDevManagerLib/modelCDMLib.h index 8f4fc74..47de063 100644 --- a/lib/creaDevManagerLib/modelCDMLib.h +++ b/lib/creaDevManagerLib/modelCDMLib.h @@ -56,7 +56,6 @@ public: const std::string& path = "/" ); - bool OpenCMakeListsFile(std::string*& result); virtual const bool Refresh(std::string*& result); private: diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp index 390af69..e7bde23 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp @@ -129,6 +129,8 @@ void wxCDMAppliDescriptionPanel::CreateControls() actionsPanelSizer->Add(createApplicationbt, 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->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnCMakeMouseExit,NULL,this); actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Applications Folder")); openFolderbt->SetToolTip(wxT("Open the appli folder in the file explorer.")); @@ -181,9 +183,19 @@ void wxCDMAppliDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event) void wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->appli->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->appli->GetCMakeLists() != NULL) + { + int CMId = this->appli->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } } void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event) @@ -219,9 +231,9 @@ void wxCDMAppliDescriptionPanel::OnBtnReturn(wxCommandEvent& event) void wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->appli->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } void wxCDMAppliDescriptionPanel::OnMouseEnter(wxMouseEvent& event) @@ -264,3 +276,30 @@ void wxCDMAppliDescriptionPanel::OnMouseExit(wxMouseEvent& event) event.Skip(); } +void wxCDMAppliDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->appli->GetCMakeLists() != NULL) + { + int CMId = this->appli->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMAppliDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->appli->GetCMakeLists() != NULL) + { + int CMId = this->appli->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h index dd44456..6e350a0 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h @@ -82,6 +82,8 @@ protected: void OnMouseEnter(wxMouseEvent& event); void OnMouseExit(wxMouseEvent& event); + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); }; diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index 524e64f..d31f2b2 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -129,6 +129,8 @@ void wxCDMLibDescriptionPanel::CreateControls() 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 Lib's CMakeLists.txt file.")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseExit,NULL,this); 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.")); @@ -182,6 +184,16 @@ void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) std::string* result; if(!this->lib->OpenCMakeListsFile(result)) wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->lib->GetCMakeLists() != NULL) + { + int CMId = this->lib->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } } void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event) @@ -263,3 +275,31 @@ void wxCDMLibDescriptionPanel::OnMouseExit(wxMouseEvent& event) wxPostEvent(this->GetParent(), *newEvent); event.Skip(); } + +void wxCDMLibDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->lib->GetCMakeLists() != NULL) + { + int CMId = this->lib->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMLibDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->lib->GetCMakeLists() != NULL) + { + int CMId = this->lib->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h index 17922de..bcf23ff 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h @@ -82,6 +82,8 @@ protected: void OnMouseEnter(wxMouseEvent& event); void OnMouseExit(wxMouseEvent& event); + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); }; -- 2.47.1