From 1dc289a6254046561dd29ba07e6caf02cc745de3 Mon Sep 17 00:00:00 2001 From: lsv Date: Fri, 20 Feb 2026 16:53:15 +0500 Subject: [PATCH 1/3] Remove localization application_name --- dlg/dlgClasses.cpp | 2 +- frm/frmEditGrid.cpp | 2 +- frm/frmHbaConfig.cpp | 2 +- frm/frmImport.cpp | 2 +- frm/frmMainConfig.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlg/dlgClasses.cpp b/dlg/dlgClasses.cpp index ae3424f..480d488 100644 --- a/dlg/dlgClasses.cpp +++ b/dlg/dlgClasses.cpp @@ -443,7 +443,7 @@ ExecutionDialog::ExecutionDialog(frmMain *frame, pgObject *_object) : DialogWith bIsExecutionCompleted = false; pgDatabase *db = object->GetDatabase(); - wxString applicationname = appearanceFactory->GetLongAppName() + _(" - Execution Tool"); + wxString applicationname = appearanceFactory->GetLongAppName() + (" - Execution Tool"); conn = db->CreateConn(applicationname); } diff --git a/frm/frmEditGrid.cpp b/frm/frmEditGrid.cpp index ef47260..9845e1d 100644 --- a/frm/frmEditGrid.cpp +++ b/frm/frmEditGrid.cpp @@ -3341,7 +3341,7 @@ bool editGridFactoryBase::CheckEnable(pgObject *obj) wxWindow *editGridFactoryBase::ViewData(frmMain *form, pgObject *obj, bool filter) { pgDatabase *db = ((pgSchemaObject *)obj)->GetDatabase(); - wxString applicationname = appearanceFactory->GetLongAppName() + _(" - Edit Grid"); + wxString applicationname = appearanceFactory->GetLongAppName() + (" - Edit Grid"); pgServer *server = db->GetServer(); pgConn *conn = db->CreateConn(applicationname); diff --git a/frm/frmHbaConfig.cpp b/frm/frmHbaConfig.cpp index e2a4f77..90ec5f8 100644 --- a/frm/frmHbaConfig.cpp +++ b/frm/frmHbaConfig.cpp @@ -48,7 +48,7 @@ END_EVENT_TABLE() frmHbaConfig::frmHbaConfig(frmMain *parent, pgServer *server) : frmConfig(parent, BACE_TITLE, 0) { - wxString applicationname = appearanceFactory->GetLongAppName() + _(" - Configuration Editor"); + wxString applicationname = appearanceFactory->GetLongAppName() + (" - Configuration Editor"); if (server) conn = server->CreateConn(wxEmptyString, 0, applicationname); Init(); diff --git a/frm/frmImport.cpp b/frm/frmImport.cpp index ddaf88f..68d57e5 100644 --- a/frm/frmImport.cpp +++ b/frm/frmImport.cpp @@ -363,7 +363,7 @@ importFactory::importFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar wxWindow *importFactory::StartDialog(frmMain *form, pgObject *obj) { pgDatabase *db = obj->GetDatabase(); - wxString applicationname = appearanceFactory->GetLongAppName() + _(" - Import Tool"); + wxString applicationname = appearanceFactory->GetLongAppName() + (" - Import Tool"); pgConn *conn = db->CreateConn(applicationname); if (conn) { diff --git a/frm/frmMainConfig.cpp b/frm/frmMainConfig.cpp index 2216494..0f49689 100644 --- a/frm/frmMainConfig.cpp +++ b/frm/frmMainConfig.cpp @@ -47,7 +47,7 @@ END_EVENT_TABLE() frmMainConfig::frmMainConfig(frmMain *parent, pgServer *server) : frmConfig(parent, BCE_TITLE, 0) { - wxString applicationname = appearanceFactory->GetLongAppName() + _(" - Configuration Editor"); + wxString applicationname = appearanceFactory->GetLongAppName() + (" - Configuration Editor"); if (server) { conn = server->CreateConn(wxEmptyString, 0, applicationname); From 979d709843aaaddd2e0f04c3eb587984fc8e323b Mon Sep 17 00:00:00 2001 From: lsv Date: Wed, 25 Feb 2026 14:38:09 +0500 Subject: [PATCH 2/3] Added division of digits for thousands. Only integers. Only Result query. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Для результатов запросов для целых чисел добавлено визуальное разделение тысяч. Величина отделения задаётся в точках и храниться в pgadmin3opt.json в параметре "thousandsWidthSeparator" раздела "ctlSQLGrid" разрешенные величины от -15 до 15. Значение по умолчанию 0. В отличии от стандартного разделителя тысяч этот влияет только на отображении чисел. --- ctl/ctlSQLGrid.cpp | 219 ++++++++++++++++++++++++++++++++++++- ctl/ctlSQLResult.cpp | 6 +- include/ctl/ctlSQLGrid.h | 162 ++------------------------- include/ctl/ctlSQLResult.h | 2 +- 4 files changed, 233 insertions(+), 156 deletions(-) diff --git a/ctl/ctlSQLGrid.cpp b/ctl/ctlSQLGrid.cpp index b260c68..88acb20 100644 --- a/ctl/ctlSQLGrid.cpp +++ b/ctl/ctlSQLGrid.cpp @@ -74,13 +74,28 @@ ctlSQLGrid::ctlSQLGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, cons Bind(wxEVT_THREAD, &ctlSQLGrid::OnShowPopup, this); setresizedpi(); SetDefaultCellOverflow(false); - //SetDefaultRenderer(new wxGridCellAutoWrapStringRenderer); - SetDefaultRenderer(new CursorCellRenderer); + // load pgadmin3opt.json + wxJSONValue def(wxJSONType::wxJSONTYPE_OBJECT); + wxJSONValue opt(wxJSONType::wxJSONTYPE_OBJECT); + int t_width=0; + def["thousandsWidthSeparator"]=t_width; + settings->ReloadJsonFileIfNeed(); + settings->ReadJsonObect("ctlSQLGrid", opt, def); + if (!opt.IsNull()) { // check + int tmp=opt["thousandsWidthSeparator"].AsInt(); + if (tmp<-15 || tmp>15) opt["thousandsWidthSeparator"]=def["thousandsWidthSeparator"]; + } + else + opt = def; + int thousandsWidthSeparator = opt["thousandsWidthSeparator"].AsInt(); + + SetDefaultRenderer(new CursorCellRenderer(thousandsWidthSeparator)); //SetUseNativeColLabels(true); //UseNativeColHeader(true); SetCellHighlightColour(wxColor(0, 0, 0)); #ifdef __WXGTK__ wxColour selbg = GetSelectionBackground(); + wxColour cbg = GetBackgroundColour(); wxColour labbg = GetLabelBackgroundColour(); wxString t1 = selbg.GetAsString(); wxString t2 = labbg.GetAsString(); @@ -93,6 +108,13 @@ ctlSQLGrid::ctlSQLGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, cons wxColour labbgn(min, min, min); SetLabelBackgroundColour(labbgn); } + if (cline.GetRGB() == cbg.GetRGB()) { + int min = wxMin(cline.GetBlue(), cline.GetGreen()); + min = wxMin(min, cline.GetRed()); + if (min > 200) min = min - 30; else min = min + 30; + wxColour newgridclr(min, min, min); + SetGridLineColour(newgridclr); + } #endif grp = NULL; isSort = false; @@ -300,10 +322,11 @@ wxString ctlSQLGrid::GetExportLine(int row, wxArrayInt cols) head = head + GetColumnName(cols[col]); wxString text; bool isnull=false; + int pgtype=0; if ( t && generatesql > 0) { // only insert , in_list and where list - text = t->GetValueWithNull( row, cols[col] , &isnull ); + text = t->GetValueWithNull( row, cols[col] , &isnull, &pgtype ); } else text = GetCellValue(row, cols[col]); wxString cname = GetColumnName(cols[col]); @@ -1295,4 +1318,194 @@ bool ctlSQLGrid::FullArrayCollapseRowsPlan(bool clear) return true; } +//// CursorCellRenderer + +void CursorCellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, + const wxRect& rect, int row, int col, bool isSelected) +{ + int hAlign, vAlign; + int sPos = -1; + bool multiline = false; + attr.GetAlignment(&hAlign, &vAlign); + ////////////////////////////////////////////////////////////////////////////// + //CursorCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); // + dc.SetBackgroundMode(wxSOLID); + bool istruncateLine=false; + wxString text = grid.GetCellValue(row, col); + int len= text.length(); + bool isfirst=true; + bool isnumber=(hAlign == wxALIGN_RIGHT && len<20 && text.IsNumber()); + // grey out fields if the grid is disabled +retry: + if (grid.IsEnabled()) + { + istruncateLine=text.Right(5)=="(...)"; + if (isSelected) + { + wxColour clr; + if (wxWindow::FindFocus() == grid.GetGridWindow()) + clr = grid.GetSelectionBackground(); + else + clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); + + + dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(clr)); + } + else + { + wxColor color; + color.Set(239, 228, 176); + if ((sPos = text.Find(wxT('\n'))) != wxNOT_FOUND) { + dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(color)); + multiline = true; + } + else + dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(attr.GetBackgroundColour())); + } + // replace \t to u+2192 + wxUniChar cc = 8594; + text.Replace("\t", cc); + } + else + { + dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); + } + + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(rect); + ////////////////////////////////////////////////////////////////////////////// + SetTextColoursAndFont(grid, attr, dc, isSelected); + ctlSQLGrid* ctrl = static_cast(&grid); + if (!ctrl->searchStr.IsEmpty()) { + int pp; + pp = text.Find(ctrl->searchStr); + if (pp >= 0) { + wxArrayString lines; + grid.StringToLines(text, lines); + wxRect r; + r.y = rect.y; + dc.SetBrush(*wxYELLOW_BRUSH); + size_t nLines = lines.GetCount(); + for (size_t l = 0; l < nLines; l++) + { + const wxString& line = lines[l]; + pp = line.Find(ctrl->searchStr); + if (line.empty() || (pp == -1)) + { + r.y += dc.GetCharHeight(); + continue; + } + + int lineWidth, lineWidthP, lineHeight, start = 0; + int dopx=0; + wxString pref; + if (hAlign == wxALIGN_RIGHT) { + start = pp + ctrl->searchStr.Len(); + pref = line.substr(start); + if (isnumber) { + int ll=pref.length(); + int num_sep=ll/3; + //if (ll % 3 == 0 && num_sep>0 ) num_sep--; + dopx=num_sep*thousands_pixel_sep; + } + } + else + pref = line.substr(start, pp); + + dc.GetTextExtent(pref, &lineWidthP, &lineHeight); + lineWidthP+=dopx; + r.x = rect.x + lineWidthP; + pref = line.substr(pp, ctrl->searchStr.Len()); + dc.GetTextExtent(pref, &lineWidth, &lineHeight); + r.width = lineWidth; + r.height = lineHeight; + if (hAlign == wxALIGN_RIGHT) r.x = rect.x + (rect.width - lineWidth - lineWidthP); + if (!(r.y < (rect.y + rect.height))) { r.y = rect.y + rect.height - 5; r.height = 5; } + if (!((r.x < (rect.x + rect.width)))) { r.x = rect.x + rect.width - 5; r.width = 5; } + dc.DrawRoundedRectangle(r, 3); + break; + } + } + } + + if (!multiline) { + //int textWidth = dc.GetTextExtent(text).GetWidth(); + wxEllipsizeMode mode(wxELLIPSIZE_END); + if (hAlign == wxALIGN_RIGHT) mode = wxELLIPSIZE_START; + const wxString& ellipsizedText = wxControl::Ellipsize + ( + text, + dc, + mode, + rect.GetWidth() - 2, + wxELLIPSIZE_FLAGS_NONE + ); + if (ellipsizedText != text) + text = ellipsizedText; // small width + else + { + bool isDraw=false; + if (isnumber && isfirst) + /* Add thousands separator */ + { + int pos = text.find('.'); + if (pos == wxString::npos) + pos = len; + int x=rect.GetRight()-1; + int yb=rect.GetTop(); + int c=0; + while (pos > 0) + { + pos -= 3; + wxString tri; + if (pos >= 0) + { + tri=text.substr(pos,3); + } else tri=text.substr(0,pos+3); + + wxSize tripl=dc.GetTextExtent(tri); + x=x-tripl.GetX(); + if (c>0) x-=thousands_pixel_sep; + dc.DrawText(tri,x,yb); + c++; + } + int new_width=rect.GetRight()-x; + isfirst=!isfirst; + if (new_width>=rect.GetWidth()) goto retry; // small width + isDraw=true; + } + if (isDraw) return; + } + + } // this draw one line + + grid.DrawTextRectangle(dc, text, + rect, hAlign, vAlign); + if (istruncateLine) { + dc.SetPen(*wxRED_PEN); + dc.DrawLine(wxPoint(rect.x,rect.y+rect.GetHeight()-2),wxPoint(rect.x+rect.width,rect.y+rect.GetHeight()-2)); + } +} + +CursorCellRenderer::CursorCellRenderer(int thous_pixel_sep):wxGridCellStringRenderer() { + thousands_pixel_sep=thous_pixel_sep; +} +wxSize CursorCellRenderer::GetBestSize(wxGrid& grid, + wxGridCellAttr& attr, + wxDC& dc, + int row, int col){ + dc.SetFont(attr.GetFont()); + const wxString text=grid.GetCellValue(row, col); + wxSize sz=dc.GetMultiLineTextExtent(text); + int len=text.length(); + if (thousands_pixel_sep !=0 && len<20 && text.IsNumber()) { + if (text[0]=='-') len--; + int num_sep=len/3; + if (len % 3 == 0 && num_sep>0 ) num_sep--; + sz.x=sz.x+num_sep*thousands_pixel_sep +1; + + } + return sz; +} + diff --git a/ctl/ctlSQLResult.cpp b/ctl/ctlSQLResult.cpp index 55193df..796ebe4 100644 --- a/ctl/ctlSQLResult.cpp +++ b/ctl/ctlSQLResult.cpp @@ -474,7 +474,8 @@ wxString ctlSQLResult::GenerateTemplate(wxString &templ,int action) if (rows.Count()>0) r=rows[r]; else r=r; } bool isnull=false; - wxString text = t->GetValueWithNull( r, e.column , &isnull ); + int pgtype=0; + wxString text = t->GetValueWithNull( r, e.column , &isnull, &pgtype ); bool needQuote = false; if (qt == 1) { @@ -1330,7 +1331,7 @@ wxString sqlResultTable::GetValueFast(int row, int col) } return ""; } -wxString sqlResultTable::GetValueWithNull(int row, int col, bool *isnull) { +wxString sqlResultTable::GetValueWithNull(int row, int col, bool *isnull, int *pgtype) { wxString s; if (thread && thread->DataValid()) { @@ -1340,6 +1341,7 @@ wxString sqlResultTable::GetValueWithNull(int row, int col, bool *isnull) { thread->DataSet()->Locate(row + 1); wxString s = thread->DataSet()->GetVal(col); *isnull = thread->DataSet()->IsNull(col); + *pgtype = thread->DataSet()->ColTypClass(col); return s; } diff --git a/include/ctl/ctlSQLGrid.h b/include/ctl/ctlSQLGrid.h index b754c41..c8be854 100644 --- a/include/ctl/ctlSQLGrid.h +++ b/include/ctl/ctlSQLGrid.h @@ -209,159 +209,21 @@ private: wxArrayDouble run; }; //#define TEST_wxGridCellAutoWrapStringRenderer -#ifndef TEST_wxGridCellAutoWrapStringRenderer + class CursorCellRenderer : public wxGridCellStringRenderer { + protected: +wxSize GetBestSize(wxGrid& grid, + wxGridCellAttr& attr, + wxDC& dc, + int row, int col) wxOVERRIDE; + public: - virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, - const wxRect& rect, int row, int col, bool isSelected) - { - int hAlign, vAlign; - int sPos = -1; - bool multiline = false; - attr.GetAlignment(&hAlign, &vAlign); - ////////////////////////////////////////////////////////////////////////////// - //CursorCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); // - dc.SetBackgroundMode(wxSOLID); - bool istruncateLine=false; - wxString text = grid.GetCellValue(row, col); - // grey out fields if the grid is disabled - if (grid.IsEnabled()) - { - istruncateLine=text.Right(5)=="(...)"; - if (isSelected) - { - wxColour clr; - if (wxWindow::FindFocus() == grid.GetGridWindow()) - clr = grid.GetSelectionBackground(); - else - clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); - - - dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(clr)); - } - else - { - wxColor color; - color.Set(239, 228, 176); - if ((sPos = text.Find(wxT('\n'))) != wxNOT_FOUND) { - dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(color)); - multiline = true; - } - else - dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(attr.GetBackgroundColour())); - } - // replace \t to u+2192 - wxUniChar cc = 8594; - text.Replace("\t", cc); - } - else - { - dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); - } - - dc.SetPen(*wxTRANSPARENT_PEN); - dc.DrawRectangle(rect); - ////////////////////////////////////////////////////////////////////////////// - SetTextColoursAndFont(grid, attr, dc, isSelected); - ctlSQLGrid* ctrl = static_cast(&grid); - if (!ctrl->searchStr.IsEmpty()) { - if (sPos == -1) sPos = text.Len(); - int pp; - - pp = text.Find(ctrl->searchStr); - if (pp >= 0) { - wxArrayString lines; - grid.StringToLines(text, lines); - wxRect r; - r.y = rect.y; - dc.SetBrush(*wxYELLOW_BRUSH); - size_t nLines = lines.GetCount(); - for (size_t l = 0; l < nLines; l++) - { - const wxString& line = lines[l]; - pp = line.Find(ctrl->searchStr); - if (line.empty() || (pp == -1)) - { - r.y += dc.GetCharHeight(); - continue; - } - - int lineWidth, lineWidthP, lineHeight, start = 0; - wxString pref; - if (hAlign == wxALIGN_RIGHT) { - start = pp + ctrl->searchStr.Len(); - pref = line.substr(start); - } - else - pref = line.substr(start, pp); - - dc.GetTextExtent(pref, &lineWidthP, &lineHeight); - r.x = rect.x + lineWidthP; - pref = line.substr(pp, ctrl->searchStr.Len()); - dc.GetTextExtent(pref, &lineWidth, &lineHeight); - r.width = lineWidth; - r.height = lineHeight; - if (hAlign == wxALIGN_RIGHT) r.x = rect.x + (rect.width - lineWidth - lineWidthP); - if (!(r.y < (rect.y + rect.height))) { r.y = rect.y + rect.height - 5; r.height = 5; } - if (!((r.x < (rect.x + rect.width)))) { r.x = rect.x + rect.width - 5; r.width = 5; } - dc.DrawRoundedRectangle(r, 3); - break; - } - } - } - - if (!multiline) { - //int textWidth = dc.GetTextExtent(text).GetWidth(); - wxEllipsizeMode mode(wxELLIPSIZE_END); - if (hAlign == wxALIGN_RIGHT) mode = wxELLIPSIZE_START; - const wxString& ellipsizedText = wxControl::Ellipsize - ( - text, - dc, - mode, - rect.GetWidth() - 2, - wxELLIPSIZE_FLAGS_NONE - ); - if (ellipsizedText != text) text = ellipsizedText; - } - grid.DrawTextRectangle(dc, text, - rect, hAlign, vAlign); - if (istruncateLine) { - dc.SetPen(*wxRED_PEN); - dc.DrawLine(wxPoint(rect.x,rect.y+rect.GetHeight()-2),wxPoint(rect.x+rect.width,rect.y+rect.GetHeight()-2)); - } - } -#else -class CursorCellRenderer : public wxGridCellAutoWrapStringRenderer -{ -public: - virtual void Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rectCell, - int row, int col, - bool isSelected) { - bool f = false; - wxString text = grid.GetCellValue(row, col); - wxColor prev; - if (!isSelected) { - wxColor color; - color.Set(239, 228, 176); - if (text.Find(wxT('\n')) != wxNOT_FOUND) - { - //dc.SetBrush(wxBrush(color, wxSOLID)); - prev = attr.GetBackgroundColour(); - attr.SetBackgroundColour(color); - f = true; - } - - } - - wxGridCellAutoWrapStringRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); - if (f) attr.SetBackgroundColour(prev); - } -#endif + void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, + const wxRect& rect, int row, int col, bool isSelected); + CursorCellRenderer(int thous_pixel_sep); +private: +int thousands_pixel_sep; }; #endif diff --git a/include/ctl/ctlSQLResult.h b/include/ctl/ctlSQLResult.h index 5f47436..2482723 100644 --- a/include/ctl/ctlSQLResult.h +++ b/include/ctl/ctlSQLResult.h @@ -97,7 +97,7 @@ public: sqlResultTable(); wxString GetValue(int row, int col); wxString GetValueFast(int row, int col); - wxString GetValueWithNull(int row, int col, bool *isnull); + wxString GetValueWithNull(int row, int col, bool *isnull,int *pgtype); wxString GetRowLabelValue( int row ) ; int GetNumberRows(); int GetNumberCols(); From 402f08266e284b235862ed1d77a4a08407eca768 Mon Sep 17 00:00:00 2001 From: lsv Date: Wed, 25 Feb 2026 16:36:33 +0500 Subject: [PATCH 3/3] A hotkey Ctrl-W to disconnect from the database. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Для отключения открытой БД из любого места браузера объектов можно использовать "Ctrl-W". Теперь эта команда доступна из любого места дерева объектов. --- schema/pgServer.cpp | 47 +++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/schema/pgServer.cpp b/schema/pgServer.cpp index 15a280a..a3953ac 100644 --- a/schema/pgServer.cpp +++ b/schema/pgServer.cpp @@ -2135,24 +2135,39 @@ bool connectServerFactory::CheckEnable(pgObject *obj) disconnectServerFactory::disconnectServerFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : contextActionFactory(list) { - mnu->Append(id, _("Disconnec&t server"), _("Disconnect from the selected server.")); + wxString msg=_("Disconnec&t server")+"\tCtrl-W"; + mnu->Append(id, msg, _("Disconnect from the selected server.")); } wxWindow *disconnectServerFactory::StartDialog(frmMain *form, pgObject *obj) { - if (obj->CheckOpenDialogs(form->GetBrowser(), form->GetBrowser()->GetSelection())) { - wxString msg = _("There are properties dialogues open for one or more objects belonging to a database which will be disconnected. Please close the properties dialogues and try again."); - wxMessageBox(msg, _("Cannot disconnect database"), wxICON_WARNING | wxOK); - } - else - { - pgServer *server = (pgServer *)obj; - server->Disconnect(form); - server->UpdateIcon(form->GetBrowser()); - form->GetBrowser()->DeleteChildren(obj->GetId()); - form->execSelChange(obj->GetId(), true); + pgServer *server=NULL; + wxTreeItemId idserver; + if (obj) { + if (!obj->IsCreatedBy(serverFactory)) { + server=obj->GetServer(); + if (server) { + idserver=server->GetId(); + form->execSelChange(idserver, false); + } else return 0; + } else { + idserver=obj->GetId(); + server = (pgServer *)obj; + } + if (server->CheckOpenDialogs(form->GetBrowser(), idserver)) + { + wxString msg = _("There are properties dialogues open for one or more objects belonging to a database which will be disconnected. Please close the properties dialogues and try again."); + wxMessageBox(msg, _("Cannot disconnect database"), wxICON_WARNING | wxOK); + } else + { + server->Disconnect(form); + server->UpdateIcon(form->GetBrowser()); + form->GetBrowser()->DeleteChildren(idserver); + form->execSelChange(idserver, true); + } + } } return 0; @@ -2161,8 +2176,12 @@ wxWindow *disconnectServerFactory::StartDialog(frmMain *form, pgObject *obj) bool disconnectServerFactory::CheckEnable(pgObject *obj) { - if (obj && obj->IsCreatedBy(serverFactory)) - return ((pgServer *)obj)->GetConnected(); + if (obj) { + pgServer *pgs=obj->GetServer(); + if (pgs) return pgs->GetConnected(); + } +// if (obj && obj->IsCreatedBy(serverFactory)) +// return ((pgServer *)obj)->GetConnected(); return false; }