diff --git a/Release_(3.0)/pgAdmin3.exe b/Release_(3.0)/pgAdmin3.exe index d662342..930dcfd 100644 Binary files a/Release_(3.0)/pgAdmin3.exe and b/Release_(3.0)/pgAdmin3.exe differ diff --git a/ctl/ctlSQLBox.cpp b/ctl/ctlSQLBox.cpp index ec7e367..e5f9f5f 100644 --- a/ctl/ctlSQLBox.cpp +++ b/ctl/ctlSQLBox.cpp @@ -22,6 +22,7 @@ #include "dlg/dlgFindReplace.h" #include "frm/menu.h" #include "utils/sysProcess.h" +#include wxString ctlSQLBox::sqlKeywords; static const wxString s_leftBrace(_T("([{")); @@ -1183,7 +1184,75 @@ void ctlSQLBox::OnMarginClick(wxStyledTextEvent &event) event.Skip(); } +void ctlSQLBox::Copy() { + wxString selText = GetSelectedText(); + if (!selText.IsEmpty()) + { + wxColor frColor[40]; + wxString str; + wxColour frc = settings->GetSQLBoxColourForeground(); + if (settings->GetSQLBoxUseSystemForeground()) + { + frc = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + } + for (int i = 0; i < 34; ++ i ) + { + frColor[i]=StyleGetForeground(i); + if (i > 0 && i < 12) + //StyleSetForeground(i, settings->GetSQLBoxColour(i)); + frColor[i]=StyleGetForeground(i); + else + frColor[i]=frc; + + //StyleSetBackground(i, bgColor); + //StyleSetFont(i, fntSQLBox); + } + //

+ int endp=GetSelectionEnd(); + int startp=GetSelectionStart(); + wxString prevColor=wxEmptyString; + wxString tColor; + wxFont fntSQLBox = settings->GetSQLFont(); + wxString fontName = fntSQLBox.GetFaceName(); + + str=wxT(""); + int k=0; + int l=1; + while (startp"); + prevColor=tColor; + } + //str.append(str[k].GetValue()); + l=1; + if (!selText[k].IsAscii()) l++; + str+=selText[k]; + if (str.EndsWith(wxT("\r\n"))) str+=wxT("
"); + startp=startp+l; + k++; + } + str=str+wxT("
"); + + + + if (wxTheClipboard->Open()) + { + wxDataObjectComposite* dataobj = new wxDataObjectComposite(); + dataobj->Add(new wxTextDataObject(selText)); + dataobj->Add(new wxHTMLDataObject(str)); + wxTheClipboard->SetData(dataobj); + wxTheClipboard->Close(); + } + + } else wxStyledTextCtrl::Copy(); + + + + + } extern "C" char *tab_complete(const char *allstr, const int startptr, const int endptr, void *dbptr); void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev) diff --git a/ctl/ctlSQLGrid.cpp b/ctl/ctlSQLGrid.cpp index 098288f..b404926 100644 --- a/ctl/ctlSQLGrid.cpp +++ b/ctl/ctlSQLGrid.cpp @@ -638,12 +638,14 @@ int recurse(ctlSQLGrid *g, int pos,int row, double &transfer) { return row; } void ctlSQLGrid::SetRowGroup(int row) { }; -bool ctlSQLGrid::FullArrayCollapseRowsPlan() +bool ctlSQLGrid::FullArrayCollapseRowsPlan(bool clear) { //wxString colKey = wxString::Format(wxT("%d:"), col) + GetColLabelValue(col); wxString text; //for(int row = 0; row < GetNumberRows(); ++row) + if (grp) { delete grp;} + if (clear) { grp=NULL; return true;} grp = new GroupRows(this); double transfersum=0; int r= recurse(this,0,0,transfersum); diff --git a/ctl/ctlSQLResult.cpp b/ctl/ctlSQLResult.cpp index e122faf..54431f5 100644 --- a/ctl/ctlSQLResult.cpp +++ b/ctl/ctlSQLResult.cpp @@ -208,8 +208,8 @@ void ctlSQLResult::DisplayData(bool single) if (c==wxT("QUERY PLAN")) { // table->isplan=true; - FullArrayCollapseRowsPlan(); - }; + FullArrayCollapseRowsPlan(false); + } else FullArrayCollapseRowsPlan(true); if (single) { diff --git a/dlg/dlgFunction.cpp b/dlg/dlgFunction.cpp index 57e906e..be97289 100644 --- a/dlg/dlgFunction.cpp +++ b/dlg/dlgFunction.cpp @@ -1041,7 +1041,8 @@ wxString dlgFunction::GetSql() name = name + wxT("(") + GetArgs(false, true) + wxT(")"); if (cbOwner->GetCurrentSelection() > 0) - AppendOwnerNew(sql, wxT("FUNCTION ") + name); + if (!isProcedure) AppendOwnerNew(sql, wxT("FUNCTION ") + name); + else AppendOwnerNew(sql, wxT("PROCEDURE ") + name); } if (false) diff --git a/include/ctl/ctlSQLBox.h b/include/ctl/ctlSQLBox.h index fcd68fe..71e33b6 100644 --- a/include/ctl/ctlSQLBox.h +++ b/include/ctl/ctlSQLBox.h @@ -50,7 +50,7 @@ public: void Create(wxWindow *parent, wxWindowID id = -1, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0); void HighlightBrace(int lb, int rb); void SetDatabase(pgConn *db); - + void Copy(); void OnKeyDown(wxKeyEvent &event); void OnAutoComplete(wxCommandEvent &event); void OnSearchReplace(wxCommandEvent &event); diff --git a/include/ctl/ctlSQLGrid.h b/include/ctl/ctlSQLGrid.h index b6b2cff..65b93e7 100644 --- a/include/ctl/ctlSQLGrid.h +++ b/include/ctl/ctlSQLGrid.h @@ -40,7 +40,7 @@ public: void OnLabelDoubleClick(wxGridEvent &event); void OnLabelClick(wxGridEvent &event); void OnCellRightClick(wxGridEvent &event); - bool FullArrayCollapseRowsPlan(); + bool FullArrayCollapseRowsPlan(bool clear); void AutoSizeColumn(int col, bool setAsMin = false, bool doLimit = true); void AutoSizeColumns(bool setAsMin); wxString GetRowLabelValue( int row ); diff --git a/schema/pgTable.cpp b/schema/pgTable.cpp index 1c72885..83b5cb5 100644 --- a/schema/pgTable.cpp +++ b/schema/pgTable.cpp @@ -321,7 +321,7 @@ wxString pgTable::GetSql(ctlTree *browser) wxString colDetails, conDetails; wxString prevComment; wxString cols_sql = wxEmptyString; - + wxString cols_type = wxEmptyString; wxString columnPrivileges; if (sql.IsNull()) @@ -357,16 +357,17 @@ wxString pgTable::GetSql(ctlTree *browser) int lastRealCol = 0; int currentCol = 0; pgColumn *column; - // Iterate the columns to find the last 'real' one while ((column = (pgColumn *)colIt1.GetNextObject()) != 0) { + if (currentCol==0) {cols_type+=column->GetDisplayName()+wxT(" ")+column->GetQuotedTypename(); + } else cols_type+=wxT(", ")+column->GetDisplayName()+wxT(" ")+column->GetQuotedTypename(); currentCol++; - + //AppendIfFilled(cols_type,wxT(","),cols_type); if (column->GetInheritedCount() == 0) lastRealCol = currentCol; } - + cols_type=wxT("-- (")+cols_type+wxT(")"); // Now build the actual column list int colCount = 0; while ((column = (pgColumn *)colIt2.GetNextObject()) != 0) @@ -725,7 +726,9 @@ wxString pgTable::GetSql(ctlTree *browser) AppendStuffNoSql(sql, browser, partitionFactory); } */ + sql+=cols_type; } + return sql; } @@ -1260,6 +1263,9 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics) // Add the statistics view columns statistics->ClearAll(); statistics->AddColumn(_("Table Name")); + if (hasSize) + statistics->AddColumn(_("Size"), 50); + statistics->AddColumn(_("Tuples inserted")); statistics->AddColumn(_("Tuples updated")); statistics->AddColumn(_("Tuples deleted")); @@ -1283,8 +1289,6 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics) statistics->AddColumn(_("Analyze counter")); statistics->AddColumn(_("Autoanalyze counter")); } - if (hasSize) - statistics->AddColumn(_("Size"), 50); wxString sql = wxT("SELECT st.relname, n_tup_ins, n_tup_upd, n_tup_del"); if (GetConnection()->BackendMinimumVersion(8, 3)) @@ -1311,11 +1315,13 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics) int i; while (!stats->Eof()) { - i = 4; + i = 5; statistics->InsertItem(pos, stats->GetVal(wxT("relname")), PGICON_STATISTICS); - statistics->SetItem(pos, 1, stats->GetVal(wxT("n_tup_ins"))); - statistics->SetItem(pos, 2, stats->GetVal(wxT("n_tup_upd"))); - statistics->SetItem(pos, 3, stats->GetVal(wxT("n_tup_del"))); + if (hasSize) + statistics->SetItem(pos, 1, stats->GetVal(wxT("size"))); + statistics->SetItem(pos, 2, stats->GetVal(wxT("n_tup_ins"))); + statistics->SetItem(pos, 3, stats->GetVal(wxT("n_tup_upd"))); + statistics->SetItem(pos, 4, stats->GetVal(wxT("n_tup_del"))); if (GetConnection()->BackendMinimumVersion(8, 3)) { statistics->SetItem(pos, i++, stats->GetVal(wxT("n_tup_hot_upd"))); @@ -1336,15 +1342,13 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics) statistics->SetItem(pos, i++, stats->GetVal(wxT("analyze_count"))); statistics->SetItem(pos, i++, stats->GetVal(wxT("autoanalyze_count"))); } - if (hasSize) - statistics->SetItem(pos, i, stats->GetVal(wxT("size"))); stats->MoveNext(); pos++; } delete stats; } - + statistics->SetColumnWidth(0,wxLIST_AUTOSIZE); }