Allow the contents of the panes on the Server Status window to be copied to the clipb...
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Fri, 27 Feb 2009 10:50:10 +0000 (10:50 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Fri, 27 Feb 2009 10:50:10 +0000 (10:50 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7618 a7884b65-44f6-0310-8a51-81a127f17b15

CHANGELOG
pgadmin/frm/frmStatus.cpp
pgadmin/include/frm/frmStatus.h

index cf19c61a44a44e0ef9c9a71d9507300f4622aca6..25185db9cc327b41550b800c4e5760eec1f2c2aa 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,8 @@ Changes
 \r
 Date       Dev Ver    Change details\r
 ---------- --- -----  --------------\r
+2009-02-27 GL  1.9.0  Allow the contents of the panes on the Server Status \r
+                      window to be copied to the clipboard.\r
 2009-02-26 GL  1.9.0  Complete UI rework of the "Server Status" Window.\r
 2009-02-23 DP  1.9.0  Add support for per-table TOAST autovacuum settings in\r
                       PostgreSQL 8.4+ [Ashesh Vashi].\r
index f5acbbef51dfaee45594c47ac119268cea4c293d..9cf1dd0ab4dc2c552ec98d334526f48808845804 100644 (file)
@@ -16,6 +16,7 @@
 #include <wx/xrc/xmlres.h>
 #include <wx/image.h>
 #include <wx/textbuf.h>
+#include <wx/clipbrd.h>
 
 // wxAUI
 #include <wx/aui/aui.h>
@@ -30,6 +31,7 @@
 #include "ctl/ctlMenuToolbar.h"
 
 // Icons
+#include "images/clip_copy.xpm"
 #include "images/readdata.xpm"
 #include "images/query_cancel.xpm"
 #include "images/terminate_backend.xpm"
 BEGIN_EVENT_TABLE(frmStatus, pgFrame)
     EVT_MENU(MNU_EXIT,                                         frmStatus::OnExit)
     
-/* We will uncomment this when we will have a need for these actions
-    EVT_MENU(MNU_CUT,                                          frmStatus::OnCut)
     EVT_MENU(MNU_COPY,                                         frmStatus::OnCopy)
-    EVT_MENU(MNU_PASTE,                                        frmStatus::OnPaste)
-    EVT_MENU(MNU_CLEAR,                                        frmStatus::OnClear)
-    EVT_MENU(MNU_UNDO,                                         frmStatus::OnUndo)
-    EVT_MENU(MNU_REDO,                                         frmStatus::OnRedo)
-*/
 
     EVT_MENU(MNU_HELP,                                         frmStatus::OnHelp)
     EVT_MENU(MNU_STATUSPAGE,                                   frmStatus::OnToggleStatusPane)
@@ -185,13 +180,7 @@ frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFr
     menuBar->Append(fileMenu, _("&File"));
 
     editMenu = new wxMenu();
-    editMenu->Append(MNU_UNDO, _("&Undo\tCtrl-Z"), _("Undo last action"), wxITEM_NORMAL);
-    editMenu->Append(MNU_REDO, _("&Redo\tCtrl-Y"), _("Redo last action"), wxITEM_NORMAL);
-    editMenu->AppendSeparator();
-    editMenu->Append(MNU_CUT, _("Cu&t\tCtrl-X"), _("Cut selected text to clipboard"), wxITEM_NORMAL);
     editMenu->Append(MNU_COPY, _("&Copy\tCtrl-C"), _("Copy selected text to clipboard"), wxITEM_NORMAL);
-    editMenu->Append(MNU_PASTE, _("&Paste\tCtrl-V"), _("Paste selected text from clipboard"), wxITEM_NORMAL);
-    editMenu->Append(MNU_CLEAR, _("C&lear window"), _("Clear edit window"), wxITEM_NORMAL);
 
     menuBar->Append(editMenu, _("&Edit"));
 
@@ -212,15 +201,8 @@ frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFr
 
     menuBar->Append(helpMenu, _("&Help"));
     
-    // Fix edit menu
-    // Currently all disabled because we don't really need edit items
-    // They are only there because they are sort-of standards
-    editMenu->Enable(MNU_UNDO, false);
-    editMenu->Enable(MNU_REDO, false);
-    editMenu->Enable(MNU_CUT, false);
+    // Setup edit menu
     editMenu->Enable(MNU_COPY, false);
-    editMenu->Enable(MNU_PASTE, false);
-    editMenu->Enable(MNU_CLEAR, false);
 
     // Finish menu bar
     SetMenuBar(menuBar);
@@ -233,6 +215,9 @@ frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFr
     toolBar = new ctlMenuToolbar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_NODIVIDER);
     toolBar->SetToolBitmapSize(wxSize(16, 16));
     toolBar->AddTool(MNU_REFRESH, _("Refresh"), wxBitmap(readdata_xpm), _("Refresh"), wxITEM_NORMAL);
+    toolBar->AddSeparator();
+    toolBar->AddTool(MNU_COPY, _("Copy"), wxBitmap(clip_copy_xpm), _("Copy selected text to clipboard"), wxITEM_NORMAL);
+    toolBar->AddSeparator();
     toolBar->AddTool(MNU_CANCEL, _("Cancel"), wxBitmap(query_cancel_xpm), _("Cancel query"), wxITEM_NORMAL);
     toolBar->AddTool(MNU_TERMINATE, _("Terminate"), wxBitmap(terminate_backend_xpm), _("Terminate backend"), wxITEM_NORMAL);
     toolBar->AddTool(MNU_COMMIT, _("Commit"), wxBitmap(storedata_xpm), _("Commit transaction"), wxITEM_NORMAL);
@@ -282,7 +267,9 @@ frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFr
     // Get our PID
     backend_pid = connection->GetBackendPID();
     
-    // Create the refresh timer (half a second)
+    // Create the refresh timer (quarter of a second)
+    // This is a horrible hack to get around the lack of a 
+    // PANE_ACTIVATED event in wxAUI.
     refreshUITimer = new wxTimer(this, TIMER_REFRESHUI_ID);
     refreshUITimer->Start(250);
 
@@ -607,6 +594,57 @@ void frmStatus::AddLogPane()
 }
 
 
+void frmStatus::OnCopy(wxCommandEvent& ev)
+{
+    ctlListView *list;
+    int row, col;
+    wxString text;
+    
+    switch(currentPane)
+    {
+        case PANE_STATUS:
+            list = statusList;
+            break;
+        case PANE_LOCKS:
+            list = lockList;
+            break;
+        case PANE_XACT:
+            list = xactList;
+            break;
+        case PANE_LOG:
+            list = logList;
+            break;
+        default:
+            // This shouldn't happen.
+            // If it does, it's no big deal, we just need to get out.
+            return;
+            break;
+    }
+    
+    row = list->GetFirstSelected();
+    
+    while (row >= 0)
+    {
+        for (col = 0; col < list->GetColumnCount(); col++)
+        {
+            text.Append(list->GetText(row, col) + wxT("\t"));
+        }
+#ifdef __WXMSW__
+        text.Append(wxT("\r\n"));
+#else
+        text.Append(wxT("\n"));
+#endif
+        row = list->GetNextSelected(row);
+    }
+    
+    if (text.Length() > 0 && wxTheClipboard->Open())
+    {
+        wxTheClipboard->SetData(new wxTextDataObject(text));
+        wxTheClipboard->Close();
+    }
+}
+
+
 void frmStatus::OnPaneClose(wxAuiManagerEvent& evt)
 {
     if (evt.pane->name == statusTitle)
@@ -1363,14 +1401,14 @@ void frmStatus::addLogFile(const wxString &filename, const wxDateTime timestamp,
                 continue;
             }
             if (tk.HasMoreTokens() || hasCr)
-                addLogLine(str);
+                addLogLine(str.Trim());
             else
                 line = str;
         }
         logList->Thaw();
     }
     if (!line.IsEmpty())
-        addLogLine(line);
+        addLogLine(line.Trim());
 }
 
 
@@ -1450,7 +1488,7 @@ int frmStatus::fillLogfileCombo()
 {
     int count=cbLogfiles->GetCount();
     if (!count)
-        cbLogfiles->Append(_(" current"));
+        cbLogfiles->Append(_("Current log"));
     else
         count--;
 
@@ -1771,6 +1809,8 @@ void frmStatus::OnSelStatusItem(wxListEvent &event)
     toolBar->EnableTool(MNU_ROLLBACK, false);
     cbLogfiles->Enable(false);
     btnRotateLog->Enable(false);
+    
+    editMenu->Enable(MNU_COPY, statusList->GetFirstSelected()>=0);
 }
 
 
@@ -1803,6 +1843,8 @@ void frmStatus::OnSelLockItem(wxListEvent &event)
     toolBar->EnableTool(MNU_ROLLBACK, false);
     cbLogfiles->Enable(false);
     btnRotateLog->Enable(false);
+    
+    editMenu->Enable(MNU_COPY, lockList->GetFirstSelected()>=0);
 }
 
 
@@ -1831,6 +1873,8 @@ void frmStatus::OnSelXactItem(wxListEvent &event)
     toolBar->EnableTool(MNU_TERMINATE, false);
     cbLogfiles->Enable(false);
     btnRotateLog->Enable(false);
+    
+    editMenu->Enable(MNU_COPY, xactList->GetFirstSelected()>=0);
 }
 
 
@@ -1851,6 +1895,8 @@ void frmStatus::OnSelLogItem(wxListEvent &event)
     toolBar->EnableTool(MNU_TERMINATE, false);
     toolBar->EnableTool(MNU_COMMIT, false);
     toolBar->EnableTool(MNU_ROLLBACK, false);
+    
+    editMenu->Enable(MNU_COPY, logList->GetFirstSelected()>=0);
 }
 
 
index 4af6090c4923fd74722e7bd842666e3624253b60..c707142c5013c0f321f52942b0a70fb2d3676626 100644 (file)
@@ -67,12 +67,12 @@ enum
 #define FRMSTATUS_PERSPECTIVE_VER wxT("$Rev$")
 
 #ifdef __WXMAC__
-#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6293500;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=321;besth=244;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=462;floaty=165;floatw=595;floath=282|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=321;besth=244;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-231;floaty=235;floatw=595;floath=282|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=0;pos=2;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=461;floaty=527;floatw=595;floath=282|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-103;floaty=351;floatw=595;floath=282|name=toolBar;caption=Tool bar;state=2124528;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=558;besth=33;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=888;floaty=829;floatw=558;floath=49|dock_size(4,0,0)=583|dock_size(5,0,0)=10|dock_size(1,10,0)=35|")
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6293500;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=321;besth=244;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=462;floaty=165;floatw=595;floath=282|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=321;besth=244;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-231;floaty=235;floatw=595;floath=282|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=0;pos=2;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=461;floaty=527;floatw=595;floath=282|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-103;floaty=351;floatw=595;floath=282|name=toolBar;caption=Tool bar;state=2124528;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=608;besth=33;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=888;floaty=829;floatw=558;floath=49|dock_size(4,0,0)=583|dock_size(5,0,0)=10|dock_size(1,10,0)=35|")
 #else
 #ifdef __WXGTK__
-#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6293500;dir=4;layer=0;row=0;pos=2;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=2108144;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=609;besth=31;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(4,0,0)=549|dock_size(5,0,0)=22|dock_size(1,10,0)=33|")
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6293500;dir=4;layer=0;row=0;pos=2;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=2108144;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=659;besth=31;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(4,0,0)=549|dock_size(5,0,0)=22|dock_size(1,10,0)=33|")
 #else
-#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6309884;dir=4;layer=0;row=1;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=174;floaty=216;floatw=578;floath=282|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=1;pos=1;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=136;floaty=339;floatw=576;floath=283|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=1;pos=2;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=133;floaty=645;floatw=577;floath=283|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=2108144;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=466;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=586;floaty=525;floatw=483;floath=49|dock_size(5,0,0)=22|dock_size(1,10,0)=25|dock_size(4,0,1)=627|")
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6309884;dir=4;layer=0;row=1;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=174;floaty=216;floatw=578;floath=282|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=1;pos=1;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=136;floaty=339;floatw=576;floath=283|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=1;pos=2;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=133;floaty=645;floatw=577;floath=283|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=2108144;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=516;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=586;floaty=525;floatw=483;floath=49|dock_size(5,0,0)=22|dock_size(1,10,0)=25|dock_size(4,0,1)=627|")
 #endif
 #endif
 
@@ -131,6 +131,8 @@ private:
 
     void OnHelp(wxCommandEvent& ev);
     void OnExit(wxCommandEvent& event);
+    
+    void OnCopy(wxCommandEvent& ev);
 
     void OnToggleStatusPane(wxCommandEvent& event);
     void OnToggleLockPane(wxCommandEvent& event);