21
21
#include "schema/pgForeignKey.h"
25
24
pgConstraintCollection::pgConstraintCollection(pgaFactory *factory, pgTable *table)
26
: pgTableObjCollection(factory, table)
25
: pgTableObjCollection(factory, table)
30
29
wxMenu *pgConstraintCollection::GetNewMenu()
32
if (!GetSchema()->GetCreatePrivilege())
31
if (!GetSchema()->GetCreatePrivilege())
35
wxMenu *menu=new wxMenu();
36
if (table->GetPrimaryKey().IsEmpty())
37
primaryKeyFactory.AppendMenu(menu);
38
foreignKeyFactory.AppendMenu(menu);
39
uniqueFactory.AppendMenu(menu);
40
checkFactory.AppendMenu(menu);
34
wxMenu *menu = new wxMenu();
35
if (table->GetPrimaryKey().IsEmpty())
36
primaryKeyFactory.AppendMenu(menu);
37
foreignKeyFactory.AppendMenu(menu);
38
excludeFactory.AppendMenu(menu);
39
uniqueFactory.AppendMenu(menu);
40
checkFactory.AppendMenu(menu);
45
45
void pgConstraintCollection::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
47
if (browser->GetChildrenCount(GetId(), false) == 0)
49
wxTreeItemId id=browser->GetItemParent(GetId());
51
table = (pgTable*)browser->GetObject(id);
52
wxASSERT(table && (table->GetMetaType() == PGM_TABLE || table->GetMetaType() == GP_PARTITION));
47
if (browser->GetChildrenCount(GetId(), false) == 0)
49
wxTreeItemId id = browser->GetItemParent(GetId());
51
table = (pgTable *)browser->GetObject(id);
52
wxASSERT(table && (table->GetMetaType() == PGM_TABLE || table->GetMetaType() == GP_PARTITION));
54
primaryKeyFactory.CreateObjects(this, browser);
55
foreignKeyFactory.CreateObjects(this, browser);
56
uniqueFactory.CreateObjects(this, browser);
57
checkFactory.CreateObjects(this, browser);
59
UpdateChildCount(browser);
61
ShowList(_("Constraints"), browser, properties);
54
primaryKeyFactory.CreateObjects(this, browser);
55
foreignKeyFactory.CreateObjects(this, browser);
56
excludeFactory.CreateObjects(this, browser);
57
uniqueFactory.CreateObjects(this, browser);
58
checkFactory.CreateObjects(this, browser);
60
UpdateChildCount(browser);
62
ShowList(_("Constraints"), browser, properties);
66
67
/////////////////////////////
68
#include "images/constraints.xpm"
69
#include "images/constraints.pngc"
70
pgConstraintFactory::pgConstraintFactory()
71
: pgTableObjFactory(__("Constraint"), 0, 0, 0)
71
pgConstraintFactory::pgConstraintFactory()
72
: pgTableObjFactory(__("Constraint"), 0, 0, 0)
73
metaType = PGM_CONSTRAINT;
74
metaType = PGM_CONSTRAINT;
76
77
pgCollection *pgConstraintFactory::CreateCollection(pgObject *obj)
78
return new pgConstraintCollection(GetCollectionFactory(), (pgTable*)obj);
79
return new pgConstraintCollection(GetCollectionFactory(), (pgTable *)obj);
82
83
pgConstraintFactory constraintFactory;
83
pgaCollectionFactory constraintCollectionFactory(&constraintFactory, __("Constraints"), constraints_xpm);
84
pgaCollectionFactory constraintCollectionFactory(&constraintFactory, __("Constraints"), constraints_png_img);