X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcreaDevManagerLib%2FwxCDMAppliDescriptionPanel.cpp;h=e7bde237655fd912d6c41851b4c880fc5f388612;hb=311bdcc514f85386f3bbbef9ff6a88bf69fd930f;hp=249ddfef5943a9e8aaa291b3ca015171938db968;hpb=d5f5793ca845b49bb8ef8e7e3880f4373ce0c6bc;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp index 249ddfe..e7bde23 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp @@ -44,6 +44,7 @@ EVT_BUTTON(ID_BUTTON_PREV, wxCDMAppliDescriptionPanel::OnBtnReturn) EVT_HYPERLINK(ID_LINK_SELECT_APPLICATION, wxCDMAppliDescriptionPanel::OnLnkApplicationSelect) EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMAppliDescriptionPanel::OnBtnCreateApplication) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMAppliDescriptionPanel::OnBtnOpenFolder) END_EVENT_TABLE() wxCDMAppliDescriptionPanel::wxCDMAppliDescriptionPanel( @@ -89,39 +90,58 @@ void wxCDMAppliDescriptionPanel::CreateControls() sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5); //Title - sizer->Add(new wxStaticText(this, -1, _("Applications")),0, wxALIGN_CENTER, 0); + sizer->Add(new wxStaticText(this, -1, _("Application Management")),0, wxALIGN_CENTER, 0); //Image sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(ApIcon64)),0, wxALIGN_CENTER, 0); //Applications - wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Available Applications")); - wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL); + wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Applications")); + propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available applications to see its details or the modify them.")); + wxPanel* propertiesPanel = new wxPanel(this); + wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); std::vector applications = this->appli->GetApplications(); for (int i = 0; i < applications.size(); i++) { - wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(this,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str())); - propertiesBoxInnerSizer -> Add(pLibrarylk, 0, wxALIGN_LEFT | wxALL, 5); + wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str())); + std::string tt = "Name: " + applications[i]->GetName() + "\n"; + tt += "Location: " + applications[i]->GetPath(); + pApplicationlk->SetToolTip(crea::std2wx(tt.c_str())); + pApplicationlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseEnter,NULL,this); + pApplicationlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseExit,NULL,this); + propertiesPanelSizer -> Add(pApplicationlk, 0, wxALIGN_LEFT | wxALL, 5); } - sizer -> Add(propertiesBoxInnerSizer, 0, wxEXPAND | wxALL, 10); + 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); + wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions")); + actionsBox->GetStaticBox()->SetToolTip(wxT("Create a new application or make any change to the appli's CMakeLists.txt file by selecting the desired action.")); + wxPanel* actionsPanel = new wxPanel(this); + wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); - wxButton* createApplicationbt = new wxButton(this, ID_BUTTON_CREATE_APPLICATION, _T("Create Application")); + wxButton* createApplicationbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_APPLICATION, _T("Create Application")); createApplicationbt->SetToolTip(wxT("Create a new application for this project.")); - actionsBoxInnerSizer->Add(createApplicationbt, 0, wxEXPAND | wxRIGHT | wxLEFT, 20); - wxButton* editCMakebt = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); + 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.")); - actionsBoxInnerSizer->Add(editCMakebt, 0, wxEXPAND | wxRIGHT | wxLEFT, 20); + 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.")); + actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5); - //Assign sizer - actionsBoxInnerSizer->SetSizeHints(this); + actionsPanel->SetSizer(actionsPanelSizer); + actionsPanelSizer->Fit(actionsPanel); + actionsBox->Add(actionsPanel, 0, wxALL, 5); + sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10); + //Assign sizer SetSizer(sizer); sizer->SetSizeHints(this); } @@ -163,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) @@ -180,6 +210,10 @@ void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event) break; } } + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + newEvent1->SetInt(applicationId); + newEvent1->SetId(0); + wxPostEvent(this->GetParent(), *newEvent1); wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); newEvent->SetInt(applicationId); @@ -194,3 +228,78 @@ void wxCDMAppliDescriptionPanel::OnBtnReturn(wxCommandEvent& event) newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); } + +void wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +{ + std::string* result; + if(!this->appli->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); +} + +void wxCDMAppliDescriptionPanel::OnMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + std::string AppName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int appId = 0; + std::vector applications = this->appli->GetApplications(); + for (int i = 0; i < applications.size(); i++) + { + if(applications[i]->GetName() == AppName) + { + appId = applications[i]->GetId(); + break; + } + } + newEvent->SetInt(appId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + +void wxCDMAppliDescriptionPanel::OnMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + std::string AppName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int appId = 0; + std::vector applications = this->appli->GetApplications(); + for (int i = 0; i < applications.size(); i++) + { + if(applications[i]->GetName() == AppName) + { + appId = applications[i]->GetId(); + break; + } + } + newEvent->SetInt(appId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + 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(); +}