On Sat, 2011-07-09 at 00:23 +0100, Thom Brown wrote:
> On 9 July 2011 00:12, Guillaume Lelarge <guilla...@lelarge.info> wrote:
> > On Fri, 2011-07-08 at 21:55 +0200, Guillaume Lelarge wrote:
> >> On Fri, 2011-07-08 at 20:06 +0100, Thom Brown wrote:
> >> > On 8 July 2011 19:46, Guillaume Lelarge <guilla...@lelarge.info> wrote:
> >> > > On Thu, 2011-07-07 at 23:24 +0100, Thom Brown wrote:
> >> > >> On 7 July 2011 23:20, Guillaume Lelarge <guilla...@lelarge.info> 
> >> > >> wrote:
> >> > >> > On Wed, 2011-07-06 at 11:59 +0100, Thom Brown wrote:
> >> > [...]
> >> > > And that should be all. The fixed patch is attached. There is one
> >> > > remaining issue: how to refresh the object's parent node in the new
> >> > > schema?
> >> >
> >> > I played around with rebuilding the node path with the new schema name
> >> > to refresh it, but I kept getting endless data type issues, and have
> >> > no idea how this node stuff works, so I'm not sure what to do about
> >> > that.  Have any guidance?  If not, I might have another attempt at
> >> > working out how to manipulate nodes.
> >> >
> >>
> >> I'll try to look into this, but I don't think I'll be lucky.
> >>
> >
> > I was wrong. I have it working. Code is ugly right now, so it'll need
> > some cleanup/refactoring/etc. Should be able to commit it tomorrow :)
> 
> Excellent.  I'll be interested to see what you needed to do to achieve
> it.  Merci beaucoup.
> 

Not much actually. See refresh.patch. ShowObject() in dlgProperty is
responsible of displaying objects in the treeview. I just added the code
that goes back to the Schemas node, and made it resfresh it.

add_schemas_v3.patch is the final patch. I'm intending to apply it
rather soon.


-- 
Guillaume
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com

Attachment: add_schemas_v3.patch.bz2
Description: application/bzip

diff --git a/pgadmin/dlg/dlgProperty.cpp b/pgadmin/dlg/dlgProperty.cpp
index dead2d3..e348c82 100644
--- a/pgadmin/dlg/dlgProperty.cpp
+++ b/pgadmin/dlg/dlgProperty.cpp
@@ -793,6 +793,9 @@ void dlgProperty::ShowObject()
 	// inherently get refreshed as well. Yay :-)
 	if (owneritem)
 	{
+		// Get the object node in case we need it later
+		wxTreeItemId objectnode = mainForm->GetBrowser()->GetItemParent(owneritem);
+
 		// Stash the selected items path
 		wxString currentPath = mainForm->GetCurrentNodePath();
 
@@ -803,6 +806,35 @@ void dlgProperty::ShowObject()
 
 		// Restore the previous selection...
 		mainForm->SetCurrentNode(mainForm->GetBrowser()->GetRootItem(), currentPath);
+
+		// If we couldn't restore the previous selection, it means that
+		// the object doesn't exist any more. Either it was dropped, or
+		// moved to another schema.
+		// If it is the latter, we need to refresh the Schemas node.
+		if (currentPath != mainForm->GetCurrentNodePath())
+		{
+			if (objectnode.IsOk())
+			{
+				// first parent is the objects' node
+				wxTreeItemId objectsnode = mainForm->GetBrowser()->GetItemParent(objectnode);
+				if (objectsnode.IsOk())
+				{
+					// second parent is the schema's node
+					wxTreeItemId schemanode = mainForm->GetBrowser()->GetItemParent(objectsnode);
+					if (objectsnode.IsOk())
+					{
+						// third parent is the schemas' node
+						wxTreeItemId schemasnode = mainForm->GetBrowser()->GetItemParent(schemanode);
+						if (objectsnode.IsOk())
+						{
+							// we finally have the schemas' node, so we refresh it
+							pgObject *schemasnodeobj = mainForm->GetBrowser()->GetObject(schemasnode);
+							mainForm->Refresh(schemasnodeobj);
+						}
+					}
+				}
+			}
+		}
 	}
 	else if (data)
 	{
-- 
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