Обсуждение: SQL Macros in QueryTool.
Hello, I've been asked to add little macro capabilities to PgAdmin's QueryTool. My plans: Every macro has: - key shortcut (key), - short descriptive title (title), - query text (query). Just right of Favourites menu, I'll add Macros menu with - Macros Setup dialog, - Separator for macro in macros: macro.title + "\t" + macro.key Macros will be stored, and added to menu just like Favourites. wxMenu description key handler will generate command event, on key shortcut hit. In frmQuery class I'll add next EVT_MENU_RANGE to event table. I'll create method which: 1. retrieve query from queryMacroList (think of queryFavoritesFolder without support for sublevels), based on event.GetId(). 2. replace $SELECTED$ placeholder with current selection (if there is placeholder in query, and there is selection in editor) 3. run query (mimic OnExecute behaviour). I'll start with implementing actual macro capabilities without configuration dialog (tester will edit xml file to add new macros). This part will be ready in two weeks time (I'm coding that in spare time). Then I'll create configuration dialog. I've got some doubts how to implement so expect question on the list. If that will work, I think of defining different macro sets for different server/databases (default macros for application, but they can be overridden by macros specific to server or database). My development platform is: - Windows Vista Bussines x64, Polish - VC++ 2005 Express - wxWidgets 2.8.4 (current stable release) - PostgreSQL 8.2.4, default package from OpenBSD, run on virtual machine. I'll start with revision 6393 of PGAdmin code. I'll build 32 bit code (don't know if PGAdmin work in Windows 64 bit environment). Regards, Krzysiek
Hi Krzysiek, Krzysztof Śmigrodzki wrote: > Hello, > I've been asked to add little macro capabilities to PgAdmin's QueryTool. Excellent :-) > My plans: <snip>That all sounds pretty much as I imagined from Jan's original suggestion. > Then I'll create configuration dialog. I've got some doubts how to > implement so expect question on the list. Please feel free - we'll try to help as much as we can. > If that will work, I think of defining different macro sets for > different server/databases (default macros for application, but they can > be overridden by macros specific to server or database). Hmm, I'm not so sure about that. As someone who admin'ed quite a few databases at once in a previous life, it seems to me that per database or even per server macros could be quite confusing. I wonder if we could have macro 'sets' that weren't necessarily tied to a specific database or server, but could be selected independently. > My development platform is: > - Windows Vista Bussines x64, Polish > - VC++ 2005 Express > - wxWidgets 2.8.4 (current stable release) > - PostgreSQL 8.2.4, default package from OpenBSD, run on virtual machine. Why not use the local installation of PostgreSQL on Windows? You'll need it for the headers and libs anyway, and it'll save the overhead of running VMware or whatever. > I'll start with revision 6393 of PGAdmin code. I'll build 32 bit code > (don't know if PGAdmin work in Windows 64 bit environment). I don't think anyone ever tried to build a 64bit binary. I can't think of any major reason why it shouldn't work though, other than most of the dependency libraries being 32bit. Anyhoo, I would advise that you develop against SVN trunk, and update on an almost daily basis. That makes it much easier to keep in sync - merging a much older tree can be much more difficult and laborious. Oh, and just so you are aware - we've gone into feature freeze now for the upcoming release, so whilst you're free to develop (and we'll be happy to help you), no patches will be committed to SVN until after we've branched 1.8. Regards, Dave.
Dave Page wrote: > <snip>That all sounds pretty much as I imagined from Jan's original > suggestion. Easier than I initially thought. The code is done. Works for me (tm). Testing in progress. >> Then I'll create configuration dialog. I've got some doubts how to >> implement so expect question on the list. > > Please feel free - we'll try to help as much as we can. Look'n'feel question. How should it look like? List with three column: - predefined names of keys on the left, - title field in middle - longer query input field on the right. (Above version would be similar to MS SQL Query Analyzer). Or maybe something more complicated? Vertical list (key, title) on the left, with arrow button to move position up and down. On the right two single line input fields (key, title) and multi-line text input for query? Any idea how to create the following functionality in wx: - first, one presses button ("choose shortcut") - then one inputs key combination - after key-up, key combination description (ex. "Ctrl-F1") is written into text field. > Hmm, I'm not so sure about that. As someone who admin'ed quite a few > databases at once in a previous life, it seems to me that per database > or even per server macros could be quite confusing. I wonder if we could > have macro 'sets' that weren't necessarily tied to a specific database > or server, but could be selected independently. I've got different perspective: different databases, different queries to achieve the same result. > Oh, and just so you are aware - we've gone into feature freeze now for > the upcoming release, so whilst you're free to develop (and we'll be > happy to help you), no patches will be committed to SVN until after > we've branched 1.8. So when will you branch? Regards, Krzysiek.
Krzysztof Śmigrodzki wrote: > Look'n'feel question. How should it look like? > List with three column: > - predefined names of keys on the left, > - title field in middle > - longer query input field on the right. > (Above version would be similar to MS SQL Query Analyzer). > > Or maybe something more complicated? > Vertical list (key, title) on the left, with arrow button to move > position up and down. On the right two single line input fields (key, > title) and multi-line text input for query? I'd model it on the query favourites design. Have a dialog containing a two column listctrl of keys and title, and then Add/Edit and Clear buttons. The clear button would remove the selected macro, and the Add/Edit button would open another simple dialog with a single line text box for the title, and a multiline for the macro code (perhaps also with a 'copy current/selected text from query tool' button). > Any idea how to create the following functionality in wx: > - first, one presses button ("choose shortcut") > - then one inputs key combination > - after key-up, key combination description (ex. "Ctrl-F1") is written > into text field. Well you'd create an OnKeyUp event and handler that would take the keycode from the event object, and use ShiftDown(), ControlDown() etc. to check the modifier keys. But I wouldn't do it that way, because the user probably has too much of a chance of selecting an invalid combination (because it's used for something else for example). I'd pre-populate the listctrl with the allowable combinations - we'd need to pick a range that doesn't conflict with anything that's already used on any of our platforms. Hopefully we can allow Ctrl-F1 -> Ctrl-F12 without interfering with anything, and maybe the Alt versions as well. >> Hmm, I'm not so sure about that. As someone who admin'ed quite a few >> databases at once in a previous life, it seems to me that per database >> or even per server macros could be quite confusing. I wonder if we >> could have macro 'sets' that weren't necessarily tied to a specific >> database or server, but could be selected independently. > > I've got different perspective: > different databases, different queries to achieve the same result. Well my databases were largely different. With sets you can easily accomodate completely diverse databases, or users who might have live, test and training databases for each of three or four applications. For them, each set would correspond to an application. >> Oh, and just so you are aware - we've gone into feature freeze now for >> the upcoming release, so whilst you're free to develop (and we'll be >> happy to help you), no patches will be committed to SVN until after >> we've branched 1.8. > > So when will you branch? Good question. We need to release no more than a couple of weeks before PostgreSQL, but absolutely no later than with PostgreSQL. Unfortunately that means it's all a bit of a guessing game at this point. I think it's fairly certain to be a couple of months or more though. If it becomes too much of an issue we can look at branching early (but still releasing later). That might work, but isn't something we've done before. Regards, Dave.
The code is available at: http://www.adal.com.pl/pgadmin3/ Diff does not include xrcDialogs.cpp nor changes to vcproj (one need to add that files manually to project). This diff is stored on my employer page, so it will be removed in few weeks. Please give it a try, and write what should be changed. Regards, Krzysiek
Krzysztof Śmigrodzki wrote: > The code is available at: > http://www.adal.com.pl/pgadmin3/ > > Diff does not include xrcDialogs.cpp nor changes to vcproj (one need to > add that files manually to project). > > This diff is stored on my employer page, so it will be removed in few > weeks. > > Please give it a try, and write what should be changed. Hi Krzysiek That was somewhat quicker than I'd expected. This is a pretty neat feature so as it's so I'd really like to squeeze it into SVN now despite being a ocuple of days into feature freeze. Does anyone object? Guillaume? So, code-wise I think there's maybe 10 minutes of stylistic changes and some messages that I'd like to tweak. Oh, and Ctrl-F1 (and possibly more) don't work for me, so I'll change it to Alt-F1). Other than that, I don't think there are any real code issues. It could do with more commenting, but then so could much of the existing code. The macro management dialog is laid out OK, but some of the controls are quite tightly packed. I think it needs a little tweaking to ensure there are 5d borders around some of the controls to stop them looking so packed together. Finally, the documentation page is missing from the patch. So, if you can handle the last two issues, and everyone else is happy, I think we can probably get this in. Sound good? Thanks, Dave.
On Fri, Jun 29, 2007 at 03:49:13PM +0100, Dave Page wrote: > Krzysztof Śmigrodzki wrote: > > The code is available at: > > http://www.adal.com.pl/pgadmin3/ > > > > Diff does not include xrcDialogs.cpp nor changes to vcproj (one need to > > add that files manually to project). > > > > This diff is stored on my employer page, so it will be removed in few > > weeks. > > > > Please give it a try, and write what should be changed. > > Hi Krzysiek > > That was somewhat quicker than I'd expected. This is a pretty neat > feature so as it's so I'd really like to squeeze it into SVN now despite > being a ocuple of days into feature freeze. Does anyone object? Guillaume? From my POV: go for it. Assuming you don't expect much trouble from it - I haven't actually looked at the code before I said that. //Magnus
Dave Page pisze: >> The code is available at: >> http://www.adal.com.pl/pgadmin3/ > Hi Krzysiek > > Oh, and Ctrl-F1 (and possibly > more) don't work for me, so I'll change it to Alt-F1). Some afterthoughts: Ctrl-F1 to Ctrl-F12 are not such a good idea. Ctrl-F4 is MDI window close in most apps. Other Ctrl-Fkey combinations may also be dangerous. I would stick with Ctrl-digit combination (one for loop to remove from constructor). > It could do with more > commenting, but then so could much of the existing code. I can add more comments to the code, but I will be able to publish them not earlier than sunday evening. > The macro management dialog is laid out OK, but some of the controls are > quite tightly packed. I think it needs a little tweaking to ensure there > are 5d borders around some of the controls to stop them looking so > packed together. Did my best, but I'm only poor database programmer, not an UI artist. Tweaked version on page above. > Finally, the documentation page is missing from the patch. It was not written at the time. But now there is something that looks like documentation on the page above. My diff generator can't process binary files, so there will be no diff to documentation. I don't have access to WinXP machine, so screenshots are from Vista. Regards, Krzysiek.
Dave Page a écrit : > Krzysztof Śmigrodzki wrote: >> The code is available at: >> http://www.adal.com.pl/pgadmin3/ >> >> Diff does not include xrcDialogs.cpp nor changes to vcproj (one need to >> add that files manually to project). >> >> This diff is stored on my employer page, so it will be removed in few >> weeks. >> >> Please give it a try, and write what should be changed. > > Hi Krzysiek > > That was somewhat quicker than I'd expected. This is a pretty neat > feature so as it's so I'd really like to squeeze it into SVN now despite > being a ocuple of days into feature freeze. Does anyone object? Guillaume? > Let's go for it. I just add a quick look at the patch and I don't think it will add so many strings. Regards. -- Guillaume. <!-- http://abs.traduc.org/ http://lfs.traduc.org/ http://docs.postgresqlfr.org/ -->
Krzysztof Śmigrodzki wrote: >> The macro management dialog is laid out OK, but some of the controls are >> quite tightly packed. I think it needs a little tweaking to ensure there >> are 5d borders around some of the controls to stop them looking so >> packed together. > > Did my best, but I'm only poor database programmer, not an UI artist. > Tweaked version on page above. :-). Thanks - I've committed the patch with a few minor cosmetic changes. Bar one last functionality fix I'm going to sneak in in the next hour or so this is definitely feature freeze now!! Regards, Dave.
Guillaume Lelarge wrote: > Let's go for it. I just add a quick look at the patch and I don't think it > will add so many strings. OK, done. I also snuck in one more additional string in the report tool, for an arguably essential feature that should have been these since day one. Thanks, Dave