Repost: Patch: view data for tables/views on double click
Repost: Patch: view data for tables/views on double click
От:
Ivan Nejgebauer <ian-pgahack@uns.ns.ac.yu>
Дата:
Andreas Pflug wrote:
> First of all, this is certainly hackers stuff, please post on
> pgadmin-hackers!
Agreed. This is a repost/rewrite of the patch I have posted to the
pgadmin-support list a few days ago.
Dave Page wrote:
> That breaks the principle of least surprise because it introduces
> inconsistent behaviour.
>
> Perhaps a better approach would be to open the data view only if
> 'double-click-for-properties' is turned off?
Andreas Pflug wrote:
> - the default action might differ from user to user. For sure, an
> unconditional "View Data" on a table is a bad idea. I already hear
> those guys yelling double clicking on a 100 million row table...
This version of the patch tries to address those issues in the following
ways:
1. There is an additional checkbox in the Preferences tab of the Options
dialog, labeled "Show data instead of properties for tables and views",
placed as a subordinate of "Show object properties on double click" (I
have stripped the "in treeview" part, since double click should also
work in the Properties pane). The checkbox is disabled if its superior
is disabled.
2. In the same tab, a parameter labeled "Maximum rows in data view" is
introduced. It is used to limit the number of rows retrieved when
constructing the data view/edit grid if greater than zero. The default
value is set to 500, although it could be set to 0 (unlimited) to keep
the behavior prior to its introduction.
The patch also arranges reading and writing of the new parameters from
and to the configuration file.
The patch is against the beta1 source tree; I could re-sync it to the
latest snapshot if needed.
i.
--- src/include/frmMain.h.old Tue Aug 10 22:51:45 2004
+++ src/include/frmMain.h Wed Sep 15 11:56:51 2004
@@ -110,6 +110,7 @@
void OnPageChange(wxNotebookEvent& event);
void OnPropSelChanged(wxListEvent& event);
+ void OnPropSelActivated(wxListEvent& event);
void OnTreeSelChanged(wxTreeEvent &event);
void OnTreeKeyDown(wxTreeEvent& event);
void OnConnect(wxCommandEvent &ev);
--- src/include/sysSettings.h.old Mon Aug 9 09:59:20 2004
+++ src/include/sysSettings.h Wed Sep 22 11:51:58 2004
@@ -53,6 +53,8 @@
void SetLastSSL(const int newval);
long GetMaxRows() const { return maxRows; }
void SetMaxRows(const long l) { maxRows=l; }
+ long GetMaxViewRows() const { return maxViewRows; }
+ void SetMaxViewRows(const long l) { maxViewRows=l; }
long GetMaxColSize() const { return maxColSize; }
void SetMaxColSize(const long l) { maxColSize=l; }
bool GetAskSaveConfirmation() const { return askSaveConfirmation; }
@@ -89,6 +91,10 @@
bool GetDoubleClickProperties() const { return doubleClickProperties; }
void SetDoubleClickProperties(const bool newval);
+ // View instead of Properties
+ bool GetDoubleClickView() const { return doubleClickView; }
+ void SetDoubleClickView(const bool newval);
+
// maximum size of server log to read
long GetMaxServerLogSize() const { return maxServerLogSize; }
void SetMaxServerLogSize(long l) { maxServerLogSize = l; }
@@ -172,9 +178,9 @@
bool showUsersForPrivileges;
bool askSaveConfirmation;
bool confirmDelete;
- long maxRows, maxColSize, autoRowCountThreshold;
+ long maxRows, maxColSize, autoRowCountThreshold, maxViewRows;
bool stickySql, unicodeFile;
- bool doubleClickProperties;
+ bool doubleClickProperties, doubleClickView;
long maxServerLogSize;
wxString searchPath;
--- src/include/frmOptions.h.old Fri Jun 11 20:17:52 2004
+++ src/include/frmOptions.h Wed Sep 22 12:30:59 2004
@@ -37,6 +37,7 @@
void OnOK(wxCommandEvent &ev);
void OnCancel(wxCommandEvent &ev);
void OnHelp(wxCommandEvent &ev);
+ void OnDoubleClickProps(wxCommandEvent &ev);
DECLARE_EVENT_TABLE()
};
--- src/ui/common/frmOptions.xrc.old Tue Sep 7 10:38:13 2004
+++ src/ui/common/frmOptions.xrc Wed Sep 22 12:03:26 2004
@@ -58,33 +58,49 @@
Read and write Unicode UTF-8 files
- 5,35d
+ 5,25d
226,12d
Do not prompt for unsaved files on exit
0
- 5,47d
+ 5,37d
226,12d
Confirm object deletion?
1
- 5,59d
+ 5,49d
226,12d
Show users for privileges?
0
- 5,71d
+ 5,61d
226,12d
- Show object properties on double click in treeview?
+ Show object properties on double click?
+ 0
+ 5,73d
+ 226,12d
+
+
+ Show data instead of properties for tables and views?
0
- 5,83d
+ 15,85d
226,12d
+
+ Maximum rows in data view
+ 5,100d
+
+
+ 500
+ 175,98d
+ 35,-1d
+ Maximums rows to retrieve into data view grid; 0 = unlimited
+
@@ -199,4 +215,4 @@
Cancel any changes and close the dialogue.
-
\ No newline at end of file
+
--- src/ui/events.cpp.old Tue Sep 7 10:34:34 2004
+++ src/ui/events.cpp Wed Sep 22 12:57:28 2004
@@ -122,6 +122,7 @@
EVT_MENU(MNU_CONTEXTMENU, frmMain::OnContextMenu)
EVT_NOTEBOOK_PAGE_CHANGED(CTL_NOTEBOOK, frmMain::OnPageChange)
EVT_LIST_ITEM_SELECTED(CTL_PROPVIEW, frmMain::OnPropSelChanged)
+ EVT_LIST_ITEM_ACTIVATED(CTL_PROPVIEW, frmMain::OnPropSelActivated)
EVT_TREE_SEL_CHANGED(CTL_BROWSER, frmMain::OnTreeSelChanged)
EVT_TREE_ITEM_EXPANDING(CTL_BROWSER, frmMain::OnExpand)
EVT_TREE_ITEM_COLLAPSING(CTL_BROWSER, frmMain::OnCollapse)
@@ -684,6 +685,30 @@
}
+void frmMain::OnPropSelActivated(wxListEvent& event)
+{
+ wxTreeItemId item=browser->GetSelection();
+ pgObject *data=(pgObject*)browser->GetItemData(item);
+ wxCommandEvent nullEvent;
+
+ if (!settings->GetDoubleClickProperties())
+ return;
+ if (data && data->IsCollection())
+ {
+ data=((pgCollection*)data)->FindChild(browser, event.GetIndex());
+ if (data)
+ {
+ int type = data->GetType();
+ if (settings->GetDoubleClickView() && (type == PG_TABLE || type == PG_VIEW))
+ ViewData(false);
+ else if (data->CanEdit())
+ if (!dlgProperty::EditObjectDialog(this, sqlPane, data))
+ checkAlive();
+ }
+ }
+}
+
+
void frmMain::OnTreeSelChanged(wxTreeEvent& event)
{
denyCollapseItem=wxTreeItemId();
@@ -958,13 +983,22 @@
}
break;
+ case PG_TABLE:
+ case PG_VIEW:
+ if (settings->GetDoubleClickProperties() && settings->GetDoubleClickView()) {
+ denyCollapseItem=item;
+ ViewData(false);
+ return;
+ }
+ /* FALL-THROUGH */
+
default:
if (settings->GetDoubleClickProperties())
{
if (data->CanEdit())
{
+ denyCollapseItem=item;
OnProperties(nullEvent);
- event.Skip();
return;
}
}
--- src/ui/frmEditGrid.cpp.old Tue Sep 7 15:44:56 2004
+++ src/ui/frmEditGrid.cpp Wed Sep 22 13:03:10 2004
@@ -599,6 +599,11 @@
{
qry += wxT(" ORDER BY ") + orderBy;
}
+ long maxViewRows = settings->GetMaxViewRows();
+ if (maxViewRows > 0)
+ {
+ qry += wxT(" LIMIT ") + NumToStr(maxViewRows);
+ }
thread=new pgQueryThread(connection, qry);
if (thread->Create() != wxTHREAD_NO_ERROR)
--- src/ui/frmOptions.cpp.old Tue Sep 7 10:38:12 2004
+++ src/ui/frmOptions.cpp Wed Sep 22 12:32:32 2004
@@ -38,6 +38,7 @@
#define txtLogfile CTRL_TEXT("txtLogfile")
#define radLoglevel CTRL_RADIOBOX("radLoglevel")
#define txtMaxRows CTRL_TEXT("txtMaxRows")
+#define txtMaxViewRows CTRL_TEXT("txtMaxViewRows")
#define txtMaxColSize CTRL_TEXT("txtMaxColSize")
#define txtFont CTRL_TEXT("txtFont")
#define chkUnicodeFile CTRL_CHECKBOX("chkUnicodeFile")
@@ -47,6 +48,7 @@
#define txtAutoRowCount CTRL_TEXT("txtAutoRowCount")
#define chkStickySql CTRL_CHECKBOX("chkStickySql")
#define chkDoubleClickProperties CTRL_CHECKBOX("chkDoubleClickProperties")
+#define chkDoubleClickView CTRL_CHECKBOX("chkDoubleClickView")
#define cbLanguage CTRL_COMBOBOX("cbLanguage")
#define txtSqlFont CTRL_TEXT("txtSqlFont")
@@ -59,6 +61,8 @@
EVT_BUTTON (XRCID("btnOK"), frmOptions::OnOK)
EVT_BUTTON (XRCID("btnHelp"), frmOptions::OnHelp)
EVT_BUTTON (XRCID("btnCancel"), frmOptions::OnCancel)
+ EVT_CHECKBOX
+ (XRCID("chkDoubleClickProperties"), frmOptions::OnDoubleClickProps)
END_EVENT_TABLE()
frmOptions::frmOptions(frmMain *parent)
@@ -82,12 +86,14 @@
wxTextValidator numval(wxFILTER_NUMERIC);
txtMaxRows->SetValidator(numval);
+ txtMaxViewRows->SetValidator(numval);
txtMaxColSize->SetValidator(numval);
txtAutoRowCount->SetValidator(numval);
txtLogfile->SetValue(settings->GetLogFile());
radLoglevel->SetSelection(settings->GetLogLevel());
txtMaxRows->SetValue(NumToStr(settings->GetMaxRows()));
+ txtMaxViewRows->SetValue(NumToStr(settings->GetMaxViewRows()));
txtMaxColSize->SetValue(NumToStr(settings->GetMaxColSize()));
chkAskSaveConfirm->SetValue(!settings->GetAskSaveConfirmation());
chkAskDelete->SetValue(settings->GetConfirmDelete());
@@ -95,6 +101,8 @@
txtAutoRowCount->SetValue(NumToStr(settings->GetAutoRowCountThreshold()));
chkStickySql->SetValue(settings->GetStickySql());
chkDoubleClickProperties->SetValue(settings->GetDoubleClickProperties());
+ chkDoubleClickView->SetValue(settings->GetDoubleClickView());
+ chkDoubleClickView->Enable(settings->GetDoubleClickProperties());
txtSqlHelpSite->SetValue(settings->GetSqlHelpSite());
txtProxy->SetValue(settings->GetProxy());
chkUnicodeFile->SetValue(settings->GetUnicodeFile());
@@ -178,12 +186,15 @@
settings->SetMaxRows(StrToLong(txtMaxRows->GetValue()));
settings->SetMaxColSize(StrToLong(txtMaxColSize->GetValue()));
+ // Preferences
settings->SetAskSaveConfirmation(!chkAskSaveConfirm->GetValue());
settings->SetConfirmDelete(chkAskDelete->GetValue());
settings->SetShowUsersForPrivileges(chkShowUsersForPrivileges->GetValue());
settings->SetAutoRowCountThreshold(StrToLong(txtAutoRowCount->GetValue()));
settings->SetStickySql(chkStickySql->GetValue());
settings->SetDoubleClickProperties(chkDoubleClickProperties->GetValue());
+ settings->SetDoubleClickView(chkDoubleClickView->GetValue());
+ settings->SetMaxViewRows(StrToLong(txtMaxViewRows->GetValue()));
settings->SetUnicodeFile(chkUnicodeFile->GetValue());
settings->SetFont(currentFont);
settings->SetSQLFont(currentSqlFont);
@@ -276,3 +287,8 @@
if (logFile.ShowModal() == wxID_OK)
txtLogfile->SetValue(logFile.GetPath());
}
+
+void frmOptions::OnDoubleClickProps(wxCommandEvent &ev)
+{
+ chkDoubleClickView->Enable(chkDoubleClickProperties->IsChecked());
+}
--- src/utils/sysSettings.cpp.old Mon Aug 9 09:59:20 2004
+++ src/utils/sysSettings.cpp Wed Sep 22 13:11:28 2004
@@ -70,6 +70,8 @@
autoRowCountThreshold=Read(wxT("AutoRowCount"), 2000);
Read(wxT("StickySql"), &stickySql, false);
Read(wxT("DoubleClickProperties"), &doubleClickProperties, true);
+ Read(wxT("DoubleClickView"), &doubleClickView, false);
+ maxViewRows=Read(wxT("MaxViewRows"), 500L);
Read(wxT("WriteUnicodeFile"), &unicodeFile, false);
Read(wxT("SearchPath"), &searchPath, wxEmptyString);
Read(wxT("MaxServerLogSize"), &maxServerLogSize, 100000L);
@@ -147,6 +149,7 @@
Write(wxT("AskSaveConfirmation"), BoolToStr(askSaveConfirmation));
Write(wxT("ConfirmDelete"), BoolToStr(confirmDelete));
Write(wxT("ShowUsersForPrivileges"), BoolToStr(showUsersForPrivileges));
+ Write(wxT("MaxViewRows"), maxViewRows);
Write(wxT("SqlHelpSite"), sqlHelpSite);
Write(wxT("Proxy"), proxy);
Write(wxT("AutoRowCount"), autoRowCountThreshold);
@@ -328,3 +331,13 @@
doubleClickProperties = newval;
Write(wxT("DoubleClickProperties"), doubleClickProperties);
}
+
+//////////////////////////////////////////////////////////////////////////
+// View instead of properties
+//////////////////////////////////////////////////////////////////////////
+
+void sysSettings::SetDoubleClickView(const bool newval)
+{
+ doubleClickView = newval;
+ Write(wxT("DoubleClickView"), doubleClickView);
+}
Re: Repost: Patch: view data for tables/views on double click
От:
"Dave Page" <dpage@vale-housing.co.uk>
Дата:
> -----Original Message----- > From: pgadmin-hackers-owner@postgresql.org > [mailto:pgadmin-hackers-owner@postgresql.org] On Behalf Of > Ivan Nejgebauer > Sent: 22 September 2004 13:18 > To: pgadmin-hackers@postgresql.org > Subject: [pgadmin-hackers] Repost: Patch: view data for > tables/views on double click > > 1. There is an additional checkbox in the Preferences tab of > the Options dialog, labeled "Show data instead of properties > for tables and views", placed as a subordinate of "Show > object properties on double click" (I have stripped the "in > treeview" part, since double click should also work in the > Properties pane). The checkbox is disabled if its superior is > disabled. I think this is exactly when it should be enabled - such that you have the choice that double click can do one of the following: - Nothing - Open the data view on a table/view (and nothing on other objects) - Open the properties dialogue. > 2. In the same tab, a parameter labeled "Maximum rows in data > view" is introduced. It is used to limit the number of rows > retrieved when constructing the data view/edit grid if > greater than zero. The default value is set to 500, although > it could be set to 0 (unlimited) to keep the behavior prior > to its introduction. I'm unconvinced about silently limiting the number of rows - that's bound to cause a few support emails with ppl not realising there's a default limit (500 seems a little low anyway - what does the maximum query rows default to? For that matter, is there any real need for a separate parameter?). In the query tool it tells the user that greater than X rows will be retrieved, and gives the option to cancel or go ahead - this seems nicer behaviour to me. > The patch also arranges reading and writing of the new > parameters from and to the configuration file. > > The patch is against the beta1 source tree; I could re-sync > it to the latest snapshot if needed. This is a new feature - it's application will be deferred until after we branch following release as we're currently in feature freeze. Sorry for the negative comments - I'm trying very hard not to discourage you from contributing further, however I'm sure you realise that pgAdmin got where it is today by us considering all aspects of its usability and design very carefully before implementing anything. We'll get there in the end though!! Regards, Dave.
Re: Repost: Patch: view data for tables/views on
От:
Ivan Nejgebauer <ian-pgahack@uns.ns.ac.yu>
Дата:
Dave Page wrote: > I think this is exactly when it should be enabled - such that you have > the choice that double click can do one of the following: > > - Nothing > - Open the data view on a table/view (and nothing on other objects) > - Open the properties dialogue. I thought about that, too, but that would be (IMO) better achieved with radio buttons or a combination of a checkbox and radio buttons, and I didn't want to rearrange the dialog too drastically. > I'm unconvinced about silently limiting the number of rows - that's > bound to cause a few support emails with ppl not realising there's a > default limit (500 seems a little low anyway - what does the maximum > query rows default to? For that matter, is there any real need for a > separate parameter?). In the query tool it tells the user that greater > than X rows will be retrieved, and gives the option to cancel or go > ahead - this seems nicer behaviour to me. I chose 500 for no particular reason; it could be higher, or zero (no limit) by default. An argument can be made for having a separate data view row limit -- with queries, the aim is usually to retrieve a fairly limited result set, and the larger set would mean that a) yes, you know what you're doing and want the larger set, or b) the query is erroneous or not specific enough, and the low query limit will warn you; with data view, on the other hand, you are interested in the totality of data, but a higher limit is there to prevent memory exhaustion and application trashing should you choose to view a hypothetical million-row table. I agree that a grid with an incomplete data set could have an indicator of that situation and a way to retrieve the rest of the data. > This is a new feature - it's application will be deferred until after we > branch following release as we're currently in feature freeze. Good, that's one thing I forgot to ask in the previous posting. > Sorry for the negative comments - I'm trying very hard not to discourage > you from contributing further, however I'm sure you realise that pgAdmin > got where it is today by us considering all aspects of its usability and > design very carefully before implementing anything. That's fine by me -- I see pgAdmin as a very nice and useful tool, which is why I want to contribute to its development in the first place, and I realize the need for thoroughly discussing any proposed addition. i.
Re: Repost: Patch: view data for tables/views on
От:
Andreas Pflug <pgadmin@pse-consulting.de>
Дата:
Ivan Nejgebauer wrote: > Dave Page wrote: > >> That breaks the principle of least surprise because it introduces >> inconsistent behaviour. >> >> Perhaps a better approach would be to open the data view only if >> 'double-click-for-properties' is turned off? > > > Andreas Pflug wrote: > >> - the default action might differ from user to user. For sure, an >> unconditional "View Data" on a table is a bad idea. I already hear >> those guys yelling double clicking on a 100 million row table... > > > This version of the patch tries to address those issues in the following > ways: You left out the most important part of my comment. I won't accept double click actions other than "properties" until we have a visual feedback in each object's context menu which marks the default action (this is not only a prerequisite, I'd like to see it in any case). If a user who's familiar with pgAdmin3 is put in front of an arbitrary pgAdmin3 installation, he should know how it behaves without analyzing option settings prior to usage. > > 2. In the same tab, a parameter labeled "Maximum rows in data view" is > introduced. A limited rowset is too undeterministic to edit on. Use a restricting query, i.e. filtered view data. > The patch is against the beta1 source tree; As a consequence of your first posting, which pointed out some inconsistent behaviour, I reworked doubleclick (and other) actions in the properties listview to match the treeview actions; see CHANGELOG.txt. Thus your patch will probably generate some non-trivial conflicts. Any patch posted should be diff'ed against cvs HEAD. Regards, Andreas