Log Message:
-----------
refresh after multiple object delete fix
Modified Files:
--------------
pgadmin3/src/ui:
events.cpp (r1.113 -> r1.114)
Index: events.cpp
===================================================================
RCS file: /projects/pgadmin3/src/ui/events.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -Lsrc/ui/events.cpp -Lsrc/ui/events.cpp -u -w -r1.113 -r1.114
--- src/ui/events.cpp
+++ src/ui/events.cpp
@@ -1112,33 +1112,100 @@
}
-
void frmMain::OnDelete(wxCommandEvent &ev)
{
wxWindow *current=wxWindow::FindFocus();
- if (current == browser)
+
+ if (current == browser || current == properties)
OnDrop(ev);
}
void frmMain::OnDrop(wxCommandEvent &ev)
{
- // This handler will primarily deal with dropping items
+ wxWindow *current=wxWindow::FindFocus();
+ wxTreeItemId item=browser->GetSelection();
+ pgCollection *collection = (pgCollection*)browser->GetItemData(item);
- // Get the item data, and feed it to the relevant handler,
- pgObject *data = GetSelectedObject();
+ if (current == browser)
+ dropSingleObject(collection, true);
+ else if (current == properties)
+ {
+ if (collection && collection->IsCollection())
+ {
+ long index=properties->GetFirstSelected();
+
+ if (index >= 0)
+ {
+ pgObject *data=collection->FindChild(browser, index);
- // accelerator can bypass disabled menu, so we need to check
if (!data || !data->CanDrop())
return;
+ if (properties->GetSelectedItemCount() == 1)
+ {
+ dropSingleObject(data, false);
+ return;
+ }
+
+ if (data->GetSystemObject())
+ {
+ wxMessageDialog msg(this, wxString::Format(_("Cannot drop system
%s"),
+ data->GetTranslatedTypeName().c_str(), ""),
+ _("Trying to drop system object"), wxICON_EXCLAMATION);
+ msg.ShowModal();
+ return;
+ }
+
+ if (data->RequireDropConfirm() || settings->GetConfirmDelete())
+ {
+ wxMessageDialog msg(this, _("Are you sure you wish to drop
multiple objects?"),
+ _("Drop multiple objects?"), wxYES_NO | wxICON_QUESTION);
+ if (msg.ShowModal() != wxID_YES)
+ {
+ return;
+ }
+ }
+
+ bool done=true;
+ long count=0;
+ while (done && data)
+ {
+ done = dropSingleObject(data, false);
+
+ if (done)
+ {
+ count++;
+ index = properties->GetNextSelected(index);
+
+ if (index >= 0)
+ data=collection->FindChild(browser, index-count);
+ else
+ break;
+ }
+ }
+ Refresh(collection);
+ }
+ }
+ }
+}
+
+
+bool frmMain::dropSingleObject(pgObject *data, bool updateFinal)
+{
+ if (updateFinal)
+ {
+ // accelerator can bypass disabled menu, so we need to check
+ if (!data || !data->CanDrop())
+ return false;
+
if (data->GetSystemObject())
{
wxMessageDialog msg(this, wxString::Format(_("Cannot drop system %s %s."),
data->GetTranslatedTypeName().c_str(),
data->GetFullIdentifier().c_str()),
_("Trying to drop system object"), wxICON_EXCLAMATION);
msg.ShowModal();
- return;
+ return false;
}
if (data->RequireDropConfirm() || settings->GetConfirmDelete())
@@ -1148,7 +1215,8 @@
wxString::Format(_("Drop %s?"),
data->GetTranslatedTypeName().c_str()), wxYES_NO | wxICON_QUESTION);
if (msg.ShowModal() != wxID_YES)
{
- return;
+ return false;
+ }
}
}
bool done=data->DropObject(this, browser);
@@ -1159,6 +1227,8 @@
wxTreeItemId parentItem=browser->GetItemParent(data->GetId());
+ if (updateFinal)
+ {
wxTreeItemId nextItem=browser->GetNextVisible(data->GetId());
if (nextItem)
{
@@ -1171,12 +1241,14 @@
if (nextItem)
browser->SelectItem(nextItem);
-
+ }
int droppedType = data->GetType();
browser->Delete(data->GetId());
// data is invalid now
+ if (updateFinal)
+ {
pgCollection *collection=0;
while (parentItem)
@@ -1191,13 +1263,16 @@
}
}
}
+ return done;
+}
void frmMain::OnRefresh(wxCommandEvent &ev)
{
// Refresh - Clear the treeview below the current selection
- pgObject *data = GetSelectedObject();
+ wxTreeItemId item=browser->GetSelection();
+ pgObject *data = (pgObject*)browser->GetItemData(item);
if (!data)
return;
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org