From: Daniel Gonzalez Date: Wed, 16 Jan 2013 13:30:57 +0000 (+0100) Subject: Feature #1711 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b8ae511b1e62c48bf4a418a13812d3ada5063550;p=crea.git Feature #1711 CreaDevManager application implementation -"Open Cmakelists" buttons in help dialogs now working! --- diff --git a/lib/creaDevManagerLib/wxCDMAppliHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMAppliHelpDialog.cpp index e3d487e..a363381 100644 --- a/lib/creaDevManagerLib/wxCDMAppliHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliHelpDialog.cpp @@ -37,6 +37,7 @@ #include "creaDevManagerIds.h" + BEGIN_EVENT_TABLE(wxCDMAppliHelpDialog, wxDialog) EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMAppliHelpDialog::OnFinish) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliHelpDialog::OnEditCMake) @@ -104,6 +105,11 @@ void wxCDMAppliHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); + wxButton* editCMakeAppliBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit Appli's CMakeLists File")); + editCMakeAppliBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeAppliBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliHelpDialog::OnCMakeListsExit,NULL,this); + v_sizer1->Add(editCMakeAppliBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30); @@ -119,23 +125,47 @@ void wxCDMAppliHelpDialog::OnFinish(wxCommandEvent& event) void wxCDMAppliHelpDialog::OnEditCMake(wxCommandEvent& event) { - //TODO: implement method - std::cout << "OnEditCMake not implemented yet." << 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 wxCDMAppliHelpDialog::OnEditCMakeMouseEnter(wxMouseEvent& event) +void wxCDMAppliHelpDialog::OnCMakeListsEnter(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnEditCMakeEnter not implemented yet." << std::endl; + 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 wxCDMAppliHelpDialog::OnEditCMakeMouseExit(wxMouseEvent& event) +void wxCDMAppliHelpDialog::OnCMakeListsExit(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnEditCMakeExit not implemented yet." << std::endl; + 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/wxCDMAppliHelpDialog.h b/lib/creaDevManagerLib/wxCDMAppliHelpDialog.h index 4f60da9..e788468 100644 --- a/lib/creaDevManagerLib/wxCDMAppliHelpDialog.h +++ b/lib/creaDevManagerLib/wxCDMAppliHelpDialog.h @@ -77,8 +77,8 @@ protected: void OnEditCMake(wxCommandEvent& event); - void OnEditCMakeMouseEnter(wxMouseEvent& event); - void OnEditCMakeMouseExit(wxMouseEvent& event); + void OnCMakeListsEnter(wxMouseEvent& event); + void OnCMakeListsExit(wxMouseEvent& event); void OnDisableHelp(wxCommandEvent& event); }; diff --git a/lib/creaDevManagerLib/wxCDMApplicationHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMApplicationHelpDialog.cpp index d9ff03a..44c9b6b 100644 --- a/lib/creaDevManagerLib/wxCDMApplicationHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMApplicationHelpDialog.cpp @@ -37,6 +37,8 @@ #include "creaDevManagerIds.h" +#include "modelCDMAppli.h" + BEGIN_EVENT_TABLE(wxCDMApplicationHelpDialog, wxDialog) EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMApplicationHelpDialog::OnFinish) EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMApplicationHelpDialog::OnCMakeLists) @@ -111,11 +113,15 @@ void wxCDMApplicationHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); - wxButton* editCMakePKGBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Application's directory CMakeLists file")); - wxButton* editCMakePRJBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Appli's directory CMakeLists file")); + wxButton* editCMakeApplicationBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Application's directory CMakeLists file")); + editCMakeApplicationBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeApplicationBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsExit,NULL,this); + wxButton* editCMakeAppliBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Appli's directory CMakeLists file")); + editCMakeAppliBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeAppliBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsExit,NULL,this); - v_sizer1->Add(editCMakePKGBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); - v_sizer1->Add(editCMakePRJBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakeApplicationBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakeAppliBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); @@ -132,22 +138,124 @@ void wxCDMApplicationHelpDialog::OnFinish(wxCommandEvent& event) void wxCDMApplicationHelpDialog::OnCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cout << "OnCMakeLists not implemented yet." << std::endl; - event.Skip(); + std::string* result; + + if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE) + { + + if(!this->application->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->application->GetCMakeLists() != NULL) + { + int CMId = this->application->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->application; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + if(!((modelCDMAppli*)node)->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMAppli*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMAppli*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else + { + wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + } + } } void wxCDMApplicationHelpDialog::OnCMakeListsEnter(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsEnter not implemented yet." << std::endl; + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->application->GetCMakeLists() != NULL) + { + int CMId = this->application->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->application; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(((modelCDMAppli*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMAppli*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } event.Skip(); } void wxCDMApplicationHelpDialog::OnCMakeListsExit(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsExit not implemented yet." << std::endl; + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->application->GetCMakeLists() != NULL) + { + int CMId = this->application->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->application; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMAppli*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMAppli*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } event.Skip(); } diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMBlackBoxHelpDialog.cpp index 4d4ff43..480e9d0 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMBlackBoxHelpDialog.cpp @@ -37,6 +37,9 @@ #include "creaDevManagerIds.h" +#include "modelCDMProject.h" +#include "modelCDMPackage.h" + BEGIN_EVENT_TABLE(wxCDMBlackBoxHelpDialog, wxDialog) EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMBlackBoxHelpDialog::OnFinish) EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMBlackBoxHelpDialog::OnCMakeLists) @@ -113,11 +116,15 @@ void wxCDMBlackBoxHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); - wxButton* editCMakePKGBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Package's directory CMakeLists file")); - wxButton* editCMakePRJBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Project's directory CMakeLists file")); + wxButton* editCMakePkgBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Package's directory CMakeLists file")); + editCMakePkgBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakePkgBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsExit,NULL,this); + wxButton* editCMakePrjBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Project's directory CMakeLists file")); + editCMakePrjBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakePrjBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsExit,NULL,this); - v_sizer1->Add(editCMakePKGBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); - v_sizer1->Add(editCMakePRJBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakePkgBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakePrjBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); @@ -134,23 +141,152 @@ void wxCDMBlackBoxHelpDialog::OnFinish(wxCommandEvent& event) void wxCDMBlackBoxHelpDialog::OnCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cout << "OnCMakeLists not implemented yet." << std::endl; - event.Skip(); + std::string* result; + + if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE) + { + modelCDMIProjectTreeNode* node = this->blackBox; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + if(!((modelCDMPackage*)node)->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMPackage*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMPackage*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else + { + wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->blackBox; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + if(!((modelCDMProject*)node)->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMProject*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else + { + wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + } + } } void wxCDMBlackBoxHelpDialog::OnCMakeListsEnter(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsEnter not implemented yet." << std::endl; + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + modelCDMIProjectTreeNode* node = this->blackBox; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(((modelCDMPackage*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMPackage*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->blackBox; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(((modelCDMProject*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } event.Skip(); } void wxCDMBlackBoxHelpDialog::OnCMakeListsExit(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsExit not implemented yet." << std::endl; - event.Skip(); + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + modelCDMIProjectTreeNode* node = this->blackBox; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMPackage*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMPackage*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->blackBox; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMProject*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + event.Skip(); } void wxCDMBlackBoxHelpDialog::OnDisableHelp(wxCommandEvent& event) diff --git a/lib/creaDevManagerLib/wxCDMLibHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMLibHelpDialog.cpp index 85e83aa..c6601ff 100644 --- a/lib/creaDevManagerLib/wxCDMLibHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMLibHelpDialog.cpp @@ -104,6 +104,11 @@ void wxCDMLibHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); + wxButton* editCMakeLibBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit Lib's CMakeLists File")); + editCMakeLibBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibHelpDialog::OnEditCMakeMouseEnter,NULL,this); + editCMakeLibBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibHelpDialog::OnEditCMakeMouseExit,NULL,this); + v_sizer1->Add(editCMakeLibBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30); @@ -119,23 +124,47 @@ void wxCDMLibHelpDialog::OnFinish(wxCommandEvent& event) void wxCDMLibHelpDialog::OnEditCMake(wxCommandEvent& event) { - //TODO: implement method - std::cout << "OnEditCMake not implemented yet." << std::endl; - event.Skip(); + 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 wxCDMLibHelpDialog::OnEditCMakeMouseEnter(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnEditCMakeEnter not implemented yet." << std::endl; + 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 wxCDMLibHelpDialog::OnEditCMakeMouseExit(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnEditCMakeExit not implemented yet." << std::endl; + 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/wxCDMLibraryHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp index 455b559..9f01d42 100644 --- a/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp @@ -37,6 +37,8 @@ #include "creaDevManagerIds.h" +#include "modelCDMLib.h" + BEGIN_EVENT_TABLE(wxCDMLibraryHelpDialog, wxDialog) EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMLibraryHelpDialog::OnFinish) EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMLibraryHelpDialog::OnCMakeLists) @@ -111,11 +113,15 @@ void wxCDMLibraryHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); - wxButton* editCMakePKGBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Library's directory CMakeLists file")); - wxButton* editCMakePRJBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Lib's directory CMakeLists file")); + wxButton* editCMakeLibraryBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Library's directory CMakeLists file")); + editCMakeLibraryBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeLibraryBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsExit,NULL,this); + wxButton* editCMakeLibBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Lib's directory CMakeLists file")); + editCMakeLibBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeLibBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsExit,NULL,this); - v_sizer1->Add(editCMakePKGBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); - v_sizer1->Add(editCMakePRJBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakeLibraryBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakeLibBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); @@ -132,23 +138,125 @@ void wxCDMLibraryHelpDialog::OnFinish(wxCommandEvent& event) void wxCDMLibraryHelpDialog::OnCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cout << "OnCMakeLists not implemented yet." << std::endl; - event.Skip(); + std::string* result; + + if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE) + { + + if(!this->library->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->library->GetCMakeLists() != NULL) + { + int CMId = this->library->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->library; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + if(!((modelCDMLib*)node)->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMLib*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMLib*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else + { + wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + } + } } void wxCDMLibraryHelpDialog::OnCMakeListsEnter(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsEnter not implemented yet." << std::endl; + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + int CMId = this->library->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->library; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(((modelCDMLib*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMLib*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } event.Skip(); } void wxCDMLibraryHelpDialog::OnCMakeListsExit(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsExit not implemented yet." << std::endl; - event.Skip(); + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + int CMId = this->library->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->library; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMLib*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMLib*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + event.Skip(); } void wxCDMLibraryHelpDialog::OnDisableHelp(wxCommandEvent& event) diff --git a/lib/creaDevManagerLib/wxCDMPackageHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMPackageHelpDialog.cpp index 0a30fa5..c7b468e 100644 --- a/lib/creaDevManagerLib/wxCDMPackageHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageHelpDialog.cpp @@ -37,7 +37,11 @@ #include "creaDevManagerIds.h" +#include "modelCDMProject.h" + BEGIN_EVENT_TABLE(wxCDMPackageHelpDialog, wxDialog) +EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMPackageHelpDialog::OnCMakeLists) +EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageHelpDialog::OnCMakeLists) EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMPackageHelpDialog::OnFinish) EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMPackageHelpDialog::OnDisableHelp) END_EVENT_TABLE() @@ -105,11 +109,15 @@ void wxCDMPackageHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); - wxButton* editCMakePKGBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Package's directory CMakeLists file")); - wxButton* editCMakePRJBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Project's directory CMakeLists file")); + wxButton* editCMakePkgBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Package's directory CMakeLists file")); + editCMakePkgBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakePkgBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsExit,NULL,this); + wxButton* editCMakePrjBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Project's directory CMakeLists file")); + editCMakePrjBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakePrjBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsExit,NULL,this); - v_sizer1->Add(editCMakePKGBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); - v_sizer1->Add(editCMakePRJBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakePkgBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakePrjBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); @@ -119,6 +127,129 @@ void wxCDMPackageHelpDialog::CreateControls() //v_sizer1->RecalcSizes(); } +void wxCDMPackageHelpDialog::OnCMakeLists(wxCommandEvent& event) +{ + std::string* result; + + if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE) + { + + if(!this->package->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->package->GetCMakeLists() != NULL) + { + int CMId = this->package->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->package; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + if(!((modelCDMProject*)node)->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMProject*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else + { + wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + } + } +} + +void wxCDMPackageHelpDialog::OnCMakeListsEnter(wxMouseEvent& event) +{ + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->package->GetCMakeLists() != NULL) + { + int CMId = this->package->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->package; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(((modelCDMProject*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + event.Skip(); +} + +void wxCDMPackageHelpDialog::OnCMakeListsExit(wxMouseEvent& event) +{ + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->package->GetCMakeLists() != NULL) + { + int CMId = this->package->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->package; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(((modelCDMProject*)node)->GetCMakeLists() != NULL) + { + int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + event.Skip(); +} + void wxCDMPackageHelpDialog::OnFinish(wxCommandEvent& event) { this->EndDialog(wxID_CANCEL);