Thread: Patch: view data for tables/views on double click
The attached patch a) defines a double click handler for the list in the properties pane, so that a double click on an item in the list launches the properties editor for the item (or the data view if the item is a table or a view); and b) modifies the tree view double click handler so that a double click on a table or a view launches the data view for the corresponding table/view. Rationale for different behavior with tables/views: most of the time, it is expected that the user is interested in table/view _data_, not properties, so the default action on a table/view shoud be to display its data. Comments? 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/ui/events.cpp.old Tue Sep 7 10:34:34 2004 +++ src/ui/events.cpp Wed Sep 15 15:12:51 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 (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()) { + denyCollapseItem=item; + ViewData(false); + return; + } + break; + default: if (settings->GetDoubleClickProperties()) { if (data->CanEdit()) { + denyCollapseItem=item; OnProperties(nullEvent); - event.Skip(); return; } }
I guess it depends on user type. If user is a developer or database designer, showing properties could be the desired default action. If user is a more like a final user, viewing data maybe is the right choice. Couldn 't be this behavoir be an option ?. Something like "Show object properties on double click in treeview" under Options -> Preferences. Diego. El jue, 16-09-2004 a las 06:42, Ivan Nejgebauer escribió: > The attached patch a) defines a double click handler for the list in the > properties pane, so that a double click on an item in the list launches > the properties editor for the item (or the data view if the item is a > table or a view); and b) modifies the tree view double click handler so > that a double click on a table or a view launches the data view for the > corresponding table/view. > > Rationale for different behavior with tables/views: most of the time, it > is expected that the user is interested in table/view _data_, not > properties, so the default action on a table/view shoud be to display > its data. > > Comments? > > 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/ui/events.cpp.old Tue Sep 7 10:34:34 2004 > +++ src/ui/events.cpp Wed Sep 15 15:12:51 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 (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()) { > + denyCollapseItem=item; > + ViewData(false); > + return; > + } > + break; > + > default: > if (settings->GetDoubleClickProperties()) > { > if (data->CanEdit()) > { > + denyCollapseItem=item; > OnProperties(nullEvent); > - event.Skip(); > return; > } > } > > ______________________________________________________________________ > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match
> -----Original Message----- > From: pgadmin-support-owner@postgresql.org > [mailto:pgadmin-support-owner@postgresql.org] On Behalf Of > Ivan Nejgebauer > Sent: 16 September 2004 10:43 > To: pgadmin-support@postgresql.org > Subject: [pgadmin-support] Patch: view data for tables/views > on double click > > The attached patch a) defines a double click handler for the > list in the properties pane, so that a double click on an > item in the list launches the properties editor for the item > (or the data view if the item is a table or a view); and b) > modifies the tree view double click handler so that a double > click on a table or a view launches the data view for the > corresponding table/view. > > Rationale for different behavior with tables/views: most of > the time, it is expected that the user is interested in > table/view _data_, not properties, so the default action on a > table/view shoud be to display its data. > > Comments? 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? Regards, Dave
Ivan Nejgebauer wrote: First of all, this is certainly hackers stuff, please post on pgadmin-hackers! > The attached patch a) defines a double click handler for the list in the > properties pane, so that a double click on an item You're right, doubleclick is missing on the property pane. in the list launches > the properties editor for the item (or the data view if the item is a > table or a view); and b) modifies the tree view double click handler so > that a double click on a table or a view launches the data view for the > corresponding table/view. This isn't acceptable like this, because it introduces different behaviour between clicking on a "properties" item and a tree item. Both must behave identically. Actually, not only double click is missing, but also right mouse click. > > Rationale for different behavior with tables/views: This is reasonable, but before that some prerequisites have to be met: - the default action should be visible to the user, preferrably displayed bold in the context menu. - 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... Regards, Andreas