Hi Dave,

I'm sending the patch on the Refresh object on Click[1].

I put the three options. "None", "Refresh object on click" and "Refresh object and children on click"

You can review it?

PS: Forgive me, of a mistake in my English.

Thank You.

[1] = http://archives.postgresql.org/pgadmin-hackers/2011-06/msg00039.php
>From 5c91e26adb64167d4f60380fbfe210bf9351bf2a Mon Sep 17 00:00:00 2001
From: Vinicius Santos <vinicius.santos.li...@gmail.com>
Date: Wed, 10 Aug 2011 00:06:14 -0300
Subject: [PATCH] Implement Refresh on click.

---
 pgadmin/frm/events.cpp              |   43 +++++++++++++++++++++++++++++++++++
 pgadmin/frm/frmOptions.cpp          |    3 ++
 pgadmin/include/utils/sysSettings.h |   10 ++++++++
 pgadmin/ui/frmOptions.xrc           |   19 +++++++++++++++
 4 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index f725d39..fbb0d7e 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -388,6 +388,7 @@ void frmMain::ResetLists()
 
 void frmMain::execSelChange(wxTreeItemId item, bool currentNode)
 {
+       static bool refresh = true;
        if (currentNode)
        {
                ResetLists();
@@ -406,6 +407,48 @@ void frmMain::execSelChange(wxTreeItemId item, bool 
currentNode)
        }
        else
        {
+               wxString settingRefreshOnClick = settings->GetRefreshOnClick();
+               if ( settingRefreshOnClick != _("None")
+                       && refresh
+                       && currentObject->GetTypeName() != wxT("Server")
+                       && currentObject->GetTypeName() != wxT("Servers")
+                       && currentObject->GetTypeName() != wxT("Databases"))
+               {
+                       refresh = false;
+                       
+                       if (settingRefreshOnClick == _("Refresh object on 
click"))
+                       {
+                               if (currentObject->GetTypeName() != 
wxT("Schema") && !currentObject->IsCollection())
+                               {
+                                       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());
+
+                                               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 92f9b75..30c0fde 100644
--- a/pgadmin/frm/frmOptions.cpp
+++ b/pgadmin/frm/frmOptions.cpp
@@ -101,6 +101,7 @@
 #define pickerSQLColour11           CTRL_COLOURPICKER("pickerSQLColour11")
 #define pickerSQLCaretColour               
CTRL_COLOURPICKER("pickerSQLCaretColour")
 #define chkKeywordsInUppercase      CTRL_CHECKBOX("chkKeywordsInUppercase")
+#define cbRefreshOnClick                       
CTRL_COMBOBOX("cbRefreshOnClick")
 
 BEGIN_EVENT_TABLE(frmOptions, pgDialog)
        EVT_MENU(MNU_HELP,                                            
frmOptions::OnHelp)
@@ -243,6 +244,7 @@ frmOptions::frmOptions(frmMain *parent)
        chkSpacesForTabs->SetValue(settings->GetSpacesForTabs());
        cbCopyQuote->SetSelection(settings->GetCopyQuoting());
        cbCopyQuoteChar->SetValue(settings->GetCopyQuoteChar());
+       cbRefreshOnClick->SetValue(settings->GetRefreshOnClick());
 
        wxString copySeparator = settings->GetCopyColSeparator();
        if (copySeparator == wxT("\t"))
@@ -553,6 +555,7 @@ void frmOptions::OnOK(wxCommandEvent &ev)
        settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue());
        
settings->SetHistoryMaxQueries(StrToLong(txtHistoryMaxQueries->GetValue()));
        
settings->SetHistoryMaxQuerySize(StrToLong(txtHistoryMaxQuerySize->GetValue()));
+       settings->SetRefreshOnClick(cbRefreshOnClick->GetValue());
 
        wxString copySeparator = cbCopySeparator->GetValue();
        if (copySeparator == _("Tab"))
diff --git a/pgadmin/include/utils/sysSettings.h 
b/pgadmin/include/utils/sysSettings.h
index 6528a5f..0ed02f7 100644
--- a/pgadmin/include/utils/sysSettings.h
+++ b/pgadmin/include/utils/sysSettings.h
@@ -669,6 +669,16 @@ public:
                WriteBool(wxT("IgnoreVersion"), newval);
        }
 
+       wxString GetRefreshOnClick() const
+       {
+               wxString s;
+               Read(wxT("RefreshOnClick"), &s, wxT("None"));
+               return s;
+       }
+       void SetRefreshOnClick(const wxString newval)
+       {
+               Write(wxT("RefreshOnClick"), newval);
+       }
        bool GetShowNotices() const
        {
                bool b;
diff --git a/pgadmin/ui/frmOptions.xrc b/pgadmin/ui/frmOptions.xrc
index 78f2430..f51d163 100644
--- a/pgadmin/ui/frmOptions.xrc
+++ b/pgadmin/ui/frmOptions.xrc
@@ -525,6 +525,25 @@
                   
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
                   <border>4</border>
                 </object>
+                <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>
             </object>
           </object>
-- 
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

Reply via email to