--- /temporary/pgadmin-git/pgadmin3/pgadmin/frm/frmMain.cpp 2011-03-31 12:54:19.000000000 +0200 +++ /root/files/pgadmin3/pgadmin/frm/frmMain.cpp 2011-03-31 11:49:33.000000000 +0200 @@ -77,6 +77,7 @@ #include "slony/slCluster.h" #include "slony/slSet.h" #include "schema/pgForeignKey.h" +#include "frm/frmPasteObject.h" #if wxDIALOG_UNIT_COMPATIBILITY @@ -357,6 +358,10 @@ new reassignDropOwnedFactory(menuFactories, editMenu, 0); editMenu->AppendSeparator(); + new copyObjectFactory(menuFactories, editMenu, 0); + new pasteObjectFactory(menuFactories, editMenu, 0); + editMenu->AppendSeparator(); + new separatorFactory(menuFactories); toolBar->AddSeparator(); @@ -1369,3 +1374,62 @@ DisplayHelp(wxT("bugreport"), HELP_PGADMIN); return 0; } + +copyObjectFactory::copyObjectFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : contextActionFactory(list) +{ + mnu->Append(id, _("&Copy table(s)..."), _("Store table(s) reference for later paste")); +} + + +wxWindow *copyObjectFactory::StartDialog(frmMain *form, pgObject *obj) +{ + form->SetCopytObject(obj); + return 0; +} + + +bool copyObjectFactory::CheckEnable(pgObject *obj) +{ + if (!obj) + return false; + + if (obj->GetConnection()) { + pgTable *table = (obj->GetMetaType() == PGM_TABLE) ? (pgTable *)obj : 0; + if (table) + return true; + pgSchema *schema = (obj->GetMetaType() == PGM_SCHEMA) ? (pgSchema *)obj : 0; + if (schema) + return true; + } + return false; +} + +pasteObjectFactory::pasteObjectFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : contextActionFactory(list) +{ + mnu->Append(id, _("&Paste table(s)..."), _("Paste table(s)")); +} + + +wxWindow *pasteObjectFactory::StartDialog(frmMain *form, pgObject *obj) +{ + pgObject *copyobj = form->GetCopytObject(); + if (copyobj) { + frmPasteObject *frm = new frmPasteObject(form, copyobj, obj); + frm->process(); + } + return 0; +} + + +bool pasteObjectFactory::CheckEnable(pgObject *obj) +{ + if (!obj) + return false; + + if (obj->GetConnection()) { + pgSchema *schema = (obj->GetMetaType() == PGM_SCHEMA) ? (pgSchema *)obj : 0; + if (schema) + return true; + } + return false; +}