Hi,

Guillaume Lelarge a écrit :
> [...]
> The roadmap still shows I need to work on the server status window. But
> it doesn't explain what I have in mind. Dave gave me some hints and
> todos. Here is my todo list on this :
> 
>  * Replace the wxNotebook widget with the wxAuiNotebook so users can
>    close tabs and rearrange tabs order via drag-and-drop.
> 

This is done in the attached patch. frmStatus.xrc should be removed, all
the widgets are created in frmStatus.cpp.

Please, do not commit, it needs more testing and, I think, more work.
And debug too: in standalone mode, it crashes at exit.

>  * Add the possibility to open many Server Status windows (we can
>    already do this with the SQL query tool) so a user can see many
>    reports at the same time.
> 

Works too.

>  * Add a dockable toolbar to enable changing connection server, timer
>    slider, filter and sort options.
> 

I'm wondering if I should add this and a menubar. My idea is to work
with panes and make it possible to add many panes in a same window. Each
pane will handle one type of report : activity, locks, transactions,
logfile.

> [...]
>  * Colour coding for the backend lines. Say green for running OK, orange
>    for running, but with the query time being past a configurable limit,
>    blue for idle, and red when waiting for a lock etc.
> 

Dave, this one is from you. Where do you want to put the configuration
of the server status. In the options dialog already available? I add a
notebookpage with all server status parameters?

>  * The ability to select a running backend, and copy the query straight
>    into a new query tool window (caveat: the stats command string may be
>    truncated, and still contain parameter placeholders).
> 
>  * Ability to select a backend process and display just the locks
>    it's holding, and the one it's waiting on.
> 

For these two, a contextual menu seems a good choice. Other ideas?

If you have comments, ideas, requests, please speak aloud :)


-- 
Guillaume.
 http://www.postgresqlfr.org
 http://dalibo.com
Index: pgadmin/include/frm/frmStatus.h
===================================================================
--- pgadmin/include/frm/frmStatus.h	(révision 7537)
+++ pgadmin/include/frm/frmStatus.h	(copie de travail)
@@ -19,14 +19,51 @@
 #include <wx/spinctrl.h>
 #include <wx/notebook.h>
 
+// wxAUI
+#include <wx/aui/aui.h>
+
 #include "dlg/dlgClasses.h"
 #include "utils/factory.h"
 
-#define CTL_STATUSLIST 300
+enum
+{
+    CTL_NTBK=250,
+    CTL_RATELABEL,
+    CTL_RATESLIDER,
+    CTL_RATELABEL2,
+    CTL_REFRESHBTN,
+    CTL_CLOSEBTN,
+    CTL_STATUSLIST,
+    CTL_CANCELBTN1,
+    CTL_TERMINATEBTN1,
+    CTL_LOCKLIST,
+    CTL_CANCELBTN2,
+    CTL_TERMINATEBTN2,
+    CTL_XACTLIST,
+    CTL_COMMITBTN,
+    CTL_ROLLBACKBTN,
+    CTL_LOGLIST,
+    CTL_LOGCBO,
+    CTL_ROTATEBTN
+};
 
+
+#define FRMSTATUS_PERSPECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=serverstatus;caption=Server Status;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;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=serverstatus;caption=Server Status;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=525;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=serverstatus;caption=Server Status;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
+#endif
+#endif
+
+
 // Class declarations
 
-class frmStatus : public pgDialog
+class frmStatus : public pgFrame
 {
 public:
     frmStatus(frmMain *form, const wxString& _title, pgConn *conn);
@@ -34,6 +71,17 @@
     void Go();
     
 private:
+    wxSlider     *slRate;
+    wxStaticText *stRate;
+    wxNotebook   *nbStatus;
+    wxComboBox   *cbLogfiles;
+    wxButton     *btnRotateLog;
+    
+    ctlListView *statusList;
+    ctlListView *lockList;
+    ctlListView *xactList;
+    ctlListView *logList;
+
     void OnHelp(wxCommandEvent& ev);
     void OnCloseBtn(wxCommandEvent &event);
     void OnClose(wxCloseEvent &event);
@@ -60,6 +108,8 @@
 
 	void checkConnection();
     
+    wxAuiManager manager;
+    
     frmMain *mainForm;
     wxButton *btnCancelSt, *btnTerminateSt,*btnCancelLk, *btnTerminateLk, *btnCommit, *btnRollback;
 
Index: pgadmin/frm/frmStatus.cpp
===================================================================
--- pgadmin/frm/frmStatus.cpp	(révision 7537)
+++ pgadmin/frm/frmStatus.cpp	(copie de travail)
@@ -17,6 +17,11 @@
 #include <wx/image.h>
 #include <wx/textbuf.h>
 
+/*
+// wxAUI
+#include <wx/aui/aui.h>
+*/
+
 // App headers
 #include "frm/frmStatus.h"
 #include "frm/frmHint.h"
@@ -26,38 +31,29 @@
 
 
 #define TIMER_ID 333
-BEGIN_EVENT_TABLE(frmStatus, pgDialog)
+BEGIN_EVENT_TABLE(frmStatus, pgFrame)
     EVT_BUTTON(wxID_REFRESH,	     				frmStatus::OnRefresh)
     EVT_BUTTON(wxID_CLOSE,	  				        frmStatus::OnCloseBtn)
     EVT_BUTTON(wxID_CANCEL,          				frmStatus::OnCloseBtn)
-    EVT_BUTTON(XRCID("btnCancelSt"),          		frmStatus::OnCancelBtn)
+    EVT_BUTTON(CTL_CANCELBTN1,          		    frmStatus::OnCancelBtn)
     EVT_BUTTON(wxID_STOP,            				frmStatus::OnTerminateBtn)
-    EVT_BUTTON(XRCID("btnCommit"),                  frmStatus::OnCommit)
-    EVT_BUTTON(XRCID("btnRollback"),                frmStatus::OnRollback)
+    EVT_BUTTON(CTL_COMMITBTN,                       frmStatus::OnCommit)
+    EVT_BUTTON(CTL_ROLLBACKBTN,                     frmStatus::OnRollback)
     EVT_CLOSE(										frmStatus::OnClose)
-    EVT_COMMAND_SCROLL(XRCID("slRate"),             frmStatus::OnRateChange)
-	EVT_NOTEBOOK_PAGE_CHANGING(XRCID("nbStatus"),	frmStatus::OnNotebookPageChanged)
+    EVT_COMMAND_SCROLL(CTL_RATESLIDER,              frmStatus::OnRateChange)
+	EVT_NOTEBOOK_PAGE_CHANGING(CTL_NOTEBOOK,        frmStatus::OnNotebookPageChanged)
     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)
-	EVT_LIST_ITEM_SELECTED(XRCID("lstXacts"),		frmStatus::OnSelXactItem)
-	EVT_LIST_ITEM_DESELECTED(XRCID("lstXacts"),		frmStatus::OnSelXactItem)
-    EVT_COMBOBOX(XRCID("cbLogfiles"),               frmStatus::OnLoadLogfile)
-    EVT_BUTTON(XRCID("btnRotateLog"),               frmStatus::OnRotateLogfile)
+	EVT_LIST_ITEM_SELECTED(CTL_STATUSLIST,		    frmStatus::OnSelStatusItem)
+	EVT_LIST_ITEM_DESELECTED(CTL_STATUSLIST,	    frmStatus::OnSelStatusItem)
+	EVT_LIST_ITEM_SELECTED(CTL_LOCKLIST,		    frmStatus::OnSelLockItem)
+	EVT_LIST_ITEM_DESELECTED(CTL_LOCKLIST,		    frmStatus::OnSelLockItem)
+	EVT_LIST_ITEM_SELECTED(CTL_XACTLIST,		    frmStatus::OnSelXactItem)
+	EVT_LIST_ITEM_DESELECTED(CTL_XACTLIST,		    frmStatus::OnSelXactItem)
+    EVT_COMBOBOX(CTL_LOGCBO,                        frmStatus::OnLoadLogfile)
+    EVT_BUTTON(CTL_ROTATEBTN,                       frmStatus::OnRotateLogfile)
 END_EVENT_TABLE();
 
 
-#define statusList      CTRL_LISTVIEW("lstStatus")
-#define lockList        CTRL_LISTVIEW("lstLocks")
-#define xactList        CTRL_LISTVIEW("lstXacts")
-#define logList         CTRL_LISTVIEW("lstLog")
-#define slRate          CTRL_SLIDER("slRate")
-#define stRate          CTRL_STATIC("stRate")
-#define nbStatus		CTRL_NOTEBOOK("nbStatus")
-#define cbLogfiles      CTRL_COMBOBOX("cbLogfiles")
-#define btnRotateLog    CTRL_BUTTON("btnRotateLog")
 
 
 void frmStatus::OnCloseBtn(wxCommandEvent &event)
@@ -78,30 +74,136 @@
 }
 
 
-frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn)
+frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFrame(NULL, _title)
 {
+    dlgName = wxT("frmStatus");
+    
 	loaded = false;
     xactPage=2;
     logPage=3;
-
-    wxWindowBase::SetFont(settings->GetSystemFont());
+    
+    /*
     LoadResource(0, wxT("frmStatus")); 
+    */
 
-    RestorePosition(-1, -1, 400, 240, 200, 150);
-    SetTitle(_title);
-    appearanceFactory->SetIcons(this);
-
     mainForm=form;
     timer=0;
     connection=conn;
     logHasTimestamp = false;
     logFormatKnown = false;
-    btnCancelSt = CTRL_BUTTON("btnCancelSt");
-    btnCancelLk = CTRL_BUTTON("btnCancelLk");
-    btnTerminateSt = CTRL_BUTTON("btnTerminateSt");
-    btnTerminateLk = CTRL_BUTTON("btnTerminateLk");
-    btnCommit = CTRL_BUTTON("btnCommit");
-    btnRollback = CTRL_BUTTON("btnRollback");
+
+    statusBar=CreateStatusBar(1);
+    SetStatusBarPane(-1);
+    
+    RestorePosition(-1, -1, 400, 240, 200, 150);
+    SetTitle(_title);
+    appearanceFactory->SetIcons(this);
+
+    wxWindowBase::SetFont(settings->GetSystemFont());
+
+    // notify wxAUI which frame to use
+    /*
+    manager.SetManagedWindow(this);
+    manager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG);
+    */
+
+    /* build UI */
+    wxFlexGridSizer *item0 = new wxFlexGridSizer(3, 1, 5, 5);
+    item0->AddGrowableCol(0);
+    item0->AddGrowableRow(0);
+    nbStatus = new wxNotebook(this, CTL_NTBK);
+    item0->Add(nbStatus, 0, wxALL|wxEXPAND|wxGROW|wxALIGN_CENTRE, 2);
+    wxFlexGridSizer *item1 = new wxFlexGridSizer(1, 5, 5, 5);
+    item1->AddGrowableCol(2);
+    wxStaticText *stRateLabel = new wxStaticText(this, CTL_RATELABEL, _("Refresh rate:"));
+    item1->Add(stRateLabel, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+    slRate = new wxSlider(this, CTL_RATESLIDER, 1, 0, 600);
+    slRate->SetSize(90, 6, 150, -1, wxSIZE_FORCE);
+    item1->Add(slRate, 0, wxLEFT|wxALIGN_CENTRE_VERTICAL, 3);
+    stRate = new wxStaticText(this, CTL_RATELABEL2, _("Stopped"));
+    item1->Add(stRate, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+    wxButton *btnRefresh = new wxButton(this, CTL_REFRESHBTN, _("Refresh"));
+    item1->Add(btnRefresh, 0, wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 5);
+    wxButton *btnClose = new wxButton(this, CTL_CLOSEBTN, _("Close"));
+    item1->Add(btnClose, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+    item0->Add(item1, 0, wxTOP|wxEXPAND|wxGROW, 2);
+    
+    // page 0 : stat activity
+    wxPanel *pnlActivity = new wxPanel(nbStatus);
+    wxFlexGridSizer *grdActivity = new wxFlexGridSizer(2, 1, 5, 5);
+    grdActivity->AddGrowableCol(0);
+    grdActivity->AddGrowableRow(0);
+    wxListCtrl *lstStatus = new wxListCtrl(pnlActivity, CTL_STATUSLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+    grdActivity->Add(lstStatus, 0, wxGROW, 3);
+    wxFlexGridSizer *item3 = new wxFlexGridSizer(1, 2, 5, 5);
+    btnCancelSt = new wxButton(pnlActivity, CTL_CANCELBTN1, _("Cancel"));
+    item3->Add(btnCancelSt, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    btnTerminateSt = new wxButton(pnlActivity, CTL_TERMINATEBTN1, _("Terminate"));
+    item3->Add(btnTerminateSt, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    grdActivity->Add(item3, 0, wxGROW, 3);
+    nbStatus->AddPage(pnlActivity, wxT("Status"));
+    pnlActivity->SetSizer(grdActivity);
+    grdActivity->Fit(pnlActivity);
+    // page 1 : lock
+    wxPanel *pnlLock = new wxPanel(nbStatus);
+    wxFlexGridSizer *grdLock = new wxFlexGridSizer(2, 1, 5, 5);
+    grdLock->AddGrowableCol(0);
+    grdLock->AddGrowableRow(0);
+    wxListCtrl *lstLocks = new wxListCtrl(pnlLock, CTL_XACTLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+    grdLock->Add(lstLocks, 0, wxGROW, 3);
+    wxFlexGridSizer *item5 = new wxFlexGridSizer(1, 2, 5, 5);
+    btnCancelLk = new wxButton(pnlLock, CTL_CANCELBTN2, _("Cancel"));
+    item5->Add(btnCancelLk, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    btnTerminateLk = new wxButton(pnlLock, CTL_TERMINATEBTN2, _("Terminate"));
+    item5->Add(btnTerminateLk, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    grdLock->Add(item5, 0, wxGROW, 3);
+    pnlLock->SetSizer(grdLock);
+    grdLock->Fit(pnlLock);
+    nbStatus->AddPage(pnlLock, wxT("Locks"));
+    // page 2 : transaction
+    wxPanel *pnlXacts = new wxPanel(nbStatus);
+    wxFlexGridSizer *grdXacts = new wxFlexGridSizer(2, 1, 5, 5);
+    grdXacts->AddGrowableCol(0);
+    grdXacts->AddGrowableRow(0);
+    wxListCtrl *lstXacts = new wxListCtrl(pnlXacts, CTL_LOCKLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+    grdXacts->Add(lstXacts, 0, wxGROW, 3);
+    wxFlexGridSizer *item4 = new wxFlexGridSizer(1, 2, 5, 5);
+    btnCommit = new wxButton(pnlXacts, CTL_COMMITBTN, _("Commit"));
+    item4->Add(btnCommit, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    btnRollback = new wxButton(pnlXacts, CTL_ROLLBACKBTN, _("Rollback"));
+    item4->Add(btnRollback, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    grdXacts->Add(item4, 0, wxGROW, 3);
+    pnlXacts->SetSizer(grdXacts);
+    grdXacts->Fit(pnlXacts);
+    nbStatus->AddPage(pnlXacts, wxT("Transactions"));
+    // page 3 : logfile
+    wxPanel *pnlLog = new wxPanel(nbStatus);
+    wxFlexGridSizer *grdLog = new wxFlexGridSizer(2, 1, 5, 5);
+    grdLog->AddGrowableCol(0);
+    grdLog->AddGrowableRow(0);
+    wxListCtrl *lstLog = new wxListCtrl(pnlLog, CTL_LOGLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+    grdLog->Add(lstLog, 0, wxGROW, 3);
+    wxFlexGridSizer *item6 = new wxFlexGridSizer(1, 2, 5, 5);
+    cbLogfiles = new wxComboBox(pnlLog, CTL_LOGCBO, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL,
+    wxCB_READONLY|wxCB_DROPDOWN);
+    item6->Add(cbLogfiles, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+    btnRotateLog = new wxButton(pnlLog, CTL_ROTATEBTN, _("Rotate"));
+    item6->Add(btnRotateLog, 0, wxALL, 5);
+    grdLog->Add(item6, 0, wxGROW, 3);
+    pnlLog->SetSizer(grdLog);
+    grdLog->Fit(pnlLog);
+    nbStatus->AddPage(pnlLog, wxT("Logfile"));
+
+    nbStatus->SetSelection(0);
+    
+    statusList = (ctlListView*)lstStatus;
+    lockList = (ctlListView*)lstLocks;
+    xactList = (ctlListView*)lstXacts;
+    logList = (ctlListView*)lstLog;
+    
+    ChangeButtonId(btnClose, wxID_CLOSE, _("Close"));
+    ChangeButtonId(btnRefresh, wxID_REFRESH, _("Refresh"));
+    
     ChangeButtonId(btnTerminateSt, wxID_STOP, _("Terminate"));
     ChangeButtonId(btnTerminateLk, wxID_STOP, _("Terminate"));
 
@@ -218,7 +320,25 @@
 	    btnCommit->Enable(false);
 	    btnRollback->Enable(false);
     }
+    
+    this->SetSizer(item0);
+    item0->Fit(this);
+    
+    /*
+    manager.AddPane(item0, wxAuiPaneInfo().Name(wxT("serverstatus")).Caption(_("Server Status")).Center().CaptionVisible(false).CloseButton(false).MinSize(wxSize(200,100)).BestSize(wxSize(350,200)));
+    
+    // Now load the layout
+    wxString perspective;	 
+    settings->Read(wxT("frmStatus/Perspective-") + VerFromRev(FRMSTATUS_PERSPECTIVE_VER), &perspective, FRMSTATUS_DEFAULT_PERSPECTIVE);
+    manager.LoadPerspective(perspective, true);
 
+    // and reset the captions for the current language
+    manager.GetPane(wxT("serverstatus")).Caption(_("Server status"));
+
+    // tell the manager to "commit" all the changes just made
+    manager.Update();
+    */
+
 	loaded = true;
 }
 
@@ -331,7 +451,7 @@
 	// To avoid hammering the lock manager (and the network for that matter),
 	// only query for the required tab.
 
-	wxLogNull nolog;
+	//wxLogNull nolog;
 
 	if (!connection)
 	    return;
Index: pgadmin/dlg/dlgClasses.cpp
===================================================================
--- pgadmin/dlg/dlgClasses.cpp	(révision 7537)
+++ pgadmin/dlg/dlgClasses.cpp	(copie de travail)
@@ -341,6 +341,7 @@
 
 void pgFrame::RestorePosition(int defaultX, int defaultY, int defaultW, int defaultH, int minW, int minH)
 {
+    assert(dlgName.Length() > 0);
     wxPoint pos(settings->Read(dlgName, wxPoint(defaultX, defaultY)));
     wxSize size;
     if (defaultW < 0)
-- 
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