Em 22/08/2011 08:04, Dave Page escreveu:
Thanks - that applies cleanly now. Unfortunately, it still doesn't work properly. Please see the attached screenshot. That was taken with "refresh object and children" turned on - I clicked on the table "test" and then clicked on the parent schema "public", but the properties and SQL panes are showing the details of the table.
I did make some tests, and now seems to be OK.
Thanks again.
>From 226782001029e9a9886cdbe23dc2a3f4f06ededc Mon Sep 17 00:00:00 2001 From: Vinicius Santos <vinicius.santos.li...@gmail.com> Date: Sun, 21 Aug 2011 18:01:16 -0300 Subject: [PATCH] Implement Refresh on click. --- pgadmin/frm/events.cpp | 49 +++++++++++++++++++++++++++++++++++ pgadmin/frm/frmOptions.cpp | 3 ++ pgadmin/include/frm/frmMain.h | 5 +++ pgadmin/include/utils/sysSettings.h | 11 ++++++++ pgadmin/ui/frmOptions.xrc | 31 ++++++++++++++++++++++ 5 files changed, 99 insertions(+), 0 deletions(-) diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp index 52b04f9..7fe098f 100644 --- a/pgadmin/frm/events.cpp +++ b/pgadmin/frm/events.cpp @@ -388,6 +388,8 @@ void frmMain::ResetLists() void frmMain::execSelChange(wxTreeItemId item, bool currentNode) { + static bool refresh = true; + if (currentNode) { ResetLists(); @@ -406,6 +408,53 @@ void frmMain::execSelChange(wxTreeItemId item, bool currentNode) } else { + int settingRefreshOnClick = settings->GetRefreshOnClick(); + + if (settingRefreshOnClick != REFRESH_OBJECT_NONE + && refresh + && currentObject->GetTypeName() != wxT("Server") + && currentObject->GetTypeName() != wxT("Servers") + && currentObject->GetTypeName() != wxT("Database") + && !currentObject->IsCollection()) + { + refresh = false; + + if (settingRefreshOnClick == REFRESH_OBJECT_ONLY ) + { + //We can not update the schema, because it would cause an update to the entire tree. + if (currentObject->GetTypeName() != wxT("Schema")) + { + wxTreeItemId currentItem = currentObject->GetId(); + + + pgObject *newData = currentObject->Refresh(browser, currentItem); + + if (newData != 0) + { + wxLogInfo(wxT("Replacing with new node %s %s for refresh"), newData->GetTypeName().c_str(), newData->GetQuotedFullIdentifier().c_str()); + + browser->DeleteChildren(currentItem); + newData->SetId(currentItem); // not done automatically + browser->SetItemData(currentItem, newData); + + // Update the node text if this is an object, as it may have been renamed + if (!newData->IsCollection()) + browser->SetItemText(currentItem, newData->GetDisplayName()); + + delete currentObject; + currentObject = newData; + } + else + browser->Delete(currentItem); + } + } + else + Refresh(currentObject); + + refresh = true; + } + + if (currentNode) { properties->Freeze(); diff --git a/pgadmin/frm/frmOptions.cpp b/pgadmin/frm/frmOptions.cpp index fbd1d6f..46904f8 100644 --- a/pgadmin/frm/frmOptions.cpp +++ b/pgadmin/frm/frmOptions.cpp @@ -141,6 +141,7 @@ #define pnlMiscHelpPath CTRL_PANEL("pnlMiscHelpPath") #define pnlMiscGuruHints CTRL_PANEL("pnlMiscGuruHints") #define pnlMiscLogging CTRL_PANEL("pnlMiscLogging") +#define cbRefreshOnClick CTRL_COMBOBOX("cbRefreshOnClick") BEGIN_EVENT_TABLE(frmOptions, pgDialog) @@ -288,6 +289,7 @@ frmOptions::frmOptions(frmMain *parent) chkSpacesForTabs->SetValue(settings->GetSpacesForTabs()); cbCopyQuote->SetSelection(settings->GetCopyQuoting()); cbCopyQuoteChar->SetValue(settings->GetCopyQuoteChar()); + cbRefreshOnClick->SetSelection(settings->GetRefreshOnClick()); wxString copySeparator = settings->GetCopyColSeparator(); if (copySeparator == wxT("\t")) @@ -649,6 +651,7 @@ void frmOptions::OnOK(wxCommandEvent &ev) settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue()); settings->SetHistoryMaxQueries(StrToLong(txtHistoryMaxQueries->GetValue())); settings->SetHistoryMaxQuerySize(StrToLong(txtHistoryMaxQuerySize->GetValue())); + settings->SetRefreshOnClick(cbRefreshOnClick->GetSelection()); wxString copySeparator = cbCopySeparator->GetValue(); if (copySeparator == _("Tab")) diff --git a/pgadmin/include/frm/frmMain.h b/pgadmin/include/frm/frmMain.h index e76f3ac..b55a24c 100644 --- a/pgadmin/include/frm/frmMain.h +++ b/pgadmin/include/frm/frmMain.h @@ -75,6 +75,11 @@ enum NBP_DEPENDENTS }; +enum +{ + REFRESH_OBJECT_NONE = 0, + REFRESH_OBJECT_ONLY +}; // Class declarations class frmMain : public pgFrame diff --git a/pgadmin/include/utils/sysSettings.h b/pgadmin/include/utils/sysSettings.h index 6528a5f..5910042 100644 --- a/pgadmin/include/utils/sysSettings.h +++ b/pgadmin/include/utils/sysSettings.h @@ -669,6 +669,17 @@ public: WriteBool(wxT("IgnoreVersion"), newval); } + int GetRefreshOnClick() const + { + int i; + Read(wxT("RefreshOnClick"), &i, 0); + return i; + } + void SetRefreshOnClick(const int newval) + { + WriteInt(wxT("RefreshOnClick"), newval); + } + bool GetShowNotices() const { bool b; diff --git a/pgadmin/ui/frmOptions.xrc b/pgadmin/ui/frmOptions.xrc index f600a91..ca29fe0 100644 --- a/pgadmin/ui/frmOptions.xrc +++ b/pgadmin/ui/frmOptions.xrc @@ -365,6 +365,37 @@ <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag> <border>4</border> </object> + <object class="sizeritem"> + <object class="wxFlexGridSizer"> + <cols>2</cols> + <rows>1</rows> + <vgap>5</vgap> + <hgap>5</hgap> + <growablecols>1</growablecols> + <object class="sizeritem"> + <object class="wxStaticText" name="stRefreshOnClick"> + <label>Refresh on click:</label> + </object> + <flag>wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag> + <border>4</border> + </object> + <object class="sizeritem"> + <object class="wxComboBox" name="cbRefreshOnClick"> + <content> + <item>None</item> + <item>Refresh object on click</item> + <item>Refresh object and children on click</item> + </content> + <style>wxCB_READONLY|wxCB_DROPDOWN</style> + </object> + <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag> + <border>4</border> + </object> + + </object> + <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag> + <border>4</border> + </object> </object> </object> <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag> -- 1.7.4.msysgit.0
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers