mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
Add Compare options dialog.
При сравнении объектов добавлена возможность исключать сравнение привелегий и комментариев.
This commit is contained in:
parent
9f28e588df
commit
d7306e633c
4 changed files with 86 additions and 3 deletions
|
|
@ -432,7 +432,8 @@ void frmMain::CreateMenus()
|
|||
new reportObjectDependentsFactory(menuFactories, reportMenu, 0);
|
||||
new reportObjectListFactory(menuFactories, reportMenu, 0);
|
||||
new reportCompareFactory(menuFactories, reportMenu, 0);
|
||||
|
||||
choiceSelectOpts.Add(0);
|
||||
choiceSelectOpts.Add(1);
|
||||
|
||||
toolsMenu->AppendSeparator();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
// App headers
|
||||
#include "pgAdmin3.h"
|
||||
#include <wx/file.h>
|
||||
#include <wx/regex.h>
|
||||
|
||||
#include "frm/frmMain.h"
|
||||
#include "frm/frmReport.h"
|
||||
|
|
@ -1222,6 +1223,59 @@ wxString reportCompareFactory::GetNodePath(wxTreeItemId node) {
|
|||
|
||||
return path;
|
||||
|
||||
}
|
||||
wxString reportCompareFactory::ApplyCompareOpts(wxString sql,int metatype) {
|
||||
if (sql.IsEmpty()) return "";
|
||||
bool no_comment = parent->getChoiceSelect(1);
|
||||
bool no_priv = parent->getChoiceSelect(0);
|
||||
if (no_comment) {
|
||||
int last = 0;
|
||||
while (last!=-1) {
|
||||
last = sql.Find("\nCOMMENT ON");
|
||||
int start = last;
|
||||
int end = -1;
|
||||
while (last!=-1) {
|
||||
last++;
|
||||
if (sql.Length() == last) { last = -1; continue; }
|
||||
wxChar c = sql.GetChar(last);
|
||||
if (c == '\'') {
|
||||
last++;
|
||||
if (sql.GetChar(last) == '\'') { continue; }
|
||||
if (sql.GetChar(last) == ';') { end = last; last = -1; continue; }
|
||||
|
||||
}
|
||||
};
|
||||
if (end != -1) {
|
||||
sql=sql.Remove(start, end - start+1);
|
||||
last = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (no_priv &&(metatype != PGM_ROLE)) {
|
||||
int last = 0;
|
||||
while (last != -1) {
|
||||
last = sql.Find("\nGRANT ");
|
||||
if (last==-1) last = sql.Find("\nREVOKE ");
|
||||
int start = last;
|
||||
int end = -1;
|
||||
while (last != -1) {
|
||||
last++;
|
||||
if (sql.Length() == last) { last = -1; continue; }
|
||||
wxChar c = sql.GetChar(last);
|
||||
if (c == ';') {
|
||||
end = last; last = -1;
|
||||
}
|
||||
};
|
||||
if (end != -1) {
|
||||
sql = sql.Remove(start, end - start + 1);
|
||||
last = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return sql;
|
||||
|
||||
}
|
||||
void reportCompareFactory::GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes, ArraySQL &list, time_t *t, wxBusyInfo *w, MyHashSQL &h_path,int lvl)
|
||||
{
|
||||
|
|
@ -1312,6 +1366,7 @@ void reportCompareFactory::GetExpandedChildNodes(wxTreeItemId node, wxArrayStrin
|
|||
if (obj ) {
|
||||
wxString s=obj->GetSql(browser);
|
||||
if (obj->GetMetaType()==PGM_SEQUENCE) s="";
|
||||
s = ApplyCompareOpts(s, obj->GetMetaType());
|
||||
int c=browser->GetChildrenCount(child,false);
|
||||
if (size>0) {
|
||||
wxString srcpath(path);
|
||||
|
|
@ -1492,6 +1547,7 @@ if (lastdb!=NULL) {
|
|||
wxMessageBox(msg, _("Error"), wxOK | wxICON_INFORMATION);
|
||||
return 0;
|
||||
}
|
||||
if (!parent->StartChoiceDialog()) return 0;
|
||||
time_t timer=wxDateTime::GetTimeNow();
|
||||
wxArrayString expandedNodes;
|
||||
ArraySQL list;
|
||||
|
|
@ -1499,12 +1555,14 @@ time_t timer=wxDateTime::GetTimeNow();
|
|||
|
||||
wxWindowDisabler disableAll;
|
||||
{
|
||||
#ifndef DEBUG
|
||||
wxBusyInfo waiting(wxString::Format(" Îáõîä èñõîäíîé ÁÄ Path = %s ,Ñòàðòîâûé îáúåêò = %s",
|
||||
browser->GetItemText(obj->GetServer()->GetId()).c_str(), obj->GetName().c_str(),parent));
|
||||
// Give the UI a chance to redraw
|
||||
wxSafeYield();
|
||||
wxMilliSleep(50);
|
||||
wxSafeYield();
|
||||
#endif
|
||||
// waiting->~wxBusyInfo();
|
||||
GetExpandedChildNodes(obj->GetId(),expandedNodes,list,&timer, NULL,h_path,0);
|
||||
}
|
||||
|
|
@ -1809,7 +1867,7 @@ std::wstring reportCompareFactory::printdiff(std::wstring str1, std::wstring str
|
|||
++it;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
wxFileName fn("D:\\PostgreSQL\\cmp.txt");
|
||||
wxFileName fn("cmp_debug.txt");
|
||||
fn.MakeAbsolute();
|
||||
|
||||
wxFile file(fn.GetFullPath(), wxFile::write);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,28 @@ public:
|
|||
currentObject = data;
|
||||
}
|
||||
bool CheckAlive();
|
||||
|
||||
//
|
||||
bool getChoiceSelect(int index) {
|
||||
for (size_t n = 0; n < choiceSelectOpts.GetCount(); n++) {
|
||||
if (choiceSelectOpts[n] == index) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool StartChoiceDialog() {
|
||||
choiceCmpOpts.Clear();
|
||||
choiceCmpOpts.Add("Priveleges ignore");
|
||||
choiceCmpOpts.Add("Comment ignore");
|
||||
wxMultiChoiceDialog dialog(this,
|
||||
wxT("A multi-choice convenience dialog"),
|
||||
wxT("Please select several compare options"),
|
||||
choiceCmpOpts);
|
||||
dialog.SetSelections(choiceSelectOpts);
|
||||
if (dialog.ShowModal() == wxID_OK) {
|
||||
choiceSelectOpts = dialog.GetSelections();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void execSelChange(wxTreeItemId item, bool currentNode);
|
||||
void Refresh(pgObject *data);
|
||||
void ExecDrop(bool cascaded);
|
||||
|
|
@ -203,6 +224,8 @@ private:
|
|||
long msgLevel;
|
||||
|
||||
bool m_refreshing;
|
||||
wxArrayString choiceCmpOpts;
|
||||
wxArrayInt choiceSelectOpts;
|
||||
|
||||
wxTreeItemId denyCollapseItem;
|
||||
pgObject *currentObject;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ private:
|
|||
protected:
|
||||
//reportCompareFactory(menuFactoryList *list) : actionFactory(list) {}
|
||||
wxString reportCompareFactory::GetNodePath(wxTreeItemId node);
|
||||
wxString ApplyCompareOpts(wxString sql, int metatype);
|
||||
wxWindow *StartDialog(frmMain *form, pgObject *obj);
|
||||
void reportCompareFactory::GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes, ArraySQL &list,time_t *t,wxBusyInfo *w, MyHashSQL &h_path,int lvl);
|
||||
std::wstring reportCompareFactory::printdiff(std::wstring str1, std::wstring str2 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue