[pgadmin-hackers] Improved copying from Edit Data Grid - rough patch

2006-02-02 Thread Edward Di Geronimo Jr.

Hello,

I want to get involved in helping polish the pgAdmin interface. As a 
first step, I've modified the copy for the Edit Data grid to have much 
more flexiblity in copying data from the grid. The present code only 
allows copying entire rows. With my changes, you can now copy rows, 
columns, or the highlighted range.


The attached patch is very rough. The most notable rough spot is it 
creates two new overloaded versions of sqlTable::GetExportLine which 
duplicate a lot of code from the original. These can definitely be 
consolidated, however, I wasn't sure what the preferred style would be 
for it.


The next thing I would like to after finishing this is modify the query 
windows to display the results in a grid instead of a list. The ability 
to copy arbitrary sections of the results would be a huge help in my 
daily work. I figured this could would most likely be reusable for that 
goal.


Feedback would be appreciated.

Ed
Index: src/frm/frmEditGrid.cpp
===
--- src/frm/frmEditGrid.cpp (revision 4983)
+++ src/frm/frmEditGrid.cpp (working copy)
@@ -323,6 +323,7 @@
 }
 
 
+#if 0
 void frmEditGrid::OnCopy(wxCommandEvent &ev)
 {
 wxArrayInt rows=sqlGrid->GetSelectedRows();
@@ -345,8 +346,70 @@
 }
 SetStatusText(wxString::Format(_("%d rows copied to clipboard."), 
rows.GetCount()));
 }
+#endif
 
+void frmEditGrid::OnCopy(wxCommandEvent &ev)
+{
+wxString str;
+int copied = 0;
+size_t i;
 
+if (sqlGrid->GetSelectedRows().GetCount()) {
+wxArrayInt rows=sqlGrid->GetSelectedRows();
+
+for (i=0 ; i < rows.GetCount() ; i++)
+{
+str.Append(sqlGrid->GetTable()->GetExportLine(rows.Item(i)));
+
+if (rows.GetCount() > 1)
+str.Append(END_OF_LINE);
+}
+
+copied = rows.GetCount();
+}
+else if (sqlGrid->GetSelectedCols().GetCount()) {
+wxArrayInt cols=sqlGrid->GetSelectedCols();
+size_t numRows = sqlGrid->GetNumberRows();
+
+for (i=0 ; i < numRows ; i++)
+{
+str.Append(sqlGrid->GetTable()->GetExportLine(i, cols));
+
+if (numRows > 1)
+str.Append(END_OF_LINE);
+}
+
+copied = numRows;
+}
+else if (sqlGrid->GetSelectionBlockTopLeft().GetCount() > 0 &&
+sqlGrid->GetSelectionBlockBottomRight().GetCount() > 0) {
+int x1, x2, y1, y2;
+
+x1 = sqlGrid->GetSelectionBlockTopLeft()[0].GetCol();
+x2 = sqlGrid->GetSelectionBlockBottomRight()[0].GetCol();
+y1 = sqlGrid->GetSelectionBlockTopLeft()[0].GetRow();
+y2 = sqlGrid->GetSelectionBlockBottomRight()[0].GetRow();
+
+for (i = y1; i <= y2; i++) {
+str.Append(sqlGrid->GetTable()->GetExportLine(i, x1, x2));
+
+if (y2 > y1)
+str.Append(END_OF_LINE);
+}
+
+copied = y2 - y1 + 1;
+}
+
+if (copied && wxTheClipboard->Open())
+{
+wxTheClipboard->SetData(new wxTextDataObject(str));
+wxTheClipboard->Close();
+}
+
+SetStatusText(wxString::Format(_("%d rows copied to clipboard."), copied));
+}
+
+
 void frmEditGrid::OnHelp(wxCommandEvent &ev)
 {
 DisplayHelp(this, wxT("editgrid"), viewdata_xpm);
@@ -1439,6 +1502,79 @@
 }
 
 
+wxString sqlTable::GetExportLine(int row, int col1, int col2)
+{
+wxString str;
+cacheLine *line = GetLine(row);
+int maxCol = (col2 < nCols - 1) ? col2 : (nCols - 1);
+if (line)
+{
+int col;
+for (col=col1 ; col <= maxCol ; col++)
+{
+if (col > col1)
+str.Append(settings->GetExportColSeparator());
+bool needQuote = settings->GetExportQuoting() > 1;
+
+// find out if string
+switch (columns[col].type)
+{
+case PGTYPCLASS_NUMERIC:
+case PGTYPCLASS_BOOL:
+break;
+default:
+needQuote=true;
+break;
+}
+if (needQuote)
+str.Append(settings->GetExportQuoteChar());
+
+str.Append(line->cols[col]);
+
+if (needQuote)
+str.Append(settings->GetExportQuoteChar());
+}
+}
+return str;
+}
+
+
+wxString sqlTable::GetExportLine(int row, wxArrayInt cols)
+{
+wxString str;
+cacheLine *line = GetLine(row);
+if (line)
+{
+int col;
+for (col=0 ; col < cols.Count() ; col++)
+{
+if (col > 0)
+str.Append(settings->GetExportColSeparator());
+bool needQuote = settings->GetExportQuoting() > 1;
+
+// find out if string
+switch (columns[cols[col]].type)
+{
+case PGTYPCLASS_NUMERIC:
+case PGTYPCLASS_BOOL:
+break;
+default:
+needQuote=true;
+ 

Re: [pgadmin-hackers] execute sql script w/o stopping after error?

2006-02-02 Thread Dave Page



-Original Message-
From: Carl R. Brune [mailto:[EMAIL PROTECTED]
Sent: Thu 2/2/2006 8:59 PM
To: Dave Page
Cc: pgadmin-hackers@postgresql.org
Subject: RE: [pgadmin-hackers] execute sql script w/o stopping after error?
 
> Thanks, Dave, for the helpful reply.

NP

> I have a feeling I sent my question to the wrong list --
> sorry if that's the case. According to

Oops, sorry - web page fixed in SVN now.

Thanks, Dave

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[pgadmin-hackers] SVN Commit by dpage: r4985 - trunk/www/support

2006-02-02 Thread svn
Author: dpage

Date: 2006-02-02 21:37:44 + (Thu, 02 Feb 2006)

New Revision: 4985

Revision summary: http://svn.pgadmin.org/cgi-bin/viewcvs.cgi/?rev=4985&view=rev

Log:
Fix list address, per Carl R. Brune



Modified:
   trunk/www/support/list.php

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [pgadmin-hackers] execute sql script w/o stopping after error?

2006-02-02 Thread Carl R. Brune

Thanks, Dave, for the helpful reply.

I have a feeling I sent my question to the wrong list --
sorry if that's the case. According to

http://www.pgadmin.org/support/list.php

"The pgadmin-support mailing list is intended for end user support
and bug reports. To subscribe to the mailing list, send an email
to [EMAIL PROTECTED] with the word 'subscribe',
without quotes, as the body of message."

Looks wrong, or at least misleading.

Anway, thanks again and regards,

Carl B.

On Thu, 2 Feb 2006, Dave Page wrote:





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Carl R. Brune
Sent: 31 January 2006 18:33
To: pgadmin-hackers@postgresql.org
Subject: [pgadmin-hackers] execute sql script w/o stopping
after error?

Does pgadmin3 offer a way to execute sql scripts without
stopping if an error is encountered? I've got a script
which starts by dropping table (which may or may not exist)
and then rebuilds it. If I execute the script with psql
(using \i) script execution continues after errors. However
if I try to do this with the query tool of pgadmin3 it stops
after the drop table statement (if the table doesn't exist).


No, at present it doesn't. You can select only specific portions of your
script to run by selecting the text, and then clicking the run button
though.

Regards, Dave.




---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


Re: [pgadmin-hackers] Compiling pgadmin on Fedora Core 3

2006-02-02 Thread Andy Burns

Stephen Tashiro wrote:

I'm compiling the source in pgadmin3-1.4.1.tar.gz on Fedora Core 3 after 
installing WxWidgets from wxGTK-2.6.2.tar.gz.


I don't know about FC3 but I did manage to build it from the .spec file 
on FC5T2 once the relevant version of Wxwidgets was updated in fedora 
itself, I just had some GCC4.1 issues to work aound but that won't 
affect you


---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [pgadmin-hackers] SVN Commit by dpage: r4984 - trunk/pgadmin3

2006-02-02 Thread Dave Page
 

> -Original Message-
> From: Andreas Pflug [mailto:[EMAIL PROTECTED] 
> Sent: 02 February 2006 16:10
> To: Dave Page
> Cc: pgadmin-hackers@postgresql.org
> Subject: Re: [pgadmin-hackers] SVN Commit by dpage: r4984 - 
> trunk/pgadmin3
> 
> [EMAIL PROTECTED] wrote:
> > Author: dpage
> > 
> > Date: 2006-02-02 13:59:06 + (Thu, 02 Feb 2006)
> > 
> > New Revision: 4984
> > 
> > Revision summary: 
> http://svn.pgadmin.org/cgi-bin/viewcvs.cgi/?rev=4984&view=rev
> > 
> > Log:
> > Fix Andreas' dodgy formatting and attribution :-p
> 
> 
> Err, blasphemy?
> 

Sorry. Suggestions for a non-blaspemous commit message?

/D

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [pgadmin-hackers] SVN Commit by dpage: r4984 - trunk/pgadmin3

2006-02-02 Thread Andreas Pflug

[EMAIL PROTECTED] wrote:

Author: dpage

Date: 2006-02-02 13:59:06 + (Thu, 02 Feb 2006)

New Revision: 4984

Revision summary: http://svn.pgadmin.org/cgi-bin/viewcvs.cgi/?rev=4984&view=rev

Log:
Fix Andreas' dodgy formatting and attribution :-p



Err, blasphemy?


Regards,
Andreas

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[pgadmin-hackers] Compiling pgadmin on Fedora Core 3

2006-02-02 Thread Stephen Tashiro
I'm compiling the source in pgadmin3-1.4.1.tar.gz on Fedora Core 3 after 
installing WxWidgets from wxGTK-2.6.2.tar.gz.


The compiling of pgadmin3 links the libraries:
-lwx_gtk2u_adv-2.6
-lwx_baseu-2.6
-lwx_baseu_net-2.6
-lwx_baseu_xml-2.6
-lwx_gtk2u_core-2.6
-lwx_gtk2u_html-2.6
-lwx_gtk2u_ogl-2.6
-lwx_gtk2u_qa-2.6
-lwx_gtk2u_stc-2.6
-lwx_gtk2u_xrc-2.6

There is no error saying those libraries cannot be found, but there are 
errors about undefined references to such things as:


`wxStringBase::InitWith(wchar_t const*, unsigned int, unsigned int)'
`wxStringBase::ConcatSelf(unsigned int, wchar_t const*, unsigned int)'
`wxLogInfo(wchar_t const*, ...)'
`wxLocale::AddCatalog(wchar_t const*)'
`operator+(wxString const&, wchar_t const*)'
`wxString::BeforeFirst(wchar_t) const'

Can someone tell me in what library those things are defined?




---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


[pgadmin-hackers] SVN Commit by dpage: r4984 - trunk/pgadmin3

2006-02-02 Thread svn
Author: dpage

Date: 2006-02-02 13:59:06 + (Thu, 02 Feb 2006)

New Revision: 4984

Revision summary: http://svn.pgadmin.org/cgi-bin/viewcvs.cgi/?rev=4984&view=rev

Log:
Fix Andreas' dodgy formatting and attribution :-p


Modified:
   trunk/pgadmin3/CHANGELOG

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[pgadmin-hackers] Query tool result discarding

2006-02-02 Thread Magnus Hagander
Hi!


A fairly typical use-case for the query tool in my org is:

BEGIN TRANSACTION;
UPDATE something SET somecol=newval WHERE something=other;
SELECT * FROM something;   -- this is to manually verify results
ROLLBACK;

Then when everything works, you replace ROLLBACK with COMMIT. This works
perfectly in the query tool in sqlserver, but pgAdmin discards the
result from SELECT and leaves the result pane empty. Because it's
overwritten by the empty result from ROLLBACK.

Attached patch fixes this very limited test case. I'm well enough
unfamiliar with that code that I think it's probably not the correct
solution "in the big scheme" (and it also seems too easy), but it might
help point one of you guys who know that code better in the right
direction. Or on the off chance that it's right, hey, there was some
luck left over :-)

//Magnus


query_discard.patch
Description: query_discard.patch

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [pgadmin-hackers] [pgadmin-support] "view data" freezes up every time

2006-02-02 Thread Dave Page
 

> -Original Message-
> From: Hiroshi Saito [mailto:[EMAIL PROTECTED] 
> Sent: 02 February 2006 08:53
> To: Dave Page
> Cc: pgadmin-hackers@postgresql.org; 
> pgadmin-support@postgresql.org; Francisco Leovey
> Subject: Re: [pgadmin-hackers] [pgadmin-support] "view data" 
> freezes up every time
> 
> Ahhh, Regret.
> I expected momentary magic.

:-)


/D

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [pgadmin-hackers] [pgadmin-support] "view data" freezes up every time

2006-02-02 Thread Hiroshi Saito
From: "Dave Page"
> > I had overlooked from the latest busyness.
> 
> That's only the built in viewer that's used on *nix and in dev mode on
> Windows. The Windows HTMLHelp viewer still stays on top. There's no easy
> way to change that from what I can tell, though some shellexec hackery
> might work by opening something like:

Ahhh, Regret.
I expected momentary magic.

Regards,
Hiroshi Saito


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [pgadmin-hackers] [pgadmin-support] "view data" freezes up every time

2006-02-02 Thread Dave Page
 

> -Original Message-
> From: Hiroshi Saito [mailto:[EMAIL PROTECTED] 
> Sent: 02 February 2006 08:43
> To: Dave Page
> Cc: pgadmin-hackers@postgresql.org; 
> pgadmin-support@postgresql.org; Francisco Leovey
> Subject: Re: [pgadmin-support] "view data" freezes up every time
> 
> Hi Dave.
> 
> From: "Dave Page"
> > > Also the help window stays always on top 
> >
> > Yes.
> 
> I find that Andreas has improved it.(developer version)
> http://cre-ent.skcapi.co.jp/~saito/pgadmin3/pgAdmin3_help_back.PNG
> 
> I had overlooked from the latest busyness.

That's only the built in viewer that's used on *nix and in dev mode on
Windows. The Windows HTMLHelp viewer still stays on top. There's no easy
way to change that from what I can tell, though some shellexec hackery
might work by opening something like:

mk:@MSITStore:docs\en_US\pgadmin3.chm::/pg/index.html

Regards, Dave.

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [pgadmin-hackers] [pgadmin-support] "view data" freezes up every time

2006-02-02 Thread Hiroshi Saito
Hi Dave.

From: "Dave Page"
> > Also the help window stays always on top 
>
> Yes.

I find that Andreas has improved it.(developer version)
http://cre-ent.skcapi.co.jp/~saito/pgadmin3/pgAdmin3_help_back.PNG

I had overlooked from the latest busyness.

Regards,
Hiroshi Saito


---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [pgadmin-hackers] execute sql script w/o stopping after error?

2006-02-02 Thread Dave Page
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Carl R. Brune
> Sent: 31 January 2006 18:33
> To: pgadmin-hackers@postgresql.org
> Subject: [pgadmin-hackers] execute sql script w/o stopping 
> after error?
> 
> Does pgadmin3 offer a way to execute sql scripts without
> stopping if an error is encountered? I've got a script
> which starts by dropping table (which may or may not exist)
> and then rebuilds it. If I execute the script with psql
> (using \i) script execution continues after errors. However
> if I try to do this with the query tool of pgadmin3 it stops
> after the drop table statement (if the table doesn't exist).

No, at present it doesn't. You can select only specific portions of your
script to run by selecting the text, and then clicking the run button
though.

Regards, Dave.

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org