>From 63c2b20eff916b89fee7135d754094a35f01770c Mon Sep 17 00:00:00 2001
From: Vinicius Santos <[email protected]>
Date: Sat, 13 Aug 2011 01:03:11 -0300
Subject: [PATCH] Implement Refresh Object on Click.
---
pgadmin/frm/events.cpp | 49 +++++++++++++++++++++++++++++++++++
pgadmin/frm/frmOptions.cpp | 3 ++
pgadmin/include/frm/frmMain.h | 5 +++
pgadmin/include/utils/sysSettings.h | 10 +++++++
pgadmin/ui/frmOptions.xrc | 32 ++++++++++++++++++++++-
5 files changed, 98 insertions(+), 1 deletions(-)
diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index f725d39..9e52671 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -38,6 +38,8 @@
#include "schema/pgTable.h"
#include "dlg/dlgProperty.h"
+
+
// Event table
BEGIN_EVENT_TABLE(frmMain, pgFrame)
EVT_CHILD_FOCUS( frmMain::OnChildFocus)
@@ -388,6 +390,7 @@ void frmMain::ResetLists()
void frmMain::execSelChange(wxTreeItemId item, bool currentNode)
{
+ static bool refresh = true;
if (currentNode)
{
ResetLists();
@@ -406,6 +409,52 @@ 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"))
+ {
+ refresh = false;
+
+ if (settingRefreshOnClick == REFRESH_OBJECT_ONLY )
+ {
+ //We can not update the schema/database,
because it would cause an update to the entire tree.
+ if (currentObject->GetTypeName() !=
wxT("Schema")
+ && currentObject->GetTypeName() !=
wxT("Database")
+ && !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());
+
+
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 92f9b75..4ef39c3 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->SetSelection(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->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..9dff7b4 100644
--- a/pgadmin/include/utils/sysSettings.h
+++ b/pgadmin/include/utils/sysSettings.h
@@ -669,6 +669,16 @@ 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 78f2430..28c34e1 100644
--- a/pgadmin/ui/frmOptions.xrc
+++ b/pgadmin/ui/frmOptions.xrc
@@ -332,7 +332,37 @@
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
- </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>
</object>
<object class="notebookpage">
--
1.7.4.msysgit.0
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers