Index: frmStatus.h =================================================================== RCS file: /projects/pgadmin3/src/include/frmStatus.h,v retrieving revision 1.12 retrieving revision 1.13 diff -Lsrc/include/frmStatus.h -Lsrc/include/frmStatus.h -u -w -r1.12 -r1.13 --- src/include/frmStatus.h +++ src/include/frmStatus.h @@ -45,7 +45,7 @@ void OnTerminateBtn(wxCommandEvent &event); void OnCancelBtn(wxCommandEvent &event); void OnSelStatusItem(wxListEvent &event); - + void OnSelLockItem(wxListEvent &event); void addLog(const wxString &str); Index: frmStatus.cpp =================================================================== RCS file: /projects/pgadmin3/src/ui/frmStatus.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -Lsrc/ui/frmStatus.cpp -Lsrc/ui/frmStatus.cpp -u -w -r1.29 -r1.30 --- src/ui/frmStatus.cpp +++ src/ui/frmStatus.cpp @@ -37,6 +37,8 @@ EVT_TIMER(TIMER_ID, frmStatus::OnRefreshTimer) EVT_LIST_ITEM_SELECTED(XRCID("lstStatus"), frmStatus::OnSelStatusItem) EVT_LIST_ITEM_DESELECTED(XRCID("lstStatus"), frmStatus::OnSelStatusItem) + EVT_LIST_ITEM_SELECTED(XRCID("lstLocks"), frmStatus::OnSelLockItem) + EVT_LIST_ITEM_DESELECTED(XRCID("lstLocks"), frmStatus::OnSelLockItem) END_EVENT_TABLE(); @@ -170,6 +172,10 @@ if (!loaded) return; wxCommandEvent nullEvent; OnRefresh(nullEvent); + + // Disable the buttons. They'll get re-enabled if a suitable item is selected. + btnCancel->Enable(false); + btnTerminate->Enable(false); } @@ -468,22 +474,36 @@ if (wxMessageBox(_("Are you sure you wish to cancel the selected query(s)?"), _("Cancel query?"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION) == wxNO) return; + ctlListView *lv; + + if (nbStatus->GetSelection() == 0) + lv = statusList; + + else if (nbStatus->GetSelection() == 1) + lv = lockList; + + else + { + wxLogError(_("Couldn't determine the source listview for a cancel backend operation!")); + return; + } + long item = -1; wxString pid; for ( ;; ) { - item = statusList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + item = lv->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if ( item == -1 ) break; - pid = statusList->GetItemText(item); + pid = lv->GetItemText(item); wxString sql = wxT("SELECT pg_cancel_backend(") + pid + wxT(");"); connection->ExecuteScalar(sql); } - OnRefresh(*(wxCommandEvent*)&event); wxMessageBox(_("A cancel signal was sent to the selected server process(es)."), _("Cancel query"), wxOK | wxICON_INFORMATION); + OnRefresh(*(wxCommandEvent*)&event); } void frmStatus::OnTerminateBtn(wxCommandEvent &event) @@ -491,23 +511,37 @@ if (wxMessageBox(_("Are you sure you wish to terminate the selected server process(es)?"), _("Terminate process?"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION) == wxNO) return; + ctlListView *lv; + + if (nbStatus->GetSelection() == 0) + lv = statusList; + + else if (nbStatus->GetSelection() == 1) + lv = lockList; + + else + { + wxLogError(_("Couldn't determine the source listview for a terminate backend operation!")); + return; + } + long item = -1; wxString pid; for ( ;; ) { - item = statusList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + item = lv->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if ( item == -1 ) break; - pid = statusList->GetItemText(item); + pid = lv->GetItemText(item); wxString sql = wxT("SELECT pg_terminate_backend(") + pid + wxT(");"); connection->ExecuteScalar(sql); } - OnRefresh(*(wxCommandEvent*)&event); wxMessageBox(_("A terminate signal was sent to the selected server process(es)."), _("Terminate process"), wxOK | wxICON_INFORMATION); + OnRefresh(*(wxCommandEvent*)&event); } void frmStatus::OnSelStatusItem(wxListEvent &event) @@ -526,3 +560,20 @@ } } } + +void frmStatus::OnSelLockItem(wxListEvent &event) +{ + if (connection->BackendMinimumVersion(7, 5)) + { + if(lockList->GetSelectedItemCount() >= 0) + { + btnCancel->Enable(true); + btnTerminate->Enable(true); + } + else + { + btnCancel->Enable(false); + btnTerminate->Enable(false); + } + } +} Index: frmStatus.xrc =================================================================== RCS file: /projects/pgadmin3/src/ui/common/frmStatus.xrc,v retrieving revision 1.9 retrieving revision 1.10 diff -Lsrc/ui/common/frmStatus.xrc -Lsrc/ui/common/frmStatus.xrc -u -w -r1.9 -r1.10 --- src/ui/common/frmStatus.xrc +++ src/ui/common/frmStatus.xrc @@ -6,7 +6,7 @@ 1 - 2 + 3 1 @@ -65,44 +65,10 @@ 395,273d - - - 1 - 2 - 5,24 - wxTOP|wxLEFT|wxEXPAND|wxGROW|wxALIGN_CENTRE - - - - 2 - 1 - - - - 53,15d - - wxBOTTOM|wxLEFT|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL - 2 - - - - - 53,15d - - wxBOTTOM|wxLEFT|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL - 2 - - 8 - - - 0 - 0 - - @@ -123,6 +89,28 @@ 2 0 + + + 3 + 1 + + + + 53,15d + + wxBOTTOM|wxLEFT|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL + 5 + + + + + 53,15d + + wxBOTTOM|wxLEFT|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL + 5 + + + \ No newline at end of file