1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: dlgCheck.cpp 4874 2006-01-06 17:33:27Z dpage $
5
// Copyright (C) 2002 - 2006, The pgAdmin Development Team
6
// This software is released under the Artistic Licence
8
// dlgCheck.cpp - PostgreSQL Check Property
10
//////////////////////////////////////////////////////////////////////////
24
#define chkDeferrable CTRL_CHECKBOX("chkDeferrable")
25
#define chkDeferred CTRL_CHECKBOX("chkDeferred")
26
#define stDeferred CTRL_STATIC("stDeferred")
27
#define txtWhere CTRL_TEXT("txtWhere")
30
BEGIN_EVENT_TABLE(dlgCheck, dlgProperty)
31
EVT_TEXT(XRCID("txtWhere"), dlgProperty::OnChange)
32
EVT_CHECKBOX(XRCID("chkDeferrable"), dlgCheck::OnCheckDeferrable)
36
dlgProperty *pgCheckFactory::CreateDialog(frmMain *frame, pgObject *node, pgObject *parent)
38
return new dlgCheck(this, frame, (pgCheck*)node, (pgTable*)parent);
42
dlgCheck::dlgCheck(pgaFactory *f, frmMain *frame, pgCheck *node, pgTable *parentNode)
43
: dlgProperty(f, frame, wxT("dlgCheck"))
50
void dlgCheck::OnCheckDeferrable(wxCommandEvent &ev)
52
bool canDef=chkDeferrable->GetValue();
53
stDeferred->Enable(canDef);
55
chkDeferred->SetValue(false);
56
chkDeferred->Enable(canDef);
60
void dlgCheck::CheckChange()
64
EnableOK(txtComment->GetValue() != check->GetComment());
69
txtComment->Enable(!GetName().IsEmpty());
70
CheckValid(enable, !txtWhere->GetValue().IsEmpty(), _("Please specify condition."));
76
pgObject *dlgCheck::GetObject()
82
pgObject *dlgCheck::CreateObject(pgCollection *collection)
84
wxString name=GetName();
89
pgObject *obj=checkFactory.CreateObjects(collection, 0, wxT(
90
"\n AND conname=") + qtString(name) + wxT(
91
"\n AND relnamespace=") + table->GetSchema()->GetOidStr());
96
int dlgCheck::Go(bool modal)
100
// edit mode: view only
103
txtWhere->SetValue(check->GetDefinition());
106
chkDeferrable->SetValue(check->GetDeferrable());
107
chkDeferred->SetValue(check->GetDeferred());
108
chkDeferrable->Disable();
109
chkDeferred->Disable();
114
txtComment->Disable();
117
cbClusterSet->Disable();
121
return dlgProperty::Go(modal);
125
wxString dlgCheck::GetSql()
128
wxString name=GetName();
132
sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
134
AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
135
sql +=wxT(" CHECK ") + GetDefinition()
139
AppendComment(sql, wxT("CONSTRAINT ") + qtIdent(name)
140
+ wxT(" ON ") + table->GetQuotedFullIdentifier(), check);
145
wxString dlgCheck::GetDefinition()
149
sql = wxT("(") + txtWhere->GetValue() + wxT(")");