Index: pgObject.cpp =================================================================== RCS file: /projects/pgadmin3/src/schema/pgObject.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -Lsrc/schema/pgObject.cpp -Lsrc/schema/pgObject.cpp -u -w -r1.80 -r1.81 --- src/schema/pgObject.cpp +++ src/schema/pgObject.cpp @@ -135,6 +135,7 @@ name = newName; expandedKids=false; needReread=false; + hintShown=false; } Index: pgTable.cpp =================================================================== RCS file: /projects/pgadmin3/src/schema/pgTable.cpp,v retrieving revision 1.64 retrieving revision 1.65 diff -Lsrc/schema/pgTable.cpp -Lsrc/schema/pgTable.cpp -u -w -r1.64 -r1.65 --- src/schema/pgTable.cpp +++ src/schema/pgTable.cpp @@ -16,6 +16,7 @@ #include "pgAdmin3.h" #include "misc.h" #include "frmHint.h" +#include "frmMaintenance.h" #include "pgObject.h" #include "pgTable.h" #include "pgCollection.h" @@ -407,23 +408,44 @@ properties->AppendItem(_("System table?"), GetSystemObject()); properties->AppendItem(_("Comment"), GetComment()); - bool showHint=false; + if (form && GetCanHint() && !hintShown) + { + ShowHint(form); + } + } +} + + +bool pgTable::GetCanHint() +{ + bool canHint=false; + if (rowsCounted) { if (!estimatedRows || (estimatedRows == 1000 && rows != 1000)) - showHint = (rows >= 20); + canHint = (rows >= 20); else { wxULongLong quot = rows*10 / estimatedRows; - showHint = ((quot > 12 || quot < 8) && (rows+20 < estimatedRows || rows > estimatedRows+20)); + canHint = ((quot > 12 || quot < 8) && (rows+20 < estimatedRows || rows > estimatedRows+20)); } } else if (estimatedRows == 1000) { - showHint = true; + canHint = true; + } + return canHint; } - if (form && showHint) - frmHint::ShowHint((wxWindow*)form, HINT_VACUUM, GetFullIdentifier()); + + +void pgTable::ShowHint(frmMain *form) +{ + hintShown = true; + int rc=frmHint::ShowHint(form, HINT_VACUUM, GetFullIdentifier()); + if (rc == HINT_RC_FIX) + { + frmMaintenance *frm=new frmMaintenance(form, this); + frm->Go(); } } Index: frmHint.cpp =================================================================== RCS file: /projects/pgadmin3/src/ui/frmHint.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -Lsrc/ui/frmHint.cpp -Lsrc/ui/frmHint.cpp -u -w -r1.4 -r1.5 --- src/ui/frmHint.cpp +++ src/ui/frmHint.cpp @@ -32,6 +32,7 @@ #define HINT_CANSUPPRESS 1 #define HINT_CANABORT 2 +#define HINT_CANFIX 4 struct { @@ -70,13 +71,14 @@ { HINT_VACUUM, __("Running VACUUM recommended"), wxT("maintenance#routine-vacuuming"), - HINT_CANSUPPRESS + HINT_CANSUPPRESS | HINT_CANFIX }, { 0,0,0,0 } }; BEGIN_EVENT_TABLE(frmHint, DialogWithHelp) + EVT_BUTTON(XRCID("btnFix"), frmHint::OnFix) END_EVENT_TABLE(); @@ -84,6 +86,8 @@ #define chkSuppress CTRL_CHECKBOX("chkSuppress") #define htmlHint (XRCCTRL(*this, "htmlHint", wxHtmlWindow)) +#define btnFix CTRL_BUTTON("btnFix") + frmHint::frmHint(wxWindow *fr, int hintno, const wxString &info) : DialogWithHelp(0) { @@ -120,7 +124,8 @@ chkSuppress->Disable(); if (!(hintArray[hintno].flags & HINT_CANABORT)) btnCancel->Disable(); - + if (!(hintArray[hintno].flags & HINT_CANFIX)) + btnFix->Hide(); currentHint = hintno; }; @@ -204,8 +209,14 @@ rc = frm->ShowModal(); delete frm; - if (!(hintArray[hintno].flags & HINT_CANABORT)) + if ((rc == wxID_CANCEL || rc == -1) && !(hintArray[hintno].flags & HINT_CANABORT)) rc = wxID_OK; } return rc; } + + +void frmHint::OnFix(wxCommandEvent &ev) +{ + EndDialog(HINT_RC_FIX); +} \ No newline at end of file Index: frmStatus.cpp =================================================================== RCS file: /projects/pgadmin3/src/ui/frmStatus.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -Lsrc/ui/frmStatus.cpp -Lsrc/ui/frmStatus.cpp -u -w -r1.47 -r1.48 --- src/ui/frmStatus.cpp +++ src/ui/frmStatus.cpp @@ -78,7 +78,7 @@ wxWindowBase::SetFont(settings->GetSystemFont()); - LoadResource(form, wxT("frmStatus")); + LoadResource(0, wxT("frmStatus")); RestorePosition(-1, -1, 400, 240, 200, 150); SetTitle(_title); Index: events.cpp =================================================================== RCS file: /projects/pgadmin3/src/ui/events.cpp,v retrieving revision 1.128 retrieving revision 1.129 diff -Lsrc/ui/events.cpp -Lsrc/ui/events.cpp -u -w -r1.128 -r1.129 --- src/ui/events.cpp +++ src/ui/events.cpp @@ -66,6 +66,7 @@ EVT_MENU(MNU_GRANTWIZARD, frmMain::OnGrantWizard) EVT_MENU(MNU_CONTENTS, frmMain::OnContents) EVT_MENU(MNU_FAQ, frmMain::OnFaq) + EVT_MENU(MNU_HINT, frmMain::OnHint) EVT_MENU(MNU_ONLINEUPDATE, frmMain::OnOnlineUpdate) EVT_MENU(MNU_ONLINEUPDATE_NEWDATA, frmMain::OnOnlineUpdateNewData) EVT_MENU(MNU_PGSQLHELP, frmMain::OnPgsqlHelp) @@ -440,6 +441,13 @@ } +void frmMain::OnHint(wxCommandEvent &event) +{ + if (currentObject) + currentObject->ShowHint(this); +} + + void frmMain::OnCheckAlive(wxCommandEvent &event) { checkAlive(); @@ -822,6 +830,8 @@ canGrantWizard=false, canCount=false; + bool canHint=data->GetCanHint(); + bool showTree=true; switch (type) @@ -1000,6 +1010,7 @@ toolsMenu->Enable(MNU_STOPSERVICE, canStop); fileMenu->Enable(MNU_PASSWORD, canDisconnect); viewMenu->Enable(MNU_COUNT, canCount); + helpMenu->Enable(MNU_HINT, canHint); // toolsMenu->Enable(MNU_INDEXCHECK, canIndexCheck); } @@ -1097,6 +1108,7 @@ } appendIfEnabled(MNU_REFRESH); + appendIfEnabled(MNU_HINT); if (browser->GetSelection() == object->GetId()) appendIfEnabled(MNU_COUNT); Index: frmMain.cpp =================================================================== RCS file: /projects/pgadmin3/src/ui/frmMain.cpp,v retrieving revision 1.125 retrieving revision 1.126 diff -Lsrc/ui/frmMain.cpp -Lsrc/ui/frmMain.cpp -u -w -r1.125 -r1.126 --- src/ui/frmMain.cpp +++ src/ui/frmMain.cpp @@ -238,6 +238,7 @@ helpMenu->Append(MNU_FAQ, _("pgAdmin III &FAQ"), _("Frequently asked questions about pgAdmin III.")); helpMenu->Append(MNU_HELP, _("&SQL Help\tF1"), _("Display help on SQL commands.")); helpMenu->Append(MNU_PGSQLHELP, _("&PostgreSQL Help"), _("Display help on PostgreSQL database system.")); + helpMenu->Append(MNU_HINT, _("Hints"), _("Display helpful hints on current object.")); helpMenu->Append(MNU_TIPOFTHEDAY, _("&Tip of the day"), _("Show a tip of the day.")); helpMenu->AppendSeparator(); helpMenu->Append(MNU_ONLINEUPDATE, _("Online Update"), _("Check online for updates")); @@ -1120,6 +1121,8 @@ viewMenu->Enable(MNU_REFRESH, refresh); viewMenu->Enable(MNU_COUNT, false); + + helpMenu->Enable(MNU_HINT, false); } Index: frmMain.h =================================================================== RCS file: /projects/pgadmin3/src/include/frmMain.h,v retrieving revision 1.63 retrieving revision 1.64 diff -Lsrc/include/frmMain.h -Lsrc/include/frmMain.h -u -w -r1.63 -r1.64 --- src/include/frmMain.h +++ src/include/frmMain.h @@ -87,6 +87,7 @@ void OnContents(wxCommandEvent& event); void OnPgsqlHelp(wxCommandEvent& event); void OnFaq(wxCommandEvent& event); + void OnHint(wxCommandEvent& event); void OnAddServer(wxCommandEvent &ev); void OnExit(wxCommandEvent& event); void OnViewData(wxCommandEvent& event); Index: pgObject.h =================================================================== RCS file: /projects/pgadmin3/src/include/pgObject.h,v retrieving revision 1.66 retrieving revision 1.67 diff -Lsrc/include/pgObject.h -Lsrc/include/pgObject.h -u -w -r1.66 -r1.67 --- src/include/pgObject.h +++ src/include/pgObject.h @@ -118,6 +118,7 @@ void iSetAcl(const wxString& newVal) { acl = newVal; } virtual bool GetSystemObject() const { return false; } virtual bool IsCollection() const { return false; } + virtual void ShowHint(frmMain *form) {} void ShowTree(frmMain *form, wxTreeCtrl *browser, ctlListView *properties, ctlSQLBox *sqlPane); @@ -161,6 +162,7 @@ virtual bool WantDummyChild() { return false; } virtual bool CanBackup() { return false; } virtual bool CanRestore() { return false; } + virtual bool GetCanHint() { return false; } protected: void CreateListColumns(ctlListView *properties, const wxString &left=_("Property"), const wxString &right=_("Value")); @@ -170,6 +172,7 @@ bool expandedKids, needReread; wxString sql; + bool hintShown; private: static void AppendRight(wxString &rights, const wxString& acl, wxChar c, wxChar *rightName); Index: pgTable.h =================================================================== RCS file: /projects/pgadmin3/src/include/pgTable.h,v retrieving revision 1.29 retrieving revision 1.30 diff -Lsrc/include/pgTable.h -Lsrc/include/pgTable.h -u -w -r1.29 -r1.30 --- src/include/pgTable.h +++ src/include/pgTable.h @@ -33,6 +33,7 @@ wxString GetAllConstraints(wxTreeCtrl *browser, wxTreeItemId collectionId, int type); void ShowTreeDetail(wxTreeCtrl *browser, frmMain *form=0, ctlListView *properties=0, ctlSQLBox *sqlPane=0); void ShowStatistics(frmMain *form, ctlListView *statistics); + void ShowHint(frmMain *form); static pgObject *ReadObjects(pgCollection *collection, wxTreeCtrl *browser, const wxString &restriction=wxT("")); static void ShowStatistics(pgCollection *collection, ctlListView *statistics); @@ -67,6 +68,7 @@ bool CanBackup() { return true; } bool CanRestore() { return true; } bool WantDummyChild() { return true; } + bool GetCanHint(); wxMenu *GetNewMenu(); wxString GetSql(wxTreeCtrl *browser); Index: frmHint.h =================================================================== RCS file: /projects/pgadmin3/src/include/frmHint.h,v retrieving revision 1.4 retrieving revision 1.5 diff -Lsrc/include/frmHint.h -Lsrc/include/frmHint.h -u -w -r1.4 -r1.5 --- src/include/frmHint.h +++ src/include/frmHint.h @@ -20,6 +20,9 @@ #define HINT_FKINDEX wxT("fki") #define HINT_VACUUM wxT("vacuum") +#define HINT_RC_FIX 42 + + class frmMain; class frmHint : public DialogWithHelp { @@ -32,6 +35,7 @@ frmHint(wxWindow *fr, int hint, const wxString &info=wxEmptyString); ~frmHint(); + void OnFix(wxCommandEvent &ev); static int GetHintNo(const wxString &hint); static bool WantHint(int hintno); wxString GetHelpPage() const; Index: frmHint.xrc =================================================================== RCS file: /projects/pgadmin3/src/ui/common/frmHint.xrc,v retrieving revision 1.3 retrieving revision 1.4 diff -Lsrc/ui/common/frmHint.xrc -Lsrc/ui/common/frmHint.xrc -u -w -r1.3 -r1.4 --- src/ui/common/frmHint.xrc +++ src/ui/common/frmHint.xrc @@ -24,7 +24,7 @@ - 4 + 5 1 @@ -38,6 +38,15 @@ 0,0 + + + 1 + 93,135d + + wxTOP|wxBOTTOM|wxLEFT|wxRIGHT + 5 + + 1