~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/dlg/dlgForeignKey.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//////////////////////////////////////////////////////////////////////////
2
2
//
3
3
// pgAdmin III - PostgreSQL Tools
4
 
// RCS-ID:      $Id: dlgForeignKey.cpp 6930 2008-01-02 00:10:01Z dpage $
5
 
// Copyright (C) 2002 - 2008, The pgAdmin Development Team
6
 
// This software is released under the Artistic Licence
 
4
// RCS-ID:      $Id: dlgForeignKey.cpp 7758 2009-03-26 20:49:59Z dpage $
 
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
 
6
// This software is released under the BSD Licence
7
7
//
8
8
// dlgForeignKey.cpp - PostgreSQL Foreign Key Property
9
9
//
54
54
    EVT_BUTTON(XRCID("btnAddRef"),              dlgForeignKey::OnAddRef)
55
55
    EVT_BUTTON(XRCID("btnRemoveRef"),           dlgForeignKey::OnRemoveRef)
56
56
    EVT_BUTTON(wxID_OK,                         dlgForeignKey::OnOK)
 
57
#ifdef __WXMAC__
 
58
    EVT_SIZE(                                   dlgForeignKey::OnChangeSize)
 
59
#endif
57
60
END_EVENT_TABLE();
58
61
 
59
62
 
98
101
}
99
102
 
100
103
 
 
104
#ifdef __WXMAC__
 
105
void dlgForeignKey::OnChangeSize(wxSizeEvent &ev)
 
106
{
 
107
        lstColumns->SetSize(wxDefaultCoord, wxDefaultCoord,
 
108
            ev.GetSize().GetWidth(), ev.GetSize().GetHeight() - 450);
 
109
    if (GetAutoLayout())
 
110
    {
 
111
        Layout();
 
112
    }
 
113
}
 
114
#endif
 
115
 
 
116
 
101
117
void dlgForeignKey::CheckChange()
102
118
{
103
119
    if (processing)
121
137
        chkDeferred->SetValue(false);
122
138
    chkDeferred->Enable(canDef);
123
139
 
124
 
    txtIndexName->Enable(chkAutoIndex->GetValue());
 
140
    txtIndexName->Enable(table && chkAutoIndex->GetValue());
125
141
 
126
142
    wxString coveringIndex;
127
143
    if (table)
 
144
    {
128
145
        coveringIndex = table->GetCoveringIndex(mainForm->GetBrowser(), cols);
129
146
 
130
 
    if (coveringIndex.IsEmpty())
131
 
    {
132
 
        if (!chkAutoIndex->IsEnabled())
133
 
        {
134
 
            chkAutoIndex->Enable();
135
 
            chkAutoIndex->SetValue(true);
136
 
            txtIndexName->Enable();
137
 
            txtIndexName->SetValue(savedIndexName);
138
 
        }
139
 
 
140
 
        wxString idxName = txtIndexName->GetValue().Strip(wxString::both);
141
 
 
142
 
        if (name != savedFKName || idxName == savedIndexName)
143
 
        {
144
 
            if (idxName.IsEmpty() || idxName == DefaultIndexName(savedFKName))
145
 
            {
146
 
                idxName = DefaultIndexName(name);
147
 
                txtIndexName->SetValue(idxName);
148
 
            }
149
 
        }
150
 
        savedIndexName = idxName;
151
 
    }
152
 
    else
153
 
    {
154
 
        if (chkAutoIndex->IsEnabled())
155
 
            savedIndexName = txtIndexName->GetValue();
156
 
 
157
 
        txtIndexName->SetValue(coveringIndex);
158
 
        chkAutoIndex->SetValue(false);
159
 
 
160
 
        txtIndexName->Disable();
161
 
        chkAutoIndex->Disable();
 
147
        if (coveringIndex.IsEmpty())
 
148
        {
 
149
            if (!chkAutoIndex->IsEnabled())
 
150
            {
 
151
                chkAutoIndex->Enable();
 
152
                chkAutoIndex->SetValue(true);
 
153
                txtIndexName->Enable();
 
154
                txtIndexName->SetValue(savedIndexName);
 
155
            }
 
156
 
 
157
            wxString idxName = txtIndexName->GetValue().Strip(wxString::both);
 
158
 
 
159
            if (name != savedFKName || idxName == savedIndexName)
 
160
            {
 
161
                if (idxName.IsEmpty() || idxName == DefaultIndexName(savedFKName))
 
162
                {
 
163
                    idxName = DefaultIndexName(name);
 
164
                    txtIndexName->SetValue(idxName);
 
165
                }
 
166
            }
 
167
            savedIndexName = idxName;
 
168
        }
 
169
        else
 
170
        {
 
171
            if (chkAutoIndex->IsEnabled())
 
172
                savedIndexName = txtIndexName->GetValue();
 
173
 
 
174
            txtIndexName->SetValue(coveringIndex);
 
175
            chkAutoIndex->SetValue(false);
 
176
 
 
177
            txtIndexName->Disable();
 
178
            chkAutoIndex->Disable();
 
179
        }
162
180
    }
163
181
 
164
182
    savedFKName = name;
170
188
        if (chkAutoIndex->GetValue())
171
189
        {
172
190
            CheckValid(enable, !txtIndexName->GetValue().IsEmpty(),
173
 
                _("Please specify FK index name."));
 
191
                _("Please specify covering index name."));
174
192
        }
175
193
        else
176
194
            enable = txtComment->GetValue() != foreignKey->GetComment();
182
200
        txtComment->Enable(!name.IsEmpty());
183
201
        CheckValid(enable, lstColumns->GetItemCount() > 0, _("Please specify columns."));
184
202
        CheckValid(enable, !chkAutoIndex->GetValue() || !txtIndexName->GetValue().IsEmpty(),
185
 
            _("Please specify FK index name."));
 
203
            _("Please specify covering index name."));
186
204
        EnableOK(enable);
187
205
    }
188
206
 
393
411
        }
394
412
        if (!table)
395
413
        {
 
414
            chkAutoIndex->Disable();
 
415
            chkAutoIndex->SetValue(false);
 
416
            txtIndexName->Disable();
396
417
            cbClusterSet->Disable();
397
418
            cbClusterSet = 0;
398
419
        }