Hi,

This patch adds a connection toolbar to the frmStatus window. It allows one to 
change the connection used byt the various reports. It is mostly important for 
the locks report because it's the only way to get the name of locked 
relations.

One thing that bugs me is the log report. It needs to keep the connection to 
the maintenance database because it's the only database where we require to 
have the adminpack functions. Should we keep two connections (one on the 
maintenance database and the one selected in the combobox)? or should we allow 
the change of connection for the locks report only?

Comments welcomed :)


-- 
Guillaume.
 http://www.postgresqlfr.org
 http://dalibo.com
Index: pgadmin/include/frm/frmStatus.h
===================================================================
--- pgadmin/include/frm/frmStatus.h	(révision 8034)
+++ pgadmin/include/frm/frmStatus.h	(copie de travail)
@@ -67,12 +67,12 @@
 #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=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|")
+#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|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
 #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=720;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=720;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|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
 #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=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|")
+#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|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
 #endif
 #endif
 
@@ -108,7 +108,7 @@
     
     long backend_pid;
 
-	bool loaded;
+	bool loaded, loading;
     long logfileLength;
     
     int currentPane;
@@ -116,6 +116,7 @@
     ctlComboBoxFix    *cbRate;
     wxComboBox    *cbLogfiles;
     wxButton      *btnRotateLog;
+    ctlComboBoxFix *cbConnection;
     
     wxTimer *refreshUITimer;
     wxTimer *statusTimer, *locksTimer, *xactTimer, *logTimer;
@@ -144,6 +145,7 @@
     void OnToggleXactPane(wxCommandEvent& event);
     void OnToggleLogPane(wxCommandEvent& event);
     void OnToggleToolBar(wxCommandEvent& event);
+    void OnToggleDatabaseBar(wxCommandEvent& event);
     void OnDefaultView(wxCommandEvent& event);
     
     void OnRefreshUITimer(wxTimerEvent &event);
@@ -173,6 +175,8 @@
     void OnCommit(wxCommandEvent &event);
     void OnRollback(wxCommandEvent &event);
 
+    void OnChangeConnection(wxCommandEvent &ev);
+
     int fillLogfileCombo();
     void emptyLogfileCombo();
 
Index: pgadmin/frm/frmStatus.cpp
===================================================================
--- pgadmin/frm/frmStatus.cpp	(révision 8034)
+++ pgadmin/frm/frmStatus.cpp	(copie de travail)
@@ -26,6 +26,8 @@
 #include "frm/frmStatus.h"
 #include "frm/frmHint.h"
 #include "frm/frmMain.h"
+#include "db/pgConn.h"
+#include "dlg/dlgSelectConnection.h"
 #include "utils/pgfeatures.h"
 #include "schema/pgServer.h"
 #include "ctl/ctlMenuToolbar.h"
@@ -40,6 +42,12 @@
 #include "images/storedata.xpm"
 
 
+#include "db/pgConn.h"
+
+
+#define CTRLID_CONNECTION       4200
+
+
 BEGIN_EVENT_TABLE(frmStatus, pgFrame)
     EVT_MENU(MNU_EXIT,                               frmStatus::OnExit)
     
@@ -51,6 +59,7 @@
     EVT_MENU(MNU_XACTPAGE,                             frmStatus::OnToggleXactPane)
     EVT_MENU(MNU_LOGPAGE,                             frmStatus::OnToggleLogPane)
     EVT_MENU(MNU_TOOLBAR,                             frmStatus::OnToggleToolBar)
+    EVT_MENU(MNU_DATABASEBAR,                         frmStatus::OnToggleDatabaseBar)
     EVT_MENU(MNU_DEFAULTVIEW,                        frmStatus::OnDefaultView)
 
     EVT_AUI_PANE_CLOSE(                             frmStatus::OnPaneClose)
@@ -82,6 +91,8 @@
     EVT_LIST_ITEM_SELECTED(CTL_LOGLIST,                frmStatus::OnSelLogItem)
     EVT_LIST_ITEM_DESELECTED(CTL_LOGLIST,            frmStatus::OnSelLogItem)
 
+    EVT_COMBOBOX(CTRLID_CONNECTION,                   frmStatus::OnChangeConnection)
+
     EVT_CLOSE(                                        frmStatus::OnClose)
 END_EVENT_TABLE();
 
@@ -192,6 +203,7 @@
     viewMenu->Append(MNU_LOGPAGE, _("Log&file\tCtrl-Alt-F"), _("Show or hide the logfile tab."), wxITEM_CHECK);
     viewMenu->AppendSeparator();
     viewMenu->Append(MNU_TOOLBAR, _("Tool&bar\tCtrl-Alt-B"), _("Show or hide the toolbar."), wxITEM_CHECK);
+    viewMenu->Append(MNU_DATABASEBAR, _("&Database bar\tCtrl-Alt-D"), _("Show or hide the database selection bar."), wxITEM_CHECK);
     viewMenu->AppendSeparator();
     viewMenu->Append(MNU_DEFAULTVIEW, _("&Default view\tCtrl-Alt-V"), _("Restore the default view."));
 
@@ -253,6 +265,11 @@
     toolBar->EnableTool(MNU_ROLLBACK, false);
     cbLogfiles->Enable(false);
     btnRotateLog->Enable(false);
+
+    // Add the database selection bar
+    cbConnection = new ctlComboBoxFix(this, CTRLID_CONNECTION, wxDefaultPosition, wxSize(-1, -1), wxCB_READONLY|wxCB_DROPDOWN);
+    cbConnection->Append(connection->GetName(), (void*)connection);
+    cbConnection->Append(_("<new connection>"), (void*)0);
     
     // Create panel
     AddStatusPane();
@@ -260,6 +277,7 @@
     AddXactPane();
     AddLogPane();
     manager.AddPane(toolBar, wxAuiPaneInfo().Name(wxT("toolBar")).Caption(_("Tool bar")).ToolbarPane().Top().LeftDockable(false).RightDockable(false));
+    manager.AddPane(cbConnection, wxAuiPaneInfo().Name(wxT("databaseBar")).Caption(_("Database bar")).ToolbarPane().Top().LeftDockable(false).RightDockable(false));
 
     // Now load the layout
     wxString perspective;
@@ -268,6 +286,7 @@
 
     // Reset the captions for the current language
     manager.GetPane(wxT("toolBar")).Caption(_("Tool bar"));
+    manager.GetPane(wxT("databaseBar")).Caption(_("Database bar"));
     manager.GetPane(wxT("Activity")).Caption(_("Activity"));
     manager.GetPane(wxT("Locks")).Caption(_("Locks"));
     manager.GetPane(wxT("Transactions")).Caption(_("Transactions"));
@@ -282,6 +301,7 @@
     viewMenu->Check(MNU_XACTPAGE, manager.GetPane(wxT("Transactions")).IsShown());
     viewMenu->Check(MNU_LOGPAGE, manager.GetPane(wxT("Logfile")).IsShown());
     viewMenu->Check(MNU_TOOLBAR, manager.GetPane(wxT("toolBar")).IsShown());
+    viewMenu->Check(MNU_DATABASEBAR, manager.GetPane(wxT("databaseBar")).IsShown());
 
     // Get our PID
     backend_pid = connection->GetBackendPID();
@@ -337,8 +357,11 @@
     }
 
     // If connection is still available, delete it
-    if (connection)
-        delete connection;
+    while (cbConnection->GetCount() > 1)
+    {
+        delete (pgConn*)cbConnection->GetClientData(0);
+        cbConnection->Delete(0);
+    }
 }
 
 
@@ -347,6 +370,11 @@
     // Show the window
     Show(true);
     
+    // Open the connection
+    cbConnection->SetSelection(0L);
+    wxCommandEvent ev;
+    OnChangeConnection(ev);
+
     // Send RateChange event to launch each timer
     wxScrollEvent nullScrollEvent;
     if (viewMenu->IsChecked(MNU_STATUSPAGE))
@@ -392,6 +420,52 @@
 }
 
 
+void frmStatus::OnChangeConnection(wxCommandEvent &ev)
+{
+    // On Solaris, this event seems to get fired when the form closes(!!)
+    if(!IsVisible() && !loading)
+        return;
+
+    unsigned int sel=cbConnection->GetCurrentSelection();
+    if (sel == cbConnection->GetCount()-1)
+    {
+        // new Connection
+        dlgSelectConnection dlg(this, mainForm);
+        int rc=dlg.Go(connection, cbConnection);
+        if (rc == wxID_OK)
+        {
+            connection = dlg.CreateConn();
+            if (connection)
+            {
+                cbConnection->Insert(connection->GetName(), sel, (void*)connection);
+                cbConnection->SetSelection(sel);
+                OnChangeConnection(ev);
+            }
+            else
+                rc = wxID_CANCEL;
+        }
+        if (rc != wxID_OK)
+        {
+            unsigned int i;
+            for (i=0 ; i < sel ; i++)
+            {
+                if (cbConnection->GetClientData(i) == connection)
+                {
+                    cbConnection->SetSelection(i);
+                    break;
+                }
+            }
+        }
+    }
+    else
+    {
+        connection = (pgConn*)cbConnection->GetClientData(sel);
+        //title = wxT("Query - ") + cbConnection->GetValue();
+        //setExtendedTitle();
+    }
+}
+
+
 void frmStatus::AddStatusPane()
 {
     // Create panel
@@ -827,12 +901,23 @@
 }
 
 
+void frmStatus::OnToggleDatabaseBar(wxCommandEvent& event)
+{
+    if (viewMenu->IsChecked(MNU_DATABASEBAR))
+        manager.GetPane(wxT("databaseBar")).Show(true);
+    else
+        manager.GetPane(wxT("databaseBar")).Show(false);
+    manager.Update();
+}
+
+
 void frmStatus::OnDefaultView(wxCommandEvent& event)
 {
     manager.LoadPerspective(FRMSTATUS_DEFAULT_PERSPECTIVE, true);
 
     // Reset the captions for the current language
     manager.GetPane(wxT("toolBar")).Caption(_("Tool bar"));
+    manager.GetPane(wxT("databaseBar")).Caption(_("Database bar"));
     manager.GetPane(wxT("Activity")).Caption(_("Activity"));
     manager.GetPane(wxT("Locks")).Caption(_("Locks"));
     manager.GetPane(wxT("Transactions")).Caption(_("Transactions"));
@@ -843,6 +928,7 @@
 
     // Sync the View menu options
     viewMenu->Check(MNU_TOOLBAR, manager.GetPane(wxT("toolBar")).IsShown());
+    viewMenu->Check(MNU_DATABASEBAR, manager.GetPane(wxT("databaseBar")).IsShown());
     viewMenu->Check(MNU_STATUSPAGE, manager.GetPane(wxT("Activity")).IsShown());
     viewMenu->Check(MNU_LOCKPAGE, manager.GetPane(wxT("Locks")).IsShown());
     viewMenu->Check(MNU_XACTPAGE, manager.GetPane(wxT("Transactions")).IsShown());
-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to