Le mercredi 16 septembre 2009 à 10:31:58, Magnus Hagander a écrit :
> On Wed, Sep 16, 2009 at 10:22, Dave Page <[email protected]> wrote:
> > On Tue, Sep 15, 2009 at 10:18 PM, Guillaume Lelarge
> > [...]
> >> The patch is not complete because of these:
> >>
> >> * Shouldn't the colors be customizable? I can add a tab on frmOptions.
> >
> > I think so.
>
> Agreed.
>
So do I. This new patch adds a tab on frmOptions to allow the colors' change.
> I'd also think the default should be "not so colorful". Meaning the
> one that will show the most (in most cases I've looked, that's idle)
> should be the default gray color. Then the colors you suggested for
> the rest (or maybe blue for running, because it's often a "softer"
> color than green).
>
Changed. Not sure it's really better.
> >> * Where do I put the configuration of the time limit? on a toolbar of
> >> the frmStatus window, or in the frmOptions dialog?
> >
> > I think frmStatus. The time limits of interest may be different on
> > your DW server than your OLTP system, so it would make sense to allow
> > control on the window itself. I think a setting against the server is
> > probably going a little too far, but if you can find a nice interface
> > for it, I could be persuaded...
>
> Actually, for starters I think we'd be fine even without the time
> limit feature at all :-)
>
I didn't add the configuration of the time limit. I will probably work on this
after this patch. I'm not sure of the UI. I think I should add it to the
toolbar, but there's already a time configuration (refresh delay).
> Now, if you can make the table sortable by "query start time", *that*
> would be useful :-)
>
It would be useful for every table pgAdmin displays (statistics come to my
mind quite instantly).
I attach the new patch.
--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com
Index: pgadmin/include/frm/frmOptions.h
===================================================================
--- pgadmin/include/frm/frmOptions.h (révision 8041)
+++ pgadmin/include/frm/frmOptions.h (copie de travail)
@@ -48,6 +48,11 @@
void OnSuppressHints(wxCommandEvent &ev);
void OnResetHints(wxCommandEvent &ev);
void OnChangeCopyQuote(wxCommandEvent &ev);
+ void OnChooseIdleProcessColour(wxCommandEvent&);
+ void OnChooseActiveProcessColour(wxCommandEvent&);
+ void OnChooseSlowProcessColour(wxCommandEvent&);
+ void OnChooseBlockedProcessColour(wxCommandEvent&);
+ wxString CheckColour(wxString colour);
DECLARE_EVENT_TABLE()
};
Index: pgadmin/include/frm/frmStatus.h
===================================================================
--- pgadmin/include/frm/frmStatus.h (révision 8041)
+++ pgadmin/include/frm/frmStatus.h (copie de travail)
@@ -48,6 +48,7 @@
MNU_COMMIT,
MNU_ROLLBACK,
MNU_COPY_QUERY,
+ MNU_HIGHLIGHTSTATUS,
TIMER_REFRESHUI_ID,
TIMER_STATUS_ID,
TIMER_LOCKS_ID,
@@ -147,6 +148,7 @@
void OnToggleLogPane(wxCommandEvent& event);
void OnToggleToolBar(wxCommandEvent& event);
void OnDefaultView(wxCommandEvent& event);
+ void OnHighlightStatus(wxCommandEvent& event);
void OnRefreshUITimer(wxTimerEvent &event);
void OnRefreshStatusTimer(wxTimerEvent &event);
Index: pgadmin/include/utils/sysSettings.h
===================================================================
--- pgadmin/include/utils/sysSettings.h (révision 8041)
+++ pgadmin/include/utils/sysSettings.h (copie de travail)
@@ -121,6 +121,16 @@
int GetLineEndingType() const { int i; Read(wxT("LineEndingType"), &i, 2); return i; }
void SetLineEndingType(const int newval) { Write(wxT("LineEndingType"), newval); }
+ // Status Colours options
+ wxString GetIdleProcessColour() const { wxString s; Read(wxT("IdleProcessColour"), &s, wxT("#5fa4d9")); return s; }
+ void SetIdleProcessColour(const wxString &newval) { Write(wxT("IdleProcessColour"), newval); }
+ wxString GetActiveProcessColour() const { wxString s; Read(wxT("ActiveProcessColour"), &s, wxT("#5fd95f")); return s; }
+ void SetActiveProcessColour(const wxString &newval) { Write(wxT("ActiveProcessColour"), newval); }
+ wxString GetSlowProcessColour() const { wxString s; Read(wxT("SlowProcessColour"), &s, wxT("#d9a75f")); return s; }
+ void SetSlowProcessColour(const wxString &newval) { Write(wxT("SlowProcessColour"), newval); }
+ wxString GetBlockedProcessColour() const { wxString s; Read(wxT("BlockedProcessColour"), &s, wxT("#d96e5f")); return s; }
+ void SetBlockedProcessColour(const wxString &newval) { Write(wxT("BlockedProcessColour"), newval); }
+
// Misc options
long GetAutoRowCountThreshold() const { long l; Read(wxT("AutoRowCount"), &l, 2000L); return l; }
void SetAutoRowCountThreshold(const long newval) { Write(wxT("AutoRowCount"), newval); }
Index: pgadmin/frm/frmOptions.cpp
===================================================================
--- pgadmin/frm/frmOptions.cpp (révision 8041)
+++ pgadmin/frm/frmOptions.cpp (copie de travail)
@@ -27,6 +27,9 @@
#include "utils/misc.h"
#include "frm/menu.h"
+// Must be after pgAdmin3.h or MSVC++ complains
+#include <wx/colordlg.h>
+
#include "images/properties.xpm"
#define nbOptions CTRL_NOTEBOOK("nbOptions")
@@ -65,23 +68,35 @@
#define lstDisplay CTRL_CHECKLISTBOX("lstDisplay")
#define chkSystemObjects CTRL_CHECKBOX("chkSystemObjects")
#define chkIgnoreVersion CTRL_CHECKBOX("chkIgnoreVersion")
+#define txtIdleProcessColour CTRL_TEXT("txtIdleProcessColour")
+#define btnIdleProcessColour CTRL_BUTTON("btnIdleProcessColour")
+#define txtActiveProcessColour CTRL_TEXT("txtActiveProcessColour")
+#define btnActiveProcessColour CTRL_BUTTON("btnActiveProcessColour")
+#define txtSlowProcessColour CTRL_TEXT("txtSlowProcessColour")
+#define btnSlowProcessColour CTRL_BUTTON("btnSlowProcessColour")
+#define txtBlockedProcessColour CTRL_TEXT("txtBlockedProcessColour")
+#define btnBlockedProcessColour CTRL_BUTTON("btnBlockedProcessColour")
BEGIN_EVENT_TABLE(frmOptions, pgDialog)
- EVT_MENU(MNU_HELP, frmOptions::OnHelp)
- EVT_BUTTON (XRCID("btnFont"), frmOptions::OnFontSelect)
- EVT_BUTTON (XRCID("btnSqlFont"), frmOptions::OnSqlFontSelect)
- EVT_BUTTON (XRCID("btnBrowseLogfile"), frmOptions::OnBrowseLogFile)
- EVT_BUTTON (XRCID("btnSlonyPath"), frmOptions::OnSlonyPathSelect)
- EVT_BUTTON (XRCID("btnPostgresqlPath"), frmOptions::OnPostgresqlPathSelect)
- EVT_BUTTON (XRCID("btnEnterprisedbPath"), frmOptions::OnEnterprisedbPathSelect)
- EVT_BUTTON (XRCID("btnGPDBPath"), frmOptions::OnGPDBPathSelect)
- EVT_BUTTON (XRCID("btnDefault"), frmOptions::OnDefault)
- EVT_CHECKBOX(XRCID("chkSuppressHints"), frmOptions::OnSuppressHints)
- EVT_CHECKBOX(XRCID("chkResetHints"), frmOptions::OnResetHints)
- EVT_BUTTON (wxID_OK, frmOptions::OnOK)
- EVT_BUTTON (wxID_HELP, frmOptions::OnHelp)
- EVT_BUTTON (wxID_CANCEL, frmOptions::OnCancel)
- EVT_COMBOBOX(XRCID("cbCopyQuote"), frmOptions::OnChangeCopyQuote)
+ EVT_MENU(MNU_HELP, frmOptions::OnHelp)
+ EVT_BUTTON (XRCID("btnFont"), frmOptions::OnFontSelect)
+ EVT_BUTTON (XRCID("btnSqlFont"), frmOptions::OnSqlFontSelect)
+ EVT_BUTTON (XRCID("btnBrowseLogfile"), frmOptions::OnBrowseLogFile)
+ EVT_BUTTON (XRCID("btnSlonyPath"), frmOptions::OnSlonyPathSelect)
+ EVT_BUTTON (XRCID("btnPostgresqlPath"), frmOptions::OnPostgresqlPathSelect)
+ EVT_BUTTON (XRCID("btnEnterprisedbPath"), frmOptions::OnEnterprisedbPathSelect)
+ EVT_BUTTON (XRCID("btnGPDBPath"), frmOptions::OnGPDBPathSelect)
+ EVT_BUTTON (XRCID("btnDefault"), frmOptions::OnDefault)
+ EVT_CHECKBOX(XRCID("chkSuppressHints"), frmOptions::OnSuppressHints)
+ EVT_CHECKBOX(XRCID("chkResetHints"), frmOptions::OnResetHints)
+ EVT_BUTTON (wxID_OK, frmOptions::OnOK)
+ EVT_BUTTON (wxID_HELP, frmOptions::OnHelp)
+ EVT_BUTTON (wxID_CANCEL, frmOptions::OnCancel)
+ EVT_COMBOBOX(XRCID("cbCopyQuote"), frmOptions::OnChangeCopyQuote)
+ EVT_BUTTON(XRCID("btnIdleProcessColour"), frmOptions::OnChooseIdleProcessColour)
+ EVT_BUTTON(XRCID("btnActiveProcessColour"), frmOptions::OnChooseActiveProcessColour)
+ EVT_BUTTON(XRCID("btnSlowProcessColour"), frmOptions::OnChooseSlowProcessColour)
+ EVT_BUTTON(XRCID("btnBlockedProcessColour"), frmOptions::OnChooseBlockedProcessColour)
END_EVENT_TABLE()
frmOptions::frmOptions(frmMain *parent)
@@ -144,6 +159,12 @@
txtGPDBPath->SetValue(settings->GetGPDBPath());
chkIgnoreVersion->SetValue(settings->GetIgnoreVersion());
+ // Get back the colours
+ txtIdleProcessColour->SetValue(settings->GetIdleProcessColour());
+ txtActiveProcessColour->SetValue(settings->GetActiveProcessColour());
+ txtSlowProcessColour->SetValue(settings->GetSlowProcessColour());
+ txtBlockedProcessColour->SetValue(settings->GetBlockedProcessColour());
+
cbLanguage->Append(_("Default"));
int sel=0;
wxLanguage langId=settings->GetCanonicalLanguage();
@@ -483,6 +504,28 @@
settings->SetShowSystemObjects(chkSystemObjects->GetValue());
}
+ // Change the status colours
+ if (txtIdleProcessColour->GetValue() != settings->GetIdleProcessColour())
+ {
+ changed = true;
+ settings->SetIdleProcessColour(CheckColour(txtIdleProcessColour->GetValue().Trim()));
+ }
+ if (txtActiveProcessColour->GetValue() != settings->GetActiveProcessColour())
+ {
+ changed = true;
+ settings->SetActiveProcessColour(CheckColour(txtActiveProcessColour->GetValue().Trim()));
+ }
+ if (txtSlowProcessColour->GetValue() != settings->GetSlowProcessColour())
+ {
+ changed = true;
+ settings->SetSlowProcessColour(CheckColour(txtSlowProcessColour->GetValue().Trim()));
+ }
+ if (txtBlockedProcessColour->GetValue() != settings->GetBlockedProcessColour())
+ {
+ changed = true;
+ settings->SetBlockedProcessColour(CheckColour(txtBlockedProcessColour->GetValue().Trim()));
+ }
+
// Change the language last, as it will affect our tests for changes
// in the display object types.
int langNo=cbLanguage->GetCurrentSelection();
@@ -555,6 +598,46 @@
}
+void frmOptions::OnChooseIdleProcessColour(wxCommandEvent &ev)
+{
+ wxColourDialog dlg( NULL );
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ txtIdleProcessColour->SetValue(dlg.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX));
+ }
+}
+
+
+void frmOptions::OnChooseActiveProcessColour(wxCommandEvent &ev)
+{
+ wxColourDialog dlg( NULL );
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ txtActiveProcessColour->SetValue(dlg.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX));
+ }
+}
+
+
+void frmOptions::OnChooseSlowProcessColour(wxCommandEvent &ev)
+{
+ wxColourDialog dlg( NULL );
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ txtSlowProcessColour->SetValue(dlg.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX));
+ }
+}
+
+
+void frmOptions::OnChooseBlockedProcessColour(wxCommandEvent &ev)
+{
+ wxColourDialog dlg( NULL );
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ txtBlockedProcessColour->SetValue(dlg.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX));
+ }
+}
+
+
optionsFactory::optionsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : actionFactory(list)
{
mnu->Append(id, _("&Options..."), _("Show options dialog."));
@@ -576,3 +659,22 @@
else
cbCopyQuoteChar->Enable();
}
+
+
+wxString frmOptions::CheckColour(wxString oldColour)
+{
+ wxString newColour = wxEmptyString;
+
+ if (oldColour != wxEmptyString)
+ {
+ wxColour colour;
+
+ if (colour.Set(oldColour))
+ newColour = colour.GetAsString(wxC2S_HTML_SYNTAX);
+ else
+ wxLogError(_("The colour specified is not valid."));
+ }
+
+ return newColour;
+}
+
Index: pgadmin/frm/frmStatus.cpp
===================================================================
--- pgadmin/frm/frmStatus.cpp (révision 8041)
+++ pgadmin/frm/frmStatus.cpp (copie de travail)
@@ -54,6 +54,7 @@
EVT_MENU(MNU_LOGPAGE, frmStatus::OnToggleLogPane)
EVT_MENU(MNU_TOOLBAR, frmStatus::OnToggleToolBar)
EVT_MENU(MNU_DEFAULTVIEW, frmStatus::OnDefaultView)
+ EVT_MENU(MNU_HIGHLIGHTSTATUS, frmStatus::OnHighlightStatus)
EVT_AUI_PANE_CLOSE( frmStatus::OnPaneClose)
@@ -148,6 +149,8 @@
frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFrame(NULL, _title)
{
+ bool highlight = false;
+
dlgName = wxT("frmStatus");
loaded = false;
@@ -194,6 +197,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_HIGHLIGHTSTATUS, _("Highlight items of the activity list"), _("Highlight or not the items of the activity list."), wxITEM_CHECK);
viewMenu->AppendSeparator();
viewMenu->Append(MNU_DEFAULTVIEW, _("&Default view\tCtrl-Alt-V"), _("Restore the default view."));
@@ -285,6 +289,10 @@
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());
+
+ // Read the highlight status checkbox
+ settings->Read(wxT("frmStatus/HighlightStatus"), &highlight, true);
+ viewMenu->Check(MNU_HIGHLIGHTSTATUS, highlight);
// Get our PID
backend_pid = connection->GetBackendPID();
@@ -313,6 +321,9 @@
settings->Write(wxT("frmStatus/Perspective-") + VerFromRev(FRMSTATUS_PERSPECTIVE_VER), manager.SavePerspective());
manager.UnInit();
SavePosition();
+
+ // Save the highlight status checkbox
+ settings->Write(wxT("frmStatus/HighlightStatus"), viewMenu->IsChecked(MNU_HIGHLIGHTSTATUS));
// For each current page, save the slider's position and delete the timer
settings->Write(wxT("frmStatus/RefreshStatusRate"), statusRate);
@@ -909,6 +920,14 @@
}
+void frmStatus::OnHighlightStatus(wxCommandEvent& event)
+{
+ wxTimerEvent evt;
+
+ OnRefreshStatusTimer(evt);
+}
+
+
void frmStatus::OnHelp(wxCommandEvent& event)
{
wxString page;
@@ -1029,7 +1048,11 @@
connection->ExecuteVoid(wxT("SET log_statement='none';SET log_duration='off';"),false);
long row=0;
- pgSet *dataSet1=connection->ExecuteSet(wxT("SELECT *,(SELECT min(pid) FROM pg_locks l1 WHERE GRANTED AND relation IN (SELECT relation FROM pg_locks l2 WHERE l2.pid=procpid AND NOT granted)) AS blockedby FROM pg_stat_activity ORDER BY procpid"));
+ pgSet *dataSet1=connection->ExecuteSet(wxT("SELECT *, ")
+ wxT("CASE WHEN query_start IS NULL THEN false ELSE query_start + '10 seconds'::interval > now() END AS slowquery, ")
+ wxT("(SELECT min(pid) FROM pg_locks l1 WHERE GRANTED AND relation IN ")
+ wxT("(SELECT relation FROM pg_locks l2 WHERE l2.pid=procpid AND NOT granted)) AS blockedby ")
+ wxT("FROM pg_stat_activity ORDER BY procpid"));
if (dataSet1)
{
statusList->Freeze();
@@ -1083,6 +1106,25 @@
statusList->SetItem(row, colpos++, dataSet1->GetVal(wxT("blockedby")));
statusList->SetItem(row, colpos, qry);
+
+ // Colorize the new line
+ if (viewMenu->IsChecked(MNU_HIGHLIGHTSTATUS))
+ {
+ statusList->SetItemBackgroundColour(row,
+ wxColour(settings->GetActiveProcessColour()));
+ if (qry == wxT("<IDLE>"))
+ statusList->SetItemBackgroundColour(row,
+ wxColour(settings->GetIdleProcessColour()));
+ if (dataSet1->GetVal(wxT("blockedby")).Length() > 0)
+ statusList->SetItemBackgroundColour(row,
+ wxColour(settings->GetBlockedProcessColour()));
+ if (dataSet1->GetBool(wxT("slowquery")))
+ statusList->SetItemBackgroundColour(row,
+ wxColour(settings->GetSlowProcessColour()));
+ }
+ else
+ statusList->SetItemBackgroundColour(row, *wxWHITE);
+
row++;
}
dataSet1->MoveNext();
Index: pgadmin/ui/frmOptions.xrc
===================================================================
--- pgadmin/ui/frmOptions.xrc (révision 8041)
+++ pgadmin/ui/frmOptions.xrc (copie de travail)
@@ -321,6 +321,63 @@
</object>
</object>
<object class="notebookpage">
+ <label>Status Window</label>
+ <object class="wxPanel" name="pnlStatusWindow">
+ <object class="wxStaticText" name="stIdleProcessColour">
+ <label>Idle Process Colour</label>
+ <pos>5,5d</pos>
+ </object>
+ <object class="wxTextCtrl" name="txtIdleProcessColour">
+ <pos>100,5d</pos>
+ <size>50,12d</size>
+ </object>
+ <object class="wxButton" name="btnIdleProcessColour">
+ <label>...</label>
+ <pos>170,5d</pos>
+ <size>20,12d</size>
+ </object>
+ <object class="wxStaticText" name="stActiveProcessColour">
+ <label>Active Process Colour</label>
+ <pos>5,22d</pos>
+ </object>
+ <object class="wxTextCtrl" name="txtActiveProcessColour">
+ <pos>100,22d</pos>
+ <size>50,12d</size>
+ </object>
+ <object class="wxButton" name="btnActiveProcessColour">
+ <label>...</label>
+ <pos>170,22d</pos>
+ <size>20,12d</size>
+ </object>
+ <object class="wxStaticText" name="stSlowProcessColour">
+ <label>Slow Process Colour</label>
+ <pos>5,39d</pos>
+ </object>
+ <object class="wxTextCtrl" name="txtSlowProcessColour">
+ <pos>100,39d</pos>
+ <size>50,12d</size>
+ </object>
+ <object class="wxButton" name="btnSlowProcessColour">
+ <label>...</label>
+ <pos>170,39d</pos>
+ <size>20,12d</size>
+ </object>
+ <object class="wxStaticText" name="stBlockedProcessColour">
+ <label>Blocked Process Colour</label>
+ <pos>5,56d</pos>
+ </object>
+ <object class="wxTextCtrl" name="txtBlockedProcessColour">
+ <pos>100,56d</pos>
+ <size>50,12d</size>
+ </object>
+ <object class="wxButton" name="btnBlockedProcessColour">
+ <label>...</label>
+ <pos>170,56d</pos>
+ <size>20,12d</size>
+ </object>
+ </object>
+ </object>
+ <object class="notebookpage">
<label>Logging</label>
<object class="wxPanel" name="pnlLogging">
<object class="wxStaticText" name="lblLogfile">
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers