1
1
//////////////////////////////////////////////////////////////////////////
3
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: frmOptions.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: frmOptions.cpp 7818 2009-04-24 08:45:42Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
8
// frmOptions.cpp - The main options dialogue
30
30
#include "images/properties.xpm"
32
extern wxLocale *locale;
33
extern wxArrayInt existingLangs;
34
extern wxArrayString existingLangNames;
36
extern wxString pgBackupExecutable;
37
extern wxString pgBackupAllExecutable;
38
extern wxString pgRestoreExecutable;
40
extern wxString edbBackupExecutable;
41
extern wxString edbBackupAllExecutable;
42
extern wxString edbRestoreExecutable;
44
32
#define nbOptions CTRL_NOTEBOOK("nbOptions")
45
33
#define txtPgHelpPath CTRL_TEXT("txtPgHelpPath")
46
34
#define txtEdbHelpPath CTRL_TEXT("txtEdbHelpPath")
35
#define txtGpHelpPath CTRL_TEXT("txtGpHelpPath")
47
36
#define txtSlonyHelpPath CTRL_TEXT("txtSlonyHelpPath")
48
37
#define txtSlonyPath CTRL_TEXT("txtSlonyPath")
49
38
#define txtPostgresqlPath CTRL_TEXT("txtPostgresqlPath")
50
39
#define txtEnterprisedbPath CTRL_TEXT("txtEnterprisedbPath")
40
#define txtGPDBPath CTRL_TEXT("txtGPDBPath")
51
41
#define txtSystemSchemas CTRL_TEXT("txtSystemSchemas")
52
42
#define txtLogfile CTRL_TEXT("txtLogfile")
53
43
#define radLoglevel CTRL_RADIOBOX("radLoglevel")
83
73
EVT_BUTTON (XRCID("btnSlonyPath"), frmOptions::OnSlonyPathSelect)
84
74
EVT_BUTTON (XRCID("btnPostgresqlPath"), frmOptions::OnPostgresqlPathSelect)
85
75
EVT_BUTTON (XRCID("btnEnterprisedbPath"), frmOptions::OnEnterprisedbPathSelect)
76
EVT_BUTTON (XRCID("btnGPDBPath"), frmOptions::OnGPDBPathSelect)
86
77
EVT_BUTTON (XRCID("btnDefault"), frmOptions::OnDefault)
87
78
EVT_CHECKBOX(XRCID("chkSuppressHints"), frmOptions::OnSuppressHints)
88
79
EVT_CHECKBOX(XRCID("chkResetHints"), frmOptions::OnResetHints)
126
116
txtAutoRowCount->SetValue(NumToStr(settings->GetAutoRowCountThreshold()));
127
117
txtIndent->SetValue(NumToStr(settings->GetIndentSpaces()));
128
118
chkSpacesForTabs->SetValue(settings->GetSpacesForTabs());
129
cbCopyQuote->SetSelection(settings->GetCopyQuoting());
130
cbCopyQuoteChar->SetValue(settings->GetCopyQuoteChar());
119
cbCopyQuote->SetSelection(settings->GetCopyQuoting());
120
cbCopyQuoteChar->SetValue(settings->GetCopyQuoteChar());
132
122
wxString copySeparator = settings->GetCopyColSeparator();
133
123
if (copySeparator == wxT("\t"))
134
124
copySeparator = _("Tab");
135
125
cbCopySeparator->SetValue(copySeparator);
137
chkTabForCompletion->SetValue(settings->GetTabForCompletion());
138
127
chkStickySql->SetValue(settings->GetStickySql());
139
128
chkIndicateNull->SetValue(settings->GetIndicateNull());
140
129
chkDoubleClickProperties->SetValue(settings->GetDoubleClickProperties());
142
131
txtPgHelpPath->SetValue(settings->GetPgHelpPath());
143
132
txtEdbHelpPath->SetValue(settings->GetEdbHelpPath());
133
txtGpHelpPath->SetValue(settings->GetGpHelpPath());
144
134
txtSlonyHelpPath->SetValue(settings->GetSlonyHelpPath());
146
136
txtSystemSchemas->SetValue(settings->GetSystemSchemas());
175
167
currentSqlFont=settings->GetSQLFont();
176
168
txtSqlFont->SetValue(currentSqlFont.GetNativeFontInfoUserDesc());
178
// Load the display options
179
lstDisplay->Append(_("Databases"));
180
lstDisplay->Append(_("Tablespaces"));
181
lstDisplay->Append(_("pgAgent jobs"));
182
lstDisplay->Append(_("Groups/group roles"));
183
lstDisplay->Append(_("Users/login roles"));
184
lstDisplay->Append(_("Catalogs"));
185
lstDisplay->Append(_("Casts"));
186
lstDisplay->Append(_("Languages"));
187
lstDisplay->Append(_("Public synonyms"));
188
lstDisplay->Append(_("Schemas"));
189
lstDisplay->Append(_("Slony-I clusters"));
190
lstDisplay->Append(_("Aggregates"));
191
lstDisplay->Append(_("Conversions"));
192
lstDisplay->Append(_("Domains"));
193
lstDisplay->Append(_("Functions"));
194
lstDisplay->Append(_("Trigger functions"));
195
lstDisplay->Append(_("Packages"));
196
lstDisplay->Append(_("Procedures"));
197
lstDisplay->Append(_("Operators"));
198
lstDisplay->Append(_("Operator classes"));
199
lstDisplay->Append(_("Operator families"));
200
lstDisplay->Append(_("Rules"));
201
lstDisplay->Append(_("Sequences"));
202
lstDisplay->Append(_("Tables"));
203
lstDisplay->Append(_("Types"));
204
lstDisplay->Append(_("Views"));
170
// Load the display options
171
lstDisplay->Append(_("Databases"));
172
lstDisplay->Append(_("Tablespaces"));
173
lstDisplay->Append(_("pgAgent Jobs"));
174
lstDisplay->Append(_("Groups/group Roles"));
175
lstDisplay->Append(_("Users/login Roles"));
176
lstDisplay->Append(_("Resource Queues"));
177
lstDisplay->Append(_("Catalogs"));
178
lstDisplay->Append(_("Casts"));
179
lstDisplay->Append(_("Languages"));
180
lstDisplay->Append(_("Public Synonyms"));
181
lstDisplay->Append(_("Schemas"));
182
lstDisplay->Append(_("Slony-I Clusters"));
183
lstDisplay->Append(_("Aggregates"));
184
lstDisplay->Append(_("Conversions"));
185
lstDisplay->Append(_("Domains"));
186
lstDisplay->Append(_("Functions"));
187
lstDisplay->Append(_("Trigger Functions"));
188
lstDisplay->Append(_("Packages"));
189
lstDisplay->Append(_("Procedures"));
190
lstDisplay->Append(_("Operators"));
191
lstDisplay->Append(_("Operator Classes"));
192
lstDisplay->Append(_("Operator Families"));
193
lstDisplay->Append(_("Sequences"));
194
lstDisplay->Append(_("Tables"));
195
lstDisplay->Append(_("External Tables"));
196
lstDisplay->Append(_("FTS Configurations"));
197
lstDisplay->Append(_("FTS Dictionaries"));
198
lstDisplay->Append(_("FTS Parsers"));
199
lstDisplay->Append(_("FTS Templates"));
200
lstDisplay->Append(_("Types"));
201
lstDisplay->Append(_("Views"));
206
for (unsigned int x=0; x < lstDisplay->GetCount(); x++)
207
lstDisplay->Check(x, settings->GetDisplayOption(lstDisplay->GetString(x)));
203
for (unsigned int x=0; x < lstDisplay->GetCount(); x++)
204
lstDisplay->Check(x, settings->GetDisplayOption(lstDisplay->GetString(x)));
209
206
chkSystemObjects->SetValue(settings->GetShowSystemObjects());
212
OnChangeCopyQuote(e);
209
OnChangeCopyQuote(e);
358
381
settings->SetAutoRowCountThreshold(StrToLong(txtAutoRowCount->GetValue()));
359
382
settings->SetIndentSpaces(StrToLong(txtIndent->GetValue()));
360
383
settings->SetSpacesForTabs(chkSpacesForTabs->GetValue());
361
settings->SetCopyQuoting(cbCopyQuote->GetCurrentSelection());
362
settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue());
384
settings->SetCopyQuoting(cbCopyQuote->GetCurrentSelection());
385
settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue());
364
387
wxString copySeparator = cbCopySeparator->GetValue();
365
388
if (copySeparator == _("Tab"))
366
389
copySeparator = wxT("\t");
367
390
settings->SetCopyColSeparator(copySeparator);
369
settings->SetTabForCompletion(chkTabForCompletion->GetValue());
370
392
settings->SetStickySql(chkStickySql->GetValue());
371
393
settings->SetIndicateNull(chkIndicateNull->GetValue());
372
394
settings->SetDoubleClickProperties(chkDoubleClickProperties->GetValue());
373
395
settings->SetUnicodeFile(chkUnicodeFile->GetValue());
374
settings->SetFont(currentFont);
396
settings->SetSystemFont(currentFont);
375
397
settings->SetSQLFont(currentSqlFont);
376
398
settings->SetSuppressGuruHints(chkSuppressHints->GetValue());
377
399
settings->SetSlonyPath(txtSlonyPath->GetValue());
378
400
settings->SetPostgresqlPath(txtPostgresqlPath->GetValue());
379
401
settings->SetEnterprisedbPath(txtEnterprisedbPath->GetValue());
402
settings->SetGPDBPath(txtGPDBPath->GetValue());
381
404
// Setup PostgreSQL/EnterpriseDB working paths
382
405
#if defined(__WXMSW__)
387
410
edbBackupExecutable = settings->GetEnterprisedbPath() + wxT("\\pg_dump.exe");
388
411
edbBackupAllExecutable = settings->GetEnterprisedbPath() + wxT("\\pg_dumpall.exe");
389
412
edbRestoreExecutable = settings->GetEnterprisedbPath() + wxT("\\pg_restore.exe");
414
gpBackupExecutable = settings->GetGPDBPath() + wxT("\\pg_dump.exe");
415
gpBackupAllExecutable = settings->GetGPDBPath() + wxT("\\pg_dumpall.exe");
416
gpRestoreExecutable = settings->GetGPDBPath() + wxT("\\pg_restore.exe");
391
418
pgBackupExecutable = settings->GetPostgresqlPath() + wxT("/pg_dump");
392
pgBackupAllExecutable = settings->GetPostgresqlPath() + wxT("/pg_dumpall");
419
pgBackupAllExecutable = settings->GetPostgresqlPath() + wxT("/pg_dumpall");
393
420
pgRestoreExecutable = settings->GetPostgresqlPath() + wxT("/pg_restore");
395
422
edbBackupExecutable = settings->GetEnterprisedbPath() + wxT("/pg_dump");
396
edbBackupAllExecutable = settings->GetEnterprisedbPath() + wxT("/pg_dumpall");
423
edbBackupAllExecutable = settings->GetEnterprisedbPath() + wxT("/pg_dumpall");
397
424
edbRestoreExecutable = settings->GetEnterprisedbPath() + wxT("/pg_restore");
426
gpBackupExecutable = settings->GetGPDBPath() + wxT("/pg_dump");
427
gpBackupAllExecutable = settings->GetGPDBPath() + wxT("/pg_dumpall");
428
gpRestoreExecutable = settings->GetGPDBPath() + wxT("/pg_restore");
400
431
if (!wxFile::Exists(pgBackupExecutable))
411
442
if (!wxFile::Exists(edbRestoreExecutable))
412
443
edbRestoreExecutable = wxEmptyString;
445
if (!wxFile::Exists(gpBackupExecutable))
446
gpBackupExecutable = wxEmptyString;
447
if (!wxFile::Exists(gpBackupAllExecutable))
448
gpBackupAllExecutable = wxEmptyString;
449
if (!wxFile::Exists(gpRestoreExecutable))
450
gpRestoreExecutable = wxEmptyString;
453
settings->SetIgnoreVersion(chkIgnoreVersion->GetValue());
414
455
if (chkResetHints->GetValue())
415
456
frmHint::ResetHints();
417
458
// Set the help paths
418
459
settings->SetPgHelpPath(txtPgHelpPath->GetValue());
419
460
settings->SetEdbHelpPath(txtEdbHelpPath->GetValue());
461
settings->SetGpHelpPath(txtGpHelpPath->GetValue());
420
462
settings->SetSlonyHelpPath(txtSlonyHelpPath->GetValue());
422
464
settings->SetSystemSchemas(txtSystemSchemas->GetValue());
466
// Save the display options
468
for (unsigned int x=0; x < lstDisplay->GetCount(); x++)
470
if (lstDisplay->IsChecked(x) != settings->GetDisplayOption(lstDisplay->GetString(x)))
473
settings->SetDisplayOption(lstDisplay->GetString(x), lstDisplay->IsChecked(x));
477
if (chkSystemObjects->GetValue() != settings->GetShowSystemObjects())
480
settings->SetShowSystemObjects(chkSystemObjects->GetValue());
483
// Change the language last, as it will affect our tests for changes
484
// in the display object types.
424
485
int langNo=cbLanguage->GetCurrentSelection();
432
493
const wxLanguageInfo *langInfo=wxLocale::GetLanguageInfo(existingLangs.Item(langNo-1));
433
494
langId = (wxLanguage) langInfo->Language;
435
if (langId != (wxLanguage)settings->Read(wxT("LanguageId"), wxLANGUAGE_UNKNOWN))
438
locale = new wxLocale();
439
if (locale->Init(langId))
444
locale->AddCatalog(wxT("fileutils"));
447
locale->AddCatalog(wxT("pgadmin3"));
448
settings->Write(wxT("LanguageId"), (long)langId);
454
// Save the display options
456
for (unsigned int x=0; x < lstDisplay->GetCount(); x++)
458
if (lstDisplay->IsChecked(x) != settings->GetDisplayOption(lstDisplay->GetString(x)))
461
settings->SetDisplayOption(lstDisplay->GetString(x), lstDisplay->IsChecked(x));
465
if (chkSystemObjects->GetValue() != settings->GetShowSystemObjects())
468
settings->SetShowSystemObjects(chkSystemObjects->GetValue());
472
wxMessageBox(_("Changes to the display options may not be visible until the browser tree is refreshed."), _("Display options"), wxICON_INFORMATION);
497
settings->SetCanonicalLanguage(langId);
500
// Did any display options change? Display this message last, so it's
501
// in the selected language.
503
wxMessageBox(_("Changes to the display options may not be visible until the browser tree is refreshed."), _("Display options"), wxICON_INFORMATION);