--- pgadmin3/pgadmin/frm/frmMain.cpp 2011-04-12 19:26:25.000000000 +0200 +++ changes/frmMain.cpp 2011-04-12 16:41:21.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 @@ -89,6 +90,7 @@ msgLevel = 0; lastPluginUtility = NULL; pluginUtilityCount = 0; + copytObject = NULL; dlgName = wxT("frmMain"); SetMinSize(wxSize(600, 450)); @@ -357,6 +359,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(); @@ -1371,3 +1377,67 @@ 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()) { + //tree item 'Tables' has GetMetaType() == PGM_TABLE ! + pgTable *table = (obj->GetMetaType() == PGM_TABLE) ? dynamic_cast(obj) : 0; + if (table) + return true; + //tree item 'Schemas' has GetMetaType() == PGM_SCHEMA ! + pgSchema *schema = (obj->GetMetaType() == PGM_SCHEMA) ? dynamic_cast(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()) { + //tree item 'Schemas' has GetMetaType() == PGM_SCHEMA ! + pgSchema *schema = (obj->GetMetaType() == PGM_SCHEMA) ? dynamic_cast(obj) : 0; + if (schema && winMain->GetCopytObject()) + return true; + } + return false; +}